@arkyn/components 3.0.1-beta.121 → 3.0.1-beta.122
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.
- package/dist/bundle.js +3141 -3125
- package/dist/bundle.umd.cjs +41 -40
- package/dist/components/phoneInput/index.d.ts +1 -106
- package/dist/components/phoneInput/index.d.ts.map +1 -1
- package/dist/components/phoneInput/index.js +11 -139
- package/dist/components/phoneInput/phoneInputCountryOption/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputCountryOption/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputCountrySelector/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputCountrySelector/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputMask/index.d.ts +1 -2
- package/dist/components/phoneInput/phoneInputMask/index.d.ts.map +1 -1
- package/dist/components/phoneInput/phoneInputMask/index.js +5 -2
- package/dist/utils/phoneInputUtilities.d.ts +1 -1713
- package/dist/utils/phoneInputUtilities.d.ts.map +1 -1
- package/dist/utils/phoneInputUtilities.js +1 -63
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phoneInputUtilities.d.ts","sourceRoot":"","sources":["../../src/utils/phoneInputUtilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"phoneInputUtilities.d.ts","sourceRoot":"","sources":["../../src/utils/phoneInputUtilities.ts"],"names":[],"mappings":"AAAA,iBAAS,KAAK,CAAC,KAAK,EAAE,MAAM,UAE3B;AAED,QAAA,MAAM,KAAK;;;CAGV,CAAC;AAEF,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAsBpD;AAED,iBAAS,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAGhD;AAED,QAAA,MAAM,UAAU,QAA2B,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { countries } from "@arkyn/templates";
|
|
2
1
|
function clear(value) {
|
|
3
2
|
return value && value.replace(/[^0-9]/g, "");
|
|
4
3
|
}
|
|
@@ -35,65 +34,4 @@ function getMask(value) {
|
|
|
35
34
|
return mask;
|
|
36
35
|
}
|
|
37
36
|
const MAX_LENGTH = clear(TYPES.NINE).length;
|
|
38
|
-
|
|
39
|
-
if (country.code === "+55") {
|
|
40
|
-
let value = clear(phoneNumber);
|
|
41
|
-
const mask = getMask(value);
|
|
42
|
-
let nextLength = value.length;
|
|
43
|
-
if (nextLength > MAX_LENGTH)
|
|
44
|
-
return;
|
|
45
|
-
value = applyMask(value, TYPES[mask]);
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
const mask = country.mask;
|
|
49
|
-
let formattedNumber = mask;
|
|
50
|
-
if (country.prefix) {
|
|
51
|
-
const prefixRegex = /\$+/g;
|
|
52
|
-
formattedNumber = formattedNumber.replace(prefixRegex, country.prefix);
|
|
53
|
-
}
|
|
54
|
-
for (let i = 0, j = 0; i < formattedNumber.length && j < phoneNumber.length; i++) {
|
|
55
|
-
if (formattedNumber[i] === "_") {
|
|
56
|
-
formattedNumber =
|
|
57
|
-
formattedNumber.substring(0, i) +
|
|
58
|
-
phoneNumber[j] +
|
|
59
|
-
formattedNumber.substring(i + 1);
|
|
60
|
-
j++;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return formattedNumber;
|
|
64
|
-
}
|
|
65
|
-
function getCountryWithPrefixCode(countryCode, prefix) {
|
|
66
|
-
const country = countries.find((country) => country.code === countryCode && country.prefix === prefix);
|
|
67
|
-
if (!country)
|
|
68
|
-
return null;
|
|
69
|
-
return country;
|
|
70
|
-
}
|
|
71
|
-
function getCountryWithoutPrefixCode(countryCode) {
|
|
72
|
-
const country = countries.find((country) => country.code === countryCode);
|
|
73
|
-
if (!country)
|
|
74
|
-
return null;
|
|
75
|
-
return country;
|
|
76
|
-
}
|
|
77
|
-
function getDefaultFormatPhoneNumber(defaultValue) {
|
|
78
|
-
const countryCode = defaultValue.split(" ")[0].split("-")[0];
|
|
79
|
-
const prefixCode = defaultValue.split(" ")[0].split("-")[1];
|
|
80
|
-
const phoneNumber = defaultValue.split(" ")[1];
|
|
81
|
-
if (!countryCode || !phoneNumber) {
|
|
82
|
-
return { country: null, formattedNumber: "" };
|
|
83
|
-
}
|
|
84
|
-
if (prefixCode) {
|
|
85
|
-
const country = getCountryWithPrefixCode(countryCode, prefixCode);
|
|
86
|
-
if (!country)
|
|
87
|
-
return { country: null, formattedNumber: "" };
|
|
88
|
-
const formattedNumber = formatPhoneNumber(phoneNumber, country);
|
|
89
|
-
const response = { country, formattedNumber };
|
|
90
|
-
return response;
|
|
91
|
-
}
|
|
92
|
-
const country = getCountryWithoutPrefixCode(countryCode);
|
|
93
|
-
if (!country)
|
|
94
|
-
return { country: null, formattedNumber: "" };
|
|
95
|
-
const formattedNumber = formatPhoneNumber(phoneNumber, country);
|
|
96
|
-
const response = { country, formattedNumber };
|
|
97
|
-
return response;
|
|
98
|
-
}
|
|
99
|
-
export { getDefaultFormatPhoneNumber, applyMask, clear, getMask, MAX_LENGTH, TYPES, };
|
|
37
|
+
export { applyMask, clear, getMask, MAX_LENGTH, TYPES };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/components",
|
|
3
|
-
"version": "3.0.1-beta.
|
|
3
|
+
"version": "3.0.1-beta.122",
|
|
4
4
|
"main": "./dist/bundle.js",
|
|
5
5
|
"module": "./dist/bundle.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"dev": "bunx vite --config documentation/vite.config.ts",
|
|
34
34
|
"build": "bunx vite build && tsc",
|
|
35
|
+
"test": "vitest --config vitest.config.ts",
|
|
35
36
|
"typecheck": "bunx tsc --project tsconfig.json --noEmit"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
@@ -55,10 +56,11 @@
|
|
|
55
56
|
"@types/is-hotkey": "^0.1.10",
|
|
56
57
|
"@types/react": "^19.0.0",
|
|
57
58
|
"@types/react-dom": "^19.0.0",
|
|
58
|
-
"@vitejs/plugin-react": "^4.7.0",
|
|
59
59
|
"bun-types": "latest",
|
|
60
60
|
"globals": "^15.15.0",
|
|
61
|
+
"jsdom": "^28.0.0",
|
|
61
62
|
"typescript": "^5.9.2",
|
|
62
|
-
"vite": "^5.4.19"
|
|
63
|
+
"vite": "^5.4.19",
|
|
64
|
+
"vitest": "^4.1.0-beta.4"
|
|
63
65
|
}
|
|
64
66
|
}
|