-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vanilla masker definition file
- Loading branch information
1 parent
8585949
commit dfd52e9
Showing
4 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Type definitions for vanilla-masker 1.2 | ||
// Project: https://fleury.io/vanilla-masker/ | ||
// Definitions by: BenLorantfy <https://github.com/BenLorantfy> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
declare module 'vanilla-masker' { | ||
type MoneyOptions = { | ||
// Decimal precision -> "90" | ||
precision?: number | undefined | ||
|
||
// Decimal separator -> ",90" | ||
separator?: string | undefined | ||
|
||
// Number delimiter -> "12.345.678" | ||
delimiter?: string | undefined | ||
|
||
// Money unit -> "R$ 12.345.678,90" | ||
unit?: string | undefined | ||
|
||
// Money unit -> "12.345.678,90 R$" | ||
suffixUnit?: string | undefined | ||
|
||
// Force type only number instead decimal, | ||
// masking decimals with ",00" | ||
// Zero cents -> "R$ 1.234.567.890,00" | ||
zeroCents?: boolean | undefined | ||
} | ||
|
||
type PatternOptions = { | ||
// Pattern to mask value against. | ||
pattern?: string | undefined | ||
|
||
// Placeholder option to represent remaining characters to be entered | ||
placeholder?: string | undefined | ||
} | ||
|
||
const VMasker: { | ||
(el: Element | NodeListOf<Element>): { | ||
maskMoney: (options?: MoneyOptions) => void | ||
maskNumber: () => void | ||
maskAlphaNum: () => void | ||
maskPattern: (pattern: string) => void | ||
unMask: () => void | ||
} | ||
toMoney: (value: string | number, options?: MoneyOptions) => string | ||
toPattern: (value: string | number, options?: string | PatternOptions) => string | ||
toNumber: (value: string | number) => string | ||
toAlphaNumeric: (value: string | number) => string | ||
} | ||
|
||
export = VMasker | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters