react-input-mask-format 1.0.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/validators/index.ts"],"sourcesContent":["function digitsOnly(value: string): string {\n return (value ?? \"\").replace(/\\D/g, \"\");\n}\n\nexport function luhn(value: string): boolean {\n const digits = digitsOnly(value);\n if (digits.length === 0) {\n return false;\n }\n let sum = 0;\n let double = false;\n for (let i = digits.length - 1; i >= 0; i--) {\n let d = digits.charCodeAt(i) - 48;\n if (double) {\n d *= 2;\n if (d > 9) {\n d -= 9;\n }\n }\n sum += d;\n double = !double;\n }\n return sum % 10 === 0;\n}\n\nconst IIN_W1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];\nconst IIN_W2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2];\n\nfunction iinBinChecksum(value: string): boolean {\n const digits = digitsOnly(value);\n if (digits.length !== 12) {\n return false;\n }\n const d = digits.split(\"\").map(c => c.charCodeAt(0) - 48);\n const weighted = (w: number[]): number =>\n w.reduce((sum, wi, i) => sum + wi * d[i], 0) % 11;\n let control = weighted(IIN_W1);\n if (control === 10) {\n control = weighted(IIN_W2);\n if (control === 10) {\n return false;\n }\n }\n return control === d[11];\n}\n\nexport function isValidIin(value: string): boolean {\n return iinBinChecksum(value);\n}\n\nexport function isValidBin(value: string): boolean {\n return iinBinChecksum(value);\n}\n\nexport function isValidKzIban(value: string): boolean {\n const s = (value ?? \"\").replace(/\\s+/g, \"\").toUpperCase();\n if (s.length !== 20 || !s.startsWith(\"KZ\") || !/^[0-9A-Z]+$/.test(s)) {\n return false;\n }\n const rearranged = s.slice(4) + s.slice(0, 4);\n let remainder = 0;\n for (let i = 0; i < rearranged.length; i++) {\n const ch = rearranged[i];\n // A→10 … Z→35, digits stay as-is\n const chunk = ch >= \"A\" && ch <= \"Z\" ? String(ch.charCodeAt(0) - 55) : ch;\n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;AAEO,SAAS,WAAW,OAAwB;AACjD,SAAO,eAAe,KAAK;AAC7B;AAEO,SAAS,WAAW,OAAwB;AACjD,SAAO,eAAe,KAAK;AAC7B;AAEO,SAAS,cAAc,OAAwB;AACpD,QAAM,KAAK,wBAAS,IAAI,QAAQ,QAAQ,EAAE,EAAE,YAAY;AACxD,MAAI,EAAE,WAAW,MAAM,CAAC,EAAE,WAAW,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,GAAG;AACpE,WAAO;AAAA,EACT;AACA,QAAM,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC;AAC5C,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,KAAK,WAAW,CAAC;AAEvB,UAAM,QAAQ,MAAM,OAAO,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI;AACvE,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,mBAAa,YAAY,MAAM,MAAM,WAAW,CAAC,IAAI,OAAO;AAAA,IAC9D;AAAA,EACF;AACA,SAAO,cAAc;AACvB;","names":[]}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "react-input-mask-format",
3
3
  "description": "Masked input component for React",
4
- "version": "1.0.5",
5
- "homepage": "https://github.com/temirtator/react-input-mask-format",
4
+ "version": "2.1.0",
5
+ "type": "module",
6
+ "homepage": "https://github.com/Temirtator/react-input-mask-format",
6
7
  "license": "MIT",
7
8
  "author": "Temirlan Shagyrov <sh.temirlan95@gmail.com>",
8
9
  "keywords": [
@@ -13,94 +14,74 @@
13
14
  "react-component"
14
15
  ],
15
16
  "peerDependencies": {
16
- "react": ">=16.8",
17
- "react-dom": ">=16.8"
17
+ "react": ">=16.8.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@babel/cli": "^7.8.3",
21
- "@babel/core": "^7.8.3",
22
- "@babel/plugin-proposal-class-properties": "^7.8.3",
23
- "@babel/plugin-transform-modules-commonjs": "^7.8.3",
24
- "@babel/plugin-transform-proto-to-assign": "^7.8.3",
25
- "@babel/polyfill": "^7.8.3",
26
- "@babel/preset-env": "^7.8.3",
27
- "@babel/preset-react": "^7.8.3",
28
- "@babel/register": "^7.8.3",
29
- "@rollup/plugin-typescript": "^8.2.1",
30
- "@types/react": "^17.0.3",
31
- "babel-eslint": "^10.0.3",
32
- "babel-loader": "^8.0.6",
33
- "babel-plugin-dev-expression": "^0.2.2",
34
- "babel-plugin-minify-dead-code-elimination": "^0.5.1",
35
- "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
36
- "chai": "^4.2.0",
37
- "console-polyfill": "^0.3.0",
38
- "cross-env": "^5.2.1",
39
- "eslint": "^6.8.0",
40
- "eslint-config-airbnb": "^18.0.1",
41
- "eslint-config-prettier": "^6.9.0",
42
- "eslint-plugin-import": "^2.20.0",
43
- "eslint-plugin-jsx-a11y": "^6.2.3",
44
- "eslint-plugin-prettier": "^3.1.2",
45
- "eslint-plugin-react": "^7.18.0",
46
- "eslint-plugin-react-hooks": "^1.7.0",
47
- "html-webpack-plugin": "^3.2.0",
48
- "husky": "^3.1.0",
49
- "karma": "^4.4.1",
50
- "karma-chrome-launcher": "^3.1.0",
51
- "karma-mocha": "^1.3.0",
52
- "karma-webpack": "^4.0.2",
53
- "lint-staged": "^9.5.0",
54
- "mocha": "^6.2.2",
55
- "prettier": "^1.19.1",
56
- "puppeteer": "^1.20.0",
57
- "react": "^16.12.0",
58
- "react-dom": "^16.12.0",
59
- "rollup": "^1.29.0",
60
- "rollup-plugin-babel": "^4.3.3",
61
- "rollup-plugin-commonjs": "^10.1.0",
62
- "rollup-plugin-node-resolve": "^5.2.0",
63
- "rollup-plugin-replace": "^2.2.0",
64
- "rollup-plugin-size-snapshot": "^0.10.0",
65
- "rollup-plugin-terser": "^5.2.0",
66
- "webpack": "^4.41.5",
67
- "webpack-cli": "^3.3.10",
68
- "webpack-dev-server": "^3.10.1"
20
+ "@eslint/js": "^9.0.0",
21
+ "@playwright/test": "^1.60.0",
22
+ "@size-limit/preset-small-lib": "^11.0.0",
23
+ "@testing-library/dom": "^10.0.0",
24
+ "@testing-library/jest-dom": "^6.0.0",
25
+ "@testing-library/react": "^16.0.0",
26
+ "@testing-library/user-event": "^14.0.0",
27
+ "@types/node": "^22.0.0",
28
+ "@types/react": "^19.0.0",
29
+ "@types/react-dom": "^19.2.3",
30
+ "@vitejs/plugin-react": "^4.3.0",
31
+ "eslint": "^9.0.0",
32
+ "eslint-plugin-react-hooks": "^5.0.0",
33
+ "jsdom": "^25.0.0",
34
+ "prettier": "^3.0.0",
35
+ "publint": "^0.2.0",
36
+ "react": "^19.0.0",
37
+ "react-dom": "^19.0.0",
38
+ "size-limit": "^11.0.0",
39
+ "tsup": "^8.0.0",
40
+ "typescript": "^5.5.0",
41
+ "typescript-eslint": "^8.0.0",
42
+ "vite": "^6.0.0",
43
+ "vitest": "^3.0.0"
69
44
  },
70
- "main": "index.js",
71
- "types": "./dist/index.d.ts",
45
+ "main": "./dist/index.cjs",
46
+ "module": "./dist/index.js",
47
+ "types": "./dist/index.d.cts",
48
+ "exports": {
49
+ ".": {
50
+ "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
51
+ "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
52
+ },
53
+ "./presets": {
54
+ "import": { "types": "./dist/presets.d.ts", "default": "./dist/presets.js" },
55
+ "require": { "types": "./dist/presets.d.cts", "default": "./dist/presets.cjs" }
56
+ },
57
+ "./validators": {
58
+ "import": { "types": "./dist/validators.d.ts", "default": "./dist/validators.js" },
59
+ "require": { "types": "./dist/validators.d.cts", "default": "./dist/validators.cjs" }
60
+ },
61
+ "./package.json": "./package.json"
62
+ },
63
+ "sideEffects": false,
72
64
  "files": [
73
- "lib",
74
65
  "dist"
75
66
  ],
76
- "lint-staged": {
77
- "*.js": "eslint"
78
- },
79
- "husky": {
80
- "hooks": {
81
- "pre-commit": "lint-staged"
82
- }
83
- },
67
+ "size-limit": [
68
+ { "path": "dist/index.js", "limit": "6 KB" },
69
+ { "path": "dist/presets.js", "limit": "2 KB" },
70
+ { "path": "dist/validators.js", "limit": "2 KB" }
71
+ ],
84
72
  "scripts": {
85
- "clean": "rimraf lib dist",
86
- "build": "cross-env BABEL_ENV=rollup rollup -c && npm run moveDeclarationFile",
87
- "start": "cross-env BABEL_ENV=test NODE_ENV=development webpack-dev-server",
88
- "prepare": "npm run lint && npm test && npm run clean && npm run build",
89
- "lint": "eslint ./src ./tests ./*.js",
90
- "lint-fix": "eslint --fix ./src ./tests ./*.js",
91
- "test": "npm run build && npm run test:input && npm run test:server-render && npm run test:build",
92
- "test:input": "cross-env NODE_ENV=test BABEL_ENV=test",
93
- "test:server-render": "cross-env BABEL_ENV=test mocha --require @babel/register ./tests/server-render",
94
- "test:build": "cross-env BABEL_ENV=test mocha --require @babel/register ./tests/build",
95
- "moveDeclarationFile": "cp -i ./index.d.ts ./dist/"
73
+ "build": "tsup",
74
+ "demo": "vite demo",
75
+ "lint": "eslint .",
76
+ "typecheck": "tsc --noEmit",
77
+ "test": "vitest run",
78
+ "test:watch": "vitest",
79
+ "test:e2e": "playwright test",
80
+ "size": "size-limit",
81
+ "prepublishOnly": "npm run build"
96
82
  },
97
83
  "repository": {
98
84
  "type": "git",
99
- "url": "https://github.com/temirtator/react-input-mask-format.git"
100
- },
101
- "dependencies": {
102
- "invariant": "^2.2.4",
103
- "prop-types": "^15.7.2",
104
- "warning": "^4.0.3"
85
+ "url": "git+https://github.com/Temirtator/react-input-mask-format.git"
105
86
  }
106
87
  }