@superdispatch/phones 0.21.6 → 0.21.13
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/.babelrc.js +5 -0
- package/.turbo/turbo-version.log +26 -0
- package/package.json +60 -34
- package/pkg/README.md +10 -0
- package/{dist-types → pkg/dist-types}/index.d.ts +82 -82
- package/pkg/package.json +34 -0
- package/playroom.ts +3 -0
- package/src/__tests__/index.spec.ts +23 -0
- package/src/apn/APN.ts +40 -0
- package/src/country-code-metadata/CountryCodeMetadata.spec.ts +1291 -0
- package/src/country-code-metadata/CountryCodeMetadata.ts +281 -0
- package/src/formatted-phone-number/FormattedPhoneNumber.ts +20 -0
- package/src/index.ts +6 -0
- package/src/phone-field/PhoneField.playroom.tsx +28 -0
- package/src/phone-field/PhoneField.spec.tsx +171 -0
- package/src/phone-field/PhoneField.stories.tsx +6 -0
- package/src/phone-field/PhoneField.tsx +200 -0
- package/src/phone-field/PhoneFieldFlag.tsx +54 -0
- package/src/phone-field/PhoneFieldMenu.tsx +53 -0
- package/src/phone-field/PhoneFieldMenuItem.spec.tsx +12 -0
- package/src/phone-field/PhoneFieldMenuItem.tsx +61 -0
- package/src/phone-field/PhoneFieldStartAdornment.tsx +68 -0
- package/src/phone-link/PhoneLink.spec.tsx +60 -0
- package/src/phone-link/PhoneLink.stories.tsx +9 -0
- package/src/phone-link/PhoneLink.tsx +59 -0
- package/src/phone-service/PhoneService.spec.ts +277 -0
- package/src/phone-service/PhoneService.ts +287 -0
- package/src/phone-text/PhoneText.spec.tsx +65 -0
- package/src/phone-text/PhoneText.stories.tsx +9 -0
- package/src/phone-text/PhoneText.tsx +38 -0
- package/tsconfig.json +19 -0
- package/LICENSE +0 -21
- /package/{dist-node → pkg/dist-node}/index.js +0 -0
- /package/{dist-node → pkg/dist-node}/index.js.map +0 -0
- /package/{dist-src → pkg/dist-src}/apn/APN.js +0 -0
- /package/{dist-src → pkg/dist-src}/country-code-metadata/CountryCodeMetadata.js +0 -0
- /package/{dist-src → pkg/dist-src}/formatted-phone-number/FormattedPhoneNumber.js +0 -0
- /package/{dist-src → pkg/dist-src}/index.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-field/PhoneField.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-field/PhoneFieldFlag.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-field/PhoneFieldMenu.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-field/PhoneFieldMenuItem.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-field/PhoneFieldStartAdornment.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-link/PhoneLink.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-service/PhoneService.js +0 -0
- /package/{dist-src → pkg/dist-src}/phone-text/PhoneText.js +0 -0
- /package/{dist-web → pkg/dist-web}/index.js +0 -0
- /package/{dist-web → pkg/dist-web}/index.js.map +0 -0
package/.babelrc.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[34m@superdispatch/phones:version[0m: cache hit, replaying output [2mfd40332366d2d744[0m
|
|
2
|
+
[34m@superdispatch/phones:version: [0m$ pika build
|
|
3
|
+
[34m@superdispatch/phones:version: [0m@pika/pack v0.5.0
|
|
4
|
+
[34m@superdispatch/phones:version: [0m[1/8] Validating source...
|
|
5
|
+
[34m@superdispatch/phones:version: [0m[2/8] Preparing pipeline...
|
|
6
|
+
[34m@superdispatch/phones:version: [0m ❇️ pkg/
|
|
7
|
+
[34m@superdispatch/phones:version: [0m[3/8] Running @pika/plugin-standard-pkg...
|
|
8
|
+
[34m@superdispatch/phones:version: [0mBrowserslist: caniuse-lite is outdated. Please run:
|
|
9
|
+
[34m@superdispatch/phones:version: [0m npx browserslist@latest --update-db
|
|
10
|
+
[34m@superdispatch/phones:version: [0m Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
|
|
11
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/dist-src/index.js [esnext]
|
|
12
|
+
[34m@superdispatch/phones:version: [0m » Linting with standard-pkg...
|
|
13
|
+
[34m@superdispatch/phones:version: [0m[4/8] Running @pika/plugin-build-web...
|
|
14
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/dist-web/index.js [module]
|
|
15
|
+
[34m@superdispatch/phones:version: [0m[5/8] Running @pika/plugin-build-node...
|
|
16
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/dist-node/index.js [main]
|
|
17
|
+
[34m@superdispatch/phones:version: [0m[6/8] Running @pika/plugin-build-types...
|
|
18
|
+
[34m@superdispatch/phones:version: [0m » no manual type definitions found, auto-generating...
|
|
19
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/dist-types/index.d.ts [types]
|
|
20
|
+
[34m@superdispatch/phones:version: [0m[7/8] Running @pika/plugin-bundle-types...
|
|
21
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/dist-types/index.d.ts
|
|
22
|
+
[34m@superdispatch/phones:version: [0m[8/8] Finalizing package...
|
|
23
|
+
[34m@superdispatch/phones:version: [0m » copying README.md...
|
|
24
|
+
[34m@superdispatch/phones:version: [0m 📝 pkg/package.json
|
|
25
|
+
[34m@superdispatch/phones:version: [0m 📦 pkg/
|
|
26
|
+
[34m@superdispatch/phones:version: [0mDone in 8.46s.
|
package/package.json
CHANGED
|
@@ -1,34 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@superdispatch/phones",
|
|
3
|
-
"version": "0.21.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"@
|
|
23
|
-
"@material-ui/
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@superdispatch/phones",
|
|
3
|
+
"version": "0.21.13",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/superdispatch/ui.git"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"main": "src/index.ts",
|
|
10
|
+
"module": "src/index.ts",
|
|
11
|
+
"browser": "pkg/dist-web/index.js",
|
|
12
|
+
"types": "src/index.ts",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"version": "pika build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@superdispatch/ui": "^0.21.13",
|
|
18
|
+
"awesome-phonenumber": "^2.70.0",
|
|
19
|
+
"clsx": "^1.1.1"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@babel/runtime": "^7.0.0",
|
|
23
|
+
"@material-ui/core": "^4.7.2",
|
|
24
|
+
"@material-ui/icons": "^4.5.1",
|
|
25
|
+
"react": "^17.0.2"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"directory": "pkg"
|
|
30
|
+
},
|
|
31
|
+
"@pika/pack": {
|
|
32
|
+
"pipeline": [
|
|
33
|
+
[
|
|
34
|
+
"@pika/plugin-standard-pkg",
|
|
35
|
+
{
|
|
36
|
+
"exclude": [
|
|
37
|
+
"**/*.spec.*",
|
|
38
|
+
"**/*.stories.*",
|
|
39
|
+
"**/*.playroom.*",
|
|
40
|
+
"**/__tests__/**",
|
|
41
|
+
"**/__testutils__/**"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
"@pika/plugin-build-web"
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
"@pika/plugin-build-node"
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"@pika/plugin-build-types"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"@pika/plugin-bundle-types"
|
|
56
|
+
]
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "5ff0a851a8c24bab48a6fdb37e353eae62bd4a35"
|
|
60
|
+
}
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
### `@superdispatch/phones`
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@superdispatch/phones)
|
|
4
|
+
[](https://bundlephobia.com/result?p=@superdispatch/phones)
|
|
5
|
+
|
|
6
|
+
#### Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
yarn add @superdispatch/phones awesome-phonenumber @material-ui/core @material-ui/icons
|
|
10
|
+
```
|
|
@@ -2,100 +2,100 @@ import AwesomePhoneNumber from 'awesome-phonenumber';
|
|
|
2
2
|
import { ForwardRefExoticComponent, RefAttributes, ReactNode, ReactElement } from 'react';
|
|
3
3
|
import { BaseTextFieldProps, LinkProps } from '@material-ui/core';
|
|
4
4
|
|
|
5
|
-
declare const COUNTRY_CODE_METADATA: readonly [readonly ["US", 1, "United States"], readonly ["CA", 1, "Canada"], readonly ["AU", 61, "Australia"], readonly ["NZ", 64, "New Zealand"], readonly ["AC", 247, "Ascension Island"], readonly ["AD", 376, "Andorra"], readonly ["AE", 971, "United Arab Emirates"], readonly ["AF", 93, "Afghanistan"], readonly ["AG", 1, "Antigua and Barbuda"], readonly ["AI", 1, "Anguilla"], readonly ["AL", 355, "Albania"], readonly ["AM", 374, "Armenia"], readonly ["AO", 244, "Angola"], readonly ["AR", 54, "Argentina"], readonly ["AS", 1, "American Samoa"], readonly ["AT", 43, "Austria"], readonly ["AW", 297, "Aruba"], readonly ["AX", 358, "Åland Islands"], readonly ["AZ", 994, "Azerbaijan"], readonly ["BA", 387, "Bosnia and Herzegovina"], readonly ["BB", 1, "Barbados"], readonly ["BD", 880, "Bangladesh"], readonly ["BE", 32, "Belgium"], readonly ["BF", 226, "Burkina Faso"], readonly ["BG", 359, "Bulgaria"], readonly ["BH", 973, "Bahrain"], readonly ["BI", 257, "Burundi"], readonly ["BJ", 229, "Benin"], readonly ["BL", 590, "Saint Barthélemy"], readonly ["BM", 1, "Bermuda"], readonly ["BN", 673, "Brunei"], readonly ["BO", 591, "Bolivia"], readonly ["BQ", 599, "Caribbean Netherlands"], readonly ["BR", 55, "Brazil"], readonly ["BS", 1, "Bahamas"], readonly ["BT", 975, "Bhutan"], readonly ["BW", 267, "Botswana"], readonly ["BY", 375, "Belarus"], readonly ["BZ", 501, "Belize"], readonly ["CC", 61, "Cocos"], readonly ["CD", 243, "Congo"], readonly ["CF", 236, "Central African Republic"], readonly ["CG", 242, "Congo"], readonly ["CH", 41, "Switzerland"], readonly ["CI", 225, "Côte d’Ivoire"], readonly ["CK", 682, "Cook Islands"], readonly ["CL", 56, "Chile"], readonly ["CM", 237, "Cameroon"], readonly ["CN", 86, "China"], readonly ["CO", 57, "Colombia"], readonly ["CR", 506, "Costa Rica"], readonly ["CU", 53, "Cuba"], readonly ["CV", 238, "Cape Verde"], readonly ["CW", 599, "Curaçao"], readonly ["CX", 61, "Christmas Island"], readonly ["CY", 357, "Cyprus"], readonly ["CZ", 420, "Czech Republic"], readonly ["DE", 49, "Germany"], readonly ["DJ", 253, "Djibouti"], readonly ["DK", 45, "Denmark"], readonly ["DM", 1, "Dominica"], readonly ["DO", 1, "Dominican Republic"], readonly ["DZ", 213, "Algeria"], readonly ["EC", 593, "Ecuador"], readonly ["EE", 372, "Estonia"], readonly ["EG", 20, "Egypt"], readonly ["EH", 212, "Western Sahara"], readonly ["ER", 291, "Eritrea"], readonly ["ES", 34, "Spain"], readonly ["ET", 251, "Ethiopia"], readonly ["FI", 358, "Finland"], readonly ["FJ", 679, "Fiji"], readonly ["FK", 500, "Falkland Islands"], readonly ["FM", 691, "Micronesia"], readonly ["FO", 298, "Faroe Islands"], readonly ["FR", 33, "France"], readonly ["GA", 241, "Gabon"], readonly ["GB", 44, "United Kingdom"], readonly ["GD", 1, "Grenada"], readonly ["GE", 995, "Georgia"], readonly ["GF", 594, "French Guiana"], readonly ["GG", 44, "Guernsey"], readonly ["GH", 233, "Ghana"], readonly ["GI", 350, "Gibraltar"], readonly ["GL", 299, "Greenland"], readonly ["GM", 220, "Gambia"], readonly ["GN", 224, "Guinea"], readonly ["GP", 590, "Guadeloupe"], readonly ["GQ", 240, "Equatorial Guinea"], readonly ["GR", 30, "Greece"], readonly ["GT", 502, "Guatemala"], readonly ["GU", 1, "Guam"], readonly ["GW", 245, "Guinea-Bissau"], readonly ["GY", 592, "Guyana"], readonly ["HK", 852, "Hong Kong"], readonly ["HN", 504, "Honduras"], readonly ["HR", 385, "Croatia"], readonly ["HT", 509, "Haiti"], readonly ["HU", 36, "Hungary"], readonly ["ID", 62, "Indonesia"], readonly ["IE", 353, "Ireland"], readonly ["IL", 972, "Israel"], readonly ["IM", 44, "Isle of Man"], readonly ["IN", 91, "India"], readonly ["IO", 246, "British Indian Ocean Territory"], readonly ["IQ", 964, "Iraq"], readonly ["IR", 98, "Iran"], readonly ["IS", 354, "Iceland"], readonly ["IT", 39, "Italy"], readonly ["JE", 44, "Jersey"], readonly ["JM", 1, "Jamaica"], readonly ["JO", 962, "Jordan"], readonly ["JP", 81, "Japan"], readonly ["KE", 254, "Kenya"], readonly ["KG", 996, "Kyrgyzstan"], readonly ["KH", 855, "Cambodia"], readonly ["KI", 686, "Kiribati"], readonly ["KM", 269, "Comoros"], readonly ["KN", 1, "Saint Kitts and Nevis"], readonly ["KP", 850, "North Korea"], readonly ["KR", 82, "South Korea"], readonly ["KW", 965, "Kuwait"], readonly ["KY", 1, "Cayman Islands"], readonly ["KZ", 7, "Kazakhstan"], readonly ["LA", 856, "Laos"], readonly ["LB", 961, "Lebanon"], readonly ["LC", 1, "Saint Lucia"], readonly ["LI", 423, "Liechtenstein"], readonly ["LK", 94, "Sri Lanka"], readonly ["LR", 231, "Liberia"], readonly ["LS", 266, "Lesotho"], readonly ["LT", 370, "Lithuania"], readonly ["LU", 352, "Luxembourg"], readonly ["LV", 371, "Latvia"], readonly ["LY", 218, "Libya"], readonly ["MA", 212, "Morocco"], readonly ["MC", 377, "Monaco"], readonly ["MD", 373, "Moldova"], readonly ["ME", 382, "Montenegro"], readonly ["MF", 590, "Saint Martin"], readonly ["MG", 261, "Madagascar"], readonly ["MH", 692, "Marshall Islands"], readonly ["MK", 389, "Macedonia"], readonly ["ML", 223, "Mali"], readonly ["MM", 95, "Myanmar"], readonly ["MN", 976, "Mongolia"], readonly ["MO", 853, "Macau"], readonly ["MP", 1, "Northern Mariana Islands"], readonly ["MQ", 596, "Martinique"], readonly ["MR", 222, "Mauritania"], readonly ["MS", 1, "Montserrat"], readonly ["MT", 356, "Malta"], readonly ["MU", 230, "Mauritius"], readonly ["MV", 960, "Maldives"], readonly ["MW", 265, "Malawi"], readonly ["MX", 52, "Mexico"], readonly ["MY", 60, "Malaysia"], readonly ["MZ", 258, "Mozambique"], readonly ["NA", 264, "Namibia"], readonly ["NC", 687, "New Caledonia"], readonly ["NE", 227, "Niger"], readonly ["NF", 672, "Norfolk Island"], readonly ["NG", 234, "Nigeria"], readonly ["NI", 505, "Nicaragua"], readonly ["NL", 31, "Netherlands"], readonly ["NO", 47, "Norway"], readonly ["NP", 977, "Nepal"], readonly ["NR", 674, "Nauru"], readonly ["NU", 683, "Niue"], readonly ["OM", 968, "Oman"], readonly ["PA", 507, "Panama"], readonly ["PE", 51, "Peru"], readonly ["PF", 689, "French Polynesia"], readonly ["PG", 675, "Papua New Guinea"], readonly ["PH", 63, "Philippines"], readonly ["PK", 92, "Pakistan"], readonly ["PL", 48, "Poland"], readonly ["PM", 508, "Saint Pierre and Miquelon"], readonly ["PR", 1, "Puerto Rico"], readonly ["PS", 970, "Palestine"], readonly ["PT", 351, "Portugal"], readonly ["PW", 680, "Palau"], readonly ["PY", 595, "Paraguay"], readonly ["QA", 974, "Qatar"], readonly ["RE", 262, "Réunion"], readonly ["RO", 40, "Romania"], readonly ["RS", 381, "Serbia"], readonly ["RU", 7, "Russia"], readonly ["RW", 250, "Rwanda"], readonly ["SA", 966, "Saudi Arabia"], readonly ["SB", 677, "Solomon Islands"], readonly ["SC", 248, "Seychelles"], readonly ["SD", 249, "Sudan"], readonly ["SE", 46, "Sweden"], readonly ["SG", 65, "Singapore"], readonly ["SH", 290, "Saint Helena"], readonly ["SI", 386, "Slovenia"], readonly ["SJ", 47, "Svalbard and Jan Mayen"], readonly ["SK", 421, "Slovakia"], readonly ["SL", 232, "Sierra Leone"], readonly ["SM", 378, "San Marino"], readonly ["SN", 221, "Senegal"], readonly ["SO", 252, "Somalia"], readonly ["SR", 597, "Suriname"], readonly ["SS", 211, "South Sudan"], readonly ["ST", 239, "São Tomé and Príncipe"], readonly ["SV", 503, "El Salvador"], readonly ["SX", 1, "Sint Maarten"], readonly ["SY", 963, "Syria"], readonly ["SZ", 268, "Swaziland"], readonly ["TA", 290, "Tristan da Cunha"], readonly ["TC", 1, "Turks and Caicos Islands"], readonly ["TD", 235, "Chad"], readonly ["TG", 228, "Togo"], readonly ["TH", 66, "Thailand"], readonly ["TJ", 992, "Tajikistan"], readonly ["TK", 690, "Tokelau"], readonly ["TL", 670, "Timor-Leste"], readonly ["TM", 993, "Turkmenistan"], readonly ["TN", 216, "Tunisia"], readonly ["TO", 676, "Tonga"], readonly ["TR", 90, "Turkey"], readonly ["TT", 1, "Trinidad and Tobago"], readonly ["TV", 688, "Tuvalu"], readonly ["TW", 886, "Taiwan"], readonly ["TZ", 255, "Tanzania"], readonly ["UA", 380, "Ukraine"], readonly ["UG", 256, "Uganda"], readonly ["UY", 598, "Uruguay"], readonly ["UZ", 998, "Uzbekistan"], readonly ["VA", 39, "Vatican City"], readonly ["VC", 1, "Saint Vincent and the Grenadines"], readonly ["VE", 58, "Venezuela"], readonly ["VG", 1, "British Virgin Islands"], readonly ["VI", 1, "U.S. Virgin Islands"], readonly ["VN", 84, "Vietnam"], readonly ["VU", 678, "Vanuatu"], readonly ["WF", 681, "Wallis and Futuna"], readonly ["WS", 685, "Samoa"], readonly ["XK", 383, "Kosovo"], readonly ["YE", 967, "Yemen"], readonly ["YT", 262, "Mayotte"], readonly ["ZA", 27, "South Africa"], readonly ["ZM", 260, "Zambia"], readonly ["ZW", 263, "Zimbabwe"]];
|
|
6
|
-
declare type CountryISO = typeof COUNTRY_CODE_METADATA[number][0];
|
|
7
|
-
declare const DEFAULT_COUNTRY: CountryISO;
|
|
8
|
-
declare function listCountries(): readonly CountryISO[];
|
|
9
|
-
declare function isCountryISO(value: unknown): value is CountryISO;
|
|
10
|
-
declare function toCountryISO(value: unknown): CountryISO;
|
|
11
|
-
declare function getCountryCode(country: CountryISO): number;
|
|
5
|
+
declare const COUNTRY_CODE_METADATA: readonly [readonly ["US", 1, "United States"], readonly ["CA", 1, "Canada"], readonly ["AU", 61, "Australia"], readonly ["NZ", 64, "New Zealand"], readonly ["AC", 247, "Ascension Island"], readonly ["AD", 376, "Andorra"], readonly ["AE", 971, "United Arab Emirates"], readonly ["AF", 93, "Afghanistan"], readonly ["AG", 1, "Antigua and Barbuda"], readonly ["AI", 1, "Anguilla"], readonly ["AL", 355, "Albania"], readonly ["AM", 374, "Armenia"], readonly ["AO", 244, "Angola"], readonly ["AR", 54, "Argentina"], readonly ["AS", 1, "American Samoa"], readonly ["AT", 43, "Austria"], readonly ["AW", 297, "Aruba"], readonly ["AX", 358, "Åland Islands"], readonly ["AZ", 994, "Azerbaijan"], readonly ["BA", 387, "Bosnia and Herzegovina"], readonly ["BB", 1, "Barbados"], readonly ["BD", 880, "Bangladesh"], readonly ["BE", 32, "Belgium"], readonly ["BF", 226, "Burkina Faso"], readonly ["BG", 359, "Bulgaria"], readonly ["BH", 973, "Bahrain"], readonly ["BI", 257, "Burundi"], readonly ["BJ", 229, "Benin"], readonly ["BL", 590, "Saint Barthélemy"], readonly ["BM", 1, "Bermuda"], readonly ["BN", 673, "Brunei"], readonly ["BO", 591, "Bolivia"], readonly ["BQ", 599, "Caribbean Netherlands"], readonly ["BR", 55, "Brazil"], readonly ["BS", 1, "Bahamas"], readonly ["BT", 975, "Bhutan"], readonly ["BW", 267, "Botswana"], readonly ["BY", 375, "Belarus"], readonly ["BZ", 501, "Belize"], readonly ["CC", 61, "Cocos"], readonly ["CD", 243, "Congo"], readonly ["CF", 236, "Central African Republic"], readonly ["CG", 242, "Congo"], readonly ["CH", 41, "Switzerland"], readonly ["CI", 225, "Côte d’Ivoire"], readonly ["CK", 682, "Cook Islands"], readonly ["CL", 56, "Chile"], readonly ["CM", 237, "Cameroon"], readonly ["CN", 86, "China"], readonly ["CO", 57, "Colombia"], readonly ["CR", 506, "Costa Rica"], readonly ["CU", 53, "Cuba"], readonly ["CV", 238, "Cape Verde"], readonly ["CW", 599, "Curaçao"], readonly ["CX", 61, "Christmas Island"], readonly ["CY", 357, "Cyprus"], readonly ["CZ", 420, "Czech Republic"], readonly ["DE", 49, "Germany"], readonly ["DJ", 253, "Djibouti"], readonly ["DK", 45, "Denmark"], readonly ["DM", 1, "Dominica"], readonly ["DO", 1, "Dominican Republic"], readonly ["DZ", 213, "Algeria"], readonly ["EC", 593, "Ecuador"], readonly ["EE", 372, "Estonia"], readonly ["EG", 20, "Egypt"], readonly ["EH", 212, "Western Sahara"], readonly ["ER", 291, "Eritrea"], readonly ["ES", 34, "Spain"], readonly ["ET", 251, "Ethiopia"], readonly ["FI", 358, "Finland"], readonly ["FJ", 679, "Fiji"], readonly ["FK", 500, "Falkland Islands"], readonly ["FM", 691, "Micronesia"], readonly ["FO", 298, "Faroe Islands"], readonly ["FR", 33, "France"], readonly ["GA", 241, "Gabon"], readonly ["GB", 44, "United Kingdom"], readonly ["GD", 1, "Grenada"], readonly ["GE", 995, "Georgia"], readonly ["GF", 594, "French Guiana"], readonly ["GG", 44, "Guernsey"], readonly ["GH", 233, "Ghana"], readonly ["GI", 350, "Gibraltar"], readonly ["GL", 299, "Greenland"], readonly ["GM", 220, "Gambia"], readonly ["GN", 224, "Guinea"], readonly ["GP", 590, "Guadeloupe"], readonly ["GQ", 240, "Equatorial Guinea"], readonly ["GR", 30, "Greece"], readonly ["GT", 502, "Guatemala"], readonly ["GU", 1, "Guam"], readonly ["GW", 245, "Guinea-Bissau"], readonly ["GY", 592, "Guyana"], readonly ["HK", 852, "Hong Kong"], readonly ["HN", 504, "Honduras"], readonly ["HR", 385, "Croatia"], readonly ["HT", 509, "Haiti"], readonly ["HU", 36, "Hungary"], readonly ["ID", 62, "Indonesia"], readonly ["IE", 353, "Ireland"], readonly ["IL", 972, "Israel"], readonly ["IM", 44, "Isle of Man"], readonly ["IN", 91, "India"], readonly ["IO", 246, "British Indian Ocean Territory"], readonly ["IQ", 964, "Iraq"], readonly ["IR", 98, "Iran"], readonly ["IS", 354, "Iceland"], readonly ["IT", 39, "Italy"], readonly ["JE", 44, "Jersey"], readonly ["JM", 1, "Jamaica"], readonly ["JO", 962, "Jordan"], readonly ["JP", 81, "Japan"], readonly ["KE", 254, "Kenya"], readonly ["KG", 996, "Kyrgyzstan"], readonly ["KH", 855, "Cambodia"], readonly ["KI", 686, "Kiribati"], readonly ["KM", 269, "Comoros"], readonly ["KN", 1, "Saint Kitts and Nevis"], readonly ["KP", 850, "North Korea"], readonly ["KR", 82, "South Korea"], readonly ["KW", 965, "Kuwait"], readonly ["KY", 1, "Cayman Islands"], readonly ["KZ", 7, "Kazakhstan"], readonly ["LA", 856, "Laos"], readonly ["LB", 961, "Lebanon"], readonly ["LC", 1, "Saint Lucia"], readonly ["LI", 423, "Liechtenstein"], readonly ["LK", 94, "Sri Lanka"], readonly ["LR", 231, "Liberia"], readonly ["LS", 266, "Lesotho"], readonly ["LT", 370, "Lithuania"], readonly ["LU", 352, "Luxembourg"], readonly ["LV", 371, "Latvia"], readonly ["LY", 218, "Libya"], readonly ["MA", 212, "Morocco"], readonly ["MC", 377, "Monaco"], readonly ["MD", 373, "Moldova"], readonly ["ME", 382, "Montenegro"], readonly ["MF", 590, "Saint Martin"], readonly ["MG", 261, "Madagascar"], readonly ["MH", 692, "Marshall Islands"], readonly ["MK", 389, "Macedonia"], readonly ["ML", 223, "Mali"], readonly ["MM", 95, "Myanmar"], readonly ["MN", 976, "Mongolia"], readonly ["MO", 853, "Macau"], readonly ["MP", 1, "Northern Mariana Islands"], readonly ["MQ", 596, "Martinique"], readonly ["MR", 222, "Mauritania"], readonly ["MS", 1, "Montserrat"], readonly ["MT", 356, "Malta"], readonly ["MU", 230, "Mauritius"], readonly ["MV", 960, "Maldives"], readonly ["MW", 265, "Malawi"], readonly ["MX", 52, "Mexico"], readonly ["MY", 60, "Malaysia"], readonly ["MZ", 258, "Mozambique"], readonly ["NA", 264, "Namibia"], readonly ["NC", 687, "New Caledonia"], readonly ["NE", 227, "Niger"], readonly ["NF", 672, "Norfolk Island"], readonly ["NG", 234, "Nigeria"], readonly ["NI", 505, "Nicaragua"], readonly ["NL", 31, "Netherlands"], readonly ["NO", 47, "Norway"], readonly ["NP", 977, "Nepal"], readonly ["NR", 674, "Nauru"], readonly ["NU", 683, "Niue"], readonly ["OM", 968, "Oman"], readonly ["PA", 507, "Panama"], readonly ["PE", 51, "Peru"], readonly ["PF", 689, "French Polynesia"], readonly ["PG", 675, "Papua New Guinea"], readonly ["PH", 63, "Philippines"], readonly ["PK", 92, "Pakistan"], readonly ["PL", 48, "Poland"], readonly ["PM", 508, "Saint Pierre and Miquelon"], readonly ["PR", 1, "Puerto Rico"], readonly ["PS", 970, "Palestine"], readonly ["PT", 351, "Portugal"], readonly ["PW", 680, "Palau"], readonly ["PY", 595, "Paraguay"], readonly ["QA", 974, "Qatar"], readonly ["RE", 262, "Réunion"], readonly ["RO", 40, "Romania"], readonly ["RS", 381, "Serbia"], readonly ["RU", 7, "Russia"], readonly ["RW", 250, "Rwanda"], readonly ["SA", 966, "Saudi Arabia"], readonly ["SB", 677, "Solomon Islands"], readonly ["SC", 248, "Seychelles"], readonly ["SD", 249, "Sudan"], readonly ["SE", 46, "Sweden"], readonly ["SG", 65, "Singapore"], readonly ["SH", 290, "Saint Helena"], readonly ["SI", 386, "Slovenia"], readonly ["SJ", 47, "Svalbard and Jan Mayen"], readonly ["SK", 421, "Slovakia"], readonly ["SL", 232, "Sierra Leone"], readonly ["SM", 378, "San Marino"], readonly ["SN", 221, "Senegal"], readonly ["SO", 252, "Somalia"], readonly ["SR", 597, "Suriname"], readonly ["SS", 211, "South Sudan"], readonly ["ST", 239, "São Tomé and Príncipe"], readonly ["SV", 503, "El Salvador"], readonly ["SX", 1, "Sint Maarten"], readonly ["SY", 963, "Syria"], readonly ["SZ", 268, "Swaziland"], readonly ["TA", 290, "Tristan da Cunha"], readonly ["TC", 1, "Turks and Caicos Islands"], readonly ["TD", 235, "Chad"], readonly ["TG", 228, "Togo"], readonly ["TH", 66, "Thailand"], readonly ["TJ", 992, "Tajikistan"], readonly ["TK", 690, "Tokelau"], readonly ["TL", 670, "Timor-Leste"], readonly ["TM", 993, "Turkmenistan"], readonly ["TN", 216, "Tunisia"], readonly ["TO", 676, "Tonga"], readonly ["TR", 90, "Turkey"], readonly ["TT", 1, "Trinidad and Tobago"], readonly ["TV", 688, "Tuvalu"], readonly ["TW", 886, "Taiwan"], readonly ["TZ", 255, "Tanzania"], readonly ["UA", 380, "Ukraine"], readonly ["UG", 256, "Uganda"], readonly ["UY", 598, "Uruguay"], readonly ["UZ", 998, "Uzbekistan"], readonly ["VA", 39, "Vatican City"], readonly ["VC", 1, "Saint Vincent and the Grenadines"], readonly ["VE", 58, "Venezuela"], readonly ["VG", 1, "British Virgin Islands"], readonly ["VI", 1, "U.S. Virgin Islands"], readonly ["VN", 84, "Vietnam"], readonly ["VU", 678, "Vanuatu"], readonly ["WF", 681, "Wallis and Futuna"], readonly ["WS", 685, "Samoa"], readonly ["XK", 383, "Kosovo"], readonly ["YE", 967, "Yemen"], readonly ["YT", 262, "Mayotte"], readonly ["ZA", 27, "South Africa"], readonly ["ZM", 260, "Zambia"], readonly ["ZW", 263, "Zimbabwe"]];
|
|
6
|
+
declare type CountryISO = typeof COUNTRY_CODE_METADATA[number][0];
|
|
7
|
+
declare const DEFAULT_COUNTRY: CountryISO;
|
|
8
|
+
declare function listCountries(): readonly CountryISO[];
|
|
9
|
+
declare function isCountryISO(value: unknown): value is CountryISO;
|
|
10
|
+
declare function toCountryISO(value: unknown): CountryISO;
|
|
11
|
+
declare function getCountryCode(country: CountryISO): number;
|
|
12
12
|
declare function formatCountry(country: CountryISO): string;
|
|
13
13
|
|
|
14
|
-
declare type APNType = AwesomePhoneNumber;
|
|
14
|
+
declare type APNType = AwesomePhoneNumber;
|
|
15
15
|
declare type APNStatic = typeof AwesomePhoneNumber;
|
|
16
16
|
|
|
17
|
-
declare type PhoneNumberPossibility = 'is-possible' | 'invalid-country-code' | 'invalid-number' | 'too-long' | 'too-short' | 'unknown';
|
|
18
|
-
interface PhoneNumberJSON {
|
|
19
|
-
valid: boolean;
|
|
20
|
-
possible: boolean;
|
|
21
|
-
possibility: PhoneNumberPossibility;
|
|
22
|
-
regionCode: CountryISO;
|
|
23
|
-
number: {
|
|
24
|
-
input: string;
|
|
25
|
-
international?: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
interface PhoneNumberInfo {
|
|
29
|
-
country: CountryISO;
|
|
30
|
-
nationalNumber: string;
|
|
31
|
-
}
|
|
32
|
-
declare type PhoneNumberFormat = 'e164' | 'international' | 'national' | 'rfc3966';
|
|
33
|
-
interface PhoneValidationRules {
|
|
34
|
-
required?: boolean;
|
|
35
|
-
requiredMessage?: string;
|
|
36
|
-
tooShortMessage?: string;
|
|
37
|
-
tooLongMessage?: string;
|
|
38
|
-
invalidMessage?: string;
|
|
39
|
-
}
|
|
40
|
-
interface PhoneFormatOptions {
|
|
41
|
-
fallback?: string;
|
|
42
|
-
country?: CountryISO;
|
|
43
|
-
format?: PhoneNumberFormat;
|
|
44
|
-
}
|
|
45
|
-
declare class PhoneService {
|
|
46
|
-
static load(): Promise<PhoneService>;
|
|
47
|
-
static checkPossibility(input: unknown): Promise<PhoneNumberPossibility>;
|
|
48
|
-
static validate(input: unknown, rules?: PhoneValidationRules): Promise<string | undefined>;
|
|
49
|
-
readonly APN: typeof AwesomePhonenumber.PhoneNumber;
|
|
50
|
-
constructor(APN: APNStatic);
|
|
51
|
-
createAPN(phone: string, country?: CountryISO): APNType;
|
|
52
|
-
getJSON(phone: string, country?: CountryISO): PhoneNumberJSON;
|
|
53
|
-
checkPossibility(input: unknown): PhoneNumberPossibility;
|
|
54
|
-
validate(input: unknown, { required, requiredMessage, invalidMessage, tooLongMessage, tooShortMessage, }?: PhoneValidationRules): string | undefined;
|
|
55
|
-
deletePrefix(phone: string, country: CountryISO): string;
|
|
56
|
-
getInfo(phone: string): PhoneNumberInfo;
|
|
57
|
-
format(input: unknown, { fallback, format, country: countryOption, }?: PhoneFormatOptions): string;
|
|
58
|
-
formatNationalNumber(apn: APNType, country: CountryISO): string | undefined;
|
|
59
|
-
private customFormat;
|
|
60
|
-
}
|
|
17
|
+
declare type PhoneNumberPossibility = 'is-possible' | 'invalid-country-code' | 'invalid-number' | 'too-long' | 'too-short' | 'unknown';
|
|
18
|
+
interface PhoneNumberJSON {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
possible: boolean;
|
|
21
|
+
possibility: PhoneNumberPossibility;
|
|
22
|
+
regionCode: CountryISO;
|
|
23
|
+
number: {
|
|
24
|
+
input: string;
|
|
25
|
+
international?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface PhoneNumberInfo {
|
|
29
|
+
country: CountryISO;
|
|
30
|
+
nationalNumber: string;
|
|
31
|
+
}
|
|
32
|
+
declare type PhoneNumberFormat = 'e164' | 'international' | 'national' | 'rfc3966';
|
|
33
|
+
interface PhoneValidationRules {
|
|
34
|
+
required?: boolean;
|
|
35
|
+
requiredMessage?: string;
|
|
36
|
+
tooShortMessage?: string;
|
|
37
|
+
tooLongMessage?: string;
|
|
38
|
+
invalidMessage?: string;
|
|
39
|
+
}
|
|
40
|
+
interface PhoneFormatOptions {
|
|
41
|
+
fallback?: string;
|
|
42
|
+
country?: CountryISO;
|
|
43
|
+
format?: PhoneNumberFormat;
|
|
44
|
+
}
|
|
45
|
+
declare class PhoneService {
|
|
46
|
+
static load(): Promise<PhoneService>;
|
|
47
|
+
static checkPossibility(input: unknown): Promise<PhoneNumberPossibility>;
|
|
48
|
+
static validate(input: unknown, rules?: PhoneValidationRules): Promise<string | undefined>;
|
|
49
|
+
readonly APN: typeof AwesomePhonenumber.PhoneNumber;
|
|
50
|
+
constructor(APN: APNStatic);
|
|
51
|
+
createAPN(phone: string, country?: CountryISO): APNType;
|
|
52
|
+
getJSON(phone: string, country?: CountryISO): PhoneNumberJSON;
|
|
53
|
+
checkPossibility(input: unknown): PhoneNumberPossibility;
|
|
54
|
+
validate(input: unknown, { required, requiredMessage, invalidMessage, tooLongMessage, tooShortMessage, }?: PhoneValidationRules): string | undefined;
|
|
55
|
+
deletePrefix(phone: string, country: CountryISO): string;
|
|
56
|
+
getInfo(phone: string): PhoneNumberInfo;
|
|
57
|
+
format(input: unknown, { fallback, format, country: countryOption, }?: PhoneFormatOptions): string;
|
|
58
|
+
formatNationalNumber(apn: APNType, country: CountryISO): string | undefined;
|
|
59
|
+
private customFormat;
|
|
60
|
+
}
|
|
61
61
|
declare function usePhoneService(): PhoneService;
|
|
62
62
|
|
|
63
63
|
declare function useFormattedPhoneNumber(input: unknown, { format, country, fallback }?: PhoneFormatOptions): string;
|
|
64
64
|
|
|
65
|
-
interface PhoneFieldProps extends Pick<BaseTextFieldProps, 'disabled' | 'error' | 'fullWidth' | 'helperText' | 'id' | 'label' | 'name' | 'placeholder' | 'required'> {
|
|
66
|
-
value?: null | string;
|
|
67
|
-
onBlur?: (value: string) => void;
|
|
68
|
-
onFocus?: (value: string) => void;
|
|
69
|
-
onChange?: (value: string) => void;
|
|
70
|
-
}
|
|
71
|
-
declare const PhoneField: ForwardRefExoticComponent<PhoneFieldProps & RefAttributes<HTMLDivElement>>;
|
|
72
|
-
interface SuspendedPhoneFieldProps extends PhoneFieldProps {
|
|
73
|
-
suspenseFallback?: ReactNode;
|
|
74
|
-
}
|
|
65
|
+
interface PhoneFieldProps extends Pick<BaseTextFieldProps, 'disabled' | 'error' | 'fullWidth' | 'helperText' | 'id' | 'label' | 'name' | 'placeholder' | 'required'> {
|
|
66
|
+
value?: null | string;
|
|
67
|
+
onBlur?: (value: string) => void;
|
|
68
|
+
onFocus?: (value: string) => void;
|
|
69
|
+
onChange?: (value: string) => void;
|
|
70
|
+
}
|
|
71
|
+
declare const PhoneField: ForwardRefExoticComponent<PhoneFieldProps & RefAttributes<HTMLDivElement>>;
|
|
72
|
+
interface SuspendedPhoneFieldProps extends PhoneFieldProps {
|
|
73
|
+
suspenseFallback?: ReactNode;
|
|
74
|
+
}
|
|
75
75
|
declare const SuspendedPhoneField: ForwardRefExoticComponent<SuspendedPhoneFieldProps & RefAttributes<HTMLDivElement>>;
|
|
76
76
|
|
|
77
|
-
interface PhoneLinkProps extends RefAttributes<HTMLAnchorElement>, Omit<LinkProps, 'ref' | 'href' | 'children'> {
|
|
78
|
-
phone: unknown;
|
|
79
|
-
country?: CountryISO;
|
|
80
|
-
format?: PhoneNumberFormat;
|
|
81
|
-
fallback?: ReactNode;
|
|
82
|
-
}
|
|
83
|
-
declare const PhoneLink: ForwardRefExoticComponent<PhoneLinkProps>;
|
|
84
|
-
interface SuspendedPhoneLinkProps extends PhoneLinkProps {
|
|
85
|
-
suspenseFallback?: ReactNode;
|
|
86
|
-
}
|
|
77
|
+
interface PhoneLinkProps extends RefAttributes<HTMLAnchorElement>, Omit<LinkProps, 'ref' | 'href' | 'children'> {
|
|
78
|
+
phone: unknown;
|
|
79
|
+
country?: CountryISO;
|
|
80
|
+
format?: PhoneNumberFormat;
|
|
81
|
+
fallback?: ReactNode;
|
|
82
|
+
}
|
|
83
|
+
declare const PhoneLink: ForwardRefExoticComponent<PhoneLinkProps>;
|
|
84
|
+
interface SuspendedPhoneLinkProps extends PhoneLinkProps {
|
|
85
|
+
suspenseFallback?: ReactNode;
|
|
86
|
+
}
|
|
87
87
|
declare const SuspendedPhoneLink: ForwardRefExoticComponent<SuspendedPhoneLinkProps>;
|
|
88
88
|
|
|
89
|
-
interface PhoneTextProps {
|
|
90
|
-
phone: unknown;
|
|
91
|
-
fallback?: ReactNode;
|
|
92
|
-
country?: CountryISO;
|
|
93
|
-
format?: PhoneNumberFormat;
|
|
94
|
-
}
|
|
95
|
-
declare function PhoneText({ phone, country, fallback, format, }: PhoneTextProps): null | ReactElement;
|
|
96
|
-
interface SuspendedPhoneTextProps extends PhoneTextProps {
|
|
97
|
-
suspenseFallback?: ReactNode;
|
|
98
|
-
}
|
|
89
|
+
interface PhoneTextProps {
|
|
90
|
+
phone: unknown;
|
|
91
|
+
fallback?: ReactNode;
|
|
92
|
+
country?: CountryISO;
|
|
93
|
+
format?: PhoneNumberFormat;
|
|
94
|
+
}
|
|
95
|
+
declare function PhoneText({ phone, country, fallback, format, }: PhoneTextProps): null | ReactElement;
|
|
96
|
+
interface SuspendedPhoneTextProps extends PhoneTextProps {
|
|
97
|
+
suspenseFallback?: ReactNode;
|
|
98
|
+
}
|
|
99
99
|
declare function SuspendedPhoneText({ suspenseFallback, ...props }: SuspendedPhoneTextProps): ReactElement;
|
|
100
100
|
|
|
101
101
|
export { CountryISO, DEFAULT_COUNTRY, PhoneField, PhoneFieldProps, PhoneFormatOptions, PhoneLink, PhoneLinkProps, PhoneNumberFormat, PhoneNumberInfo, PhoneNumberPossibility, PhoneService, PhoneText, PhoneTextProps, PhoneValidationRules, SuspendedPhoneField, SuspendedPhoneFieldProps, SuspendedPhoneLink, SuspendedPhoneLinkProps, SuspendedPhoneText, SuspendedPhoneTextProps, formatCountry, getCountryCode, isCountryISO, listCountries, toCountryISO, useFormattedPhoneNumber, usePhoneService };
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@superdispatch/phones",
|
|
3
|
+
"version": "0.21.8",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist-*/",
|
|
7
|
+
"bin/"
|
|
8
|
+
],
|
|
9
|
+
"pika": true,
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/superdispatch/ui.git"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@superdispatch/ui": "^0.21.8",
|
|
17
|
+
"awesome-phonenumber": "^2.70.0",
|
|
18
|
+
"clsx": "^1.1.1"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@babel/runtime": "^7.0.0",
|
|
22
|
+
"@material-ui/core": "^4.7.2",
|
|
23
|
+
"@material-ui/icons": "^4.5.1",
|
|
24
|
+
"react": "^17.0.2"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"directory": "pkg"
|
|
29
|
+
},
|
|
30
|
+
"esnext": "dist-src/index.js",
|
|
31
|
+
"module": "dist-web/index.js",
|
|
32
|
+
"main": "dist-node/index.js",
|
|
33
|
+
"types": "dist-types/index.d.ts"
|
|
34
|
+
}
|
package/playroom.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as api from '..';
|
|
2
|
+
|
|
3
|
+
test('api', () => {
|
|
4
|
+
expect(api).toMatchInlineSnapshot(`
|
|
5
|
+
Object {
|
|
6
|
+
"DEFAULT_COUNTRY": "US",
|
|
7
|
+
"PhoneField": React.forwardRef(PhoneField),
|
|
8
|
+
"PhoneLink": React.forwardRef(PhoneLink),
|
|
9
|
+
"PhoneService": [Function],
|
|
10
|
+
"PhoneText": [Function],
|
|
11
|
+
"SuspendedPhoneField": React.forwardRef(SuspendedPhoneField),
|
|
12
|
+
"SuspendedPhoneLink": React.forwardRef(SuspendedPhoneLink),
|
|
13
|
+
"SuspendedPhoneText": [Function],
|
|
14
|
+
"formatCountry": [Function],
|
|
15
|
+
"getCountryCode": [Function],
|
|
16
|
+
"isCountryISO": [Function],
|
|
17
|
+
"listCountries": [Function],
|
|
18
|
+
"toCountryISO": [Function],
|
|
19
|
+
"useFormattedPhoneNumber": [Function],
|
|
20
|
+
"usePhoneService": [Function],
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
});
|
package/src/apn/APN.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type AwesomePhoneNumber from 'awesome-phonenumber';
|
|
2
|
+
|
|
3
|
+
export type APNType = AwesomePhoneNumber;
|
|
4
|
+
export type APNStatic = typeof AwesomePhoneNumber;
|
|
5
|
+
export type AYTType = ReturnType<APNStatic['getAsYouType']>;
|
|
6
|
+
|
|
7
|
+
let loadError: undefined | Error;
|
|
8
|
+
let loadedAPN: undefined | APNStatic;
|
|
9
|
+
|
|
10
|
+
export function loadAPN(): Promise<APNStatic> {
|
|
11
|
+
return import(
|
|
12
|
+
/* webpackPrefetch: true */
|
|
13
|
+
/* webpackChunkName: "apn" */
|
|
14
|
+
'awesome-phonenumber'
|
|
15
|
+
).then(
|
|
16
|
+
(apn) => {
|
|
17
|
+
loadedAPN = apn.default;
|
|
18
|
+
|
|
19
|
+
return loadedAPN;
|
|
20
|
+
},
|
|
21
|
+
(error: Error) => {
|
|
22
|
+
loadError = error;
|
|
23
|
+
|
|
24
|
+
throw error;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getAPN(): APNStatic {
|
|
30
|
+
if (loadError) {
|
|
31
|
+
throw loadError;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!loadedAPN) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
36
|
+
throw loadAPN();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return loadedAPN;
|
|
40
|
+
}
|