mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
The documentation states that the mask property can be false, but the type does not describe this feature, it is necessary when you need to disable the mask
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
// Type definitions for react-text-mask 5.4
|
|
// Project: https://github.com/text-mask/text-mask/tree/master/react
|
|
// Definitions by: Guilherme Hübner <https://github.com/guilhermehubner>
|
|
// Deividi Cavarzan <https://github.com/cavarzan>
|
|
// Artem Lyubchuk <https://github.com/needpower>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.8
|
|
|
|
import * as React from "react";
|
|
|
|
export type maskArray = Array<string | RegExp> | boolean;
|
|
|
|
export interface MaskedInputProps
|
|
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
mask?: maskArray | ((value: string) => maskArray);
|
|
|
|
guide?: boolean;
|
|
|
|
placeholderChar?: string;
|
|
|
|
keepCharPositions?: boolean;
|
|
|
|
pipe?: (
|
|
conformedValue: string,
|
|
config: any
|
|
) => false | string | { value: string; indexesOfPipedChars: number[] };
|
|
|
|
showMask?: boolean;
|
|
|
|
render?: (ref: (inputElement: HTMLElement) => void, props: any) => any;
|
|
}
|
|
|
|
export interface conformToMaskResult {
|
|
conformedValue: string;
|
|
meta: {
|
|
someCharsRejected: boolean;
|
|
};
|
|
}
|
|
|
|
export default class MaskedInput extends React.Component<
|
|
MaskedInputProps,
|
|
any
|
|
> {
|
|
inputElement: HTMLElement;
|
|
}
|
|
|
|
export function conformToMask(
|
|
text: string,
|
|
mask: maskArray | ((value: string) => maskArray),
|
|
config: any
|
|
): conformToMaskResult;
|