@rpcbase/ui 0.207.0 → 0.208.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.
- package/dist/index.js +7 -7
- package/dist/index19.js +1 -1
- package/dist/index19.js.map +1 -1
- package/dist/index200.js +56 -55
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +60 -8
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +7 -15
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +15 -143
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +145 -4
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +4 -11
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +10 -104
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +94 -347
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +349 -87
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +73 -304
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +309 -193
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +211 -19
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +18 -27
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +27 -187
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +186 -16
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +18 -44
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +60 -8
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +42 -23
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +9 -44
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +25 -18
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +45 -3
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +17 -4
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +3 -21
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +4 -24
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +17 -64
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +23 -13
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +68 -4
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +14 -50
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +4 -6
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +50 -26
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +5 -13
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +25 -8
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +17 -3
- package/dist/index232.js.map +1 -0
- package/dist/index233.js +8 -24
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +2 -71
- package/dist/index235.js +29 -3
- package/dist/index235.js.map +1 -0
- package/dist/index236.js +69 -12
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +3 -54
- package/dist/index238.js +11 -114
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +51 -6
- package/dist/index239.js.map +1 -1
- package/dist/index240.js +115 -13
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +6 -687
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +13 -253
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +662 -676
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +252 -7430
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +700 -6
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +7429 -11
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +5 -4
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +11 -458
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +5 -37
- package/dist/index249.js.map +1 -1
- package/dist/index250.js +458 -18
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +34 -24
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +19 -4
- package/dist/index252.js.map +1 -1
- package/dist/index253.js +23 -54
- package/dist/index253.js.map +1 -1
- package/dist/index254.js +4 -7
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +57 -11
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +8 -3
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +12 -16
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +3 -26
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +15 -42
- package/dist/index259.js.map +1 -1
- package/dist/index260.js +25 -13
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +40 -22
- package/dist/index261.js.map +1 -1
- package/dist/index262.js +13 -17
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +24 -34
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +17 -5
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +35 -9
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +5 -8
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +9 -9
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +8 -10
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +9 -7
- package/dist/index269.js.map +1 -1
- package/dist/index270.js +9 -72
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +7 -171
- package/dist/index271.js.map +1 -1
- package/dist/index272.js +63 -104
- package/dist/index272.js.map +1 -1
- package/dist/index273.js +169 -12
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +109 -75
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +12 -44
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +79 -12
- package/dist/index276.js.map +1 -1
- package/dist/index277.js +45 -15
- package/dist/index277.js.map +1 -1
- package/dist/index278.js +12 -98
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +15 -55
- package/dist/index279.js.map +1 -1
- package/dist/index280.js +89 -98
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +27 -42
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +92 -97
- package/dist/index282.js.map +1 -1
- package/dist/index283.js +62 -46
- package/dist/index283.js.map +1 -1
- package/dist/index284.js +108 -38
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +48 -135
- package/dist/index285.js.map +1 -1
- package/dist/index286.js +43 -139
- package/dist/index286.js.map +1 -1
- package/dist/index287.js +105 -217
- package/dist/index287.js.map +1 -1
- package/dist/index288.js +109 -210
- package/dist/index288.js.map +1 -1
- package/dist/index289.js +168 -212
- package/dist/index289.js.map +1 -1
- package/dist/index290.js +240 -5
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +298 -6
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +5 -7
- package/dist/index292.js.map +1 -1
- package/dist/index293.js +4 -4
- package/dist/index293.js.map +1 -1
- package/dist/index294.js +7 -6
- package/dist/index294.js.map +1 -1
- package/dist/index295.js +6 -21
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +6 -10
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +18 -123
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +10 -164
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +116 -58
- package/dist/index299.js.map +1 -1
- package/dist/index300.js +161 -106
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +66 -489
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +106 -59
- package/dist/index302.js.map +1 -1
- package/dist/index303.js +492 -4
- package/dist/index303.js.map +1 -1
- package/dist/index304.js +62 -27
- package/dist/index304.js.map +1 -1
- package/dist/index305.js +4 -66
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +27 -152
- package/dist/index306.js.map +1 -1
- package/dist/index307.js +59 -555
- package/dist/index307.js.map +1 -1
- package/dist/index308.js +143 -201
- package/dist/index308.js.map +1 -1
- package/dist/index309.js +56 -326
- package/dist/index309.js.map +1 -1
- package/dist/index310.js +553 -260
- package/dist/index310.js.map +1 -1
- package/dist/index311.js +214 -0
- package/dist/index311.js.map +1 -0
- package/dist/index312.js +335 -0
- package/dist/index312.js.map +1 -0
- package/dist/index313.js +272 -0
- package/dist/index313.js.map +1 -0
- package/package.json +2 -2
- package/dist/index234.js.map +0 -1
- package/dist/index237.js.map +0 -1
package/dist/index297.js
CHANGED
|
@@ -1,130 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (typeof Intl > "u" || Intl.DisplayNames === void 0) return null;
|
|
15
|
-
try {
|
|
16
|
-
let t = Array.isArray(e) ? e : e ? [e] : void 0;
|
|
17
|
-
return new Intl.DisplayNames(t, { type: "region" });
|
|
18
|
-
} catch {
|
|
19
|
-
return null;
|
|
1
|
+
//#region src/components/PhoneNumberInput/messages.ts
|
|
2
|
+
var e = {
|
|
3
|
+
en: {
|
|
4
|
+
lengthTooLong: (e) => e ? `This number looks too long for ${e}.` : "This number looks too long.",
|
|
5
|
+
noMatches: "No matching countries",
|
|
6
|
+
selectCountryLabel: "Select a country",
|
|
7
|
+
selectedCountryLabel: (e) => e ? `${e} flag` : "Selected country"
|
|
8
|
+
},
|
|
9
|
+
fr: {
|
|
10
|
+
lengthTooLong: (e) => e ? `This number looks too long for ${e}.` : "This number looks too long.",
|
|
11
|
+
noMatches: "Aucun pays correspondant",
|
|
12
|
+
selectCountryLabel: "Select a country",
|
|
13
|
+
selectedCountryLabel: (e) => e ? `${e} flag` : "Selected country"
|
|
20
14
|
}
|
|
21
|
-
}
|
|
22
|
-
function
|
|
23
|
-
let r = l(t), i = l("en");
|
|
24
|
-
return n.map((t) => {
|
|
25
|
-
let n = e(t), a = r?.of(t) ?? i?.of(t) ?? t, o = i?.of(t) ?? a, s = S(t), c = Array.from(new Set([
|
|
26
|
-
a,
|
|
27
|
-
o,
|
|
28
|
-
t.toUpperCase(),
|
|
29
|
-
t.toLowerCase(),
|
|
30
|
-
...s
|
|
31
|
-
].filter(Boolean)));
|
|
32
|
-
return {
|
|
33
|
-
value: t,
|
|
34
|
-
name: a,
|
|
35
|
-
dialCode: n,
|
|
36
|
-
label: `${a} (+${n})`,
|
|
37
|
-
flag: _(t),
|
|
38
|
-
searchableTokens: c,
|
|
39
|
-
normalizedSearchableTokens: c.map((e) => b(e))
|
|
40
|
-
};
|
|
41
|
-
}).sort((e, t) => {
|
|
42
|
-
let n = d(e.value), r = d(t.value);
|
|
43
|
-
return n === r ? e.name.localeCompare(t.name) : n - r;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function d(t) {
|
|
47
|
-
return t === "US" ? 0 : t === "CA" ? 1 : e(t) === "1" ? 2 : 3;
|
|
48
|
-
}
|
|
49
|
-
function f(e) {
|
|
50
|
-
return e ? Array.isArray(e) ? e.join("\0") : e : i;
|
|
51
|
-
}
|
|
52
|
-
function p(e) {
|
|
53
|
-
if (e !== i) {
|
|
54
|
-
if (e.includes("\0")) {
|
|
55
|
-
let t = e.split("\0").filter(Boolean);
|
|
56
|
-
return t.length === 0 ? void 0 : t.length === 1 ? t[0] ?? void 0 : t;
|
|
57
|
-
}
|
|
58
|
-
return e;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function m(e, t) {
|
|
62
|
-
let n = r.get(t);
|
|
63
|
-
if (n) return n;
|
|
64
|
-
let i = u(e);
|
|
65
|
-
return r.set(t, i), i;
|
|
66
|
-
}
|
|
67
|
-
function h(e) {
|
|
68
|
-
return {
|
|
69
|
-
code: e.value,
|
|
70
|
-
name: e.name,
|
|
71
|
-
dialCode: e.dialCode,
|
|
72
|
-
flag: e.flag
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function g(t) {
|
|
15
|
+
};
|
|
16
|
+
function t(t, n) {
|
|
76
17
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
dialCode: e(t),
|
|
80
|
-
flag: _(t)
|
|
18
|
+
...e[(Array.isArray(t) ? t : t ? [t] : []).map((e) => e.split("-")[0]?.toLowerCase()).find((t) => t && e[t]) ?? "en"] ?? e.en,
|
|
19
|
+
...n ?? {}
|
|
81
20
|
};
|
|
82
21
|
}
|
|
83
|
-
function _(e) {
|
|
84
|
-
let t = e?.toUpperCase();
|
|
85
|
-
if (!t || t.length !== 2 || /[^A-Z]/.test(t)) return "";
|
|
86
|
-
let n = 127397;
|
|
87
|
-
return String.fromCodePoint(t.charCodeAt(0) + n, t.charCodeAt(1) + n);
|
|
88
|
-
}
|
|
89
|
-
var v = /[\u0300-\u036f]/g;
|
|
90
|
-
function y(e) {
|
|
91
|
-
return e.normalize("NFD").replace(v, "");
|
|
92
|
-
}
|
|
93
|
-
function b(e) {
|
|
94
|
-
return y(e).toLowerCase();
|
|
95
|
-
}
|
|
96
|
-
function x(e, t) {
|
|
97
|
-
let n = 2 ** 53 - 1;
|
|
98
|
-
for (let r of e) {
|
|
99
|
-
let e = r.indexOf(t);
|
|
100
|
-
e >= 0 && e < n && (n = e);
|
|
101
|
-
}
|
|
102
|
-
return n === 2 ** 53 - 1 ? 2 ** 53 - 1 : n;
|
|
103
|
-
}
|
|
104
|
-
function S(e) {
|
|
105
|
-
switch (e) {
|
|
106
|
-
case "US": return [
|
|
107
|
-
"USA",
|
|
108
|
-
"United States",
|
|
109
|
-
"America",
|
|
110
|
-
"United States of America"
|
|
111
|
-
];
|
|
112
|
-
case "GB": return [
|
|
113
|
-
"UK",
|
|
114
|
-
"United Kingdom",
|
|
115
|
-
"Great Britain",
|
|
116
|
-
"England"
|
|
117
|
-
];
|
|
118
|
-
case "AE": return ["UAE", "United Arab Emirates"];
|
|
119
|
-
case "KR": return ["South Korea", "Korea"];
|
|
120
|
-
case "CN": return ["China", "PRC"];
|
|
121
|
-
case "CD": return ["DRC", "Congo-Kinshasa"];
|
|
122
|
-
case "CG": return ["Congo-Brazzaville"];
|
|
123
|
-
case "BR": return ["Brazil"];
|
|
124
|
-
default: return [];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
22
|
//#endregion
|
|
128
|
-
export {
|
|
23
|
+
export { t as resolveMessages };
|
|
129
24
|
|
|
130
25
|
//# sourceMappingURL=index297.js.map
|
package/dist/index297.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index297.js","names":["CountryCode","getCountryCallingCode","CountryOption","PhoneNumberSelectedCountry","getCountryList","DEFAULT_COUNTRY","COUNTRY_OPTIONS","COUNTRY_OPTIONS_CACHE","Map","DEFAULT_LOCALE_CACHE_KEY","COUNTRY_DIAL_CODES","Array","from","Set","map","code","sort","a","b","length","MAX_DIAL_CODE_LENGTH","reduce","max","dial","Math","COMMON_IDD_PREFIXES","getValidCountry","input","includes","createDisplayNames","locale","Intl","DisplayNames","locales","isArray","undefined","type","buildCountryOptions","displayNames","englishDisplayNames","country","dialCode","localizedName","of","englishName","aliasTokens","getCountryAliases","searchableTokens","toUpperCase","toLowerCase","filter","Boolean","value","name","label","flag","countryCodeToFlagEmoji","normalizedSearchableTokens","token","normalizeSearchValue","priorityA","getCountryPriority","priorityB","localeCompare","getLocaleCacheKey","join","parseLocaleCacheKey","cacheKey","parts","split","getCachedCountryOptions","cached","get","built","set","toSelectedCountry","option","buildFallbackSelectedCountry","upper","test","base","String","fromCodePoint","charCodeAt","DIACRITICS_REGEX","stripDiacritics","normalize","replace","optionMatchIndex","tokens","query","best","Number","MAX_SAFE_INTEGER","index","indexOf"],"sources":["../src/components/PhoneNumberInput/country-options.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { getCountryCallingCode } from \"libphonenumber-js\"\n\nimport type { CountryOption, PhoneNumberSelectedCountry } from \"./types\"\nimport { getCountryList } from \"./countries\"\n\n\nexport const DEFAULT_COUNTRY: CountryCode = \"US\"\nconst COUNTRY_OPTIONS = getCountryList()\n\nconst COUNTRY_OPTIONS_CACHE = new Map<string, CountryOption[]>()\nconst DEFAULT_LOCALE_CACHE_KEY = \"__default_locale__\"\nexport const COUNTRY_DIAL_CODES = Array.from(\n new Set(COUNTRY_OPTIONS.map((code) => getCountryCallingCode(code)))\n).sort((a, b) => b.length - a.length)\nexport const MAX_DIAL_CODE_LENGTH = COUNTRY_DIAL_CODES.reduce(\n (max, dial) => Math.max(max, dial.length),\n 0\n)\nexport const COMMON_IDD_PREFIXES = [\"0011\", \"001\", \"011\", \"00\", \"810\"]\n\nexport function getValidCountry(input: CountryCode | undefined) {\n if (!input) {\n return DEFAULT_COUNTRY\n }\n\n return COUNTRY_OPTIONS.includes(input) ? input : DEFAULT_COUNTRY\n}\n\nfunction createDisplayNames(locale?: string | string[]) {\n if (typeof Intl === \"undefined\" || typeof Intl.DisplayNames === \"undefined\") {\n return null\n }\n\n try {\n const locales = Array.isArray(locale) ? locale : locale ? [locale] : undefined\n return new Intl.DisplayNames(locales, { type: \"region\" })\n } catch {\n return null\n }\n}\n\nfunction buildCountryOptions(locale?: string | string[]) {\n const displayNames = createDisplayNames(locale)\n const englishDisplayNames = createDisplayNames(\"en\")\n\n return COUNTRY_OPTIONS\n .map((country) => {\n const dialCode = getCountryCallingCode(country)\n const localizedName = displayNames?.of(country) ?? englishDisplayNames?.of(country) ?? country\n const englishName = englishDisplayNames?.of(country) ?? localizedName\n const aliasTokens = getCountryAliases(country)\n const searchableTokens = Array.from(\n new Set(\n [localizedName, englishName, country.toUpperCase(), country.toLowerCase(), ...aliasTokens].filter(\n Boolean\n )\n )\n ) as string[]\n return {\n value: country,\n name: localizedName,\n dialCode,\n label: `${localizedName} (+${dialCode})`,\n flag: countryCodeToFlagEmoji(country),\n searchableTokens,\n normalizedSearchableTokens: searchableTokens.map((token) => normalizeSearchValue(token)),\n }\n })\n .sort((a, b) => {\n const priorityA = getCountryPriority(a.value)\n const priorityB = getCountryPriority(b.value)\n if (priorityA !== priorityB) {\n return priorityA - priorityB\n }\n return a.name.localeCompare(b.name)\n })\n}\n\nfunction getCountryPriority(code: CountryCode) {\n if (code === \"US\") return 0\n if (code === \"CA\") return 1\n if (getCountryCallingCode(code) === \"1\") return 2\n return 3\n}\n\nexport function getLocaleCacheKey(locale?: string | string[]) {\n if (!locale) {\n return DEFAULT_LOCALE_CACHE_KEY\n }\n if (Array.isArray(locale)) {\n return locale.join(\"\\u0000\")\n }\n return locale\n}\n\nexport function parseLocaleCacheKey(cacheKey: string): string | string[] | undefined {\n if (cacheKey === DEFAULT_LOCALE_CACHE_KEY) {\n return undefined\n }\n\n if (cacheKey.includes(\"\\u0000\")) {\n const parts = cacheKey.split(\"\\u0000\").filter(Boolean)\n if (parts.length === 0) {\n return undefined\n }\n if (parts.length === 1) {\n return parts[0] ?? undefined\n }\n return parts\n }\n\n return cacheKey\n}\n\nexport function getCachedCountryOptions(locale: string | string[] | undefined, cacheKey: string) {\n const cached = COUNTRY_OPTIONS_CACHE.get(cacheKey)\n if (cached) {\n return cached\n }\n const built = buildCountryOptions(locale)\n COUNTRY_OPTIONS_CACHE.set(cacheKey, built)\n return built\n}\n\nexport function toSelectedCountry(option: CountryOption): PhoneNumberSelectedCountry {\n return {\n code: option.value,\n name: option.name,\n dialCode: option.dialCode,\n flag: option.flag,\n }\n}\n\nexport function buildFallbackSelectedCountry(country: CountryCode): PhoneNumberSelectedCountry {\n return {\n code: country,\n name: country,\n dialCode: getCountryCallingCode(country),\n flag: countryCodeToFlagEmoji(country),\n }\n}\n\nfunction countryCodeToFlagEmoji(country: CountryCode) {\n const upper = country?.toUpperCase()\n\n if (!upper || upper.length !== 2 || /[^A-Z]/.test(upper)) {\n return \"\"\n }\n\n const base = 127397\n return String.fromCodePoint(\n upper.charCodeAt(0) + base,\n upper.charCodeAt(1) + base\n )\n}\n\nconst DIACRITICS_REGEX = /[\\u0300-\\u036f]/g\n\nfunction stripDiacritics(value: string) {\n return value.normalize(\"NFD\").replace(DIACRITICS_REGEX, \"\")\n}\n\nexport function normalizeSearchValue(value: string) {\n return stripDiacritics(value).toLowerCase()\n}\n\nexport function optionMatchIndex(tokens: string[], query: string) {\n let best = Number.MAX_SAFE_INTEGER\n for (const token of tokens) {\n const index = token.indexOf(query)\n if (index >= 0 && index < best) {\n best = index\n }\n }\n return best === Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : best\n}\n\nfunction getCountryAliases(code: CountryCode): string[] {\n switch (code) {\n case \"US\":\n return [\"USA\", \"United States\", \"America\", \"United States of America\"]\n case \"GB\":\n return [\"UK\", \"United Kingdom\", \"Great Britain\", \"England\"]\n case \"AE\":\n return [\"UAE\", \"United Arab Emirates\"]\n case \"KR\":\n return [\"South Korea\", \"Korea\"]\n case \"CN\":\n return [\"China\", \"PRC\"]\n case \"CD\":\n return [\"DRC\", \"Congo-Kinshasa\"]\n case \"CG\":\n return [\"Congo-Brazzaville\"]\n case \"BR\":\n return [\"Brazil\"]\n default:\n return []\n }\n}\n\n"],"mappings":";;AAQA,IAAMM,IAAkBF,GAAgB,EAElCG,oBAAwB,IAAIC,KAA8B,EAC1DC,IAA2B,sBACpBC,IAAqBC,MAAMC,KACtC,IAAIC,IAAIP,EAAgBQ,KAAKC,MAASd,EAAsBc,EAAK,CAAC,CACpE,CAAC,CAACC,MAAMC,GAAGC,MAAMA,EAAEC,SAASF,EAAEE,OAAO,EACxBC,IAAuBV,EAAmBW,QACpDC,GAAKC,MAASC,KAAKF,IAAIA,GAAKC,EAAKJ,OAAO,EACzC,EACD,EACYM,IAAsB;CAAC;CAAQ;CAAO;CAAO;CAAM;CAAM;AAEtE,SAAgBC,EAAgBC,GAAgC;AAK9D,QAJKA,KAIErB,EAAgBsB,SAASD,EAAM,GAAGA,IAAAA;;AAG3C,SAASE,EAAmBC,GAA4B;AACtD,KAAI,OAAOC,OAAS,OAAsBA,KAAKC,iBAAiB,OAC9D,QAAO;AAGT,KAAI;EACF,IAAMC,IAAUtB,MAAMuB,QAAQJ,EAAO,GAAGA,IAASA,IAAS,CAACA,EAAO,GAAGK,KAAAA;AACrE,SAAO,IAAIJ,KAAKC,aAAaC,GAAS,EAAEG,MAAM,UAAU,CAAC;SACnD;AACN,SAAO;;;AAIX,SAASC,EAAoBP,GAA4B;CACvD,IAAMQ,IAAeT,EAAmBC,EAAO,EACzCS,IAAsBV,EAAmB,KAAK;AAEpD,QAAOvB,EACJQ,KAAK0B,MAAY;EAChB,IAAMC,IAAWxC,EAAsBuC,EAAQ,EACzCE,IAAgBJ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B;GAAiB;GAAU;EAC7D,KAAK,KACH,QAAO,CAAC,OAAO,uBAAuB;EACxC,KAAK,KACH,QAAO,CAAC,eAAe,QAAQ;EACjC,KAAK,KACH,QAAO,CAAC,SAAS,MAAM;EACzB,KAAK,KACH,QAAO,CAAC,OAAO,iBAAiB;EAClC,KAAK,KACH,QAAO,CAAC,oBAAoB;EAC9B,KAAK,KACH,QAAO,CAAC,SAAS;EACnB,QACE,QAAO,EAAE"}
|
|
1
|
+
{"version":3,"file":"index297.js","names":["PhoneNumberInputMessages","MESSAGE_DICTIONARY","Record","en","lengthTooLong","country","noMatches","selectCountryLabel","selectedCountryLabel","fr","resolveMessages","locale","overrides","Partial","locales","Array","isArray","preferred","map","entry","split","toLowerCase","find","code","base"],"sources":["../src/components/PhoneNumberInput/messages.ts"],"sourcesContent":["import type { PhoneNumberInputMessages } from \"./types\"\n\n\nconst MESSAGE_DICTIONARY: Record<string, PhoneNumberInputMessages> = {\n en: {\n lengthTooLong: (country) =>\n country ? `This number looks too long for ${country}.` : \"This number looks too long.\",\n noMatches: \"No matching countries\",\n selectCountryLabel: \"Select a country\",\n selectedCountryLabel: (country) => (country ? `${country} flag` : \"Selected country\"),\n },\n fr: {\n lengthTooLong: (country) =>\n country\n ? `This number looks too long for ${country}.`\n : \"This number looks too long.\",\n noMatches: \"Aucun pays correspondant\",\n selectCountryLabel: \"Select a country\",\n selectedCountryLabel: (country) => (country ? `${country} flag` : \"Selected country\"),\n },\n}\n\nexport function resolveMessages(\n locale: string | string[] | undefined,\n overrides?: Partial<PhoneNumberInputMessages>\n): PhoneNumberInputMessages {\n const locales = Array.isArray(locale) ? locale : locale ? [locale] : []\n const preferred = locales\n .map((entry) => entry.split(\"-\")[0]?.toLowerCase())\n .find((code) => code && MESSAGE_DICTIONARY[code])\n const base = MESSAGE_DICTIONARY[preferred ?? \"en\"] ?? MESSAGE_DICTIONARY.en\n return {\n ...base,\n ...(overrides ?? {}),\n }\n}\n\n"],"mappings":";AAGA,IAAMC,IAA+D;CACnEE,IAAI;EACFC,gBAAgBC,MACdA,IAAU,kCAAkCA,EAAO,KAAM;EAC3DC,WAAW;EACXC,oBAAoB;EACpBC,uBAAuBH,MAAaA,IAAU,GAAGA,EAAO,SAAU;EACnE;CACDI,IAAI;EACFL,gBAAgBC,MACdA,IACI,kCAAkCA,EAAO,KACzC;EACNC,WAAW;EACXC,oBAAoB;EACpBC,uBAAuBH,MAAaA,IAAU,GAAGA,EAAO,SAAU;EACpE;CACD;AAED,SAAgBK,EACdC,GACAC,GAC0B;AAM1B,QAAO;EACL,GAFWX,GAJGc,MAAMC,QAAQL,EAAO,GAAGA,IAASA,IAAS,CAACA,EAAO,GAAG,EAAE,EAEpEO,KAAKC,MAAUA,EAAMC,MAAM,IAAI,CAAC,IAAIC,aAAa,CAAC,CAClDC,MAAMC,MAASA,KAAQtB,EAAmBsB,GAAM,IACN,SAAStB,EAAmBE;EAGvE,GAAIS,KAAa,EAAE;EACpB"}
|
package/dist/index298.js
CHANGED
|
@@ -1,168 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return e ? e.length > a ? !1 : i.some((t) => t.startsWith(e)) : !0;
|
|
11
|
-
}
|
|
12
|
-
var c = /[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g;
|
|
13
|
-
function l(e) {
|
|
14
|
-
return e.replace(c, "");
|
|
15
|
-
}
|
|
16
|
-
function u(e, t, n = {}) {
|
|
17
|
-
let { force: r = !1 } = n, i = `+${t}`;
|
|
18
|
-
if (!e.startsWith(i) || !r) return e;
|
|
19
|
-
let a = e.slice(i.length).trimStart();
|
|
20
|
-
if (a.startsWith("0")) return e;
|
|
21
|
-
if (!a) return `${i} 0`;
|
|
22
|
-
let [o, ...s] = a.split(" ");
|
|
23
|
-
return `${i} ${`0${o ?? ""}`}${s.length > 0 ? ` ${s.join(" ")}` : ""}`.replace(/\s\s+/g, " ").trimEnd();
|
|
24
|
-
}
|
|
25
|
-
var d = {
|
|
26
|
-
GG: "GB",
|
|
27
|
-
JE: "GB",
|
|
28
|
-
IM: "GB"
|
|
29
|
-
};
|
|
30
|
-
function f(e) {
|
|
31
|
-
if (e) return d[e] ?? e;
|
|
32
|
-
}
|
|
33
|
-
function p(e, t, n) {
|
|
34
|
-
if (!e || !n || (e.nationalNumber ?? "").length < 4) return;
|
|
35
|
-
let r = e.countryCallingCode;
|
|
36
|
-
if (!r) return;
|
|
37
|
-
let i = e.getMetadata, a = (typeof i == "function" ? i() : null)?.country_calling_codes?.[r];
|
|
38
|
-
if (!a || a.length === 0) return;
|
|
39
|
-
let o = [];
|
|
40
|
-
for (let e of a) {
|
|
41
|
-
let t = f(e);
|
|
42
|
-
t && !o.includes(t) && o.push(t);
|
|
43
|
-
}
|
|
44
|
-
if (o.length !== 0) return t && o.includes(t) ? t : o.includes("US") ? "US" : o[0];
|
|
45
|
-
}
|
|
46
|
-
function m(e, t, n, r) {
|
|
47
|
-
return e ? r ? !n || !e.startsWith(n) || !e.slice(n.length).startsWith("0") ? !1 : e.slice(n.length + 1) === (t.startsWith(n) ? t.slice(n.length) : t) : e.startsWith("0") : !1;
|
|
48
|
-
}
|
|
49
|
-
function h(e) {
|
|
50
|
-
for (let t of r) if (e.startsWith(t)) return e.slice(t.length);
|
|
51
|
-
return e;
|
|
52
|
-
}
|
|
53
|
-
function g(e, t, r = {}) {
|
|
54
|
-
let { allowJustPlus: i = !1, removeNationalPrefix: s = !0, previousValue: c } = r, u = l(e).trim();
|
|
55
|
-
if (!u) return "";
|
|
56
|
-
if (u === "+") return i ? "+" : "";
|
|
57
|
-
if (u.startsWith("+")) {
|
|
58
|
-
let e = o(u);
|
|
59
|
-
if (!e) return i ? "+" : "";
|
|
60
|
-
let r = h(e);
|
|
61
|
-
if (r !== e) return r ? `+${r}` : i ? "+" : "";
|
|
62
|
-
if (s && t) {
|
|
63
|
-
let r = n(t);
|
|
64
|
-
if (e.startsWith(r) && e.slice(r.length).startsWith("0")) {
|
|
65
|
-
let t = e.slice(r.length + 1);
|
|
66
|
-
return t ? `+${r}${t}` : `+${r}`;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return `+${e}`;
|
|
70
|
-
}
|
|
71
|
-
let d = o(u);
|
|
72
|
-
if (!d) return "";
|
|
73
|
-
let f = h(d);
|
|
74
|
-
if (f !== d) return f ? `+${f}` : i ? "+" : "";
|
|
75
|
-
let p = typeof c == "string" ? c : "", m = p && p.startsWith("+") ? o(p) : "";
|
|
76
|
-
if (m && m.length > d.length && m.endsWith(d) && m.length - d.length <= a) return `+${d}`;
|
|
77
|
-
if (d === "0") return "0";
|
|
78
|
-
if (s && t && d.length > 1 && d.startsWith("0") && !d.startsWith("00")) {
|
|
79
|
-
let e = n(t), r = d.slice(1);
|
|
80
|
-
return r ? `+${e}${r}` : `+${e}`;
|
|
81
|
-
}
|
|
82
|
-
return t ? d.length <= 4 ? `+${d}` : `+${n(t)}${d}` : d;
|
|
83
|
-
}
|
|
84
|
-
function _(e, n) {
|
|
85
|
-
if (e === "+") return {
|
|
86
|
-
international: "+",
|
|
87
|
-
national: "",
|
|
88
|
-
formatted: "+",
|
|
89
|
-
phoneNumber: null,
|
|
90
|
-
detectedCountry: void 0,
|
|
91
|
-
inferredCountry: void 0,
|
|
92
|
-
hasExplicitInternationalPrefix: !0
|
|
93
|
-
};
|
|
94
|
-
let r = /^\s*\+/.test(e), i = n ? new t(n) : new t(), a = i.input(e), s = i.getNumber(), c = o(e), l = f(s?.country ?? i.country ?? void 0), u = l ?? !s ? void 0 : f(p(s, n, c)), d = s?.formatInternational() ?? a;
|
|
95
|
-
return {
|
|
96
|
-
international: d,
|
|
97
|
-
national: s?.formatNational() ?? o(d),
|
|
98
|
-
formatted: a,
|
|
99
|
-
phoneNumber: s,
|
|
100
|
-
detectedCountry: l,
|
|
101
|
-
inferredCountry: u,
|
|
102
|
-
hasExplicitInternationalPrefix: r
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function v(e, t) {
|
|
106
|
-
return e.startsWith(t) ? e.slice(t.length) : e;
|
|
107
|
-
}
|
|
108
|
-
function y(t, n) {
|
|
109
|
-
if (!n || !t) return null;
|
|
110
|
-
try {
|
|
111
|
-
return e(t, n) === "TOO_LONG" ? "TOO_LONG" : null;
|
|
112
|
-
} catch {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function b(e, t, r, i = {}) {
|
|
117
|
-
let { hasRemovedNationalPrefix: a = !1, detectedCountry: c, hasExplicitInternationalPrefix: l = !1 } = i;
|
|
118
|
-
if (!e) return {
|
|
119
|
-
shouldSuggest: !1,
|
|
120
|
-
query: ""
|
|
121
|
-
};
|
|
122
|
-
if (e === "+") return {
|
|
123
|
-
shouldSuggest: !0,
|
|
124
|
-
query: ""
|
|
125
|
-
};
|
|
126
|
-
let u = o(e);
|
|
127
|
-
if (!u) return {
|
|
128
|
-
shouldSuggest: !0,
|
|
129
|
-
query: ""
|
|
130
|
-
};
|
|
131
|
-
if (a) return {
|
|
132
|
-
shouldSuggest: !1,
|
|
133
|
-
query: ""
|
|
134
|
-
};
|
|
135
|
-
if (l && !c) return s(u) ? {
|
|
136
|
-
shouldSuggest: !0,
|
|
137
|
-
query: u
|
|
138
|
-
} : {
|
|
139
|
-
shouldSuggest: !1,
|
|
140
|
-
query: ""
|
|
141
|
-
};
|
|
142
|
-
let d = r?.countryCallingCode ?? null;
|
|
143
|
-
if (!d) {
|
|
144
|
-
if (t) {
|
|
145
|
-
let e = n(t);
|
|
146
|
-
u.startsWith(e) && (d = e);
|
|
147
|
-
} else if (!l) return {
|
|
148
|
-
shouldSuggest: !1,
|
|
149
|
-
query: ""
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
return !d || v(u, d).length === 0 ? {
|
|
153
|
-
shouldSuggest: !0,
|
|
154
|
-
query: u
|
|
155
|
-
} : {
|
|
156
|
-
shouldSuggest: !1,
|
|
157
|
-
query: ""
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function x(e, t) {
|
|
161
|
-
if (e.shouldSuggest) return !1;
|
|
162
|
-
let { hasExplicitInternationalPrefix: n = !1, detectedCountry: r } = t;
|
|
163
|
-
return n ? !!r : !0;
|
|
1
|
+
import { getCountries as e } from "./index295.js";
|
|
2
|
+
//#region src/components/PhoneNumberInput/countries.ts
|
|
3
|
+
var t = new Set([
|
|
4
|
+
"IM",
|
|
5
|
+
"GG",
|
|
6
|
+
"JE"
|
|
7
|
+
]), n = e().filter((e) => !t.has(e));
|
|
8
|
+
function r() {
|
|
9
|
+
return n;
|
|
164
10
|
}
|
|
165
11
|
//#endregion
|
|
166
|
-
export {
|
|
12
|
+
export { r as getCountryList };
|
|
167
13
|
|
|
168
14
|
//# sourceMappingURL=index298.js.map
|
package/dist/index298.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index298.js","names":["CountryCode","AsYouType","getCountryCallingCode","validatePhoneNumberLength","COMMON_IDD_PREFIXES","COUNTRY_DIAL_CODES","DEFAULT_COUNTRY","MAX_DIAL_CODE_LENGTH","LengthIssue","sanitizeDigits","value","replace","isDialCodeProgress","digits","length","some","dial","startsWith","INVISIBLE_FORMATTING_CHARACTERS","stripInvisibleFormatting","injectNationalPrefixDisplay","international","dialCode","options","force","prefix","remainder","slice","trimStart","alreadyHasTrunk","firstGroup","restGroups","split","rebuiltFirstGroup","rebuiltRemainder","join","trimEnd","DETECTED_COUNTRY_OVERRIDES","Partial","Record","GG","JE","IM","canonicalizeDetectedCountry","candidate","undefined","AsYouTypeNumber","ReturnType","inferCountryFromDialCode","phoneNumber","baseCountry","normalizedDigits","nationalDigits","nationalNumber","countryCallingCode","metadataGetter","getMetadata","metadata","country_calling_codes","candidates","canonicalCandidates","canonical","includes","push","detectNationalPrefixForDisplay","rawDigits","internationalDigits","hasExplicitInternationalPrefix","rawAfterTrunk","internationalAfterDial","stripIddPrefix","normalizeInputValue","rawValue","country","allowJustPlus","removeNationalPrefix","previousValue","cleaned","trimmed","trim","digitsWithoutIdd","withoutPrefix","digitsOnly","previousNormalized","previousDigits","endsWith","removedPrefixLength","formatWithAsYouType","national","formatted","detectedCountry","inferredCountry","test","formatter","input","getNumber","formatInternational","formatNational","stripPrefix","getLengthIssue","result","SuggestionState","shouldSuggest","query","getSuggestionState","normalized","hasRemovedNationalPrefix","baseDial","shouldDisplayExplicitCountrySelection","suggestion","Boolean"],"sources":["../src/components/PhoneNumberInput/normalization.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { AsYouType, getCountryCallingCode, validatePhoneNumberLength } from \"libphonenumber-js\"\n\nimport {\n COMMON_IDD_PREFIXES,\n COUNTRY_DIAL_CODES,\n DEFAULT_COUNTRY,\n MAX_DIAL_CODE_LENGTH,\n} from \"./country-options\"\n\n\nexport type LengthIssue = \"TOO_LONG\"\n\nexport function sanitizeDigits(value: string) {\n return value.replace(/\\D/g, \"\")\n}\n\nfunction isDialCodeProgress(digits: string) {\n if (!digits) {\n return true\n }\n\n if (digits.length > MAX_DIAL_CODE_LENGTH) {\n return false\n }\n\n return COUNTRY_DIAL_CODES.some((dial) => dial.startsWith(digits))\n}\n\nconst INVISIBLE_FORMATTING_CHARACTERS =\n /[\\u061C\\u200B-\\u200F\\u202A-\\u202E\\u2066-\\u2069\\uFEFF]/g\n\nfunction stripInvisibleFormatting(value: string) {\n return value.replace(INVISIBLE_FORMATTING_CHARACTERS, \"\")\n}\n\nexport function injectNationalPrefixDisplay(\n international: string,\n dialCode: string,\n options: { force?: boolean } = {}\n) {\n // Preserve a user-typed national trunk (e.g. the French \"0\") purely for display\n // so validation can continue to use the canonical E.164 representation internally.\n const { force = false } = options\n const prefix = `+${dialCode}`\n\n if (!international.startsWith(prefix)) {\n return international\n }\n\n if (!force) {\n return international\n }\n\n const remainder = international.slice(prefix.length).trimStart()\n const alreadyHasTrunk = remainder.startsWith(\"0\")\n\n if (alreadyHasTrunk) {\n return international\n }\n\n if (!remainder) {\n return `${prefix} 0`\n }\n\n const [firstGroup, ...restGroups] = remainder.split(\" \")\n const rebuiltFirstGroup = `0${firstGroup ?? \"\"}`\n const rebuiltRemainder = restGroups.length > 0 ? ` ${restGroups.join(\" \")}` : \"\"\n\n return `${prefix} ${rebuiltFirstGroup}${rebuiltRemainder}`.replace(/\\s\\s+/g, \" \").trimEnd()\n}\n\nconst DETECTED_COUNTRY_OVERRIDES: Partial<Record<CountryCode, CountryCode>> = {\n GG: \"GB\",\n JE: \"GB\",\n IM: \"GB\",\n}\n\nfunction canonicalizeDetectedCountry(candidate: CountryCode | undefined): CountryCode | undefined {\n if (!candidate) {\n return undefined\n }\n return DETECTED_COUNTRY_OVERRIDES[candidate] ?? candidate\n}\n\ntype AsYouTypeNumber = ReturnType<AsYouType[\"getNumber\"]>\n\nfunction inferCountryFromDialCode(\n phoneNumber: AsYouTypeNumber,\n baseCountry: CountryCode | undefined,\n normalizedDigits: string\n): CountryCode | undefined {\n if (!phoneNumber) {\n return undefined\n }\n\n if (!normalizedDigits) {\n return undefined\n }\n\n const nationalDigits = phoneNumber.nationalNumber ?? \"\"\n if (nationalDigits.length < 4) {\n return undefined\n }\n\n const dial = phoneNumber.countryCallingCode\n if (!dial) {\n return undefined\n }\n\n const metadataGetter = (phoneNumber as unknown as { getMetadata?: () => unknown }).getMetadata\n const metadata =\n typeof metadataGetter === \"function\"\n ? (metadataGetter() as {\n country_calling_codes?: Record<string, string[]>\n } | null)\n : null\n\n const candidates = metadata?.country_calling_codes?.[dial]\n if (!candidates || candidates.length === 0) {\n return undefined\n }\n\n const canonicalCandidates: CountryCode[] = []\n for (const candidate of candidates) {\n const canonical = canonicalizeDetectedCountry(candidate as CountryCode)\n if (canonical && !canonicalCandidates.includes(canonical)) {\n canonicalCandidates.push(canonical)\n }\n }\n\n if (canonicalCandidates.length === 0) {\n return undefined\n }\n\n if (baseCountry && canonicalCandidates.includes(baseCountry)) {\n return baseCountry\n }\n\n if (canonicalCandidates.includes(DEFAULT_COUNTRY)) {\n return DEFAULT_COUNTRY\n }\n\n return canonicalCandidates[0]\n}\n\nexport function detectNationalPrefixForDisplay(\n rawDigits: string,\n internationalDigits: string,\n dialCode: string,\n hasExplicitInternationalPrefix: boolean\n) {\n if (!rawDigits) {\n return false\n }\n\n if (!hasExplicitInternationalPrefix) {\n return rawDigits.startsWith(\"0\")\n }\n\n if (!dialCode) {\n return false\n }\n\n if (!rawDigits.startsWith(dialCode)) {\n return false\n }\n\n if (!rawDigits.slice(dialCode.length).startsWith(\"0\")) {\n return false\n }\n\n const rawAfterTrunk = rawDigits.slice(dialCode.length + 1)\n const internationalAfterDial = internationalDigits.startsWith(dialCode)\n ? internationalDigits.slice(dialCode.length)\n : internationalDigits\n\n return rawAfterTrunk === internationalAfterDial\n}\n\nfunction stripIddPrefix(digits: string) {\n for (const prefix of COMMON_IDD_PREFIXES) {\n if (digits.startsWith(prefix)) {\n return digits.slice(prefix.length)\n }\n }\n return digits\n}\n\nexport function normalizeInputValue(\n rawValue: string,\n country: CountryCode | undefined,\n options: {\n allowJustPlus?: boolean\n removeNationalPrefix?: boolean\n previousValue?: string\n } = {}\n) {\n const { allowJustPlus = false, removeNationalPrefix = true, previousValue } = options\n const cleaned = stripInvisibleFormatting(rawValue)\n const trimmed = cleaned.trim()\n\n if (!trimmed) {\n return \"\"\n }\n\n if (trimmed === \"+\") {\n return allowJustPlus ? \"+\" : \"\"\n }\n\n if (trimmed.startsWith(\"+\")) {\n const digits = sanitizeDigits(trimmed)\n if (!digits) {\n return allowJustPlus ? \"+\" : \"\"\n }\n const digitsWithoutIdd = stripIddPrefix(digits)\n if (digitsWithoutIdd !== digits) {\n return digitsWithoutIdd ? `+${digitsWithoutIdd}` : allowJustPlus ? \"+\" : \"\"\n }\n if (removeNationalPrefix && country) {\n const dial = getCountryCallingCode(country)\n if (digits.startsWith(dial) && digits.slice(dial.length).startsWith(\"0\")) {\n const withoutPrefix = digits.slice(dial.length + 1)\n return withoutPrefix ? `+${dial}${withoutPrefix}` : `+${dial}`\n }\n }\n return `+${digits}`\n }\n\n const digitsOnly = sanitizeDigits(trimmed)\n if (!digitsOnly) {\n return \"\"\n }\n\n const digitsWithoutIdd = stripIddPrefix(digitsOnly)\n if (digitsWithoutIdd !== digitsOnly) {\n return digitsWithoutIdd ? `+${digitsWithoutIdd}` : allowJustPlus ? \"+\" : \"\"\n }\n\n const previousNormalized = typeof previousValue === \"string\" ? previousValue : \"\"\n const previousDigits =\n previousNormalized && previousNormalized.startsWith(\"+\")\n ? sanitizeDigits(previousNormalized)\n : \"\"\n\n if (previousDigits && previousDigits.length > digitsOnly.length) {\n if (previousDigits.endsWith(digitsOnly)) {\n const removedPrefixLength = previousDigits.length - digitsOnly.length\n if (removedPrefixLength <= MAX_DIAL_CODE_LENGTH) {\n return `+${digitsOnly}`\n }\n }\n }\n\n if (digitsOnly === \"0\") {\n return \"0\"\n }\n\n if (\n removeNationalPrefix &&\n country &&\n digitsOnly.length > 1 &&\n digitsOnly.startsWith(\"0\") &&\n !digitsOnly.startsWith(\"00\")\n ) {\n const dial = getCountryCallingCode(country)\n const withoutPrefix = digitsOnly.slice(1)\n return withoutPrefix ? `+${dial}${withoutPrefix}` : `+${dial}`\n }\n\n if (!country) {\n return digitsOnly\n }\n\n if (digitsOnly.length <= 4) {\n return `+${digitsOnly}`\n }\n\n const dial = getCountryCallingCode(country)\n return `+${dial}${digitsOnly}`\n}\n\nexport function formatWithAsYouType(value: string, baseCountry?: CountryCode) {\n if (value === \"+\") {\n return {\n international: \"+\",\n national: \"\",\n formatted: \"+\",\n phoneNumber: null,\n detectedCountry: undefined,\n inferredCountry: undefined,\n hasExplicitInternationalPrefix: true,\n }\n }\n\n const hasExplicitInternationalPrefix = /^\\s*\\+/.test(value)\n const formatter = baseCountry ? new AsYouType(baseCountry) : new AsYouType()\n const formatted = formatter.input(value)\n const phoneNumber = formatter.getNumber()\n const digits = sanitizeDigits(value)\n const detectedCountry = canonicalizeDetectedCountry(\n (phoneNumber?.country ?? formatter.country ?? undefined) as CountryCode | undefined\n )\n const inferredCountry =\n detectedCountry ?? !phoneNumber\n ? undefined\n : canonicalizeDetectedCountry(\n inferCountryFromDialCode(phoneNumber, baseCountry, digits)\n )\n\n const international = phoneNumber?.formatInternational() ?? formatted\n const national = phoneNumber?.formatNational() ?? sanitizeDigits(international)\n\n return {\n international,\n national,\n formatted,\n phoneNumber,\n detectedCountry,\n inferredCountry,\n hasExplicitInternationalPrefix,\n }\n}\n\nexport function stripPrefix(value: string, prefix: string) {\n return value.startsWith(prefix) ? value.slice(prefix.length) : value\n}\n\nexport function getLengthIssue(value: string, country: CountryCode | undefined): LengthIssue | null {\n if (!country || !value) {\n return null\n }\n\n try {\n const result = validatePhoneNumberLength(value, country)\n return result === \"TOO_LONG\" ? \"TOO_LONG\" : null\n } catch {\n return null\n }\n}\n\ntype SuggestionState = {\n shouldSuggest: boolean\n query: string\n}\n\nexport function getSuggestionState(\n normalized: string,\n baseCountry: CountryCode | undefined,\n phoneNumber: ReturnType<AsYouType[\"getNumber\"]>,\n options: {\n hasRemovedNationalPrefix?: boolean\n detectedCountry?: CountryCode\n hasExplicitInternationalPrefix?: boolean\n } = {}\n): SuggestionState {\n const {\n hasRemovedNationalPrefix = false,\n detectedCountry,\n hasExplicitInternationalPrefix = false,\n } = options\n\n if (!normalized) {\n return { shouldSuggest: false, query: \"\" }\n }\n\n if (normalized === \"+\") {\n return { shouldSuggest: true, query: \"\" }\n }\n\n const digits = sanitizeDigits(normalized)\n if (!digits) {\n return { shouldSuggest: true, query: \"\" }\n }\n\n if (hasRemovedNationalPrefix) {\n return { shouldSuggest: false, query: \"\" }\n }\n\n if (hasExplicitInternationalPrefix && !detectedCountry) {\n if (!isDialCodeProgress(digits)) {\n return { shouldSuggest: false, query: \"\" }\n }\n return { shouldSuggest: true, query: digits }\n }\n\n let dial = phoneNumber?.countryCallingCode ?? null\n if (!dial) {\n if (baseCountry) {\n const baseDial = getCountryCallingCode(baseCountry)\n if (digits.startsWith(baseDial)) {\n dial = baseDial\n }\n } else if (!hasExplicitInternationalPrefix) {\n return { shouldSuggest: false, query: \"\" }\n }\n }\n\n if (!dial) {\n return { shouldSuggest: true, query: digits }\n }\n\n const nationalDigits = stripPrefix(digits, dial)\n if (nationalDigits.length === 0) {\n return { shouldSuggest: true, query: digits }\n }\n\n return { shouldSuggest: false, query: \"\" }\n}\n\nexport function shouldDisplayExplicitCountrySelection(\n suggestion: SuggestionState,\n options: { detectedCountry?: CountryCode; hasExplicitInternationalPrefix?: boolean }\n) {\n if (suggestion.shouldSuggest) {\n return false\n }\n\n const { hasExplicitInternationalPrefix = false, detectedCountry } = options\n\n if (!hasExplicitInternationalPrefix) {\n return true\n }\n\n return Boolean(detectedCountry)\n}\n"],"mappings":";;;;;AAaA,SAAgBS,EAAeC,GAAe;AAC5C,QAAOA,EAAMC,QAAQ,OAAO,GAAG;;AAGjC,SAASC,EAAmBC,GAAgB;AAS1C,QARKA,IAIDA,EAAOC,SAASP,IACX,KAGFF,EAAmBU,MAAMC,MAASA,EAAKC,WAAWJ,EAAO,CAAC,GAPxD;;AAUX,IAAMK,IACJ;AAEF,SAASC,EAAyBT,GAAe;AAC/C,QAAOA,EAAMC,QAAQO,GAAiC,GAAG;;AAG3D,SAAgBE,EACdC,GACAC,GACAC,IAA+B,EAAE,EACjC;CAGA,IAAM,EAAEC,WAAQ,OAAUD,GACpBE,IAAS,IAAIH;AAMnB,KAJI,CAACD,EAAcJ,WAAWQ,EAAO,IAIjC,CAACD,EACH,QAAOH;CAGT,IAAMK,IAAYL,EAAcM,MAAMF,EAAOX,OAAO,CAACc,WAAW;AAGhE,KAFwBF,EAAUT,WAAW,IAAI,CAG/C,QAAOI;AAGT,KAAI,CAACK,EACH,QAAO,GAAGD,EAAM;CAGlB,IAAM,CAACK,GAAY,GAAGC,KAAcL,EAAUM,MAAM,IAAI;AAIxD,QAAO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,QAAO;CAGT,IAAM,EAAEnC,oCAAiC,IAAOuB,uBAAoBnE;AAMpE,QAJK4C,IAIE2C,EAAQpB,IAHN"}
|
|
1
|
+
{"version":3,"file":"index298.js","names":["getCountries","CountryCode","EXCLUDED_COUNTRIES","EXCLUDED_SET","Set","FILTERED_COUNTRIES","filter","code","has","getCountryList"],"sources":["../src/components/PhoneNumberInput/countries.ts"],"sourcesContent":["import { getCountries } from \"libphonenumber-js\"\nimport type { CountryCode } from \"libphonenumber-js\"\n\n\nconst EXCLUDED_COUNTRIES: CountryCode[] = [\"IM\", \"GG\", \"JE\"]\nconst EXCLUDED_SET = new Set(EXCLUDED_COUNTRIES)\n\nconst FILTERED_COUNTRIES = getCountries().filter((code) => !EXCLUDED_SET.has(code))\n\nexport function getCountryList(): CountryCode[] {\n return FILTERED_COUNTRIES\n}\n"],"mappings":";;AAKA,IAAMG,IAAe,IAAIC,IADiB;CAAC;CAAM;CAAM;CAAK,CACZ,EAE1CC,IAAqBL,GAAc,CAACM,QAAQC,MAAS,CAACJ,EAAaK,IAAID,EAAK,CAAC;AAEnF,SAAgBE,IAAgC;AAC9C,QAAOJ"}
|
package/dist/index299.js
CHANGED
|
@@ -1,72 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { getCountryCallingCode as e } from "./index296.js";
|
|
2
|
+
import { getCountryList as t } from "./index298.js";
|
|
3
|
+
var n = t(), r = /* @__PURE__ */ new Map(), i = "__default_locale__", a = Array.from(new Set(n.map((t) => e(t)))).sort((e, t) => t.length - e.length), o = a.reduce((e, t) => Math.max(e, t.length), 0), s = [
|
|
4
|
+
"0011",
|
|
5
|
+
"001",
|
|
6
|
+
"011",
|
|
7
|
+
"00",
|
|
8
|
+
"810"
|
|
9
|
+
];
|
|
10
|
+
function c(e) {
|
|
11
|
+
return e && n.includes(e) ? e : "US";
|
|
6
12
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
function l(e) {
|
|
14
|
+
if (typeof Intl > "u" || Intl.DisplayNames === void 0) return null;
|
|
15
|
+
try {
|
|
16
|
+
let t = Array.isArray(e) ? e : e ? [e] : void 0;
|
|
17
|
+
return new Intl.DisplayNames(t, { type: "region" });
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function u(t) {
|
|
23
|
+
let r = l(t), i = l("en");
|
|
24
|
+
return n.map((t) => {
|
|
25
|
+
let n = e(t), a = r?.of(t) ?? i?.of(t) ?? t, o = i?.of(t) ?? a, s = S(t), c = Array.from(new Set([
|
|
26
|
+
a,
|
|
27
|
+
o,
|
|
28
|
+
t.toUpperCase(),
|
|
29
|
+
t.toLowerCase(),
|
|
30
|
+
...s
|
|
31
|
+
].filter(Boolean)));
|
|
32
|
+
return {
|
|
33
|
+
value: t,
|
|
34
|
+
name: a,
|
|
35
|
+
dialCode: n,
|
|
36
|
+
label: `${a} (+${n})`,
|
|
37
|
+
flag: _(t),
|
|
38
|
+
searchableTokens: c,
|
|
39
|
+
normalizedSearchableTokens: c.map((e) => b(e))
|
|
40
|
+
};
|
|
41
|
+
}).sort((e, t) => {
|
|
42
|
+
let n = d(e.value), r = d(t.value);
|
|
43
|
+
return n === r ? e.name.localeCompare(t.name) : n - r;
|
|
44
|
+
});
|
|
11
45
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
let r = 0;
|
|
15
|
-
for (let i = 0; i < t.length; i += 1) if (e(t[i] ?? "") && (r += 1, r === n)) return i + 1;
|
|
16
|
-
return t.length;
|
|
46
|
+
function d(t) {
|
|
47
|
+
return t === "US" ? 0 : t === "CA" ? 1 : e(t) === "1" ? 2 : 3;
|
|
17
48
|
}
|
|
18
|
-
function
|
|
19
|
-
return
|
|
49
|
+
function f(e) {
|
|
50
|
+
return e ? Array.isArray(e) ? e.join("\0") : e : i;
|
|
20
51
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
52
|
+
function p(e) {
|
|
53
|
+
if (e !== i) {
|
|
54
|
+
if (e.includes("\0")) {
|
|
55
|
+
let t = e.split("\0").filter(Boolean);
|
|
56
|
+
return t.length === 0 ? void 0 : t.length === 1 ? t[0] ?? void 0 : t;
|
|
57
|
+
}
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
25
60
|
}
|
|
26
|
-
function
|
|
27
|
-
let n = t;
|
|
28
|
-
|
|
29
|
-
|
|
61
|
+
function m(e, t) {
|
|
62
|
+
let n = r.get(t);
|
|
63
|
+
if (n) return n;
|
|
64
|
+
let i = u(e);
|
|
65
|
+
return r.set(t, i), i;
|
|
30
66
|
}
|
|
31
|
-
function
|
|
32
|
-
let { value: n } = e, r = e.selectionStart ?? n.length, i = e.selectionEnd ?? r, a = r <= 1 && n.startsWith("+"), o = i <= 1 && n.startsWith("+");
|
|
67
|
+
function h(e) {
|
|
33
68
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
preserveStartIndex: a,
|
|
39
|
-
preserveEndIndex: o,
|
|
40
|
-
wasAtStart: r === 0,
|
|
41
|
-
wasAtEnd: i === n.length
|
|
69
|
+
code: e.value,
|
|
70
|
+
name: e.name,
|
|
71
|
+
dialCode: e.dialCode,
|
|
72
|
+
flag: e.flag
|
|
42
73
|
};
|
|
43
74
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end: e
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (e.wasAtStart) return {
|
|
54
|
-
start: 0,
|
|
55
|
-
end: 0
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
let r = e.preserveStartIndex ? Math.min(e.selectionStart, t.length) : n(t, e.startDigits), i = e.preserveEndIndex ? Math.min(e.selectionEnd, t.length) : n(t, e.endDigits), a = r, o = i;
|
|
59
|
-
e.wasAtStart && (a = 0), e.wasAtEnd && (o = t.length), e.selectionStart === e.selectionEnd && (a = o);
|
|
60
|
-
let s = Math.min(Math.max(a, 0), t.length), c = Math.min(Math.max(o, 0), t.length);
|
|
61
|
-
return s > c ? {
|
|
62
|
-
start: c,
|
|
63
|
-
end: c
|
|
64
|
-
} : {
|
|
65
|
-
start: s,
|
|
66
|
-
end: c
|
|
75
|
+
function g(t) {
|
|
76
|
+
return {
|
|
77
|
+
code: t,
|
|
78
|
+
name: t,
|
|
79
|
+
dialCode: e(t),
|
|
80
|
+
flag: _(t)
|
|
67
81
|
};
|
|
68
82
|
}
|
|
83
|
+
function _(e) {
|
|
84
|
+
let t = e?.toUpperCase();
|
|
85
|
+
if (!t || t.length !== 2 || /[^A-Z]/.test(t)) return "";
|
|
86
|
+
let n = 127397;
|
|
87
|
+
return String.fromCodePoint(t.charCodeAt(0) + n, t.charCodeAt(1) + n);
|
|
88
|
+
}
|
|
89
|
+
var v = /[\u0300-\u036f]/g;
|
|
90
|
+
function y(e) {
|
|
91
|
+
return e.normalize("NFD").replace(v, "");
|
|
92
|
+
}
|
|
93
|
+
function b(e) {
|
|
94
|
+
return y(e).toLowerCase();
|
|
95
|
+
}
|
|
96
|
+
function x(e, t) {
|
|
97
|
+
let n = 2 ** 53 - 1;
|
|
98
|
+
for (let r of e) {
|
|
99
|
+
let e = r.indexOf(t);
|
|
100
|
+
e >= 0 && e < n && (n = e);
|
|
101
|
+
}
|
|
102
|
+
return n === 2 ** 53 - 1 ? 2 ** 53 - 1 : n;
|
|
103
|
+
}
|
|
104
|
+
function S(e) {
|
|
105
|
+
switch (e) {
|
|
106
|
+
case "US": return [
|
|
107
|
+
"USA",
|
|
108
|
+
"United States",
|
|
109
|
+
"America",
|
|
110
|
+
"United States of America"
|
|
111
|
+
];
|
|
112
|
+
case "GB": return [
|
|
113
|
+
"UK",
|
|
114
|
+
"United Kingdom",
|
|
115
|
+
"Great Britain",
|
|
116
|
+
"England"
|
|
117
|
+
];
|
|
118
|
+
case "AE": return ["UAE", "United Arab Emirates"];
|
|
119
|
+
case "KR": return ["South Korea", "Korea"];
|
|
120
|
+
case "CN": return ["China", "PRC"];
|
|
121
|
+
case "CD": return ["DRC", "Congo-Kinshasa"];
|
|
122
|
+
case "CG": return ["Congo-Brazzaville"];
|
|
123
|
+
case "BR": return ["Brazil"];
|
|
124
|
+
default: return [];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
69
127
|
//#endregion
|
|
70
|
-
export { o as
|
|
128
|
+
export { s as COMMON_IDD_PREFIXES, a as COUNTRY_DIAL_CODES, o as MAX_DIAL_CODE_LENGTH, g as buildFallbackSelectedCountry, m as getCachedCountryOptions, f as getLocaleCacheKey, c as getValidCountry, b as normalizeSearchValue, x as optionMatchIndex, p as parseLocaleCacheKey, h as toSelectedCountry };
|
|
71
129
|
|
|
72
130
|
//# sourceMappingURL=index299.js.map
|
package/dist/index299.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index299.js","names":["isDigitCharacter","char","code","charCodeAt","countDigitsBefore","value","index","count","limit","Math","min","length","position","findIndexForDigitCount","digitCount","startsWith","seen","isFormattingCharacter","skipFormattingCharactersLeft","next","skipFormattingCharactersRight","SelectionSnapshot","selectionStart","selectionEnd","startDigits","endDigits","preserveStartIndex","preserveEndIndex","wasAtStart","wasAtEnd","captureSelectionSnapshot","input","HTMLInputElement","resolveSelection","snapshot","end","start","resolvedStart","resolvedEnd","clampedStart","max","clampedEnd"],"sources":["../src/components/PhoneNumberInput/selection.ts"],"sourcesContent":["function isDigitCharacter(char: string) {\n if (!char) {\n return false\n }\n const code = char.charCodeAt(0)\n return code >= 48 && code <= 57\n}\n\nfunction countDigitsBefore(value: string, index: number) {\n let count = 0\n const limit = Math.min(index, value.length)\n for (let position = 0; position < limit; position += 1) {\n if (isDigitCharacter(value[position] ?? \"\")) {\n count += 1\n }\n }\n return count\n}\n\nfunction findIndexForDigitCount(value: string, digitCount: number) {\n if (digitCount <= 0) {\n return value.startsWith(\"+\") ? Math.min(1, value.length) : 0\n }\n\n let seen = 0\n for (let index = 0; index < value.length; index += 1) {\n if (isDigitCharacter(value[index] ?? \"\")) {\n seen += 1\n if (seen === digitCount) {\n return index + 1\n }\n }\n }\n\n return value.length\n}\n\nfunction isFormattingCharacter(char: string) {\n if (!char) {\n return false\n }\n if (isDigitCharacter(char)) {\n return false\n }\n return char !== \"+\"\n}\n\nexport function skipFormattingCharactersLeft(value: string, index: number) {\n let position = index\n while (position > 0) {\n const next = value[position - 1] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position -= 1\n }\n return position\n}\n\nexport function skipFormattingCharactersRight(value: string, index: number) {\n let position = index\n while (position < value.length) {\n const next = value[position] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position += 1\n }\n return position\n}\n\ntype SelectionSnapshot = {\n selectionStart: number\n selectionEnd: number\n startDigits: number\n endDigits: number\n preserveStartIndex: boolean\n preserveEndIndex: boolean\n wasAtStart: boolean\n wasAtEnd: boolean\n}\n\nexport function captureSelectionSnapshot(input: HTMLInputElement): SelectionSnapshot {\n const { value } = input\n const selectionStart = input.selectionStart ?? value.length\n const selectionEnd = input.selectionEnd ?? selectionStart\n const preserveStartIndex = selectionStart <= 1 && value.startsWith(\"+\")\n const preserveEndIndex = selectionEnd <= 1 && value.startsWith(\"+\")\n\n return {\n selectionStart,\n selectionEnd,\n startDigits: countDigitsBefore(value, selectionStart),\n endDigits: countDigitsBefore(value, selectionEnd),\n preserveStartIndex,\n preserveEndIndex,\n wasAtStart: selectionStart === 0,\n wasAtEnd: selectionEnd === value.length,\n }\n}\n\nexport function resolveSelection(snapshot: SelectionSnapshot, value: string) {\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n if (snapshot.wasAtEnd) {\n const end = value.length\n return { start: end, end }\n }\n if (snapshot.wasAtStart) {\n return { start: 0, end: 0 }\n }\n }\n\n const start = snapshot.preserveStartIndex\n ? Math.min(snapshot.selectionStart, value.length)\n : findIndexForDigitCount(value, snapshot.startDigits)\n const end = snapshot.preserveEndIndex\n ? Math.min(snapshot.selectionEnd, value.length)\n : findIndexForDigitCount(value, snapshot.endDigits)\n\n let resolvedStart = start\n let resolvedEnd = end\n\n if (snapshot.wasAtStart) {\n resolvedStart = 0\n }\n\n if (snapshot.wasAtEnd) {\n resolvedEnd = value.length\n }\n\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n resolvedStart = resolvedEnd\n }\n\n const clampedStart = Math.min(Math.max(resolvedStart, 0), value.length)\n const clampedEnd = Math.min(Math.max(resolvedEnd, 0), value.length)\n\n if (clampedStart > clampedEnd) {\n return { start: clampedEnd, end: clampedEnd }\n }\n\n return { start: clampedStart, end: clampedEnd }\n}\n\n"],"mappings":";AAAA,SAASA,EAAiBC,GAAc;AACtC,KAAI,CAACA,EACH,QAAO;CAET,IAAMC,IAAOD,EAAKE,WAAW,EAAE;AAC/B,QAAOD,KAAQ,MAAMA,KAAQ;;AAG/B,SAASE,EAAkBC,GAAeC,GAAe;CACvD,IAAIC,IAAQ,GACNC,IAAQC,KAAKC,IAAIJ,GAAOD,EAAMM,OAAO;AAC3C,MAAK,IAAIC,IAAW,GAAGA,IAAWJ,GAAOI,KAAY,EACnD,CAAIZ,EAAiBK,EAAMO,MAAa,GAAG,KACzCL,KAAS;AAGb,QAAOA;;AAGT,SAASM,EAAuBR,GAAeS,GAAoB;AACjE,KAAIA,KAAc,EAChB,QAAOT,EAAMU,WAAW,IAAI,GAAGN,KAAKC,IAAI,GAAGL,EAAMM,OAAO,GAAG;CAG7D,IAAIK,IAAO;AACX,MAAK,IAAIV,IAAQ,GAAGA,IAAQD,EAAMM,QAAQL,KAAS,EACjD,KAAIN,EAAiBK,EAAMC,MAAU,GAAG,KACtCU,KAAQ,GACJA,MAASF,GACX,QAAOR,IAAQ;AAKrB,QAAOD,EAAMM;;AAGf,SAASM,EAAsBhB,GAAc;AAO3C,QANI,CAACA,KAGDD,EAAiBC,E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;AAUlB,CARID,EAASN,eACXS,IAAgB,IAGdH,EAASL,aACXS,IAAcjC,EAAMM,SAGlBuB,EAASZ,mBAAmBY,EAASX,iBACvCc,IAAgBC;CAGlB,IAAMC,IAAe9B,KAAKC,IAAID,KAAK+B,IAAIH,GAAe,EAAE,EAAEhC,EAAMM,OAAO,EACjE8B,IAAahC,KAAKC,IAAID,KAAK+B,IAAIF,GAAa,EAAE,EAAEjC,EAAMM,OAAO;AAMnE,QAJI4B,IAAeE,IACV;EAAEL,OAAOK;EAAYN,KAAKM;EAAY,GAGxC;EAAEL,OAAOG;EAAcJ,KAAKM;EAAY"}
|
|
1
|
+
{"version":3,"file":"index299.js","names":["CountryCode","getCountryCallingCode","CountryOption","PhoneNumberSelectedCountry","getCountryList","DEFAULT_COUNTRY","COUNTRY_OPTIONS","COUNTRY_OPTIONS_CACHE","Map","DEFAULT_LOCALE_CACHE_KEY","COUNTRY_DIAL_CODES","Array","from","Set","map","code","sort","a","b","length","MAX_DIAL_CODE_LENGTH","reduce","max","dial","Math","COMMON_IDD_PREFIXES","getValidCountry","input","includes","createDisplayNames","locale","Intl","DisplayNames","locales","isArray","undefined","type","buildCountryOptions","displayNames","englishDisplayNames","country","dialCode","localizedName","of","englishName","aliasTokens","getCountryAliases","searchableTokens","toUpperCase","toLowerCase","filter","Boolean","value","name","label","flag","countryCodeToFlagEmoji","normalizedSearchableTokens","token","normalizeSearchValue","priorityA","getCountryPriority","priorityB","localeCompare","getLocaleCacheKey","join","parseLocaleCacheKey","cacheKey","parts","split","getCachedCountryOptions","cached","get","built","set","toSelectedCountry","option","buildFallbackSelectedCountry","upper","test","base","String","fromCodePoint","charCodeAt","DIACRITICS_REGEX","stripDiacritics","normalize","replace","optionMatchIndex","tokens","query","best","Number","MAX_SAFE_INTEGER","index","indexOf"],"sources":["../src/components/PhoneNumberInput/country-options.ts"],"sourcesContent":["import type { CountryCode } from \"libphonenumber-js\"\nimport { getCountryCallingCode } from \"libphonenumber-js\"\n\nimport type { CountryOption, PhoneNumberSelectedCountry } from \"./types\"\nimport { getCountryList } from \"./countries\"\n\n\nexport const DEFAULT_COUNTRY: CountryCode = \"US\"\nconst COUNTRY_OPTIONS = getCountryList()\n\nconst COUNTRY_OPTIONS_CACHE = new Map<string, CountryOption[]>()\nconst DEFAULT_LOCALE_CACHE_KEY = \"__default_locale__\"\nexport const COUNTRY_DIAL_CODES = Array.from(\n new Set(COUNTRY_OPTIONS.map((code) => getCountryCallingCode(code)))\n).sort((a, b) => b.length - a.length)\nexport const MAX_DIAL_CODE_LENGTH = COUNTRY_DIAL_CODES.reduce(\n (max, dial) => Math.max(max, dial.length),\n 0\n)\nexport const COMMON_IDD_PREFIXES = [\"0011\", \"001\", \"011\", \"00\", \"810\"]\n\nexport function getValidCountry(input: CountryCode | undefined) {\n if (!input) {\n return DEFAULT_COUNTRY\n }\n\n return COUNTRY_OPTIONS.includes(input) ? input : DEFAULT_COUNTRY\n}\n\nfunction createDisplayNames(locale?: string | string[]) {\n if (typeof Intl === \"undefined\" || typeof Intl.DisplayNames === \"undefined\") {\n return null\n }\n\n try {\n const locales = Array.isArray(locale) ? locale : locale ? [locale] : undefined\n return new Intl.DisplayNames(locales, { type: \"region\" })\n } catch {\n return null\n }\n}\n\nfunction buildCountryOptions(locale?: string | string[]) {\n const displayNames = createDisplayNames(locale)\n const englishDisplayNames = createDisplayNames(\"en\")\n\n return COUNTRY_OPTIONS\n .map((country) => {\n const dialCode = getCountryCallingCode(country)\n const localizedName = displayNames?.of(country) ?? englishDisplayNames?.of(country) ?? country\n const englishName = englishDisplayNames?.of(country) ?? localizedName\n const aliasTokens = getCountryAliases(country)\n const searchableTokens = Array.from(\n new Set(\n [localizedName, englishName, country.toUpperCase(), country.toLowerCase(), ...aliasTokens].filter(\n Boolean\n )\n )\n ) as string[]\n return {\n value: country,\n name: localizedName,\n dialCode,\n label: `${localizedName} (+${dialCode})`,\n flag: countryCodeToFlagEmoji(country),\n searchableTokens,\n normalizedSearchableTokens: searchableTokens.map((token) => normalizeSearchValue(token)),\n }\n })\n .sort((a, b) => {\n const priorityA = getCountryPriority(a.value)\n const priorityB = getCountryPriority(b.value)\n if (priorityA !== priorityB) {\n return priorityA - priorityB\n }\n return a.name.localeCompare(b.name)\n })\n}\n\nfunction getCountryPriority(code: CountryCode) {\n if (code === \"US\") return 0\n if (code === \"CA\") return 1\n if (getCountryCallingCode(code) === \"1\") return 2\n return 3\n}\n\nexport function getLocaleCacheKey(locale?: string | string[]) {\n if (!locale) {\n return DEFAULT_LOCALE_CACHE_KEY\n }\n if (Array.isArray(locale)) {\n return locale.join(\"\\u0000\")\n }\n return locale\n}\n\nexport function parseLocaleCacheKey(cacheKey: string): string | string[] | undefined {\n if (cacheKey === DEFAULT_LOCALE_CACHE_KEY) {\n return undefined\n }\n\n if (cacheKey.includes(\"\\u0000\")) {\n const parts = cacheKey.split(\"\\u0000\").filter(Boolean)\n if (parts.length === 0) {\n return undefined\n }\n if (parts.length === 1) {\n return parts[0] ?? undefined\n }\n return parts\n }\n\n return cacheKey\n}\n\nexport function getCachedCountryOptions(locale: string | string[] | undefined, cacheKey: string) {\n const cached = COUNTRY_OPTIONS_CACHE.get(cacheKey)\n if (cached) {\n return cached\n }\n const built = buildCountryOptions(locale)\n COUNTRY_OPTIONS_CACHE.set(cacheKey, built)\n return built\n}\n\nexport function toSelectedCountry(option: CountryOption): PhoneNumberSelectedCountry {\n return {\n code: option.value,\n name: option.name,\n dialCode: option.dialCode,\n flag: option.flag,\n }\n}\n\nexport function buildFallbackSelectedCountry(country: CountryCode): PhoneNumberSelectedCountry {\n return {\n code: country,\n name: country,\n dialCode: getCountryCallingCode(country),\n flag: countryCodeToFlagEmoji(country),\n }\n}\n\nfunction countryCodeToFlagEmoji(country: CountryCode) {\n const upper = country?.toUpperCase()\n\n if (!upper || upper.length !== 2 || /[^A-Z]/.test(upper)) {\n return \"\"\n }\n\n const base = 127397\n return String.fromCodePoint(\n upper.charCodeAt(0) + base,\n upper.charCodeAt(1) + base\n )\n}\n\nconst DIACRITICS_REGEX = /[\\u0300-\\u036f]/g\n\nfunction stripDiacritics(value: string) {\n return value.normalize(\"NFD\").replace(DIACRITICS_REGEX, \"\")\n}\n\nexport function normalizeSearchValue(value: string) {\n return stripDiacritics(value).toLowerCase()\n}\n\nexport function optionMatchIndex(tokens: string[], query: string) {\n let best = Number.MAX_SAFE_INTEGER\n for (const token of tokens) {\n const index = token.indexOf(query)\n if (index >= 0 && index < best) {\n best = index\n }\n }\n return best === Number.MAX_SAFE_INTEGER ? Number.MAX_SAFE_INTEGER : best\n}\n\nfunction getCountryAliases(code: CountryCode): string[] {\n switch (code) {\n case \"US\":\n return [\"USA\", \"United States\", \"America\", \"United States of America\"]\n case \"GB\":\n return [\"UK\", \"United Kingdom\", \"Great Britain\", \"England\"]\n case \"AE\":\n return [\"UAE\", \"United Arab Emirates\"]\n case \"KR\":\n return [\"South Korea\", \"Korea\"]\n case \"CN\":\n return [\"China\", \"PRC\"]\n case \"CD\":\n return [\"DRC\", \"Congo-Kinshasa\"]\n case \"CG\":\n return [\"Congo-Brazzaville\"]\n case \"BR\":\n return [\"Brazil\"]\n default:\n return []\n }\n}\n\n"],"mappings":";;AAQA,IAAMM,IAAkBF,GAAgB,EAElCG,oBAAwB,IAAIC,KAA8B,EAC1DC,IAA2B,sBACpBC,IAAqBC,MAAMC,KACtC,IAAIC,IAAIP,EAAgBQ,KAAKC,MAASd,EAAsBc,EAAK,CAAC,CACpE,CAAC,CAACC,MAAMC,GAAGC,MAAMA,EAAEC,SAASF,EAAEE,OAAO,EACxBC,IAAuBV,EAAmBW,QACpDC,GAAKC,MAASC,KAAKF,IAAIA,GAAKC,EAAKJ,OAAO,EACzC,EACD,EACYM,IAAsB;CAAC;CAAQ;CAAO;CAAO;CAAM;CAAM;AAEtE,SAAgBC,EAAgBC,GAAgC;AAK9D,QAJKA,KAIErB,EAAgBsB,SAASD,EAAM,GAAGA,IAAAA;;AAG3C,SAASE,EAAmBC,GAA4B;AACtD,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