diff --git a/package.json b/package.json index ad434b3..10cb34b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "react", "typescript" ], - "version": "2.1.18", + "version": "2.1.19", "main": "./dist/index.cjs.js", "module": "./dist/index.esm.js", "types": "./dist/index.d.ts", @@ -57,7 +57,6 @@ "@types/react": "^18.0.23", "@types/react-dom": "^18.0.7", "@types/styled-components": "^5.1.26", - "@types/vanilla-masker": "^1.2.1", "@typescript-eslint/eslint-plugin": "^5.40.0", "@typescript-eslint/parser": "^5.40.0", "babel-loader": "^8.2.5", diff --git a/src/types/vanilla-masker.d.ts b/src/types/vanilla-masker.d.ts new file mode 100755 index 0000000..cbd25dc --- /dev/null +++ b/src/types/vanilla-masker.d.ts @@ -0,0 +1,52 @@ +// Type definitions for vanilla-masker 1.2 +// Project: https://fleury.io/vanilla-masker/ +// Definitions by: 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): { + 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 +} diff --git a/tsconfig.json b/tsconfig.json index c640d92..b4e9180 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["src"], + "include": ["src", "**/*.ts", "**/*.tsx", "**/*.d.ts"], "exclude": ["node_modules", "dist"], "compilerOptions": { "resolveJsonModule": true, diff --git a/yarn.lock b/yarn.lock index 86df539..1353000 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3290,11 +3290,6 @@ resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ== -"@types/vanilla-masker@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@types/vanilla-masker/-/vanilla-masker-1.2.1.tgz#5eb024a7ee9d5e9e2caf7e61cb07c37a80c74445" - integrity sha512-b5ajZhEff5Ymf0znJ6ReHd4RIzZxb8QORD52/gC9qiG1wgBG+uraJbOgIXIyn4/OLOko/bmDajXuxn2WnYD3ew== - "@types/webpack-env@^1.16.0": version "1.16.3" resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.16.3.tgz#b776327a73e561b71e7881d0cd6d34a1424db86a"