react-input-mask-format 2.3.0 → 2.5.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.
@@ -1,7 +1,28 @@
1
- // src/validators/index.ts
1
+ import {
2
+ RU_PLATE_LETTERS,
3
+ toRuPlateChar
4
+ } from "./chunk-OMKRB5AE.js";
5
+
6
+ // src/validators/shared.ts
2
7
  function digitsOnly(value) {
3
8
  return (value != null ? value : "").replace(/\D/g, "");
4
9
  }
10
+ function remainder(numeric, modulus) {
11
+ let r = 0;
12
+ for (let i = 0; i < numeric.length; i++) {
13
+ r = (r * 10 + (numeric.charCodeAt(i) - 48)) % modulus;
14
+ }
15
+ return r;
16
+ }
17
+ function isIbanChecksumValid(iban) {
18
+ const rearranged = iban.slice(4) + iban.slice(0, 4);
19
+ let numeric = "";
20
+ for (let i = 0; i < rearranged.length; i++) {
21
+ const ch = rearranged[i];
22
+ numeric += ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch;
23
+ }
24
+ return remainder(numeric, 97) === 1;
25
+ }
5
26
  function luhn(value) {
6
27
  const digits = digitsOnly(value);
7
28
  if (digits.length === 0) {
@@ -22,6 +43,16 @@ function luhn(value) {
22
43
  }
23
44
  return sum % 10 === 0;
24
45
  }
46
+ function isRealDate(year, month, day) {
47
+ if (month < 1 || month > 12 || day < 1) {
48
+ return false;
49
+ }
50
+ const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
51
+ const daysInMonth = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
52
+ return day <= daysInMonth[month - 1];
53
+ }
54
+
55
+ // src/validators/kz.ts
25
56
  var IIN_W1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
26
57
  var IIN_W2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2];
27
58
  function iinBinChecksum(value) {
@@ -51,21 +82,149 @@ function isValidKzIban(value) {
51
82
  if (s.length !== 20 || !s.startsWith("KZ") || !/^[0-9A-Z]+$/.test(s)) {
52
83
  return false;
53
84
  }
54
- const rearranged = s.slice(4) + s.slice(0, 4);
55
- let remainder = 0;
56
- for (let i = 0; i < rearranged.length; i++) {
57
- const ch = rearranged[i];
58
- const chunk = ch >= "A" && ch <= "Z" ? String(ch.charCodeAt(0) - 55) : ch;
59
- for (let j = 0; j < chunk.length; j++) {
60
- remainder = (remainder * 10 + (chunk.charCodeAt(j) - 48)) % 97;
61
- }
85
+ return isIbanChecksumValid(s);
86
+ }
87
+
88
+ // src/validators/ru.ts
89
+ var INN10_W = [2, 4, 10, 3, 5, 9, 4, 6, 8];
90
+ var INN12_W1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
91
+ var INN12_W2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];
92
+ var SNILS_W = [9, 8, 7, 6, 5, 4, 3, 2, 1];
93
+ var SNILS_UNCHECKED_MAX = 1001998;
94
+ function toDigits(digits) {
95
+ return digits.split("").map((c) => c.charCodeAt(0) - 48);
96
+ }
97
+ function weightedSum(d, weights) {
98
+ return weights.reduce((sum, w, i) => sum + w * d[i], 0);
99
+ }
100
+ function isValidRuInn(value) {
101
+ const d = toDigits(digitsOnly(value));
102
+ if (d.length === 10) {
103
+ return weightedSum(d, INN10_W) % 11 % 10 === d[9];
62
104
  }
63
- return remainder === 1;
105
+ if (d.length === 12) {
106
+ return weightedSum(d, INN12_W1) % 11 % 10 === d[10] && weightedSum(d, INN12_W2) % 11 % 10 === d[11];
107
+ }
108
+ return false;
109
+ }
110
+ function isValidRuSnils(value) {
111
+ const digits = digitsOnly(value);
112
+ if (digits.length !== 11) {
113
+ return false;
114
+ }
115
+ if (Number(digits.slice(0, 9)) <= SNILS_UNCHECKED_MAX) {
116
+ return true;
117
+ }
118
+ const d = toDigits(digits);
119
+ let control = weightedSum(d, SNILS_W) % 101;
120
+ if (control === 100) {
121
+ control = 0;
122
+ }
123
+ return control === d[9] * 10 + d[10];
124
+ }
125
+ function isValidRuOgrn(value) {
126
+ const digits = digitsOnly(value);
127
+ if (digits.length !== 13 || digits[0] !== "1" && digits[0] !== "5") {
128
+ return false;
129
+ }
130
+ return remainder(digits.slice(0, 12), 11) % 10 === Number(digits[12]);
131
+ }
132
+ function isValidRuOgrnip(value) {
133
+ const digits = digitsOnly(value);
134
+ if (digits.length !== 15 || digits[0] !== "3") {
135
+ return false;
136
+ }
137
+ return remainder(digits.slice(0, 14), 13) % 10 === Number(digits[14]);
138
+ }
139
+ function compactUpper(value) {
140
+ return (value != null ? value : "").replace(/\s+/g, "").toUpperCase();
141
+ }
142
+ function isValidRuKpp(value) {
143
+ return /^\d{4}[\dA-Z]{2}\d{3}$/.test(compactUpper(value));
144
+ }
145
+ function isValidRuBik(value) {
146
+ return /^[012]\d{8}$/.test(digitsOnly(value));
147
+ }
148
+ var ACCOUNT_W = [7, 1, 3];
149
+ function isValidRuAccount(account, bik) {
150
+ const a = digitsOnly(account);
151
+ const b = digitsOnly(bik);
152
+ if (a.length !== 20 || !isValidRuBik(b)) {
153
+ return false;
154
+ }
155
+ if (a.startsWith("03")) {
156
+ return true;
157
+ }
158
+ const rkcKeyed = a.startsWith("30101") || a.startsWith("40102");
159
+ const prefix = rkcKeyed ? "0" + b.slice(4, 6) : b.slice(6, 9);
160
+ const s = prefix + a;
161
+ let sum = 0;
162
+ for (let i = 0; i < s.length; i++) {
163
+ sum += (s.charCodeAt(i) - 48) * ACCOUNT_W[i % 3];
164
+ }
165
+ return sum % 10 === 0;
166
+ }
167
+ function isValidRuIban(value) {
168
+ const s = compactUpper(value);
169
+ if (s.length !== 33 || !s.startsWith("RU") || !/^[0-9A-Z]+$/.test(s)) {
170
+ return false;
171
+ }
172
+ return isIbanChecksumValid(s);
173
+ }
174
+ var PLATE_RE = new RegExp(
175
+ `^[${RU_PLATE_LETTERS}](\\d{3})[${RU_PLATE_LETTERS}]{2}(\\d{2}|[1-9]\\d{2})$`
176
+ );
177
+ function isValidRuPlate(value) {
178
+ const s = (value != null ? value : "").replace(/\s+/g, "").replace(/_+$/, "").split("").map(toRuPlateChar).join("");
179
+ const m = PLATE_RE.exec(s);
180
+ if (!m) {
181
+ return false;
182
+ }
183
+ return m[1] !== "000" && Number(m[2]) !== 0;
184
+ }
185
+
186
+ // src/validators/uz.ts
187
+ var PINFL_W = [7, 3, 1, 7, 3, 1, 7, 3, 1, 7, 3, 1, 7];
188
+ var CENTURY_BY_FIRST_DIGIT = [0, 1800, 1800, 1900, 1900, 2e3, 2e3];
189
+ function isValidUzPinfl(value) {
190
+ const digits = digitsOnly(value);
191
+ if (digits.length !== 14) {
192
+ return false;
193
+ }
194
+ const first = Number(digits[0]);
195
+ if (first < 1 || first > 6) {
196
+ return false;
197
+ }
198
+ const day = Number(digits.slice(1, 3));
199
+ const month = Number(digits.slice(3, 5));
200
+ const year = CENTURY_BY_FIRST_DIGIT[first] + Number(digits.slice(5, 7));
201
+ if (!isRealDate(year, month, day)) {
202
+ return false;
203
+ }
204
+ let sum = 0;
205
+ for (let i = 0; i < PINFL_W.length; i++) {
206
+ sum += (digits.charCodeAt(i) - 48) * PINFL_W[i];
207
+ }
208
+ return sum % 10 === Number(digits[13]);
209
+ }
210
+ function isValidUzInn(value) {
211
+ return digitsOnly(value).length === 9;
64
212
  }
65
213
  export {
66
214
  isValidBin,
67
215
  isValidIin,
68
216
  isValidKzIban,
217
+ isValidRuAccount,
218
+ isValidRuBik,
219
+ isValidRuIban,
220
+ isValidRuInn,
221
+ isValidRuKpp,
222
+ isValidRuOgrn,
223
+ isValidRuOgrnip,
224
+ isValidRuPlate,
225
+ isValidRuSnils,
226
+ isValidUzInn,
227
+ isValidUzPinfl,
69
228
  luhn
70
229
  };
71
230
  //# sourceMappingURL=validators.js.map
@@ -1 +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 for (let j = 0; j < chunk.length; j++) {\n remainder = (remainder * 10 + (chunk.charCodeAt(j) - 48)) % 97;\n }\n }\n return remainder === 1;\n}\n"],"mappings":";AAAA,SAAS,WAAW,OAAuB;AACzC,UAAQ,wBAAS,IAAI,QAAQ,OAAO,EAAE;AACxC;AAEO,SAAS,KAAK,OAAwB;AAC3C,QAAM,SAAS,WAAW,KAAK;AAC/B,MAAI,OAAO,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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":[]}
1
+ {"version":3,"sources":["../src/validators/shared.ts","../src/validators/kz.ts","../src/validators/ru.ts","../src/validators/uz.ts"],"sourcesContent":["export function digitsOnly(value: string): string {\n return (value ?? \"\").replace(/\\D/g, \"\");\n}\n\n// Remainder of an arbitrary-length digit string (es2019 target: no BigInt literals)\nexport function remainder(numeric: string, modulus: number): number {\n let r = 0;\n for (let i = 0; i < numeric.length; i++) {\n r = (r * 10 + (numeric.charCodeAt(i) - 48)) % modulus;\n }\n return r;\n}\n\n// ISO 7064 MOD-97-10; expects a compact uppercase [0-9A-Z]+ string\nexport function isIbanChecksumValid(iban: string): boolean {\n const rearranged = iban.slice(4) + iban.slice(0, 4);\n let numeric = \"\";\n for (let i = 0; i < rearranged.length; i++) {\n const ch = rearranged[i];\n // A→10 … Z→35, digits stay as-is\n numeric += ch >= \"A\" && ch <= \"Z\" ? String(ch.charCodeAt(0) - 55) : ch;\n }\n return remainder(numeric, 97) === 1;\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\n// Calendar check without the clock (validators must be deterministic)\nexport function isRealDate(year: number, month: number, day: number): boolean {\n if (month < 1 || month > 12 || day < 1) {\n return false;\n }\n const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n const daysInMonth = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n return day <= daysInMonth[month - 1];\n}\n","import { digitsOnly, isIbanChecksumValid } from \"./shared\";\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 return isIbanChecksumValid(s);\n}\n","import { digitsOnly, remainder, isIbanChecksumValid } from \"./shared\";\nimport { RU_PLATE_LETTERS, toRuPlateChar } from \"../utils/ru-plate\";\n\nconst INN10_W = [2, 4, 10, 3, 5, 9, 4, 6, 8];\nconst INN12_W1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8];\nconst INN12_W2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8];\nconst SNILS_W = [9, 8, 7, 6, 5, 4, 3, 2, 1];\n// SNILS numbers up to 001-001-998 were issued before the checksum existed\nconst SNILS_UNCHECKED_MAX = 1001998;\n\nfunction toDigits(digits: string): number[] {\n return digits.split(\"\").map(c => c.charCodeAt(0) - 48);\n}\n\nfunction weightedSum(d: number[], weights: number[]): number {\n return weights.reduce((sum, w, i) => sum + w * d[i], 0);\n}\n\nexport function isValidRuInn(value: string): boolean {\n const d = toDigits(digitsOnly(value));\n if (d.length === 10) {\n return weightedSum(d, INN10_W) % 11 % 10 === d[9];\n }\n if (d.length === 12) {\n return (\n weightedSum(d, INN12_W1) % 11 % 10 === d[10] &&\n weightedSum(d, INN12_W2) % 11 % 10 === d[11]\n );\n }\n return false;\n}\n\nexport function isValidRuSnils(value: string): boolean {\n const digits = digitsOnly(value);\n if (digits.length !== 11) {\n return false;\n }\n if (Number(digits.slice(0, 9)) <= SNILS_UNCHECKED_MAX) {\n return true;\n }\n const d = toDigits(digits);\n let control = weightedSum(d, SNILS_W) % 101;\n if (control === 100) {\n control = 0;\n }\n return control === d[9] * 10 + d[10];\n}\n\nexport function isValidRuOgrn(value: string): boolean {\n const digits = digitsOnly(value);\n // 1/5 = OGRN; 2, 6-9 are ГРН record numbers\n if (digits.length !== 13 || (digits[0] !== \"1\" && digits[0] !== \"5\")) {\n return false;\n }\n return remainder(digits.slice(0, 12), 11) % 10 === Number(digits[12]);\n}\n\nexport function isValidRuOgrnip(value: string): boolean {\n const digits = digitsOnly(value);\n if (digits.length !== 15 || digits[0] !== \"3\") {\n return false;\n }\n // the check digit is the last digit of the remainder (10-12 → 0-2)\n return remainder(digits.slice(0, 14), 13) % 10 === Number(digits[14]);\n}\n\nfunction compactUpper(value: string): string {\n return (value ?? \"\").replace(/\\s+/g, \"\").toUpperCase();\n}\n\nexport function isValidRuKpp(value: string): boolean {\n return /^\\d{4}[\\dA-Z]{2}\\d{3}$/.test(compactUpper(value));\n}\n\nexport function isValidRuBik(value: string): boolean {\n // 732-P: first digit 0 (direct), 1 (indirect), 2 (CBR client); legacy BIKs start with 04\n return /^[012]\\d{8}$/.test(digitsOnly(value));\n}\n\nconst ACCOUNT_W = [7, 1, 3];\n\nexport function isValidRuAccount(account: string, bik: string): boolean {\n const a = digitsOnly(account);\n const b = digitsOnly(bik);\n if (a.length !== 20 || !isValidRuBik(b)) {\n return false;\n }\n // Treasury accounts (03…) carry no control key under CBR order 515: structure only.\n if (a.startsWith(\"03\")) {\n return true;\n }\n // Correspondent accounts (30101…) and single treasury accounts (40102…, ЕКС) are keyed\n // with the RKC prefix \"0\" + BIK[4..5]; everything else with the last 3 BIK digits.\n const rkcKeyed = a.startsWith(\"30101\") || a.startsWith(\"40102\");\n const prefix = rkcKeyed ? \"0\" + b.slice(4, 6) : b.slice(6, 9);\n const s = prefix + a;\n let sum = 0;\n for (let i = 0; i < s.length; i++) {\n sum += (s.charCodeAt(i) - 48) * ACCOUNT_W[i % 3];\n }\n return sum % 10 === 0;\n}\n\nexport function isValidRuIban(value: string): boolean {\n const s = compactUpper(value);\n if (s.length !== 33 || !s.startsWith(\"RU\") || !/^[0-9A-Z]+$/.test(s)) {\n return false;\n }\n return isIbanChecksumValid(s);\n}\n\nconst PLATE_RE = new RegExp(\n `^[${RU_PLATE_LETTERS}](\\\\d{3})[${RU_PLATE_LETTERS}]{2}(\\\\d{2}|[1-9]\\\\d{2})$`\n);\n\nexport function isValidRuPlate(value: string): boolean {\n const s = (value ?? \"\").replace(/\\s+/g, \"\").replace(/_+$/, \"\").split(\"\").map(toRuPlateChar).join(\"\");\n const m = PLATE_RE.exec(s);\n if (!m) {\n return false;\n }\n // 000 is never issued; region 00 does not exist\n return m[1] !== \"000\" && Number(m[2]) !== 0;\n}\n","import { digitsOnly, isRealDate } from \"./shared\";\n\n// Cabinet of Ministers resolution No. 177 (12.04.2022): mod 10 with repeating weights 7-3-1\nconst PINFL_W = [7, 3, 1, 7, 3, 1, 7, 3, 1, 7, 3, 1, 7];\n// first digit = sex + century: 1-2 → 1800s, 3-4 → 1900s, 5-6 → 2000s\nconst CENTURY_BY_FIRST_DIGIT = [0, 1800, 1800, 1900, 1900, 2000, 2000];\n\nexport function isValidUzPinfl(value: string): boolean {\n const digits = digitsOnly(value);\n if (digits.length !== 14) {\n return false;\n }\n const first = Number(digits[0]);\n if (first < 1 || first > 6) {\n return false;\n }\n const day = Number(digits.slice(1, 3));\n const month = Number(digits.slice(3, 5));\n const year = CENTURY_BY_FIRST_DIGIT[first] + Number(digits.slice(5, 7));\n if (!isRealDate(year, month, day)) {\n return false;\n }\n let sum = 0;\n for (let i = 0; i < PINFL_W.length; i++) {\n sum += (digits.charCodeAt(i) - 48) * PINFL_W[i];\n }\n return sum % 10 === Number(digits[13]);\n}\n\n// The INN control digit algorithm is not published — length only\nexport function isValidUzInn(value: string): boolean {\n return digitsOnly(value).length === 9;\n}\n"],"mappings":";;;;;;AAAO,SAAS,WAAW,OAAuB;AAChD,UAAQ,wBAAS,IAAI,QAAQ,OAAO,EAAE;AACxC;AAGO,SAAS,UAAU,SAAiB,SAAyB;AAClE,MAAI,IAAI;AACR,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,SAAK,IAAI,MAAM,QAAQ,WAAW,CAAC,IAAI,OAAO;AAAA,EAChD;AACA,SAAO;AACT;AAGO,SAAS,oBAAoB,MAAuB;AACzD,QAAM,aAAa,KAAK,MAAM,CAAC,IAAI,KAAK,MAAM,GAAG,CAAC;AAClD,MAAI,UAAU;AACd,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,KAAK,WAAW,CAAC;AAEvB,eAAW,MAAM,OAAO,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI;AAAA,EACtE;AACA,SAAO,UAAU,SAAS,EAAE,MAAM;AACpC;AAEO,SAAS,KAAK,OAAwB;AAC3C,QAAM,SAAS,WAAW,KAAK;AAC/B,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AACA,MAAI,MAAM;AACV,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G,GAAG,GAAG,CAAC;AAEtD,IAAM,yBAAyB,CAAC,GAAG,MAAM,MAAM,MAAM,MAAM,KAAM,GAAI;AAE9D,SAAS,eAAe,OAAwB;AACrD,QAAM,SAAS,WAAW,KAAK;AAC/B,MAAI,OAAO,WAAW,IAAI;AACxB,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,OAAO,OAAO,CAAC,CAAC;AAC9B,MAAI,QAAQ,KAAK,QAAQ,GAAG;AAC1B,WAAO;AAAA,EACT;AACA,QAAM,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AACrC,QAAM,QAAQ,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AACvC,QAAM,OAAO,uBAAuB,KAAK,IAAI,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AACtE,MAAI,CAAC,WAAW,MAAM,OAAO,GAAG,GAAG;AACjC,WAAO;AAAA,EACT;AACA,MAAI,MAAM;AACV,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,YAAQ,OAAO,WAAW,CAAC,IAAI,MAAM,QAAQ,CAAC;AAAA,EAChD;AACA,SAAO,MAAM,OAAO,OAAO,OAAO,EAAE,CAAC;AACvC;AAGO,SAAS,aAAa,OAAwB;AACnD,SAAO,WAAW,KAAK,EAAE,WAAW;AACtC;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-input-mask-format",
3
3
  "description": "Masked input component for React",
4
- "version": "2.3.0",
4
+ "version": "2.5.0",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/Temirtator/react-input-mask-format",
7
7
  "license": "MIT",
@@ -11,7 +11,15 @@
11
11
  "input",
12
12
  "mask",
13
13
  "masked",
14
- "react-component"
14
+ "react-component",
15
+ "presets",
16
+ "russia",
17
+ "inn",
18
+ "snils",
19
+ "ogrn",
20
+ "kazakhstan",
21
+ "uzbekistan",
22
+ "pinfl"
15
23
  ],
16
24
  "peerDependencies": {
17
25
  "react": ">=16.8.0"
@@ -82,6 +90,7 @@
82
90
  "scripts": {
83
91
  "build": "tsup",
84
92
  "demo": "vite demo",
93
+ "demo:build": "vite build demo",
85
94
  "lint": "eslint .",
86
95
  "typecheck": "tsc --noEmit",
87
96
  "test": "vitest run",