When implementing a Maskito preprocessor, the first argument provided to the processor function is an object representing the state of the input element before any changes are applied, combined with the new data being processed.
This object contains:
elementState: The current state of the input element, including its value and the current selection (a tuple of [from, to]).data: The new characters being inserted or modified. This string may be empty if the user action is a deletion or if the input is being validated.
type firstArgDemo = {
// current input's element state BEFORE any changes are applied
elementState: {
value: string;
selection: [from: number, to: number];
};
// new typed characters which is going to be inserted to the element
data: string; // can be empty string if it is deletion or validation
};