@superdispatch/phones 0.15.0 → 0.16.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-web/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
  import { useMemo, forwardRef, useRef, useState, useCallback, useEffect, Suspense } from 'react';
2
2
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
- import { Typography, MenuItem, Menu, Divider, InputAdornment, ButtonBase, TextField, Link } from '@material-ui/core';
5
- import { Color, mergeRefs, renderChildren } from '@superdispatch/ui';
6
- import { makeStyles } from '@material-ui/styles';
4
+ import { Typography, MenuItem, Menu, Divider, InputAdornment, ButtonBase, TextField, Link } from '@mui/material';
5
+ import { v5, Color as Color$1, mergeRefs as mergeRefs$1, renderChildren as renderChildren$2 } from '@superdispatch/ui';
6
+ import { makeStyles } from '@mui/styles';
7
7
  import clsx from 'clsx';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { ArrowDropUp, ArrowDropDown } from '@material-ui/icons';
9
+ import { ArrowDropUp, ArrowDropDown } from '@mui/icons-material';
10
+ import { Typography as Typography$1, MenuItem as MenuItem$1, Menu as Menu$1, Divider as Divider$1, InputAdornment as InputAdornment$1, ButtonBase as ButtonBase$1, TextField as TextField$1, Link as Link$1 } from '@material-ui/core';
11
+ import { makeStyles as makeStyles$1 } from '@material-ui/styles';
12
+ import { ArrowDropUp as ArrowDropUp$1, ArrowDropDown as ArrowDropDown$1 } from '@material-ui/icons';
10
13
 
11
14
  var COUNTRY_CODE_METADATA = /*#__PURE__*/JSON.parse('[["US",1,"United States"],["CA",1,"Canada"],["AU",61,"Australia"],["NZ",64,"New Zealand"],["AC",247,"Ascension Island"],["AD",376,"Andorra"],["AE",971,"United Arab Emirates"],["AF",93,"Afghanistan"],["AG",1,"Antigua and Barbuda"],["AI",1,"Anguilla"],["AL",355,"Albania"],["AM",374,"Armenia"],["AO",244,"Angola"],["AR",54,"Argentina"],["AS",1,"American Samoa"],["AT",43,"Austria"],["AW",297,"Aruba"],["AX",358,"Åland Islands"],["AZ",994,"Azerbaijan"],["BA",387,"Bosnia and Herzegovina"],["BB",1,"Barbados"],["BD",880,"Bangladesh"],["BE",32,"Belgium"],["BF",226,"Burkina Faso"],["BG",359,"Bulgaria"],["BH",973,"Bahrain"],["BI",257,"Burundi"],["BJ",229,"Benin"],["BL",590,"Saint Barthélemy"],["BM",1,"Bermuda"],["BN",673,"Brunei"],["BO",591,"Bolivia"],["BQ",599,"Caribbean Netherlands"],["BR",55,"Brazil"],["BS",1,"Bahamas"],["BT",975,"Bhutan"],["BW",267,"Botswana"],["BY",375,"Belarus"],["BZ",501,"Belize"],["CC",61,"Cocos"],["CD",243,"Congo"],["CF",236,"Central African Republic"],["CG",242,"Congo"],["CH",41,"Switzerland"],["CI",225,"Côte d’Ivoire"],["CK",682,"Cook Islands"],["CL",56,"Chile"],["CM",237,"Cameroon"],["CN",86,"China"],["CO",57,"Colombia"],["CR",506,"Costa Rica"],["CU",53,"Cuba"],["CV",238,"Cape Verde"],["CW",599,"Curaçao"],["CX",61,"Christmas Island"],["CY",357,"Cyprus"],["CZ",420,"Czech Republic"],["DE",49,"Germany"],["DJ",253,"Djibouti"],["DK",45,"Denmark"],["DM",1,"Dominica"],["DO",1,"Dominican Republic"],["DZ",213,"Algeria"],["EC",593,"Ecuador"],["EE",372,"Estonia"],["EG",20,"Egypt"],["EH",212,"Western Sahara"],["ER",291,"Eritrea"],["ES",34,"Spain"],["ET",251,"Ethiopia"],["FI",358,"Finland"],["FJ",679,"Fiji"],["FK",500,"Falkland Islands"],["FM",691,"Micronesia"],["FO",298,"Faroe Islands"],["FR",33,"France"],["GA",241,"Gabon"],["GB",44,"United Kingdom"],["GD",1,"Grenada"],["GE",995,"Georgia"],["GF",594,"French Guiana"],["GG",44,"Guernsey"],["GH",233,"Ghana"],["GI",350,"Gibraltar"],["GL",299,"Greenland"],["GM",220,"Gambia"],["GN",224,"Guinea"],["GP",590,"Guadeloupe"],["GQ",240,"Equatorial Guinea"],["GR",30,"Greece"],["GT",502,"Guatemala"],["GU",1,"Guam"],["GW",245,"Guinea-Bissau"],["GY",592,"Guyana"],["HK",852,"Hong Kong"],["HN",504,"Honduras"],["HR",385,"Croatia"],["HT",509,"Haiti"],["HU",36,"Hungary"],["ID",62,"Indonesia"],["IE",353,"Ireland"],["IL",972,"Israel"],["IM",44,"Isle of Man"],["IN",91,"India"],["IO",246,"British Indian Ocean Territory"],["IQ",964,"Iraq"],["IR",98,"Iran"],["IS",354,"Iceland"],["IT",39,"Italy"],["JE",44,"Jersey"],["JM",1,"Jamaica"],["JO",962,"Jordan"],["JP",81,"Japan"],["KE",254,"Kenya"],["KG",996,"Kyrgyzstan"],["KH",855,"Cambodia"],["KI",686,"Kiribati"],["KM",269,"Comoros"],["KN",1,"Saint Kitts and Nevis"],["KP",850,"North Korea"],["KR",82,"South Korea"],["KW",965,"Kuwait"],["KY",1,"Cayman Islands"],["KZ",7,"Kazakhstan"],["LA",856,"Laos"],["LB",961,"Lebanon"],["LC",1,"Saint Lucia"],["LI",423,"Liechtenstein"],["LK",94,"Sri Lanka"],["LR",231,"Liberia"],["LS",266,"Lesotho"],["LT",370,"Lithuania"],["LU",352,"Luxembourg"],["LV",371,"Latvia"],["LY",218,"Libya"],["MA",212,"Morocco"],["MC",377,"Monaco"],["MD",373,"Moldova"],["ME",382,"Montenegro"],["MF",590,"Saint Martin"],["MG",261,"Madagascar"],["MH",692,"Marshall Islands"],["MK",389,"Macedonia"],["ML",223,"Mali"],["MM",95,"Myanmar"],["MN",976,"Mongolia"],["MO",853,"Macau"],["MP",1,"Northern Mariana Islands"],["MQ",596,"Martinique"],["MR",222,"Mauritania"],["MS",1,"Montserrat"],["MT",356,"Malta"],["MU",230,"Mauritius"],["MV",960,"Maldives"],["MW",265,"Malawi"],["MX",52,"Mexico"],["MY",60,"Malaysia"],["MZ",258,"Mozambique"],["NA",264,"Namibia"],["NC",687,"New Caledonia"],["NE",227,"Niger"],["NF",672,"Norfolk Island"],["NG",234,"Nigeria"],["NI",505,"Nicaragua"],["NL",31,"Netherlands"],["NO",47,"Norway"],["NP",977,"Nepal"],["NR",674,"Nauru"],["NU",683,"Niue"],["OM",968,"Oman"],["PA",507,"Panama"],["PE",51,"Peru"],["PF",689,"French Polynesia"],["PG",675,"Papua New Guinea"],["PH",63,"Philippines"],["PK",92,"Pakistan"],["PL",48,"Poland"],["PM",508,"Saint Pierre and Miquelon"],["PR",1,"Puerto Rico"],["PS",970,"Palestine"],["PT",351,"Portugal"],["PW",680,"Palau"],["PY",595,"Paraguay"],["QA",974,"Qatar"],["RE",262,"Réunion"],["RO",40,"Romania"],["RS",381,"Serbia"],["RU",7,"Russia"],["RW",250,"Rwanda"],["SA",966,"Saudi Arabia"],["SB",677,"Solomon Islands"],["SC",248,"Seychelles"],["SD",249,"Sudan"],["SE",46,"Sweden"],["SG",65,"Singapore"],["SH",290,"Saint Helena"],["SI",386,"Slovenia"],["SJ",47,"Svalbard and Jan Mayen"],["SK",421,"Slovakia"],["SL",232,"Sierra Leone"],["SM",378,"San Marino"],["SN",221,"Senegal"],["SO",252,"Somalia"],["SR",597,"Suriname"],["SS",211,"South Sudan"],["ST",239,"São Tomé and Príncipe"],["SV",503,"El Salvador"],["SX",1,"Sint Maarten"],["SY",963,"Syria"],["SZ",268,"Swaziland"],["TA",290,"Tristan da Cunha"],["TC",1,"Turks and Caicos Islands"],["TD",235,"Chad"],["TG",228,"Togo"],["TH",66,"Thailand"],["TJ",992,"Tajikistan"],["TK",690,"Tokelau"],["TL",670,"Timor-Leste"],["TM",993,"Turkmenistan"],["TN",216,"Tunisia"],["TO",676,"Tonga"],["TR",90,"Turkey"],["TT",1,"Trinidad and Tobago"],["TV",688,"Tuvalu"],["TW",886,"Taiwan"],["TZ",255,"Tanzania"],["UA",380,"Ukraine"],["UG",256,"Uganda"],["UY",598,"Uruguay"],["UZ",998,"Uzbekistan"],["VA",39,"Vatican City"],["VC",1,"Saint Vincent and the Grenadines"],["VE",58,"Venezuela"],["VG",1,"British Virgin Islands"],["VI",1,"U.S. Virgin Islands"],["VN",84,"Vietnam"],["VU",678,"Vanuatu"],["WF",681,"Wallis and Futuna"],["WS",685,"Samoa"],["XK",383,"Kosovo"],["YE",967,"Yemen"],["YT",262,"Mayotte"],["ZA",27,"South Africa"],["ZM",260,"Zambia"],["ZW",263,"Zimbabwe"]]');
12
15
  var DEFAULT_COUNTRY = 'US';
@@ -314,6 +317,9 @@ var useStyles$1 = /*#__PURE__*/makeStyles(theme => ({
314
317
  gutters: {},
315
318
  root: {},
316
319
  selected: {},
320
+ disabled: {},
321
+ divider: {},
322
+ focusVisible: {},
317
323
  flag: {
318
324
  marginRight: theme.spacing(1)
319
325
  }
@@ -338,7 +344,6 @@ var PhoneFieldMenuItem = /*#__PURE__*/forwardRef((_ref, ref) => {
338
344
  var countryCode = useMemo(() => getCountryCode(country), [country]);
339
345
  return /*#__PURE__*/jsxs(MenuItem, _objectSpread(_objectSpread({}, props), {}, {
340
346
  ref: ref,
341
- button: true,
342
347
  classes: styles,
343
348
  children: [/*#__PURE__*/jsx(PhoneFieldFlag, {
344
349
  country: country,
@@ -386,6 +391,9 @@ var PhoneFieldMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
386
391
  });
387
392
  if (process.env.NODE_ENV !== "production") PhoneFieldMenu.displayName = "PhoneFieldMenu";
388
393
 
394
+ var {
395
+ Color
396
+ } = v5;
389
397
  var useStyles$3 = /*#__PURE__*/makeStyles(theme => ({
390
398
  root: {
391
399
  marginLeft: theme.spacing(-1),
@@ -439,6 +447,9 @@ if (process.env.NODE_ENV !== "production") PhoneFieldStartAdornment.displayName
439
447
 
440
448
  var _excluded$2 = ["value", "onBlur", "onFocus", "onChange"],
441
449
  _excluded2$1 = ["label", "fullWidth", "helperText", "suspenseFallback"];
450
+ var {
451
+ mergeRefs
452
+ } = v5;
442
453
 
443
454
  function normalizeValue(value) {
444
455
  return typeof value === 'string' ? value : '';
@@ -575,6 +586,9 @@ if (process.env.NODE_ENV !== "production") SuspendedPhoneField.displayName = "Su
575
586
 
576
587
  var _excluded$3 = ["phone", "country", "fallback", "format"],
577
588
  _excluded2$2 = ["suspenseFallback"];
589
+ var {
590
+ renderChildren
591
+ } = v5;
578
592
  var PhoneLink = /*#__PURE__*/forwardRef((_ref, ref) => {
579
593
  var {
580
594
  phone,
@@ -621,6 +635,9 @@ var SuspendedPhoneLink = /*#__PURE__*/forwardRef((_ref2, ref) => {
621
635
  if (process.env.NODE_ENV !== "production") SuspendedPhoneLink.displayName = "SuspendedPhoneLink";
622
636
 
623
637
  var _excluded$4 = ["suspenseFallback"];
638
+ var {
639
+ renderChildren: renderChildren$1
640
+ } = v5;
624
641
  function PhoneText(_ref) {
625
642
  var {
626
643
  phone,
@@ -632,7 +649,7 @@ function PhoneText(_ref) {
632
649
  format,
633
650
  country
634
651
  });
635
- return renderChildren(children || fallback);
652
+ return renderChildren$1(children || fallback);
636
653
  }
637
654
  function SuspendedPhoneText(_ref2) {
638
655
  var {
@@ -646,5 +663,664 @@ function SuspendedPhoneText(_ref2) {
646
663
  });
647
664
  }
648
665
 
649
- export { DEFAULT_COUNTRY, PhoneField, PhoneLink, PhoneService, PhoneText, SuspendedPhoneField, SuspendedPhoneLink, SuspendedPhoneText, formatCountry, getCountryCode, isCountryISO, listCountries, toCountryISO, useFormattedPhoneNumber, usePhoneService };
666
+
667
+
668
+ var index = /*#__PURE__*/Object.freeze({
669
+ __proto__: null,
670
+ DEFAULT_COUNTRY: DEFAULT_COUNTRY,
671
+ listCountries: listCountries,
672
+ isCountryISO: isCountryISO,
673
+ toCountryISO: toCountryISO,
674
+ getCountryCode: getCountryCode,
675
+ formatCountry: formatCountry,
676
+ useFormattedPhoneNumber: useFormattedPhoneNumber,
677
+ PhoneField: PhoneField,
678
+ SuspendedPhoneField: SuspendedPhoneField,
679
+ PhoneLink: PhoneLink,
680
+ SuspendedPhoneLink: SuspendedPhoneLink,
681
+ PhoneService: PhoneService,
682
+ usePhoneService: usePhoneService,
683
+ PhoneText: PhoneText,
684
+ SuspendedPhoneText: SuspendedPhoneText
685
+ });
686
+
687
+ var COUNTRY_CODE_METADATA$1 = /*#__PURE__*/JSON.parse('[["US",1,"United States"],["CA",1,"Canada"],["AU",61,"Australia"],["NZ",64,"New Zealand"],["AC",247,"Ascension Island"],["AD",376,"Andorra"],["AE",971,"United Arab Emirates"],["AF",93,"Afghanistan"],["AG",1,"Antigua and Barbuda"],["AI",1,"Anguilla"],["AL",355,"Albania"],["AM",374,"Armenia"],["AO",244,"Angola"],["AR",54,"Argentina"],["AS",1,"American Samoa"],["AT",43,"Austria"],["AW",297,"Aruba"],["AX",358,"Åland Islands"],["AZ",994,"Azerbaijan"],["BA",387,"Bosnia and Herzegovina"],["BB",1,"Barbados"],["BD",880,"Bangladesh"],["BE",32,"Belgium"],["BF",226,"Burkina Faso"],["BG",359,"Bulgaria"],["BH",973,"Bahrain"],["BI",257,"Burundi"],["BJ",229,"Benin"],["BL",590,"Saint Barthélemy"],["BM",1,"Bermuda"],["BN",673,"Brunei"],["BO",591,"Bolivia"],["BQ",599,"Caribbean Netherlands"],["BR",55,"Brazil"],["BS",1,"Bahamas"],["BT",975,"Bhutan"],["BW",267,"Botswana"],["BY",375,"Belarus"],["BZ",501,"Belize"],["CC",61,"Cocos"],["CD",243,"Congo"],["CF",236,"Central African Republic"],["CG",242,"Congo"],["CH",41,"Switzerland"],["CI",225,"Côte d’Ivoire"],["CK",682,"Cook Islands"],["CL",56,"Chile"],["CM",237,"Cameroon"],["CN",86,"China"],["CO",57,"Colombia"],["CR",506,"Costa Rica"],["CU",53,"Cuba"],["CV",238,"Cape Verde"],["CW",599,"Curaçao"],["CX",61,"Christmas Island"],["CY",357,"Cyprus"],["CZ",420,"Czech Republic"],["DE",49,"Germany"],["DJ",253,"Djibouti"],["DK",45,"Denmark"],["DM",1,"Dominica"],["DO",1,"Dominican Republic"],["DZ",213,"Algeria"],["EC",593,"Ecuador"],["EE",372,"Estonia"],["EG",20,"Egypt"],["EH",212,"Western Sahara"],["ER",291,"Eritrea"],["ES",34,"Spain"],["ET",251,"Ethiopia"],["FI",358,"Finland"],["FJ",679,"Fiji"],["FK",500,"Falkland Islands"],["FM",691,"Micronesia"],["FO",298,"Faroe Islands"],["FR",33,"France"],["GA",241,"Gabon"],["GB",44,"United Kingdom"],["GD",1,"Grenada"],["GE",995,"Georgia"],["GF",594,"French Guiana"],["GG",44,"Guernsey"],["GH",233,"Ghana"],["GI",350,"Gibraltar"],["GL",299,"Greenland"],["GM",220,"Gambia"],["GN",224,"Guinea"],["GP",590,"Guadeloupe"],["GQ",240,"Equatorial Guinea"],["GR",30,"Greece"],["GT",502,"Guatemala"],["GU",1,"Guam"],["GW",245,"Guinea-Bissau"],["GY",592,"Guyana"],["HK",852,"Hong Kong"],["HN",504,"Honduras"],["HR",385,"Croatia"],["HT",509,"Haiti"],["HU",36,"Hungary"],["ID",62,"Indonesia"],["IE",353,"Ireland"],["IL",972,"Israel"],["IM",44,"Isle of Man"],["IN",91,"India"],["IO",246,"British Indian Ocean Territory"],["IQ",964,"Iraq"],["IR",98,"Iran"],["IS",354,"Iceland"],["IT",39,"Italy"],["JE",44,"Jersey"],["JM",1,"Jamaica"],["JO",962,"Jordan"],["JP",81,"Japan"],["KE",254,"Kenya"],["KG",996,"Kyrgyzstan"],["KH",855,"Cambodia"],["KI",686,"Kiribati"],["KM",269,"Comoros"],["KN",1,"Saint Kitts and Nevis"],["KP",850,"North Korea"],["KR",82,"South Korea"],["KW",965,"Kuwait"],["KY",1,"Cayman Islands"],["KZ",7,"Kazakhstan"],["LA",856,"Laos"],["LB",961,"Lebanon"],["LC",1,"Saint Lucia"],["LI",423,"Liechtenstein"],["LK",94,"Sri Lanka"],["LR",231,"Liberia"],["LS",266,"Lesotho"],["LT",370,"Lithuania"],["LU",352,"Luxembourg"],["LV",371,"Latvia"],["LY",218,"Libya"],["MA",212,"Morocco"],["MC",377,"Monaco"],["MD",373,"Moldova"],["ME",382,"Montenegro"],["MF",590,"Saint Martin"],["MG",261,"Madagascar"],["MH",692,"Marshall Islands"],["MK",389,"Macedonia"],["ML",223,"Mali"],["MM",95,"Myanmar"],["MN",976,"Mongolia"],["MO",853,"Macau"],["MP",1,"Northern Mariana Islands"],["MQ",596,"Martinique"],["MR",222,"Mauritania"],["MS",1,"Montserrat"],["MT",356,"Malta"],["MU",230,"Mauritius"],["MV",960,"Maldives"],["MW",265,"Malawi"],["MX",52,"Mexico"],["MY",60,"Malaysia"],["MZ",258,"Mozambique"],["NA",264,"Namibia"],["NC",687,"New Caledonia"],["NE",227,"Niger"],["NF",672,"Norfolk Island"],["NG",234,"Nigeria"],["NI",505,"Nicaragua"],["NL",31,"Netherlands"],["NO",47,"Norway"],["NP",977,"Nepal"],["NR",674,"Nauru"],["NU",683,"Niue"],["OM",968,"Oman"],["PA",507,"Panama"],["PE",51,"Peru"],["PF",689,"French Polynesia"],["PG",675,"Papua New Guinea"],["PH",63,"Philippines"],["PK",92,"Pakistan"],["PL",48,"Poland"],["PM",508,"Saint Pierre and Miquelon"],["PR",1,"Puerto Rico"],["PS",970,"Palestine"],["PT",351,"Portugal"],["PW",680,"Palau"],["PY",595,"Paraguay"],["QA",974,"Qatar"],["RE",262,"Réunion"],["RO",40,"Romania"],["RS",381,"Serbia"],["RU",7,"Russia"],["RW",250,"Rwanda"],["SA",966,"Saudi Arabia"],["SB",677,"Solomon Islands"],["SC",248,"Seychelles"],["SD",249,"Sudan"],["SE",46,"Sweden"],["SG",65,"Singapore"],["SH",290,"Saint Helena"],["SI",386,"Slovenia"],["SJ",47,"Svalbard and Jan Mayen"],["SK",421,"Slovakia"],["SL",232,"Sierra Leone"],["SM",378,"San Marino"],["SN",221,"Senegal"],["SO",252,"Somalia"],["SR",597,"Suriname"],["SS",211,"South Sudan"],["ST",239,"São Tomé and Príncipe"],["SV",503,"El Salvador"],["SX",1,"Sint Maarten"],["SY",963,"Syria"],["SZ",268,"Swaziland"],["TA",290,"Tristan da Cunha"],["TC",1,"Turks and Caicos Islands"],["TD",235,"Chad"],["TG",228,"Togo"],["TH",66,"Thailand"],["TJ",992,"Tajikistan"],["TK",690,"Tokelau"],["TL",670,"Timor-Leste"],["TM",993,"Turkmenistan"],["TN",216,"Tunisia"],["TO",676,"Tonga"],["TR",90,"Turkey"],["TT",1,"Trinidad and Tobago"],["TV",688,"Tuvalu"],["TW",886,"Taiwan"],["TZ",255,"Tanzania"],["UA",380,"Ukraine"],["UG",256,"Uganda"],["UY",598,"Uruguay"],["UZ",998,"Uzbekistan"],["VA",39,"Vatican City"],["VC",1,"Saint Vincent and the Grenadines"],["VE",58,"Venezuela"],["VG",1,"British Virgin Islands"],["VI",1,"U.S. Virgin Islands"],["VN",84,"Vietnam"],["VU",678,"Vanuatu"],["WF",681,"Wallis and Futuna"],["WS",685,"Samoa"],["XK",383,"Kosovo"],["YE",967,"Yemen"],["YT",262,"Mayotte"],["ZA",27,"South Africa"],["ZM",260,"Zambia"],["ZW",263,"Zimbabwe"]]');
688
+ var DEFAULT_COUNTRY$1 = 'US';
689
+ var COUNTRIES$1 = [];
690
+ var COUNTRY_CODE_MAP$1 = /*#__PURE__*/new Map();
691
+ var COUNTRY_NAME_MAP$1 = /*#__PURE__*/new Map();
692
+
693
+ for (var [country$1, code$1, name$1] of COUNTRY_CODE_METADATA$1) {
694
+ COUNTRIES$1.push(country$1);
695
+ COUNTRY_CODE_MAP$1.set(country$1, code$1);
696
+ COUNTRY_NAME_MAP$1.set(country$1, name$1);
697
+ }
698
+
699
+ function listCountries$1() {
700
+ return COUNTRIES$1;
701
+ }
702
+ function isCountryISO$1(value) {
703
+ return typeof value == 'string' && COUNTRY_CODE_MAP$1.has(value);
704
+ }
705
+ function toCountryISO$1(value) {
706
+ return isCountryISO$1(value) ? value : DEFAULT_COUNTRY$1;
707
+ }
708
+ function getCountryCode$1(country) {
709
+ return COUNTRY_CODE_MAP$1.get(country) || 0;
710
+ }
711
+ function formatCountry$1(country) {
712
+ return COUNTRY_NAME_MAP$1.get(country) || 'Invalid Country ISO';
713
+ }
714
+
715
+ var loadError$1;
716
+ var loadedAPN$1;
717
+ function loadAPN$1() {
718
+ return import(
719
+ /* webpackPrefetch: true */
720
+
721
+ /* webpackChunkName: "apn" */
722
+ 'awesome-phonenumber').then(apn => {
723
+ loadedAPN$1 = apn.default;
724
+ return loadedAPN$1;
725
+ }, error => {
726
+ loadError$1 = error;
727
+ throw error;
728
+ });
729
+ }
730
+ function getAPN$1() {
731
+ if (loadError$1) {
732
+ throw loadError$1;
733
+ }
734
+
735
+ if (!loadedAPN$1) {
736
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
737
+ throw loadAPN$1();
738
+ }
739
+
740
+ return loadedAPN$1;
741
+ }
742
+
743
+ var PLUS_SIGN$1 = '+';
744
+ var NON_PHONE_SYMBOLS_PATTERN$1 = /[^+\d]/g;
745
+ var PHONE_PATTERN$1 = /^\+?\d+/g;
746
+
747
+ function getPrefix$1(country) {
748
+ return PLUS_SIGN$1 + String(getCountryCode$1(toCountryISO$1(country)));
749
+ }
750
+
751
+ function trim$1(input) {
752
+ return typeof input == 'string' ? input.trim() : undefined;
753
+ }
754
+
755
+ function normalize$1(input) {
756
+ if (typeof input == 'string') {
757
+ var matches = input.replace(NON_PHONE_SYMBOLS_PATTERN$1, '').match(PHONE_PATTERN$1);
758
+ if (matches !== null && matches !== void 0 && matches[0]) return matches[0];
759
+ }
760
+
761
+ return '';
762
+ }
763
+
764
+ function normalizeNational$1(country, input) {
765
+ var phone = normalize$1(input);
766
+ var prefix = getPrefix$1(country);
767
+
768
+ if (phone.startsWith(PLUS_SIGN$1)) {
769
+ return phone.slice(prefix.length);
770
+ }
771
+
772
+ return phone;
773
+ }
774
+
775
+ class PhoneService$1 {
776
+ static load() {
777
+ return loadAPN$1().then(APN => new PhoneService$1(APN));
778
+ }
779
+
780
+ static checkPossibility(input) {
781
+ return this.load().then(phoneService => phoneService.checkPossibility(input));
782
+ }
783
+
784
+ static validate(input, rules) {
785
+ return this.load().then(phoneService => phoneService.validate(input, rules));
786
+ }
787
+
788
+ constructor(APN) {
789
+ this.APN = APN;
790
+ }
791
+
792
+ createAPN(phone, country) {
793
+ var asYouType = this.APN.getAsYouType(toCountryISO$1(country));
794
+ asYouType.reset(normalize$1(phone));
795
+ return asYouType.getPhoneNumber();
796
+ }
797
+
798
+ getJSON(phone, country) {
799
+ return this.createAPN(phone, country).toJSON();
800
+ }
801
+
802
+ checkPossibility(input) {
803
+ var phone = trim$1(input);
804
+
805
+ if (!phone) {
806
+ return 'unknown';
807
+ }
808
+
809
+ var apn = phone.startsWith(PLUS_SIGN$1) ? new this.APN(phone) : new this.APN(phone, DEFAULT_COUNTRY$1);
810
+ var {
811
+ valid,
812
+ possible,
813
+ possibility
814
+ } = apn.toJSON(); // Avoid false positive short phone numbers.
815
+
816
+ if (!valid && possible) {
817
+ return 'invalid-number';
818
+ }
819
+
820
+ return possibility;
821
+ }
822
+
823
+ validate(input) {
824
+ var {
825
+ required,
826
+ requiredMessage = 'This field is required',
827
+ invalidMessage = 'Invalid phone number',
828
+ tooLongMessage = 'Phone number is too long',
829
+ tooShortMessage = 'Phone number is too short'
830
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
831
+ var phone = trim$1(input);
832
+
833
+ if (!phone) {
834
+ if (required) {
835
+ return requiredMessage;
836
+ }
837
+
838
+ return undefined;
839
+ }
840
+
841
+ switch (this.checkPossibility(phone)) {
842
+ case 'is-possible':
843
+ return undefined;
844
+
845
+ case 'too-long':
846
+ return tooLongMessage;
847
+
848
+ case 'too-short':
849
+ return tooShortMessage;
850
+ }
851
+
852
+ return invalidMessage;
853
+ }
854
+
855
+ getInfo(phone) {
856
+ var {
857
+ regionCode,
858
+ number: {
859
+ input,
860
+ national: nationalNumber
861
+ }
862
+ } = this.getJSON(phone);
863
+ var country = toCountryISO$1(regionCode);
864
+
865
+ if (!nationalNumber) {
866
+ nationalNumber = normalizeNational$1(country, input);
867
+ }
868
+
869
+ return {
870
+ country,
871
+ nationalNumber
872
+ };
873
+ }
874
+
875
+ format(input) {
876
+ var {
877
+ country,
878
+ format = 'e164',
879
+ fallback = ''
880
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
881
+ var phone = normalize$1(input);
882
+
883
+ if (!phone) {
884
+ return fallback;
885
+ }
886
+
887
+ var apn = this.createAPN(phone, country);
888
+ var formatted = apn.getNumber(format);
889
+
890
+ if (!formatted) {
891
+ country = toCountryISO$1(apn.getRegionCode());
892
+ var nationalNumber = normalizeNational$1(country, phone);
893
+
894
+ if (format === 'national') {
895
+ return nationalNumber;
896
+ }
897
+
898
+ var prefix = '';
899
+ var separator = '';
900
+
901
+ if (format === 'rfc3966') {
902
+ prefix = 'tel:';
903
+ separator = '-';
904
+ }
905
+
906
+ if (format === 'international') {
907
+ separator = ' ';
908
+ }
909
+
910
+ formatted = prefix + getPrefix$1(country);
911
+
912
+ if (nationalNumber) {
913
+ formatted += separator + nationalNumber;
914
+ }
915
+ }
916
+
917
+ return formatted;
918
+ }
919
+
920
+ }
921
+ function usePhoneService$1() {
922
+ var APN = getAPN$1();
923
+ return useMemo(() => new PhoneService$1(APN), [APN]);
924
+ }
925
+
926
+ function useFormattedPhoneNumber$1(input) {
927
+ var {
928
+ format,
929
+ country,
930
+ fallback = ''
931
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
932
+ var phoneService = usePhoneService$1();
933
+ return useMemo(() => {
934
+ if (phoneService.checkPossibility(input) !== 'is-possible') {
935
+ return fallback;
936
+ }
937
+
938
+ return phoneService.format(input, {
939
+ format,
940
+ country,
941
+ fallback
942
+ });
943
+ }, [phoneService, input, format, country, fallback]);
944
+ }
945
+
946
+ var _excluded$5 = ["country", "alt", "className"];
947
+ var useStyles$4 = /*#__PURE__*/makeStyles$1(theme => ({
948
+ root: {
949
+ minHeight: theme.spacing(2),
950
+ minWidth: theme.spacing(2.75)
951
+ }
952
+ }), {
953
+ name: 'SD-PhoneFieldFlag'
954
+ });
955
+ var PhoneFieldFlag$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
956
+ var {
957
+ country,
958
+ alt = country,
959
+ className
960
+ } = _ref,
961
+ props = _objectWithoutProperties(_ref, _excluded$5);
962
+
963
+ var styles = useStyles$4();
964
+
965
+ if (country === 'AC' || country === 'BQ' || country === 'EH' || country === 'TA') {
966
+ return /*#__PURE__*/jsx(Typography$1, {
967
+ ref: ref,
968
+ variant: "h6",
969
+ align: "center",
970
+ component: "span",
971
+ color: "textSecondary",
972
+ className: clsx(styles.root, className),
973
+ children: country
974
+ });
975
+ }
976
+
977
+ return /*#__PURE__*/jsx("img", _objectSpread(_objectSpread({}, props), {}, {
978
+ alt: alt,
979
+ ref: ref,
980
+ className: clsx(styles.root, className),
981
+ src: "https://cdn.jsdelivr.net/gh/madebybowtie/FlagKit@2.2/Assets/SVG/".concat(country, ".svg")
982
+ }));
983
+ });
984
+ if (process.env.NODE_ENV !== "production") PhoneFieldFlag$1.displayName = "PhoneFieldFlag";
985
+
986
+ var _excluded$6 = ["country", "classes"],
987
+ _excluded2$3 = ["flag"];
988
+ var useStyles$5 = /*#__PURE__*/makeStyles$1(theme => ({
989
+ dense: {},
990
+ gutters: {},
991
+ root: {},
992
+ selected: {},
993
+ flag: {
994
+ marginRight: theme.spacing(1)
995
+ }
996
+ }), {
997
+ name: 'SD-PhoneFieldMenuItem'
998
+ });
999
+ var PhoneFieldMenuItem$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
1000
+ var {
1001
+ country,
1002
+ classes
1003
+ } = _ref,
1004
+ props = _objectWithoutProperties(_ref, _excluded$6);
1005
+
1006
+ var _useStyles = useStyles$5({
1007
+ classes
1008
+ }),
1009
+ {
1010
+ flag: flagClassName
1011
+ } = _useStyles,
1012
+ styles = _objectWithoutProperties(_useStyles, _excluded2$3);
1013
+
1014
+ var countryCode = useMemo(() => getCountryCode$1(country), [country]);
1015
+ return /*#__PURE__*/jsxs(MenuItem$1, _objectSpread(_objectSpread({}, props), {}, {
1016
+ ref: ref,
1017
+ button: true,
1018
+ classes: styles,
1019
+ children: [/*#__PURE__*/jsx(PhoneFieldFlag$1, {
1020
+ country: country,
1021
+ className: flagClassName
1022
+ }), formatCountry$1(country), "\xA0", /*#__PURE__*/jsx(Typography$1, {
1023
+ color: "textSecondary",
1024
+ children: countryCode
1025
+ })]
1026
+ }));
1027
+ });
1028
+ if (process.env.NODE_ENV !== "production") PhoneFieldMenuItem$1.displayName = "PhoneFieldMenuItem";
1029
+
1030
+ var useStyles$6 = /*#__PURE__*/makeStyles$1(theme => ({
1031
+ paper: {
1032
+ maxHeight: theme.spacing(30)
1033
+ }
1034
+ }), {
1035
+ name: 'SD-PhoneFieldMenu'
1036
+ });
1037
+ var PhoneFieldMenu$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
1038
+ var {
1039
+ anchorEl,
1040
+ value,
1041
+ onClose,
1042
+ onChange
1043
+ } = _ref;
1044
+ var styles = useStyles$6();
1045
+ return /*#__PURE__*/jsx(Menu$1, {
1046
+ ref: ref,
1047
+ open: !!anchorEl,
1048
+ onClose: onClose,
1049
+ anchorEl: anchorEl,
1050
+ classes: {
1051
+ paper: styles.paper
1052
+ },
1053
+ children: listCountries$1().map(country => [/*#__PURE__*/jsx(PhoneFieldMenuItem$1, {
1054
+ country: country,
1055
+ selected: country === value,
1056
+ onClick: () => {
1057
+ onChange(country);
1058
+ onClose();
1059
+ }
1060
+ }, country), country === 'NZ' && /*#__PURE__*/jsx(Divider$1, {}, "divider")])
1061
+ });
1062
+ });
1063
+ if (process.env.NODE_ENV !== "production") PhoneFieldMenu$1.displayName = "PhoneFieldMenu";
1064
+
1065
+ var useStyles$7 = /*#__PURE__*/makeStyles$1(theme => ({
1066
+ root: {
1067
+ marginLeft: theme.spacing(-1),
1068
+ marginRight: 0
1069
+ },
1070
+ button: {
1071
+ color: Color$1.Blue300,
1072
+ padding: theme.spacing(0.5, 0.5, 0.5, 1),
1073
+ borderRadius: theme.spacing(0.5, 0, 0, 0.5),
1074
+ '&:hover, &:focus': {
1075
+ backgroundColor: Color$1.Blue50
1076
+ }
1077
+ }
1078
+ }), {
1079
+ name: 'SD-PhoneFieldStartAdornment'
1080
+ });
1081
+ var PhoneFieldStartAdornment$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
1082
+ var {
1083
+ country,
1084
+ onClick,
1085
+ isExpanded
1086
+ } = _ref;
1087
+ var styles = useStyles$7();
1088
+ var [title, countryCode] = useMemo(() => {
1089
+ var code = "+".concat(getCountryCode$1(country));
1090
+ return ["".concat(formatCountry$1(country), ": ").concat(code), code];
1091
+ }, [country]);
1092
+ return /*#__PURE__*/jsx(InputAdornment$1, {
1093
+ ref: ref,
1094
+ position: "start",
1095
+ className: styles.root,
1096
+ children: /*#__PURE__*/jsxs(ButtonBase$1, {
1097
+ title: title,
1098
+ onClick: onClick,
1099
+ className: styles.button,
1100
+ "aria-expanded": isExpanded,
1101
+ children: [/*#__PURE__*/jsx(PhoneFieldFlag$1, {
1102
+ country: country
1103
+ }), isExpanded ? /*#__PURE__*/jsx(ArrowDropUp$1, {
1104
+ htmlColor: Color$1.Dark200
1105
+ }) : /*#__PURE__*/jsx(ArrowDropDown$1, {
1106
+ htmlColor: Color$1.Dark200
1107
+ }), /*#__PURE__*/jsx(Typography$1, {
1108
+ color: "textPrimary",
1109
+ children: countryCode
1110
+ })]
1111
+ })
1112
+ });
1113
+ });
1114
+ if (process.env.NODE_ENV !== "production") PhoneFieldStartAdornment$1.displayName = "PhoneFieldStartAdornment";
1115
+
1116
+ var _excluded$7 = ["value", "onBlur", "onFocus", "onChange"],
1117
+ _excluded2$4 = ["label", "fullWidth", "helperText", "suspenseFallback"];
1118
+
1119
+ function normalizeValue$1(value) {
1120
+ return typeof value === 'string' ? value : '';
1121
+ }
1122
+
1123
+ var PhoneField$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
1124
+ var {
1125
+ value: valueProp,
1126
+ onBlur: _onBlur,
1127
+ onFocus: _onFocus,
1128
+ onChange: _onChange
1129
+ } = _ref,
1130
+ props = _objectWithoutProperties(_ref, _excluded$7);
1131
+
1132
+ var rootRef = useRef(null);
1133
+ var inputRef = useRef(null);
1134
+ var [menuAnchor, setMenuAnchor] = useState(null);
1135
+ var phoneService = usePhoneService$1();
1136
+ var createState = useCallback(value => _objectSpread({
1137
+ value
1138
+ }, phoneService.getInfo(value)), [phoneService]);
1139
+ var value = useMemo(() => normalizeValue$1(valueProp), [valueProp]);
1140
+ var [{
1141
+ country,
1142
+ nationalNumber
1143
+ }, setValue] = useState(() => createState(value));
1144
+ var placeholder = useMemo(() => phoneService.APN.getExample(country).getNumber('national'), [country, phoneService.APN]);
1145
+
1146
+ function handleChange(fn, nextCountry, nextNationalNumber) {
1147
+ if (fn) {
1148
+ var nextValue = phoneService.format(nextNationalNumber, {
1149
+ country: nextCountry
1150
+ });
1151
+ setValue({
1152
+ value: nextValue,
1153
+ country: nextCountry,
1154
+ nationalNumber: nextNationalNumber
1155
+ });
1156
+ fn(nextValue);
1157
+ }
1158
+ }
1159
+
1160
+ function handleChangeEvent(fn, _ref2) {
1161
+ var {
1162
+ target: {
1163
+ value: nextValue
1164
+ }
1165
+ } = _ref2;
1166
+
1167
+ if (fn) {
1168
+ handleChange(fn, country, phoneService.format(nextValue, {
1169
+ country,
1170
+ format: 'national'
1171
+ }));
1172
+ }
1173
+ }
1174
+
1175
+ useEffect(() => {
1176
+ setValue(prev => // Ignore `props.value` changes when they were performed from inside.
1177
+ prev.value === value ? prev : createState(value));
1178
+ }, [value, createState]);
1179
+ return /*#__PURE__*/jsxs(Fragment, {
1180
+ children: [/*#__PURE__*/jsx(PhoneFieldMenu$1, {
1181
+ value: country,
1182
+ anchorEl: menuAnchor,
1183
+ onClose: () => {
1184
+ setMenuAnchor(null);
1185
+ },
1186
+ onChange: nextRegion => {
1187
+ handleChange(_onChange, nextRegion, nationalNumber);
1188
+ }
1189
+ }), /*#__PURE__*/jsx(TextField$1, _objectSpread(_objectSpread({}, props), {}, {
1190
+ type: "tel",
1191
+ variant: "outlined",
1192
+ autoComplete: "off",
1193
+ value: nationalNumber,
1194
+ placeholder: placeholder,
1195
+ ref: mergeRefs$1(ref, rootRef),
1196
+ inputRef: inputRef,
1197
+ onBlur: event => {
1198
+ handleChangeEvent(_onBlur, event);
1199
+ },
1200
+ onFocus: event => {
1201
+ handleChangeEvent(_onFocus, event);
1202
+ },
1203
+ onChange: event => {
1204
+ handleChangeEvent(_onChange, event);
1205
+ },
1206
+ InputProps: {
1207
+ startAdornment: /*#__PURE__*/jsx(PhoneFieldStartAdornment$1, {
1208
+ country: country,
1209
+ isExpanded: !!menuAnchor,
1210
+ onClick: () => {
1211
+ var _inputRef$current;
1212
+
1213
+ // `FocusTrap` inside of `Menu` will restore focus to
1214
+ // the last focused element. We want to manually focus input
1215
+ // to trick the `FocusTrap`.
1216
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
1217
+ setMenuAnchor(rootRef.current);
1218
+ }
1219
+ })
1220
+ }
1221
+ }))]
1222
+ });
1223
+ });
1224
+ if (process.env.NODE_ENV !== "production") PhoneField$1.displayName = "PhoneField";
1225
+ var SuspendedPhoneField$1 = /*#__PURE__*/forwardRef((_ref3, ref) => {
1226
+ var {
1227
+ label,
1228
+ fullWidth,
1229
+ helperText,
1230
+ suspenseFallback = /*#__PURE__*/jsx(TextField$1, {
1231
+ disabled: true,
1232
+ label: label,
1233
+ fullWidth: fullWidth,
1234
+ helperText: helperText,
1235
+ placeholder: "Loading\u2026"
1236
+ })
1237
+ } = _ref3,
1238
+ props = _objectWithoutProperties(_ref3, _excluded2$4);
1239
+
1240
+ return /*#__PURE__*/jsx(Suspense, {
1241
+ fallback: suspenseFallback,
1242
+ children: /*#__PURE__*/jsx(PhoneField$1, _objectSpread(_objectSpread({}, props), {}, {
1243
+ ref: ref,
1244
+ label: label,
1245
+ fullWidth: fullWidth,
1246
+ helperText: helperText
1247
+ }))
1248
+ });
1249
+ });
1250
+ if (process.env.NODE_ENV !== "production") SuspendedPhoneField$1.displayName = "SuspendedPhoneField";
1251
+
1252
+ var _excluded$8 = ["phone", "country", "fallback", "format"],
1253
+ _excluded2$5 = ["suspenseFallback"];
1254
+ var PhoneLink$1 = /*#__PURE__*/forwardRef((_ref, ref) => {
1255
+ var {
1256
+ phone,
1257
+ country,
1258
+ fallback,
1259
+ format = 'international'
1260
+ } = _ref,
1261
+ props = _objectWithoutProperties(_ref, _excluded$8);
1262
+
1263
+ var service = usePhoneService$1();
1264
+ var [text, href] = useMemo(() => {
1265
+ if (service.checkPossibility(phone) !== 'is-possible') {
1266
+ return [undefined, undefined];
1267
+ }
1268
+
1269
+ return [service.format(phone, {
1270
+ country,
1271
+ format
1272
+ }), service.format(phone, {
1273
+ country,
1274
+ format: 'rfc3966'
1275
+ })];
1276
+ }, [phone, country, format, service]);
1277
+ return !href ? renderChildren$2(fallback) : /*#__PURE__*/jsx(Link$1, _objectSpread(_objectSpread({}, props), {}, {
1278
+ ref: ref,
1279
+ href: href,
1280
+ children: text
1281
+ }));
1282
+ });
1283
+ if (process.env.NODE_ENV !== "production") PhoneLink$1.displayName = "PhoneLink";
1284
+ var SuspendedPhoneLink$1 = /*#__PURE__*/forwardRef((_ref2, ref) => {
1285
+ var {
1286
+ suspenseFallback = null
1287
+ } = _ref2,
1288
+ props = _objectWithoutProperties(_ref2, _excluded2$5);
1289
+
1290
+ return /*#__PURE__*/jsx(Suspense, {
1291
+ fallback: suspenseFallback,
1292
+ children: /*#__PURE__*/jsx(PhoneLink$1, _objectSpread(_objectSpread({}, props), {}, {
1293
+ ref: ref
1294
+ }))
1295
+ });
1296
+ });
1297
+ if (process.env.NODE_ENV !== "production") SuspendedPhoneLink$1.displayName = "SuspendedPhoneLink";
1298
+
1299
+ var _excluded$9 = ["suspenseFallback"];
1300
+ function PhoneText$1(_ref) {
1301
+ var {
1302
+ phone,
1303
+ country,
1304
+ fallback,
1305
+ format = 'international'
1306
+ } = _ref;
1307
+ var children = useFormattedPhoneNumber$1(phone, {
1308
+ format,
1309
+ country
1310
+ });
1311
+ return renderChildren$2(children || fallback);
1312
+ }
1313
+ function SuspendedPhoneText$1(_ref2) {
1314
+ var {
1315
+ suspenseFallback = null
1316
+ } = _ref2,
1317
+ props = _objectWithoutProperties(_ref2, _excluded$9);
1318
+
1319
+ return /*#__PURE__*/jsx(Suspense, {
1320
+ fallback: suspenseFallback,
1321
+ children: /*#__PURE__*/jsx(PhoneText$1, _objectSpread({}, props))
1322
+ });
1323
+ }
1324
+
1325
+ export { DEFAULT_COUNTRY$1 as DEFAULT_COUNTRY, PhoneField$1 as PhoneField, PhoneLink$1 as PhoneLink, PhoneService$1 as PhoneService, PhoneText$1 as PhoneText, SuspendedPhoneField$1 as SuspendedPhoneField, SuspendedPhoneLink$1 as SuspendedPhoneLink, SuspendedPhoneText$1 as SuspendedPhoneText, formatCountry$1 as formatCountry, getCountryCode$1 as getCountryCode, isCountryISO$1 as isCountryISO, listCountries$1 as listCountries, toCountryISO$1 as toCountryISO, useFormattedPhoneNumber$1 as useFormattedPhoneNumber, usePhoneService$1 as usePhoneService, index as v5 };
650
1326
  //# sourceMappingURL=index.js.map