@caspeco/casper-ui-library 10.0.4 → 10.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.
- package/dist/components/input/input-recipe.d.ts.map +1 -1
- package/dist/components/input/input-recipe.js +8 -3
- package/dist/components/input/input.composition.d.ts.map +1 -1
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +76 -52
- package/dist/components/input/types.d.ts +2 -2
- package/dist/components/input/types.d.ts.map +1 -1
- package/dist/components/menu/menu-box-button.d.ts +4 -1
- package/dist/components/menu/menu-box-button.d.ts.map +1 -1
- package/dist/components/menu/menu-box-button.js +15 -14
- package/dist/components/phone-input/country-data.d.ts +22 -0
- package/dist/components/phone-input/country-data.d.ts.map +1 -0
- package/dist/components/phone-input/country-data.js +38 -0
- package/dist/components/phone-input/country-data.spec.d.ts +2 -0
- package/dist/components/phone-input/country-data.spec.d.ts.map +1 -0
- package/dist/components/phone-input/country-list.d.ts +19 -0
- package/dist/components/phone-input/country-list.d.ts.map +1 -0
- package/dist/components/phone-input/country-list.js +27 -0
- package/dist/components/phone-input/country-selector.d.ts +59 -0
- package/dist/components/phone-input/country-selector.d.ts.map +1 -0
- package/dist/components/phone-input/country-selector.js +120 -0
- package/dist/components/phone-input/index.d.ts +5 -0
- package/dist/components/phone-input/index.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input-helpers.d.ts +47 -0
- package/dist/components/phone-input/phone-input-helpers.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input-helpers.js +134 -0
- package/dist/components/phone-input/phone-input-helpers.spec.d.ts +2 -0
- package/dist/components/phone-input/phone-input-helpers.spec.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.composition.d.ts +26 -0
- package/dist/components/phone-input/phone-input.composition.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.d.ts +22 -0
- package/dist/components/phone-input/phone-input.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.js +43 -0
- package/dist/components/phone-input/phone-input.spec.d.ts +2 -0
- package/dist/components/phone-input/phone-input.spec.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.visual.test.d.ts +2 -0
- package/dist/components/phone-input/phone-input.visual.test.d.ts.map +1 -0
- package/dist/components/phone-input/translations.d.ts +60 -0
- package/dist/components/phone-input/translations.d.ts.map +1 -0
- package/dist/components/phone-input/translations.js +54 -0
- package/dist/components/phone-input/types.d.ts +45 -0
- package/dist/components/phone-input/types.d.ts.map +1 -0
- package/dist/components/phone-input/use-phone-input.d.ts +49 -0
- package/dist/components/phone-input/use-phone-input.d.ts.map +1 -0
- package/dist/components/phone-input/use-phone-input.js +138 -0
- package/dist/components/phone-input/use-phone-input.spec.d.ts +2 -0
- package/dist/components/phone-input/use-phone-input.spec.d.ts.map +1 -0
- package/dist/hooks/use-measured-width.d.ts +23 -0
- package/dist/hooks/use-measured-width.d.ts.map +1 -0
- package/dist/hooks/use-measured-width.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +289 -285
- package/dist/node_modules/country-flag-icons/modules/countries.json.js +4 -0
- package/dist/node_modules/country-flag-icons/modules/hasFlag.js +7 -0
- package/dist/node_modules/country-flag-icons/modules/react/3x2/index.js +6303 -0
- package/dist/node_modules/country-flag-icons/react/3x2/index.js +269 -0
- package/dist/node_modules/libphonenumber-js/es6/ParseError.js +89 -0
- package/dist/node_modules/libphonenumber-js/es6/PhoneNumber.js +192 -0
- package/dist/node_modules/libphonenumber-js/es6/constants.js +10 -0
- package/dist/node_modules/libphonenumber-js/es6/format.js +98 -0
- package/dist/node_modules/libphonenumber-js/es6/getCountries.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +11 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +16 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +11 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +18 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +46 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +27 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +23 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +39 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +31 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +23 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +25 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryAndCallingCodeFromOneOfThem.js +12 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +9 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +43 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +12 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +52 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +14 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isCallingCode.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isCountryCode.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isObject.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +20 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +6 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +79 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +19 -0
- package/dist/node_modules/libphonenumber-js/es6/isPossible.js +35 -0
- package/dist/node_modules/libphonenumber-js/es6/isValid.js +14 -0
- package/dist/node_modules/libphonenumber-js/es6/isValidPhoneNumber.js +59 -0
- package/dist/node_modules/libphonenumber-js/es6/metadata.js +494 -0
- package/dist/node_modules/libphonenumber-js/es6/normalizeArguments.js +108 -0
- package/dist/node_modules/libphonenumber-js/es6/parse.js +138 -0
- package/dist/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +40 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumber.js +9 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +55 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +62 -0
- package/dist/node_modules/libphonenumber-js/es6/tools/semver-compare.js +14 -0
- package/dist/node_modules/libphonenumber-js/metadata.min.json.js +4 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountries.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/isSupportedCountry.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/isValidPhoneNumber.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/parsePhoneNumber.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/withMetadataArgument.js +8 -0
- package/dist/test-utils/create-visual-tests.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import h from "./tools/semver-compare.js";
|
|
2
|
+
import l from "./helpers/isObject.js";
|
|
3
|
+
import v from "./helpers/isCallingCode.js";
|
|
4
|
+
function o(e) {
|
|
5
|
+
"@babel/helpers - typeof";
|
|
6
|
+
return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
|
|
7
|
+
return typeof t;
|
|
8
|
+
} : function(t) {
|
|
9
|
+
return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
|
|
10
|
+
}, o(e);
|
|
11
|
+
}
|
|
12
|
+
function u(e, t) {
|
|
13
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
14
|
+
}
|
|
15
|
+
function d(e, t) {
|
|
16
|
+
for (var n = 0; n < t.length; n++) {
|
|
17
|
+
var a = t[n];
|
|
18
|
+
a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(e, P(a.key), a);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function s(e, t, n) {
|
|
22
|
+
return t && d(e.prototype, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
23
|
+
}
|
|
24
|
+
function P(e) {
|
|
25
|
+
var t = C(e, "string");
|
|
26
|
+
return o(t) == "symbol" ? t : t + "";
|
|
27
|
+
}
|
|
28
|
+
function C(e, t) {
|
|
29
|
+
if (o(e) != "object" || !e) return e;
|
|
30
|
+
var n = e[Symbol.toPrimitive];
|
|
31
|
+
if (n !== void 0) {
|
|
32
|
+
var a = n.call(e, t);
|
|
33
|
+
if (o(a) != "object") return a;
|
|
34
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
35
|
+
}
|
|
36
|
+
return String(e);
|
|
37
|
+
}
|
|
38
|
+
var p = "1.2.0", b = "1.7.35", g = " ext. ", F = /* @__PURE__ */ (function() {
|
|
39
|
+
function e(t) {
|
|
40
|
+
u(this, e), N(t), this.metadata = t, m.call(this, t);
|
|
41
|
+
}
|
|
42
|
+
return s(e, [{
|
|
43
|
+
key: "getCountries",
|
|
44
|
+
value: function() {
|
|
45
|
+
return Object.keys(this.metadata.countries).filter(function(n) {
|
|
46
|
+
return n !== "001";
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "getCountryMetadata",
|
|
51
|
+
value: function(n) {
|
|
52
|
+
return this.metadata.countries[n];
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "nonGeographic",
|
|
56
|
+
value: function() {
|
|
57
|
+
if (!(this.v1 || this.v2 || this.v3))
|
|
58
|
+
return this.metadata.nonGeographic || this.metadata.nonGeographical;
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "hasCountry",
|
|
62
|
+
value: function(n) {
|
|
63
|
+
return this.getCountryMetadata(n) !== void 0;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "hasCallingCode",
|
|
67
|
+
value: function(n) {
|
|
68
|
+
if (this.getCountryCodesForCallingCode(n))
|
|
69
|
+
return !0;
|
|
70
|
+
if (this.nonGeographic()) {
|
|
71
|
+
if (this.nonGeographic()[n])
|
|
72
|
+
return !0;
|
|
73
|
+
} else {
|
|
74
|
+
var a = this.countryCallingCodes()[n];
|
|
75
|
+
if (a && a.length === 1 && a[0] === "001")
|
|
76
|
+
return !0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "isNonGeographicCallingCode",
|
|
81
|
+
value: function(n) {
|
|
82
|
+
return this.nonGeographic() ? !!this.nonGeographic()[n] : !this.getCountryCodesForCallingCode(n);
|
|
83
|
+
}
|
|
84
|
+
// Deprecated.
|
|
85
|
+
}, {
|
|
86
|
+
key: "country",
|
|
87
|
+
value: function(n) {
|
|
88
|
+
return this.selectNumberingPlan(n);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Selects a telephone numbering plan based on either a country code or a calling code.
|
|
92
|
+
* @param {string} argument — Country code or calling code.
|
|
93
|
+
* @param {string} legacyArgumentCallingCode — Legacy argument: calling code, if the first argument is not passed.
|
|
94
|
+
*/
|
|
95
|
+
}, {
|
|
96
|
+
key: "selectNumberingPlan",
|
|
97
|
+
value: function(n, a) {
|
|
98
|
+
var i, r;
|
|
99
|
+
if (n && (v(n) ? r = n : i = n), a && (r = a), i && i !== "001") {
|
|
100
|
+
var f = this.getCountryMetadata(i);
|
|
101
|
+
if (!f)
|
|
102
|
+
throw new Error("Unknown country: ".concat(i));
|
|
103
|
+
this.numberingPlan = new c(f, this);
|
|
104
|
+
} else if (r) {
|
|
105
|
+
if (!this.hasCallingCode(r))
|
|
106
|
+
throw new Error("Unknown calling code: ".concat(r));
|
|
107
|
+
this.numberingPlan = new c(this.getNumberingPlanMetadata(r), this);
|
|
108
|
+
} else
|
|
109
|
+
this.numberingPlan = void 0;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "getCountryCodesForCallingCode",
|
|
114
|
+
value: function(n) {
|
|
115
|
+
var a = this.countryCallingCodes()[n];
|
|
116
|
+
if (a)
|
|
117
|
+
return a.length === 1 && a[0].length === 3 ? void 0 : a;
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "getCountryCodeForCallingCode",
|
|
121
|
+
value: function(n) {
|
|
122
|
+
var a = this.getCountryCodesForCallingCode(n);
|
|
123
|
+
if (a)
|
|
124
|
+
return a[0];
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "getNumberingPlanMetadata",
|
|
128
|
+
value: function(n) {
|
|
129
|
+
var a = this.getCountryCodeForCallingCode(n);
|
|
130
|
+
if (a)
|
|
131
|
+
return this.getCountryMetadata(a);
|
|
132
|
+
if (this.nonGeographic()) {
|
|
133
|
+
var i = this.nonGeographic()[n];
|
|
134
|
+
if (i)
|
|
135
|
+
return i;
|
|
136
|
+
} else {
|
|
137
|
+
var r = this.countryCallingCodes()[n];
|
|
138
|
+
if (r && r.length === 1 && r[0] === "001")
|
|
139
|
+
return this.metadata.countries["001"];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Deprecated.
|
|
143
|
+
}, {
|
|
144
|
+
key: "countryCallingCode",
|
|
145
|
+
value: function() {
|
|
146
|
+
return this.numberingPlan.callingCode();
|
|
147
|
+
}
|
|
148
|
+
// Deprecated.
|
|
149
|
+
}, {
|
|
150
|
+
key: "IDDPrefix",
|
|
151
|
+
value: function() {
|
|
152
|
+
return this.numberingPlan.IDDPrefix();
|
|
153
|
+
}
|
|
154
|
+
// Deprecated.
|
|
155
|
+
}, {
|
|
156
|
+
key: "defaultIDDPrefix",
|
|
157
|
+
value: function() {
|
|
158
|
+
return this.numberingPlan.defaultIDDPrefix();
|
|
159
|
+
}
|
|
160
|
+
// Deprecated.
|
|
161
|
+
}, {
|
|
162
|
+
key: "nationalNumberPattern",
|
|
163
|
+
value: function() {
|
|
164
|
+
return this.numberingPlan.nationalNumberPattern();
|
|
165
|
+
}
|
|
166
|
+
// Deprecated.
|
|
167
|
+
}, {
|
|
168
|
+
key: "possibleLengths",
|
|
169
|
+
value: function() {
|
|
170
|
+
return this.numberingPlan.possibleLengths();
|
|
171
|
+
}
|
|
172
|
+
// Deprecated.
|
|
173
|
+
}, {
|
|
174
|
+
key: "formats",
|
|
175
|
+
value: function() {
|
|
176
|
+
return this.numberingPlan.formats();
|
|
177
|
+
}
|
|
178
|
+
// Deprecated.
|
|
179
|
+
}, {
|
|
180
|
+
key: "nationalPrefixForParsing",
|
|
181
|
+
value: function() {
|
|
182
|
+
return this.numberingPlan.nationalPrefixForParsing();
|
|
183
|
+
}
|
|
184
|
+
// Deprecated.
|
|
185
|
+
}, {
|
|
186
|
+
key: "nationalPrefixTransformRule",
|
|
187
|
+
value: function() {
|
|
188
|
+
return this.numberingPlan.nationalPrefixTransformRule();
|
|
189
|
+
}
|
|
190
|
+
// Deprecated.
|
|
191
|
+
}, {
|
|
192
|
+
key: "leadingDigits",
|
|
193
|
+
value: function() {
|
|
194
|
+
return this.numberingPlan.leadingDigits();
|
|
195
|
+
}
|
|
196
|
+
// Deprecated.
|
|
197
|
+
}, {
|
|
198
|
+
key: "hasTypes",
|
|
199
|
+
value: function() {
|
|
200
|
+
return this.numberingPlan.hasTypes();
|
|
201
|
+
}
|
|
202
|
+
// Deprecated.
|
|
203
|
+
}, {
|
|
204
|
+
key: "type",
|
|
205
|
+
value: function(n) {
|
|
206
|
+
return this.numberingPlan.type(n);
|
|
207
|
+
}
|
|
208
|
+
// Deprecated.
|
|
209
|
+
}, {
|
|
210
|
+
key: "ext",
|
|
211
|
+
value: function() {
|
|
212
|
+
return this.numberingPlan.ext();
|
|
213
|
+
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "countryCallingCodes",
|
|
216
|
+
value: function() {
|
|
217
|
+
return this.v1 ? this.metadata.country_phone_code_to_countries : this.metadata.country_calling_codes;
|
|
218
|
+
}
|
|
219
|
+
// Deprecated.
|
|
220
|
+
}, {
|
|
221
|
+
key: "chooseCountryByCountryCallingCode",
|
|
222
|
+
value: function(n) {
|
|
223
|
+
return this.selectNumberingPlan(n);
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
key: "hasSelectedNumberingPlan",
|
|
227
|
+
value: function() {
|
|
228
|
+
return this.numberingPlan !== void 0;
|
|
229
|
+
}
|
|
230
|
+
}]);
|
|
231
|
+
})(), c = /* @__PURE__ */ (function() {
|
|
232
|
+
function e(t, n) {
|
|
233
|
+
u(this, e), this.globalMetadataObject = n, this.metadata = t, m.call(this, n.metadata);
|
|
234
|
+
}
|
|
235
|
+
return s(e, [{
|
|
236
|
+
key: "callingCode",
|
|
237
|
+
value: function() {
|
|
238
|
+
return this.metadata[0];
|
|
239
|
+
}
|
|
240
|
+
// When multiple countries share the same calling code,
|
|
241
|
+
// all phone number formatting rules are included in the metadata
|
|
242
|
+
// of the "default" country for that calling code.
|
|
243
|
+
// Any other countries' metdata doesn't include any formatting rules.
|
|
244
|
+
// Google developers said that such storage architecture was chosen for performance reasons.
|
|
245
|
+
//
|
|
246
|
+
// For example, for NANPA region ("North American Numbering Plan Administration",
|
|
247
|
+
// which includes USA, Canada, Cayman Islands, Bahamas, etc) all formatting rules
|
|
248
|
+
// are contained in the metadata of `US` country.
|
|
249
|
+
//
|
|
250
|
+
// This is not public API.
|
|
251
|
+
//
|
|
252
|
+
}, {
|
|
253
|
+
key: "_getDefaultCountryMetadataForThisCallingCode",
|
|
254
|
+
value: function() {
|
|
255
|
+
return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
|
|
256
|
+
}
|
|
257
|
+
// Deprecated.
|
|
258
|
+
}, {
|
|
259
|
+
key: "getDefaultCountryMetadataForRegion",
|
|
260
|
+
value: function() {
|
|
261
|
+
return this._getDefaultCountryMetadataForThisCallingCode();
|
|
262
|
+
}
|
|
263
|
+
// Is always present.
|
|
264
|
+
}, {
|
|
265
|
+
key: "IDDPrefix",
|
|
266
|
+
value: function() {
|
|
267
|
+
if (!(this.v1 || this.v2))
|
|
268
|
+
return this.metadata[1];
|
|
269
|
+
}
|
|
270
|
+
// Is only present when a country supports multiple IDD prefixes.
|
|
271
|
+
}, {
|
|
272
|
+
key: "defaultIDDPrefix",
|
|
273
|
+
value: function() {
|
|
274
|
+
if (!(this.v1 || this.v2))
|
|
275
|
+
return this.metadata[12];
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "nationalNumberPattern",
|
|
279
|
+
value: function() {
|
|
280
|
+
return this.v1 || this.v2 ? this.metadata[1] : this.metadata[2];
|
|
281
|
+
}
|
|
282
|
+
// "possible length" data is always present in Google's metadata.
|
|
283
|
+
}, {
|
|
284
|
+
key: "possibleLengths",
|
|
285
|
+
value: function() {
|
|
286
|
+
if (!this.v1)
|
|
287
|
+
return this.metadata[this.v2 ? 2 : 3];
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
key: "_getFormats",
|
|
291
|
+
value: function(n) {
|
|
292
|
+
return n[this.v1 ? 2 : this.v2 ? 3 : 4];
|
|
293
|
+
}
|
|
294
|
+
// For countries of the same region (e.g. NANPA)
|
|
295
|
+
// formats are all stored in the "main" country for that region.
|
|
296
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
297
|
+
}, {
|
|
298
|
+
key: "formats",
|
|
299
|
+
value: function() {
|
|
300
|
+
var n = this, a = this._getFormats(this.metadata) || this._getFormats(this._getDefaultCountryMetadataForThisCallingCode()) || [];
|
|
301
|
+
return a.map(function(i) {
|
|
302
|
+
return new k(i, n);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
key: "nationalPrefix",
|
|
307
|
+
value: function() {
|
|
308
|
+
return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
|
|
309
|
+
}
|
|
310
|
+
}, {
|
|
311
|
+
key: "_getNationalPrefixFormattingRule",
|
|
312
|
+
value: function(n) {
|
|
313
|
+
return n[this.v1 ? 4 : this.v2 ? 5 : 6];
|
|
314
|
+
}
|
|
315
|
+
// For countries of the same region (e.g. NANPA)
|
|
316
|
+
// national prefix formatting rule is stored in the "main" country for that region.
|
|
317
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
318
|
+
}, {
|
|
319
|
+
key: "nationalPrefixFormattingRule",
|
|
320
|
+
value: function() {
|
|
321
|
+
return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this._getDefaultCountryMetadataForThisCallingCode());
|
|
322
|
+
}
|
|
323
|
+
}, {
|
|
324
|
+
key: "_nationalPrefixForParsing",
|
|
325
|
+
value: function() {
|
|
326
|
+
return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
|
|
327
|
+
}
|
|
328
|
+
}, {
|
|
329
|
+
key: "nationalPrefixForParsing",
|
|
330
|
+
value: function() {
|
|
331
|
+
return this._nationalPrefixForParsing() || this.nationalPrefix();
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "nationalPrefixTransformRule",
|
|
335
|
+
value: function() {
|
|
336
|
+
return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
|
|
337
|
+
}
|
|
338
|
+
}, {
|
|
339
|
+
key: "_getNationalPrefixIsOptionalWhenFormatting",
|
|
340
|
+
value: function() {
|
|
341
|
+
return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
|
|
342
|
+
}
|
|
343
|
+
// For countries of the same region (e.g. NANPA)
|
|
344
|
+
// "national prefix is optional when formatting" flag is
|
|
345
|
+
// stored in the "main" country for that region.
|
|
346
|
+
// E.g. "RU" and "KZ", "US" and "CA".
|
|
347
|
+
}, {
|
|
348
|
+
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
|
349
|
+
value: function() {
|
|
350
|
+
return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this._getDefaultCountryMetadataForThisCallingCode());
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
key: "leadingDigits",
|
|
354
|
+
value: function() {
|
|
355
|
+
return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
|
|
356
|
+
}
|
|
357
|
+
}, {
|
|
358
|
+
key: "types",
|
|
359
|
+
value: function() {
|
|
360
|
+
return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "hasTypes",
|
|
364
|
+
value: function() {
|
|
365
|
+
return this.types() && this.types().length === 0 ? !1 : !!this.types();
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "type",
|
|
369
|
+
value: function(n) {
|
|
370
|
+
if (this.hasTypes() && y(this.types(), n))
|
|
371
|
+
return new _(y(this.types(), n), this);
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "ext",
|
|
375
|
+
value: function() {
|
|
376
|
+
return this.v1 || this.v2 ? g : this.metadata[13] || g;
|
|
377
|
+
}
|
|
378
|
+
}]);
|
|
379
|
+
})(), k = /* @__PURE__ */ (function() {
|
|
380
|
+
function e(t, n) {
|
|
381
|
+
u(this, e), this._format = t, this.metadata = n;
|
|
382
|
+
}
|
|
383
|
+
return s(e, [{
|
|
384
|
+
key: "pattern",
|
|
385
|
+
value: function() {
|
|
386
|
+
return this._format[0];
|
|
387
|
+
}
|
|
388
|
+
}, {
|
|
389
|
+
key: "format",
|
|
390
|
+
value: function() {
|
|
391
|
+
return this._format[1];
|
|
392
|
+
}
|
|
393
|
+
}, {
|
|
394
|
+
key: "leadingDigitsPatterns",
|
|
395
|
+
value: function() {
|
|
396
|
+
return this._format[2] || [];
|
|
397
|
+
}
|
|
398
|
+
}, {
|
|
399
|
+
key: "nationalPrefixFormattingRule",
|
|
400
|
+
value: function() {
|
|
401
|
+
return this._format[3] || this.metadata.nationalPrefixFormattingRule();
|
|
402
|
+
}
|
|
403
|
+
}, {
|
|
404
|
+
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
|
405
|
+
value: function() {
|
|
406
|
+
return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
|
|
410
|
+
value: function() {
|
|
411
|
+
return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
|
412
|
+
}
|
|
413
|
+
// Checks whether national prefix formatting rule contains national prefix.
|
|
414
|
+
}, {
|
|
415
|
+
key: "usesNationalPrefix",
|
|
416
|
+
value: function() {
|
|
417
|
+
return !!(this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
|
|
418
|
+
!x.test(this.nationalPrefixFormattingRule()));
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
key: "internationalFormat",
|
|
422
|
+
value: function() {
|
|
423
|
+
return this._format[5] || this.format();
|
|
424
|
+
}
|
|
425
|
+
}]);
|
|
426
|
+
})(), x = /^\(?\$1\)?$/, _ = /* @__PURE__ */ (function() {
|
|
427
|
+
function e(t, n) {
|
|
428
|
+
u(this, e), this.type = t, this.metadata = n;
|
|
429
|
+
}
|
|
430
|
+
return s(e, [{
|
|
431
|
+
key: "pattern",
|
|
432
|
+
value: function() {
|
|
433
|
+
return this.metadata.v1 ? this.type : this.type[0];
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
key: "possibleLengths",
|
|
437
|
+
value: function() {
|
|
438
|
+
if (!this.metadata.v1)
|
|
439
|
+
return this.type[1] || this.metadata.possibleLengths();
|
|
440
|
+
}
|
|
441
|
+
}]);
|
|
442
|
+
})();
|
|
443
|
+
function y(e, t) {
|
|
444
|
+
switch (t) {
|
|
445
|
+
case "FIXED_LINE":
|
|
446
|
+
return e[0];
|
|
447
|
+
case "MOBILE":
|
|
448
|
+
return e[1];
|
|
449
|
+
case "TOLL_FREE":
|
|
450
|
+
return e[2];
|
|
451
|
+
case "PREMIUM_RATE":
|
|
452
|
+
return e[3];
|
|
453
|
+
case "PERSONAL_NUMBER":
|
|
454
|
+
return e[4];
|
|
455
|
+
case "VOICEMAIL":
|
|
456
|
+
return e[5];
|
|
457
|
+
case "UAN":
|
|
458
|
+
return e[6];
|
|
459
|
+
case "PAGER":
|
|
460
|
+
return e[7];
|
|
461
|
+
case "VOIP":
|
|
462
|
+
return e[8];
|
|
463
|
+
case "SHARED_COST":
|
|
464
|
+
return e[9];
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function N(e) {
|
|
468
|
+
if (!e)
|
|
469
|
+
throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");
|
|
470
|
+
if (!l(e) || !l(e.countries))
|
|
471
|
+
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(l(e) ? "an object of shape: { " + Object.keys(e).join(", ") + " }" : "a " + I(e) + ": " + e, "."));
|
|
472
|
+
}
|
|
473
|
+
var I = function(t) {
|
|
474
|
+
return o(t);
|
|
475
|
+
};
|
|
476
|
+
function M(e, t) {
|
|
477
|
+
var n = new F(t);
|
|
478
|
+
if (n.hasCountry(e))
|
|
479
|
+
return n.selectNumberingPlan(e).countryCallingCode();
|
|
480
|
+
throw new Error("Unknown country: ".concat(e));
|
|
481
|
+
}
|
|
482
|
+
function w(e, t) {
|
|
483
|
+
return t.countries.hasOwnProperty(e);
|
|
484
|
+
}
|
|
485
|
+
function m(e) {
|
|
486
|
+
var t = e.version;
|
|
487
|
+
typeof t == "number" ? (this.v1 = t === 1, this.v2 = t === 2, this.v3 = t === 3, this.v4 = t === 4) : t ? h(t, p) === -1 ? this.v2 = !0 : h(t, b) === -1 ? this.v3 = !0 : this.v4 = !0 : this.v1 = !0;
|
|
488
|
+
}
|
|
489
|
+
export {
|
|
490
|
+
F as default,
|
|
491
|
+
M as getCountryCallingCode,
|
|
492
|
+
w as isSupportedCountry,
|
|
493
|
+
N as validateMetadata
|
|
494
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import b from "./helpers/isObject.js";
|
|
2
|
+
function f(r) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
|
|
5
|
+
return typeof t;
|
|
6
|
+
} : function(t) {
|
|
7
|
+
return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
|
|
8
|
+
}, f(r);
|
|
9
|
+
}
|
|
10
|
+
function y(r, t) {
|
|
11
|
+
var e = Object.keys(r);
|
|
12
|
+
if (Object.getOwnPropertySymbols) {
|
|
13
|
+
var n = Object.getOwnPropertySymbols(r);
|
|
14
|
+
t && (n = n.filter(function(o) {
|
|
15
|
+
return Object.getOwnPropertyDescriptor(r, o).enumerable;
|
|
16
|
+
})), e.push.apply(e, n);
|
|
17
|
+
}
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
function m(r) {
|
|
21
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
22
|
+
var e = arguments[t] != null ? arguments[t] : {};
|
|
23
|
+
t % 2 ? y(Object(e), !0).forEach(function(n) {
|
|
24
|
+
g(r, n, e[n]);
|
|
25
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : y(Object(e)).forEach(function(n) {
|
|
26
|
+
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return r;
|
|
30
|
+
}
|
|
31
|
+
function g(r, t, e) {
|
|
32
|
+
return (t = v(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
|
|
33
|
+
}
|
|
34
|
+
function v(r) {
|
|
35
|
+
var t = d(r, "string");
|
|
36
|
+
return f(t) == "symbol" ? t : t + "";
|
|
37
|
+
}
|
|
38
|
+
function d(r, t) {
|
|
39
|
+
if (f(r) != "object" || !r) return r;
|
|
40
|
+
var e = r[Symbol.toPrimitive];
|
|
41
|
+
if (e !== void 0) {
|
|
42
|
+
var n = e.call(r, t);
|
|
43
|
+
if (f(n) != "object") return n;
|
|
44
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
45
|
+
}
|
|
46
|
+
return (t === "string" ? String : Number)(r);
|
|
47
|
+
}
|
|
48
|
+
function O(r, t) {
|
|
49
|
+
return _(r) || w(r, t) || h(r, t) || j();
|
|
50
|
+
}
|
|
51
|
+
function j() {
|
|
52
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
53
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
54
|
+
}
|
|
55
|
+
function h(r, t) {
|
|
56
|
+
if (r) {
|
|
57
|
+
if (typeof r == "string") return s(r, t);
|
|
58
|
+
var e = {}.toString.call(r).slice(8, -1);
|
|
59
|
+
return e === "Object" && r.constructor && (e = r.constructor.name), e === "Map" || e === "Set" ? Array.from(r) : e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e) ? s(r, t) : void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function s(r, t) {
|
|
63
|
+
(t == null || t > r.length) && (t = r.length);
|
|
64
|
+
for (var e = 0, n = Array(t); e < t; e++) n[e] = r[e];
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
function w(r, t) {
|
|
68
|
+
var e = r == null ? null : typeof Symbol < "u" && r[Symbol.iterator] || r["@@iterator"];
|
|
69
|
+
if (e != null) {
|
|
70
|
+
var n, o, u, l, c = [], i = !0, a = !1;
|
|
71
|
+
try {
|
|
72
|
+
if (u = (e = e.call(r)).next, t !== 0) for (; !(i = (n = u.call(e)).done) && (c.push(n.value), c.length !== t); i = !0) ;
|
|
73
|
+
} catch (p) {
|
|
74
|
+
a = !0, o = p;
|
|
75
|
+
} finally {
|
|
76
|
+
try {
|
|
77
|
+
if (!i && e.return != null && (l = e.return(), Object(l) !== l)) return;
|
|
78
|
+
} finally {
|
|
79
|
+
if (a) throw o;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return c;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function _(r) {
|
|
86
|
+
if (Array.isArray(r)) return r;
|
|
87
|
+
}
|
|
88
|
+
function S(r) {
|
|
89
|
+
var t = Array.prototype.slice.call(r), e = O(t, 4), n = e[0], o = e[1], u = e[2], l = e[3], c, i, a;
|
|
90
|
+
if (typeof n == "string")
|
|
91
|
+
c = n;
|
|
92
|
+
else throw new TypeError("A text for parsing must be a string.");
|
|
93
|
+
if (!o || typeof o == "string")
|
|
94
|
+
l ? (i = u, a = l) : (i = void 0, a = u), o && (i = m({
|
|
95
|
+
defaultCountry: o
|
|
96
|
+
}, i));
|
|
97
|
+
else if (b(o))
|
|
98
|
+
u ? (i = o, a = u) : a = o;
|
|
99
|
+
else throw new Error("Invalid second argument: ".concat(o));
|
|
100
|
+
return {
|
|
101
|
+
text: c,
|
|
102
|
+
options: i,
|
|
103
|
+
metadata: a
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
S as default
|
|
108
|
+
};
|