@desource/phone-mask 0.2.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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/esm/country-code-emodji.js +1 -0
- package/dist/esm/data.min.js +1 -0
- package/dist/esm/entries.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils.js +1 -0
- package/dist/phone-mask.cjs.js +1 -0
- package/dist/phone-mask.umd.min.js +1 -0
- package/dist/types/country-code-emodji.d.ts +7 -0
- package/dist/types/country-code-emodji.d.ts.map +1 -0
- package/dist/types/data-types.d.ts +2 -0
- package/dist/types/data-types.d.ts.map +1 -0
- package/dist/types/entries.d.ts +81 -0
- package/dist/types/entries.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/utils.d.ts +15 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +64 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @desource/phone-mask
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Initial release of phone-mask monorepo packages
|
|
8
|
+
- Core phone masking library with Google libphonenumber integration
|
|
9
|
+
- Vue 3 component and directive for phone input
|
|
10
|
+
- Nuxt 3 module with zero-config setup
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DeSource Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# @desource/phone-mask
|
|
2
|
+
|
|
3
|
+
> Core TypeScript library for international phone number masking with Google's libphonenumber data
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@desource/phone-mask)
|
|
6
|
+
[](https://bundlephobia.com/package/@desource/phone-mask)
|
|
7
|
+
[](https://github.com/DeSource-Labs/phone-mask/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
Framework-agnostic phone masking library that stays up-to-date with Google's libphonenumber database.
|
|
10
|
+
|
|
11
|
+
## β¨ Features
|
|
12
|
+
|
|
13
|
+
- π **240+ countries** with accurate masks and dialing codes
|
|
14
|
+
- π **Auto-synced** from Google's libphonenumber
|
|
15
|
+
- πͺΆ **Tiny** β 13 KB minified, 4 KB gzipped
|
|
16
|
+
- π³ **Tree-shakeable** β import only what you need
|
|
17
|
+
- π§ **TypeScript** β fully typed
|
|
18
|
+
- π― **Zero dependencies**
|
|
19
|
+
|
|
20
|
+
## π¦ Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @desource/phone-mask
|
|
24
|
+
# or
|
|
25
|
+
yarn add @desource/phone-mask
|
|
26
|
+
# or
|
|
27
|
+
pnpm add @desource/phone-mask
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## π Quick Start
|
|
31
|
+
|
|
32
|
+
### Basic Formatting
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { MasksBaseMap, MasksMap, formatDigitsWithMap } from '@desource/phone-mask';
|
|
36
|
+
|
|
37
|
+
// Get US mask with country code prefix
|
|
38
|
+
const prefixUsMask = MasksBaseMap.US;
|
|
39
|
+
// "+1 ###-###-####"
|
|
40
|
+
|
|
41
|
+
// Format digits
|
|
42
|
+
const result = formatDigitsWithMap(prefixUsMask, '2025551234');
|
|
43
|
+
console.log(result.display); // "+1 202-555-1234"
|
|
44
|
+
console.log(result.map); // [-1, -1, -1, 0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, 9]
|
|
45
|
+
|
|
46
|
+
// Get US mask without country code prefix
|
|
47
|
+
const usMask = MasksMap.US.mask;
|
|
48
|
+
// "###-###-####"
|
|
49
|
+
|
|
50
|
+
// Format digits without country code
|
|
51
|
+
const resultNoCode = formatDigitsWithMap(usMask, '2025551234');
|
|
52
|
+
console.log(resultNoCode.display); // "202-555-1234"
|
|
53
|
+
console.log(resultNoCode.map); // [0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, 9]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Working with Country Data
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { MasksFullMapEn, type MaskFull } from '@desource/phone-mask';
|
|
60
|
+
|
|
61
|
+
// Access country data
|
|
62
|
+
const us = MasksFullMapEn.US;
|
|
63
|
+
|
|
64
|
+
console.log(us.name); // "United States"
|
|
65
|
+
console.log(us.code); // "+1"
|
|
66
|
+
console.log(us.mask); // "###-###-####"
|
|
67
|
+
console.log(us.flag); // "πΊπΈ"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Multiple Mask Variants
|
|
71
|
+
|
|
72
|
+
Some countries have multiple mask formats:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { MasksFullMapEn } from '@desource/phone-mask';
|
|
76
|
+
|
|
77
|
+
const gb = MasksFullMapEn.GB;
|
|
78
|
+
console.log(gb.mask);
|
|
79
|
+
// [
|
|
80
|
+
// "### ### ####",
|
|
81
|
+
// "#### ######",
|
|
82
|
+
// "## #### ####"
|
|
83
|
+
// ]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Localized Country Names
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { MasksFullMap } from '@desource/phone-mask';
|
|
90
|
+
|
|
91
|
+
// Get localized names
|
|
92
|
+
const germanMap = MasksFullMap('de');
|
|
93
|
+
console.log(germanMap.US.name); // "Vereinigte Staaten"
|
|
94
|
+
|
|
95
|
+
const frenchMap = MasksFullMap('fr');
|
|
96
|
+
console.log(frenchMap.US.name); // "Γtats-Unis"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Utility Functions
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import {
|
|
103
|
+
toArray,
|
|
104
|
+
countPlaceholders,
|
|
105
|
+
removeCountryCodePrefix,
|
|
106
|
+
pickMaskVariant,
|
|
107
|
+
extractDigits
|
|
108
|
+
} from '@desource/phone-mask';
|
|
109
|
+
|
|
110
|
+
// Ensure mask is an array
|
|
111
|
+
const masks = toArray('+1 ###-###-####');
|
|
112
|
+
// ["+1 ###-###-####"]
|
|
113
|
+
|
|
114
|
+
// Count placeholder digits
|
|
115
|
+
const count = countPlaceholders('+1 ###-###-####');
|
|
116
|
+
// 10
|
|
117
|
+
|
|
118
|
+
// Remove country code prefix
|
|
119
|
+
const stripped = removeCountryCodePrefix('+1 ###-###-####');
|
|
120
|
+
// "###-###-####"
|
|
121
|
+
|
|
122
|
+
// Pick best mask variant for digit count
|
|
123
|
+
const variants = ['+44 ### ### ####', '+44 #### ######'];
|
|
124
|
+
const best = pickMaskVariant(variants, 11);
|
|
125
|
+
// "+44 #### ######"
|
|
126
|
+
|
|
127
|
+
// Extract only digits from string
|
|
128
|
+
const digits = extractDigits('+1 (202) 555-1234');
|
|
129
|
+
// "12025551234"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## π API Reference
|
|
133
|
+
|
|
134
|
+
### Types
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
// Country ISO 3166-1 alpha-2 code
|
|
138
|
+
type CountryKey = 'US' | 'GB' | 'DE' | ... // 240+ countries
|
|
139
|
+
|
|
140
|
+
// Mask interfaces
|
|
141
|
+
interface MaskBase {
|
|
142
|
+
id: CountryKey;
|
|
143
|
+
mask: string | Array<string>;
|
|
144
|
+
}
|
|
145
|
+
interface Mask extends MaskBase {
|
|
146
|
+
code: string;
|
|
147
|
+
}
|
|
148
|
+
interface MaskWithFlag extends Mask {
|
|
149
|
+
flag: string;
|
|
150
|
+
}
|
|
151
|
+
interface MaskFull extends MaskWithFlag {
|
|
152
|
+
name: string;
|
|
153
|
+
}
|
|
154
|
+
type MaskBaseMap = Record<CountryKey, string | Array<string>>;
|
|
155
|
+
type MaskMap = Record<CountryKey, Omit<Mask, 'id'>>;
|
|
156
|
+
type MaskWithFlagMap = Record<CountryKey, Omit<MaskWithFlag, 'id'>>;
|
|
157
|
+
type MaskFullMap = Record<CountryKey, Omit<MaskFull, 'id'>>;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Core Exports
|
|
161
|
+
|
|
162
|
+
#### `MasksBaseMap` & `MasksBase`
|
|
163
|
+
|
|
164
|
+
Basic country masks including country code prefix (lightweight version):
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
const MasksBaseMap: MaskBaseMap;
|
|
168
|
+
const MasksBase: MaskBase[];
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Use these to get raw masks with country code prefix.
|
|
172
|
+
**Note:** some helper functions may expect masks without country code.
|
|
173
|
+
|
|
174
|
+
#### `MasksMap` & `Masks`
|
|
175
|
+
|
|
176
|
+
Masks with country code as separate property:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const MasksMap: MaskMap;
|
|
180
|
+
const Masks: Mask[];
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### `MasksWithFlagMap` & `MasksWithFlag`
|
|
184
|
+
|
|
185
|
+
Masks with country code and flag:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const MasksWithFlagMap: MaskWithFlagMap;
|
|
189
|
+
const MasksWithFlag: MaskWithFlag[];
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### `MasksFullMapEn` & `MasksFullEn`
|
|
193
|
+
|
|
194
|
+
Full country data with country names in English:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const MasksFullMapEn: MaskFullMap;
|
|
198
|
+
const MasksFullEn: MaskFull[];
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### `MasksFullMap(locale: string)` & `MasksFull(locale: string)`
|
|
202
|
+
|
|
203
|
+
Get full country data with localized country names:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
function MasksFullMap(locale: string): MaskFullMap;
|
|
207
|
+
function MasksFull(locale: string): MaskFull[];
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Supported locales**: `en`, `de`, `fr`, `es`, `it`, `pt`, `ru`, `zh`, `ja`, `ko`, and more.
|
|
211
|
+
|
|
212
|
+
#### Utility Functions
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
// Convert single mask or array to array
|
|
216
|
+
function toArray<T>(value: T | T[]): T[];
|
|
217
|
+
|
|
218
|
+
// Count # placeholders in mask
|
|
219
|
+
function countPlaceholders(mask: string): number;
|
|
220
|
+
|
|
221
|
+
// Remove country code prefix from mask
|
|
222
|
+
function removeCountryCodePrefix(mask: string): string;
|
|
223
|
+
|
|
224
|
+
// Pick best mask variant for digit length
|
|
225
|
+
function pickMaskVariant(masks: string[], digitLength: number): string;
|
|
226
|
+
|
|
227
|
+
// Extract digits from any string
|
|
228
|
+
function extractDigits(value: string, maxLength?: number): string;
|
|
229
|
+
|
|
230
|
+
// Format digits according to template
|
|
231
|
+
function formatDigitsWithMap(value: string, digits: string): { display: string; map: number[] };
|
|
232
|
+
|
|
233
|
+
// Get flag emoji for country code
|
|
234
|
+
function getFlagEmoji(countryCode: CountryKey): string;
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## π― Use Cases
|
|
238
|
+
|
|
239
|
+
### Custom Input Formatting
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import { MasksFullMapEn, formatDigitsWithMap, extractDigits } from '@desource/phone-mask';
|
|
243
|
+
|
|
244
|
+
function formatPhoneInput(value: string, countryCode: string = 'US') {
|
|
245
|
+
const country = MasksFullMapEn[countryCode];
|
|
246
|
+
const mask = country?.mask;
|
|
247
|
+
if (!mask) return value;
|
|
248
|
+
|
|
249
|
+
const template = Array.isArray(mask) ? mask[0] : mask;
|
|
250
|
+
const digits = extractDigits(value);
|
|
251
|
+
|
|
252
|
+
return `${country.code} ${formatDigitsWithMap(template, digits).display}`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Usage
|
|
256
|
+
const formatted = formatPhoneInput('2025551234', 'US');
|
|
257
|
+
// "+1 202-555-1234"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Phone Number Validation
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
import { MasksFullMapEn, countPlaceholders, toArray } from '@desource/phone-mask';
|
|
264
|
+
|
|
265
|
+
function isValidPhoneLength(digits: string, country: string): boolean {
|
|
266
|
+
const mask = MasksFullMapEn[country]?.mask;
|
|
267
|
+
if (!mask) return false;
|
|
268
|
+
|
|
269
|
+
const masks = toArray(mask);
|
|
270
|
+
const validLengths = masks.map((m) => countPlaceholders(m));
|
|
271
|
+
|
|
272
|
+
return validLengths.includes(digits.length);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Usage
|
|
276
|
+
isValidPhoneLength('2025551234', 'US'); // true (10 digits)
|
|
277
|
+
isValidPhoneLength('202555', 'US'); // false (too short)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Building a Country Selector
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
import { MasksFullEn, type CountryKey, type MaskFull } from '@desource/phone-mask';
|
|
284
|
+
|
|
285
|
+
type CountryOption = Omit<MaskFull, 'mask'>;
|
|
286
|
+
|
|
287
|
+
function getCountryOptions(): CountryOption[] {
|
|
288
|
+
return Object.entries(MasksFullEn).map((data) => ({
|
|
289
|
+
id: data.id,
|
|
290
|
+
name: data.name,
|
|
291
|
+
code: data.code,
|
|
292
|
+
flag: data.flag
|
|
293
|
+
}));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Usage
|
|
297
|
+
const countries = getCountryOptions();
|
|
298
|
+
// [
|
|
299
|
+
// { id: 'US', name: 'United States', code: '+1', flag: 'πΊπΈ' },
|
|
300
|
+
// { id: 'GB', name: 'United Kingdom', code: '+44', flag: 'π¬π§' },
|
|
301
|
+
// ...
|
|
302
|
+
// ]
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Getting Flag Emojis
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
import { getFlagEmoji } from '@desource/phone-mask';
|
|
309
|
+
|
|
310
|
+
// Get flag emoji for country code
|
|
311
|
+
const flag = getFlagEmoji('US'); // "πΊπΈ"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## π Data Updates
|
|
315
|
+
|
|
316
|
+
The library syncs with [Google's libphonenumber](https://github.com/google/libphonenumber) weekly via automated workflow. To update manually:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
pnpm gen
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
This fetches the latest data and regenerates `data.json`.
|
|
323
|
+
|
|
324
|
+
## π Bundle Size
|
|
325
|
+
|
|
326
|
+
| Export | Size (minified) | Gzipped |
|
|
327
|
+
| ------------------- | --------------- | ------- |
|
|
328
|
+
| Full library | 13 KB | 4 KB |
|
|
329
|
+
| MasksFullMapEn only | 8 KB | 3 KB |
|
|
330
|
+
| Utilities only | 2 KB | 1 KB |
|
|
331
|
+
|
|
332
|
+
All exports are tree-shakeable β only import what you use!
|
|
333
|
+
|
|
334
|
+
## π Related Packages
|
|
335
|
+
|
|
336
|
+
- [@desource/phone-mask-vue](../phone-mask-vue) β Vue 3 component + directive
|
|
337
|
+
- [@desource/phone-mask-nuxt](../phone-mask-nuxt) β Nuxt 3 module
|
|
338
|
+
|
|
339
|
+
## π License
|
|
340
|
+
|
|
341
|
+
[MIT](../../LICENSE) Β© 2025 DeSource Labs
|
|
342
|
+
|
|
343
|
+
## π€ Contributing
|
|
344
|
+
|
|
345
|
+
See [Contributing Guide](../../CONTRIBUTING.md)
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
<div align="center">
|
|
350
|
+
<sub>Made with β€οΈ by <a href="https://github.com/DeSource-Labs">DeSource Labs</a></sub>
|
|
351
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=/^[a-z]{2}$/i,countryCodeEmoji=o=>{if(!t.test(o)){const t=typeof o;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===t?o:t}' instead.`)}const e=[...o.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)};export{countryCodeEmoji};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const M={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 ####-#####","+212 ###-######","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 ###-######","+212 ##-#######","+212 ####-#####"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]};export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./data.min.js";import{countryCodeEmoji as n}from"./country-code-emodji.js";const t=Object.entries(e),divideMask=e=>e.split(/ (.*)/s);function getCodeAndMask(e){let n="",t="";if(Array.isArray(e)){const o=[];for(const t of e){const[e,s]=divideMask(t);n||(n=e),o.push(s)}t=o}else{const[o,s]=divideMask(e);n=o,t=s}return[n,t]}const o=e,s=t.map(([e,n])=>({id:e,mask:n})),a=t.reduce((e,[n,t])=>{const[o,s]=getCodeAndMask(t);return e[n]={code:o,mask:s},e},{}),r=t.map(([e,n])=>{const[t,o]=getCodeAndMask(n);return{id:e,code:t,mask:o}}),d=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o);return e[t]={code:s,mask:a,flag:n(t)},e},{}),c=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,flag:n(e)}}),MasksFullMap=e=>{const o=new Intl.DisplayNames([e],{type:"region"});return t.reduce((e,[t,s])=>{const[a,r]=getCodeAndMask(s),d=o.of(t)??"";return e[t]={code:a,mask:r,name:d,flag:n(t)},e},{})},MasksFull=e=>{const o=new Intl.DisplayNames([e],{type:"region"});return t.map(([e,t])=>{const[s,a]=getCodeAndMask(t);return{id:e,code:s,mask:a,name:o.of(e)??"",flag:n(e)}})},m=t.reduce((e,[t,o])=>{const[s,a]=getCodeAndMask(o),r=new Intl.DisplayNames(["en"],{type:"region"});return e[t]={code:s,mask:a,name:r.of(t)??"",flag:n(t)},e},{}),i=t.map(([e,t])=>{const[o,s]=getCodeAndMask(t);return{id:e,code:o,mask:s,name:new Intl.DisplayNames(["en"],{type:"region"}).of(e)??"",flag:n(e)}}),g=n;export{r as Masks,s as MasksBase,o as MasksBaseMap,MasksFull,i as MasksFullEn,MasksFullMap,m as MasksFullMapEn,a as MasksMap,c as MasksWithFlag,d as MasksWithFlagMap,g as getFlagEmoji};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Masks as r,MasksBase as o,MasksBaseMap as t,MasksFull as i,MasksFullEn as m,MasksFullMap as s,MasksFullMapEn as e,MasksMap as p,MasksWithFlag as f,MasksWithFlagMap as j,getFlagEmoji as l}from"./entries.js";import{countPlaceholders as n,formatDigitsWithMap as u,pickMaskVariant as x,removeCountryCodePrefix as a,toArray as b}from"./utils.js";export{r as Masks,o as MasksBase,t as MasksBaseMap,i as MasksFull,m as MasksFullEn,s as MasksFullMap,e as MasksFullMapEn,p as MasksMap,f as MasksWithFlag,j as MasksWithFlagMap,n as countPlaceholders,u as formatDigitsWithMap,l as getFlagEmoji,x as pickMaskVariant,a as removeCountryCodePrefix,b as toArray};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function toArray(t){return Array.isArray(t)?t:[t]}function countPlaceholders(t){return(t.match(/#/g)||[]).length}function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")}function pickMaskVariant(t,n){if(1===t.length)return t[0];const r=t.map(t=>({mask:t,count:countPlaceholders(t)})),e=r.filter(t=>t.count>=n).sort((t,n)=>t.count-n.count);if(e.length>0)return e[0].mask;const o=r.sort((t,n)=>n.count-t.count)[0];return o?o.mask:t[0]}function formatDigitsWithMap(t,n){let r="";const e=[];let o=0;const c=n.length,a=t.length;for(let i=0;i<a;i++){const a=t[i];if("#"===a){if(!(o<c))break;r+=n[o],e.push(o),o++}else{const n=-1!==t.indexOf("#",i+1)&&o<c;(r.length>0||n)&&(r+=a,e.push(-1))}}return{display:r,map:e}}export{countPlaceholders,formatDigitsWithMap,pickMaskVariant,removeCountryCodePrefix,toArray};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const data={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 ####-#####","+212 ###-######","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 ###-######","+212 ##-#######","+212 ####-#####"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},CC_REGEX=/^[a-z]{2}$/i,countryCodeEmoji=t=>{if(!CC_REGEX.test(t)){const e=typeof t;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===e?t:e}' instead.`)}const e=[...t.toUpperCase()].map(t=>(t.codePointAt(0)??0)+127397);return String.fromCodePoint(...e)},dataEntries=Object.entries(data),divideMask=t=>t.split(/ (.*)/s);function getCodeAndMask(t){let e="",s="";if(Array.isArray(t)){const a=[];for(const s of t){const[t,o]=divideMask(s);e||(e=t),a.push(o)}s=a}else{const[a,o]=divideMask(t);e=a,s=o}return[e,s]}const MasksBaseMap=data,MasksBase=dataEntries.map(([t,e])=>({id:t,mask:e})),MasksMap=dataEntries.reduce((t,[e,s])=>{const[a,o]=getCodeAndMask(s);return t[e]={code:a,mask:o},t},{}),Masks=dataEntries.map(([t,e])=>{const[s,a]=getCodeAndMask(e);return{id:t,code:s,mask:a}}),MasksWithFlagMap=dataEntries.reduce((t,[e,s])=>{const[a,o]=getCodeAndMask(s);return t[e]={code:a,mask:o,flag:countryCodeEmoji(e)},t},{}),MasksWithFlag=dataEntries.map(([t,e])=>{const[s,a]=getCodeAndMask(e);return{id:t,code:s,mask:a,flag:countryCodeEmoji(t)}}),MasksFullMapEn=dataEntries.reduce((t,[e,s])=>{const[a,o]=getCodeAndMask(s),n=new Intl.DisplayNames(["en"],{type:"region"});return t[e]={code:a,mask:o,name:n.of(e)??"",flag:countryCodeEmoji(e)},t},{}),MasksFullEn=dataEntries.map(([t,e])=>{const[s,a]=getCodeAndMask(e);return{id:t,code:s,mask:a,name:new Intl.DisplayNames(["en"],{type:"region"}).of(t)??"",flag:countryCodeEmoji(t)}}),getFlagEmoji=countryCodeEmoji;function countPlaceholders(t){return(t.match(/#/g)||[]).length}exports.Masks=Masks,exports.MasksBase=MasksBase,exports.MasksBaseMap=MasksBaseMap,exports.MasksFull=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return dataEntries.map(([t,s])=>{const[a,o]=getCodeAndMask(s);return{id:t,code:a,mask:o,name:e.of(t)??"",flag:countryCodeEmoji(t)}})},exports.MasksFullEn=MasksFullEn,exports.MasksFullMap=t=>{const e=new Intl.DisplayNames([t],{type:"region"});return dataEntries.reduce((t,[s,a])=>{const[o,n]=getCodeAndMask(a),r=e.of(s)??"";return t[s]={code:o,mask:n,name:r,flag:countryCodeEmoji(s)},t},{})},exports.MasksFullMapEn=MasksFullMapEn,exports.MasksMap=MasksMap,exports.MasksWithFlag=MasksWithFlag,exports.MasksWithFlagMap=MasksWithFlagMap,exports.countPlaceholders=countPlaceholders,exports.formatDigitsWithMap=function formatDigitsWithMap(t,e){let s="";const a=[];let o=0;const n=e.length,r=t.length;for(let M=0;M<r;M++){const r=t[M];if("#"===r){if(!(o<n))break;s+=e[o],a.push(o),o++}else{const e=-1!==t.indexOf("#",M+1)&&o<n;(s.length>0||e)&&(s+=r,a.push(-1))}}return{display:s,map:a}},exports.getFlagEmoji=getFlagEmoji,exports.pickMaskVariant=function pickMaskVariant(t,e){if(1===t.length)return t[0];const s=t.map(t=>({mask:t,count:countPlaceholders(t)})),a=s.filter(t=>t.count>=e).sort((t,e)=>t.count-e.count);if(a.length>0)return a[0].mask;const o=s.sort((t,e)=>e.count-t.count)[0];return o?o.mask:t[0]},exports.removeCountryCodePrefix=function removeCountryCodePrefix(t){return t.replace(/^\+\d+\s?/,"")},exports.toArray=function toArray(t){return Array.isArray(t)?t:[t]};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).phoneMask={})}(this,function(e){"use strict";const t={AC:"+247 #####",AD:["+376 ### ###","+376 #### ####"],AE:["+971 # ### ####","+971 ## ### ####","+971 ### ######","+971 ### # #####"],AF:"+93 ## ### ####",AG:"+1 ###-###-####",AI:"+1 ###-###-####",AL:["+355 ## ### ###","+355 ## ### ####","+355 ### ####","+355 ### ###","+355 ### #####"],AM:["+374 ## ######","+374 ### ## ###"],AO:"+244 ### ### ###",AR:["+54 ## ####-####","+54 # ## ####-####","+54 ###-###-####"],AS:"+1 ###-###-####",AT:["+43 # #########","+43 ### ######"],AU:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###","+61 ## ### ##"],AW:"+297 ### ####",AX:["+358 ## #######","+358 ### ######"],AZ:["+994 ## ### ## ##","+994 ### ## ## ##"],BA:["+387 ## ###-###","+387 ## ### ###"],BB:"+1 ###-###-####",BD:["+880 #-#######","+880 ####-######","+880 ###-#######"],BE:["+32 ## ## ## ##","+32 ### ## ## ##","+32 ### ## ###"],BF:"+226 ## ## ## ##",BG:["+359 # ### ###","+359 ## ### ###","+359 ### ## ###"],BH:"+973 #### ####",BI:"+257 ## ## ## ##",BJ:["+229 ## ## ## ## ##","+229 ## ## ## ##"],BL:"+590 ### ## ## ##",BM:"+1 ###-###-####",BN:"+673 ### ####",BO:["+591 # #######","+591 ########","+591 ### ## ####"],BQ:"+599 ### ####",BR:["+55 ## ####-####","+55 ## #####-####","+55 ### ## ####","+55 ####-####"],BS:"+1 ###-###-####",BT:["+975 # ### ###","+975 ## ## ## ##"],BW:["+267 ### ####","+267 ## ### ###","+267 #### ### ###","+267 ## #####"],BY:["+375 ### ##-##-##","+375 ## ###-##-##","+375 ### ### ####"],BZ:["+501 ###-####","+501 #-###-####-###"],CA:"+1 ###-###-####",CC:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CD:["+243 ## #####","+243 ### ### ###"],CF:"+236 ## ## ## ##",CG:["+242 ## ### ####","+242 # #### ####"],CH:["+41 ## ### ## ##","+41 ### ### ###"],CI:["+225 ## ## # #####","+225 ## ## ## ####"],CK:"+682 ## ###",CL:["+56 ### ### ###","+56 # #### ####","+56 ### ### ####","+56 ## ### ####"],CM:["+237 # ## ## ## ##","+237 ## ## ## ##"],CN:["+86 ## #### ####","+86 ### #### ####","+86 ### ### ####","+86 ########"],CO:["+57 ### #######","+57 # ### #######"],CR:["+506 #### ####","+506 ###-###-####"],CU:["+53 # #######","+53 ### #######"],CV:"+238 ### ## ##",CW:["+599 # ### ####","+599 ### ####"],CX:["+61 # #### ####","+61 ### ### ###","+61 #### ### ###"],CY:"+357 ## ######",CZ:"+420 ### ### ###",DE:["+49 ## ######","+49 #### #######","+49 ### ##########","+49 ### # ######","+49 ### # ####","+49 ### #### ####","+49 ########"],DJ:"+253 ## ## ## ##",DK:"+45 ## ## ## ##",DM:"+1 ###-###-####",DO:"+1 ###-###-####",DZ:["+213 ## ## ## ##","+213 ### ## ## ##","+213 ## ### ## ##"],EC:["+593 #-###-####","+593 ## ### ####","+593 #### ### ####"],EE:["+372 ### ####","+372 #### ####","+372 ## ## ####"],EG:["+20 # ########","+20 ## ########","+20 ### ### ####"],EH:["+212 ####-#####","+212 ###-######","+212 ##-#######"],ER:"+291 # ### ###",ES:["+34 ### ## ## ##","+34 ### ### ###"],ET:"+251 ## ### ####",FI:["+358 ## #######","+358 ### ######"],FJ:["+679 ### ####","+679 #### ### ####"],FK:"+500 #####",FM:"+691 ### ####",FO:"+298 ######",FR:["+33 # ## ## ## ##","+33 ### ## ## ##"],GA:"+241 ## ## ## ##",GB:["+44 ### ### ####","+44 #### ######","+44 ## #### ####"],GD:"+1 ###-###-####",GE:["+995 ## ### ## ##","+995 ### ## ## ##","+995 ### ### ###"],GF:"+594 ### ## ## ##",GG:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],GH:["+233 ## ### ####","+233 ### #####"],GI:["+350 ### #####","+350 ########"],GL:"+299 ## ## ##",GM:"+220 ### ####",GN:["+224 ## ## ## ##","+224 ### ## ## ##"],GP:"+590 ### ## ## ##",GQ:["+240 ### ### ###","+240 ### ######"],GR:["+30 ## #### ####","+30 ### ### ####"],GT:["+502 #### ####","+502 #### ### ####"],GU:"+1 ###-###-####",GW:["+245 ### ### ###","+245 ### ####"],GY:"+592 ### ####",HK:["+852 #### ####","+852 ### ### ###","+852 ### ## ### ###"],HN:["+504 ####-####","+504 ###########"],HR:["+385 # #### ###","+385 ## ### ####","+385 ### ### ###","+385 ## ## ###","+385 ## ### ###"],HT:"+509 ## ## ####",HU:["+36 # ### ####","+36 ## ### ####","+36 ## ### ###"],ID:["+62 ## #######","+62 ###-###-###","+62 ### #######","+62 ### # ### ###","+62 ### ### ####"],IE:["+353 ## #####","+353 ## ### ####","+353 #### ### ###","+353 ### ### ###"],IL:["+972 #-###-####","+972 ##-###-####","+972 #-###-###-###"],IM:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],IN:["+91 ##### #####","+91 #### ## ####","+91 #### ### ### ###","+91 #### ### ####"],IO:"+246 ### ####",IQ:["+964 # ### ####","+964 ### ### ####"],IR:["+98 ## #### ####","+98 ### ### ####"],IS:"+354 ### ####",IT:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],JE:["+44 #### ######","+44 ### ### ####","+44 ## #### ####"],JM:"+1 ###-###-####",JO:["+962 # ### ####","+962 # #### ####","+962 ### #####","+962 ## #######"],JP:["+81 #-####-####","+81 ##-####-####","+81 ###-###-###","+81 ##-###-####"],KE:["+254 ## #######","+254 ### ######","+254 ### ### ###"],KG:["+996 ### ### ###","+996 ### ### # ##"],KH:["+855 ## ### ###","+855 #### ### ###"],KI:["+686 #####","+686 ########"],KM:"+269 ### ## ##",KN:"+1 ###-###-####",KP:["+850 # ### ####","+850 ### ### ####"],KR:["+82 #-###-####","+82 ##-####-####","+82 ##-###-####"],KW:["+965 #### ####","+965 ### #####","+965 #### ###"],KY:"+1 ###-###-####",KZ:["+7 ##### # ## ##","+7 ### ### ####","+7 ### ###-##-##"],LA:["+856 ## ### ###","+856 ## ## ### ###"],LB:["+961 # ### ###","+961 ## ### ###"],LC:"+1 ###-###-####",LI:["+423 ### ## ##","+423 ### ### ###"],LK:["+94 ### ### ###","+94 ## ### ####"],LR:["+231 ## ### ###","+231 ## ### ####"],LS:"+266 #### ####",LT:["+370 ### #####","+370 ### ## ###"],LU:["+352 ## ## ## ##","+352 ### ### ###","+352 ### ## ###"],LV:"+371 ## ### ###",LY:"+218 ##-#######",MA:["+212 ###-######","+212 ##-#######","+212 ####-#####"],MC:["+377 ## ## ## ##","+377 # ## ## ## ##"],MD:["+373 ## ### ###","+373 ### ## ###","+373 ### #####"],ME:"+382 ## ### ###",MF:"+590 ### ## ## ##",MG:"+261 ## ## ### ##",MH:"+692 ###-####",MK:["+389 # ### ####","+389 ## ### ###","+389 ### # ## ##"],ML:"+223 ## ## ## ##",MM:["+95 # ### ###","+95 # ### ####","+95 ### ### ####"],MN:"+976 #### ####",MO:["+853 #### ####","+853 #### ###"],MP:"+1 ###-###-####",MQ:"+596 ### ## ## ##",MR:"+222 ## ## ## ##",MS:"+1 ###-###-####",MT:"+356 #### ####",MU:["+230 #### ####","+230 ### ####"],MV:["+960 ###-####","+960 ### ### ####"],MW:["+265 # ### ###","+265 ### ## ## ##"],MX:"+52 ### ### ####",MY:["+60 #-#### ####","+60 ##-### ####","+60 #-###-##-####","+60 ###-### ####"],MZ:["+258 ## ### ###","+258 ## ### ####","+258 ### ### ###"],NA:["+264 ## ### ###","+264 ## ### ####","+264 ### ### ###"],NC:"+687 ##.##.##",NE:["+227 ## ## ## ##","+227 ## ### ###"],NF:["+672 ## ####","+672 # #####"],NG:["+234 #### ## ####","+234 ### ### ####","+234 ### #### ####"],NI:"+505 #### ####",NL:["+31 ## ### ####","+31 # ########","+31 ### ####","+31 ## #######"],NO:["+47 ## ## ## ##","+47 ### ## ###"],NP:["+977 #-#######","+977 ###-#######","+977 ###########"],NR:"+674 ### ####",NU:["+683 ####","+683 ### ####"],NZ:["+64 # ### ####","+64 ## ### ####","+64 ### ### ###"],OM:["+968 ## ######","+968 #### ####","+968 ### #####"],PA:["+507 ###-####","+507 ####-####"],PE:["+51 # #######","+51 ### ### ###","+51 ### #####"],PF:["+689 ## ## ## ##","+689 ### ## ## ##"],PG:["+675 ### ####","+675 #### ####"],PH:["+63 # #### ####","+63 ### ### ####","+63 #### # ### ####"],PK:["+92 ## ########","+92 ### #######","+92 ### ### ##","+92 #### #####"],PL:["+48 ## ### ## ##","+48 ### ### ###"],PM:["+508 ## ## ##","+508 ### ## ## ##"],PR:"+1 ###-###-####",PS:["+970 # ### ####","+970 ### ### ###","+970 #### ### ###"],PT:["+351 ## ### ####","+351 ### ### ###"],PW:"+680 ### ####",PY:["+595 ## ### ####","+595 ### ######","+595 #### ### ####"],QA:["+974 #### ####","+974 ### ####"],RE:"+262 ### ## ## ##",RO:["+40 ## ### ####","+40 ### ### ###"],RS:["+381 ## ######","+381 ## #######","+381 ### #####"],RU:"+7 ### ###-##-##",RW:"+250 ### ### ###",SA:["+966 ## ### ####","+966 ### ### ####","+966 #### #####"],SB:["+677 #####","+677 ## #####"],SC:["+248 # ### ###","+248 #######"],SD:"+249 ## ### ####",SE:["+46 # ## ## ##","+46 ## ### ## ##","+46 ## ## ## ##","+46 ### ## ## ###"],SG:["+65 #### ####","+65 #### ### ####"],SH:"+290 #####",SI:["+386 # ### ## ##","+386 ## ### ###","+386 ## ######","+386 ### #####"],SJ:["+47 ## ## ## ##","+47 ### ## ###"],SK:["+421 #/### ### ##","+421 ### ### ###","+421 #######"],SL:"+232 ## ######",SM:["+378 #### ######","+378 ## ## ## ##"],SN:["+221 ## ### ## ##","+221 ### ## ## ##"],SO:["+252 # ######","+252 # #######"],SR:["+597 ###-###","+597 ###-####","+597 ##-##-##"],SS:"+211 ### ### ###",ST:"+239 ### ####",SV:["+503 #### ####","+503 ### ####"],SX:"+1 ###-###-####",SY:["+963 ## ### ####","+963 ### ### ###"],SZ:["+268 #### ####","+268 ##### ####"],TA:"+290 ####",TC:"+1 ###-###-####",TD:"+235 ## ## ## ##",TG:"+228 ## ## ## ##",TH:["+66 # ### ####","+66 ## ### ####","+66 #### ### ###"],TJ:["+992 ### ## ####","+992 ## ### ####"],TK:"+690 ####",TL:["+670 ### ####","+670 #### ####"],TM:["+993 ## ##-##-##","+993 ## ######"],TN:"+216 ## ### ###",TO:["+676 ##-###","+676 ### ####","+676 #### ###"],TR:["+90 ### ### ## ##","+90 ### ### ####"],TT:"+1 ###-###-####",TV:["+688 ## ###","+688 ## ####"],TW:["+886 # #### ####","+886 ### ### ###","+886 ## ### ####","+886 ## #### ####"],TZ:["+255 ## ### ####","+255 ### ### ###","+255 ### ## ####"],UA:["+380 #### #####","+380 ## ### ####","+380 ### ### ###"],UG:["+256 ## #######","+256 ### ######"],US:"+1 ###-###-####",UY:["+598 #### ####","+598 ## ### ###","+598 ### ####"],UZ:"+998 ## ### ## ##",VA:["+39 ## #### ####","+39 ### ### ####","+39 ### ### ###"],VC:"+1 ###-###-####",VE:"+58 ###-#######",VG:"+1 ###-###-####",VI:"+1 ###-###-####",VN:["+84 ### #### ###","+84 ### ### ###","+84 #### ######","+84 ## ### ## ##"],VU:["+678 #####","+678 ### ####"],WF:["+681 ## ## ##","+681 ### ## ## ##"],WS:["+685 #####","+685 ## #####","+685 ### ###"],XK:["+383 ## ### ###","+383 ### #####"],YE:["+967 # ### ###","+967 ### ### ###"],YT:"+262 ### ## ## ##",ZA:["+27 ## ### ####","+27 ### ### ###"],ZM:["+260 ### ### ###","+260 ## #######","+260 #########"],ZW:["+263 ## #####","+263 ## ### ####","+263 ### ####","+263 #### ######"]},n=/^[a-z]{2}$/i,s=e=>{if(!n.test(e)){const t=typeof e;throw new TypeError(`cc argument must be an ISO 3166-1 alpha-2 string, but got '${"string"===t?e:t}' instead.`)}const t=[...e.toUpperCase()].map(e=>(e.codePointAt(0)??0)+127397);return String.fromCodePoint(...t)},o=Object.entries(t),r=e=>e.split(/ (.*)/s);function a(e){let t="",n="";if(Array.isArray(e)){const s=[];for(const n of e){const[e,o]=r(n);t||(t=e),s.push(o)}n=s}else{const[s,o]=r(e);t=s,n=o}return[t,n]}const c=t,i=o.map(([e,t])=>({id:e,mask:t})),M=o.reduce((e,[t,n])=>{const[s,o]=a(n);return e[t]={code:s,mask:o},e},{}),u=o.map(([e,t])=>{const[n,s]=a(t);return{id:e,code:n,mask:s}}),l=o.reduce((e,[t,n])=>{const[o,r]=a(n);return e[t]={code:o,mask:r,flag:s(t)},e},{}),f=o.map(([e,t])=>{const[n,o]=a(t);return{id:e,code:n,mask:o,flag:s(e)}}),p=o.reduce((e,[t,n])=>{const[o,r]=a(n),c=new Intl.DisplayNames(["en"],{type:"region"});return e[t]={code:o,mask:r,name:c.of(t)??"",flag:s(t)},e},{}),m=o.map(([e,t])=>{const[n,o]=a(t);return{id:e,code:n,mask:o,name:new Intl.DisplayNames(["en"],{type:"region"}).of(e)??"",flag:s(e)}}),d=s;function S(e){return(e.match(/#/g)||[]).length}e.Masks=u,e.MasksBase=i,e.MasksBaseMap=c,e.MasksFull=e=>{const t=new Intl.DisplayNames([e],{type:"region"});return o.map(([e,n])=>{const[o,r]=a(n);return{id:e,code:o,mask:r,name:t.of(e)??"",flag:s(e)}})},e.MasksFullEn=m,e.MasksFullMap=e=>{const t=new Intl.DisplayNames([e],{type:"region"});return o.reduce((e,[n,o])=>{const[r,c]=a(o),i=t.of(n)??"";return e[n]={code:r,mask:c,name:i,flag:s(n)},e},{})},e.MasksFullMapEn=p,e.MasksMap=M,e.MasksWithFlag=f,e.MasksWithFlagMap=l,e.countPlaceholders=S,e.formatDigitsWithMap=function(e,t){let n="";const s=[];let o=0;const r=t.length,a=e.length;for(let c=0;c<a;c++){const a=e[c];if("#"===a){if(!(o<r))break;n+=t[o],s.push(o),o++}else{const t=-1!==e.indexOf("#",c+1)&&o<r;(n.length>0||t)&&(n+=a,s.push(-1))}}return{display:n,map:s}},e.getFlagEmoji=d,e.pickMaskVariant=function(e,t){if(1===e.length)return e[0];const n=e.map(e=>({mask:e,count:S(e)})),s=n.filter(e=>e.count>=t).sort((e,t)=>e.count-t.count);if(s.length>0)return s[0].mask;const o=n.sort((e,t)=>t.count-e.count)[0];return o?o.mask:e[0]},e.removeCountryCodePrefix=function(e){return e.replace(/^\+\d+\s?/,"")},e.toArray=function(e){return Array.isArray(e)?e:[e]},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-code-emodji.d.ts","sourceRoot":"","sources":["../../src/country-code-emodji.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,MAU7C,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type CountryKey = 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
|
|
2
|
+
//# sourceMappingURL=data-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../../src/data-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CountryKey } from './data-types';
|
|
2
|
+
interface MaskBase {
|
|
3
|
+
id: CountryKey;
|
|
4
|
+
mask: string | Array<string>;
|
|
5
|
+
}
|
|
6
|
+
interface Mask extends MaskBase {
|
|
7
|
+
code: string;
|
|
8
|
+
}
|
|
9
|
+
interface MaskWithFlag extends Mask {
|
|
10
|
+
flag: string;
|
|
11
|
+
}
|
|
12
|
+
interface MaskFull extends MaskWithFlag {
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
type MaskBaseMap = Record<CountryKey, string | Array<string>>;
|
|
16
|
+
type MaskMap = Record<CountryKey, Omit<Mask, 'id'>>;
|
|
17
|
+
type MaskWithFlagMap = Record<CountryKey, Omit<MaskWithFlag, 'id'>>;
|
|
18
|
+
type MaskFullMap = Record<CountryKey, Omit<MaskFull, 'id'>>;
|
|
19
|
+
/**
|
|
20
|
+
* Base masks (including country code) map
|
|
21
|
+
* @example
|
|
22
|
+
* MasksBaseMap.US // "+1 ###-###-####"
|
|
23
|
+
*/
|
|
24
|
+
export declare const MasksBaseMap: MaskBaseMap;
|
|
25
|
+
/** Base masks (including country code) array
|
|
26
|
+
* @example
|
|
27
|
+
* MasksBase[0] // { id: 'US', mask: "+1 ###-###-####" }
|
|
28
|
+
*/
|
|
29
|
+
export declare const MasksBase: MaskBase[];
|
|
30
|
+
/**
|
|
31
|
+
* Masks map with country code as separate property
|
|
32
|
+
* @example
|
|
33
|
+
* MasksMap.US // { code: "+1", mask: "###-###-####" }
|
|
34
|
+
*/
|
|
35
|
+
export declare const MasksMap: MaskMap;
|
|
36
|
+
/**
|
|
37
|
+
* Masks array with country code as separate property
|
|
38
|
+
* @example
|
|
39
|
+
* Masks[0] // { id: 'US', code: "+1", mask: "###-###-####" }
|
|
40
|
+
*/
|
|
41
|
+
export declare const Masks: Mask[];
|
|
42
|
+
/**
|
|
43
|
+
* Masks map with flag emoji
|
|
44
|
+
* @example
|
|
45
|
+
* MasksWithFlagMap.US // { code: "+1", mask: "###-###-####", flag: "πΊπΈ" }
|
|
46
|
+
*/
|
|
47
|
+
export declare const MasksWithFlagMap: MaskWithFlagMap;
|
|
48
|
+
/**
|
|
49
|
+
* Masks array with flag emoji
|
|
50
|
+
* @example
|
|
51
|
+
* MasksWithFlag[0] // { id: 'US', code: "+1", mask: "###-###-####", flag: "πΊπΈ" }
|
|
52
|
+
*/
|
|
53
|
+
export declare const MasksWithFlag: MaskWithFlag[];
|
|
54
|
+
/**
|
|
55
|
+
* Full masks map with name and flag emoji. Name is localized based on provided language.
|
|
56
|
+
* @example
|
|
57
|
+
* MasksFullMap.US // { code: "+1", mask: "###-###-####", name: "United States", flag: "πΊπΈ" }
|
|
58
|
+
*/
|
|
59
|
+
export declare const MasksFullMap: (lang: string) => MaskFullMap;
|
|
60
|
+
/**
|
|
61
|
+
* Full masks array with name and flag emoji. Name is localized based on provided language.
|
|
62
|
+
* @example
|
|
63
|
+
* MasksFull[0] // { id: 'US', code: "+1", mask: "###-###-####", name: "United States", flag: "πΊπΈ" }
|
|
64
|
+
*/
|
|
65
|
+
export declare const MasksFull: (lang: string) => MaskFull[];
|
|
66
|
+
/**
|
|
67
|
+
* Full masks map with name and flag emoji in English
|
|
68
|
+
* @example
|
|
69
|
+
* MasksFullMapEn.US // { code: "+1", mask: "###-###-####", name: "United States", flag: "πΊπΈ" }
|
|
70
|
+
*/
|
|
71
|
+
export declare const MasksFullMapEn: MaskFullMap;
|
|
72
|
+
/**
|
|
73
|
+
* Full masks array with name and flag emoji in English
|
|
74
|
+
* @example
|
|
75
|
+
* MasksFullEn[0] // { id: 'US', code: "+1", mask: "###-###-####", name: "United States", flag: "πΊπΈ" }
|
|
76
|
+
*/
|
|
77
|
+
export declare const MasksFullEn: MaskFull[];
|
|
78
|
+
/** Get flag emoji by country ISO code */
|
|
79
|
+
export declare const getFlagEmoji: (cc: string) => string;
|
|
80
|
+
export type { CountryKey, MaskBaseMap, MaskBase, MaskMap, Mask, MaskWithFlagMap, MaskWithFlag, MaskFullMap, MaskFull };
|
|
81
|
+
//# sourceMappingURL=entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,QAAQ;IAChB,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;CAC9B;AACD,UAAU,IAAK,SAAQ,QAAQ;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,YAAa,SAAQ,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,QAAS,SAAQ,YAAY;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9D,KAAK,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACpD,KAAK,eAAe,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACpE,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;AAsB5D;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,WAAkB,CAAC;AAC9C;;;GAGG;AACH,eAAO,MAAM,SAAS,YAA4D,CAAC;AACnF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,SAIJ,CAAC;AAClB;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAGhB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,iBAIJ,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,aAAa,gBAGxB,CAAC;AACH;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,gBAQxC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,eAYrC,CAAC;AACF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAKN,CAAC;AACtB;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAUtB,CAAC;AACH,yCAAyC;AACzC,eAAO,MAAM,YAAY,wBAAmB,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type FormatResult = {
|
|
2
|
+
display: string;
|
|
3
|
+
map: number[];
|
|
4
|
+
};
|
|
5
|
+
/** Ensure mask is an array of strings */
|
|
6
|
+
export declare function toArray<T>(mask: T | T[]): T[];
|
|
7
|
+
/** Count number of placeholders (#) in a mask string */
|
|
8
|
+
export declare function countPlaceholders(maskStr: string): number;
|
|
9
|
+
/** Remove country code prefix (e.g., +1 ) from a mask string */
|
|
10
|
+
export declare function removeCountryCodePrefix(maskStr: string): string;
|
|
11
|
+
/** Pick the most suitable mask variant based on typed digits count */
|
|
12
|
+
export declare function pickMaskVariant(variants: string[], typedDigitsCount: number): string;
|
|
13
|
+
/** Formatting with mapping for efficient position tracking */
|
|
14
|
+
export declare function formatDigitsWithMap(maskTemplate: string, digitStr: string): FormatResult;
|
|
15
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,yCAAyC;AACzC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAE7C;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,gEAAgE;AAChE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAgBpF;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAgCxF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@desource/phone-mask",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "β‘ Ultra-lightweight international phone number formatter & validator with auto-sync to Google libphonenumber. Framework-agnostic core library.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"phone",
|
|
7
|
+
"mask",
|
|
8
|
+
"international",
|
|
9
|
+
"libphonenumber",
|
|
10
|
+
"google",
|
|
11
|
+
"phone-number",
|
|
12
|
+
"formatting",
|
|
13
|
+
"validation",
|
|
14
|
+
"country-code",
|
|
15
|
+
"intl",
|
|
16
|
+
"input",
|
|
17
|
+
"typescript",
|
|
18
|
+
"tree-shakeable"
|
|
19
|
+
],
|
|
20
|
+
"author": "Stefan Popov <stefan@desource-labs.org>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/DeSource-Labs/phone-mask.git",
|
|
25
|
+
"directory": "packages/phone-mask"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/DeSource-Labs/phone-mask/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/DeSource-Labs/phone-mask/tree/main/packages/phone-mask#readme",
|
|
31
|
+
"private": false,
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"main": "dist/phone-mask.cjs.js",
|
|
36
|
+
"module": "dist/esm/index.js",
|
|
37
|
+
"types": "dist/types/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"CHANGELOG.md",
|
|
41
|
+
"README.md"
|
|
42
|
+
],
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/types/index.d.ts",
|
|
47
|
+
"import": "./dist/esm/index.js",
|
|
48
|
+
"require": "./dist/phone-mask.cjs.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"google-libphonenumber": "^3.2.43",
|
|
53
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
54
|
+
"vite-plugin-dts": "^4.5.4"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"clean": "rimraf dist",
|
|
58
|
+
"build": "vite build",
|
|
59
|
+
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
|
|
60
|
+
"dev": "vite",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
62
|
+
"gen": "pnpm add -D google-libphonenumber@latest && node scripts/gen.js"
|
|
63
|
+
}
|
|
64
|
+
}
|