@signalapp/minimask
Version:
Simple HTML input masking
29 lines (26 loc) • 913 B
TypeScript
declare function createCreditCardExpirationFormatter(): Formatter;
type FormatterToken = Readonly<{
/**
* This should be a single character
*/
char: string;
/**
* The index of the `char` in the original string. Two tokens can share the
* same index, but they should always be in order.
*/
index: number;
/**
* If `mask` is true, the `char` will be dropped from the unformatted string.
*/
mask: boolean;
}>;
/**
* A generator function or a function returning an iterable that returns a
* sequence of tokens representing the formatted string.
*/
type Formatter = (input: string) => Iterable<FormatterToken>;
/**
* Bind to an input element, masking the value of it.
*/
declare function minimask(input: HTMLInputElement, formatter: Formatter): () => void;
export { type Formatter, type FormatterToken, createCreditCardExpirationFormatter, minimask };