@zonos/elements 1.5.0 → 1.5.2
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/cjs/{TaxId-Q6aDqqWv.js → TaxId-ChhNwG04.js} +36 -0
- package/dist/cjs/{cart-B6Aty-21.js → cart-BJpqPdFU.js} +100 -64
- package/dist/cjs/{collect-DnrvaXUI.js → collect-CyUttsvB.js} +4 -4
- package/dist/cjs/{debounce-Cd2emZPn.js → debounce-BhgA8_3W.js} +2 -2
- package/dist/cjs/{debounce-vY0QYT6o.js → debounce-DRPMxNew.js} +1 -1
- package/dist/cjs/{getBorderRadius-CyYZw4qq.js → getBorderRadius-CJ_95w3o.js} +1 -1
- package/dist/cjs/{getMissingRequiredShippingFields-D03ICqss.js → getMissingRequiredShippingFields-DEbNbRAZ.js} +1 -1
- package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
- package/dist/cjs/{hasInclusivePrice-CPCoVeU3.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
- package/dist/cjs/index.cjs.js +116 -13
- package/dist/cjs/{invoice-Cj8W7NW0.js → invoice-DzRkkpLu.js} +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-BzNeXeDe.js → localization-BhNVhLZs.js} +725 -89
- package/dist/cjs/{paypal-CuKshRmZ.js → paypal-DCSqbdjW.js} +5 -5
- package/dist/cjs/{placeTestOrder-7czjwkjm.js → placeTestOrder-Bkip4PUT.js} +3 -3
- package/dist/cjs/{renderCheckoutCurrency-BH8t2b2x.js → renderCheckoutCurrency-BDvEZ3Hv.js} +2 -2
- package/dist/cjs/shouldRenderShortAddressCodeInput-gpu_bMfp.js +21 -0
- package/dist/cjs/{shouldShowLanguageSelect-yAbtCmd8.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
- package/dist/cjs/{submitGtag-D79e8u6s.js → submitGtag-D4sB7w4z.js} +2 -2
- package/dist/cjs/{throttle-zSVRQLC0.js → taxIdFields-e4OCgr8K.js} +57 -2
- package/dist/cjs/taxIdRules-BBj8kQxJ.js +58 -0
- package/dist/cjs/{updateCheckoutSessionAttributes-jMtfOL2m.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +2 -2
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +26 -31
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-address_4.cjs.entry.js +28 -31
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +8 -7
- package/dist/cjs/zonos-badge.cjs.entry.js +1 -1
- package/dist/cjs/zonos-banner.cjs.entry.js +1 -1
- package/dist/cjs/zonos-button_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +9 -8
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +91 -86
- package/dist/cjs/zonos-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +15 -14
- package/dist/cjs/zonos-collapse.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +7 -6
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +13 -12
- package/dist/cjs/zonos-collect.cjs.entry.js +10 -9
- package/dist/cjs/zonos-controller.cjs.entry.js +10 -9
- package/dist/cjs/zonos-country-flag.cjs.entry.js +3 -3
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +5 -5
- package/dist/cjs/zonos-hello.cjs.entry.js +5 -5
- package/dist/cjs/zonos-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +9 -8
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +13 -12
- package/dist/cjs/zonos-invoice.cjs.entry.js +10 -9
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-logo.cjs.entry.js +1 -1
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +8 -7
- package/dist/cjs/zonos-shipping-rich-radio.cjs.entry.js +2 -2
- package/dist/cjs/zonos-stripe-input.cjs.entry.js +2 -2
- package/dist/cjs/zonos-text.cjs.entry.js +1 -1
- package/dist/cjs/zonos-v-stack.cjs.entry.js +1 -1
- package/dist/cjs/{zonosStore-Bx9jK82G.js → zonosStore-CDV83QyK.js} +2 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +4 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.js +12 -4
- package/dist/collection/components/main/zonos-controller.js +3 -2
- package/dist/collection/components/store/checkout/cart.js +3 -2
- package/dist/collection/components/store/checkout/stripe.js +20 -21
- package/dist/collection/components/store/storageStore.js +7 -6
- package/dist/collection/components/store/translationStore/strings.arabic.js +35 -2
- package/dist/collection/components/store/translationStore/strings.base.js +35 -2
- package/dist/collection/components/store/translationStore/strings.chinese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.danish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.dutch.js +35 -2
- package/dist/collection/components/store/translationStore/strings.french.js +35 -2
- package/dist/collection/components/store/translationStore/strings.german.js +35 -2
- package/dist/collection/components/store/translationStore/strings.hebrew.js +35 -2
- package/dist/collection/components/store/translationStore/strings.indonesian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.italian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.japanese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.korean.js +35 -2
- package/dist/collection/components/store/translationStore/strings.norwegian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.polish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.portuguese.js +35 -2
- package/dist/collection/components/store/translationStore/strings.russian.js +35 -2
- package/dist/collection/components/store/translationStore/strings.spanish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.swedish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.turkish.js +35 -2
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +35 -2
- package/dist/collection/components/store/zonosStore.js +2 -1
- package/dist/collection/components/stripe/zonos-address/zonos-address.css +5 -0
- package/dist/collection/components/stripe/zonos-address/zonos-address.js +37 -22
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.css +5 -0
- package/dist/collection/components/stripe/zonos-custom-address/zonos-custom-address.js +34 -21
- package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +24 -35
- package/dist/collection/components/utils/checkout/getCheckoutTaxIdPayload.js +16 -0
- package/dist/collection/components/utils/checkout/getTaxIdFieldState.js +26 -0
- package/dist/collection/components/utils/checkout/resolveTaxIdSelection.js +23 -0
- package/dist/collection/components/utils/checkout/shouldRenderTaxIdInput.js +7 -11
- package/dist/collection/components/utils/checkout/taxIdFields.js +29 -0
- package/dist/collection/components/utils/handleFetch.js +19 -9
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
- package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
- package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
- package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
- package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
- package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
- package/dist/collection/components/utils/safeStorage.js +39 -0
- package/dist/collection/components/utils/taxId/taxIdRules.js +44 -0
- package/dist/collection/components/utils/taxIdValidationResult.js +57 -58
- package/dist/collection/index.js +1 -0
- package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
- package/dist/collection/scripts/_zonosBase.js +6 -2
- package/dist/collection/types/checkout/TaxId.js +31 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
- package/dist/collection/types/generated/graphql.internal.types.js +215 -1
- package/dist/esm/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +32 -1
- package/dist/esm/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +100 -65
- package/dist/esm/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +4 -4
- package/dist/esm/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +1 -1
- package/dist/esm/{debounce-CrmpwbEE.js → debounce-DWqMT4lo.js} +2 -2
- package/dist/esm/{getBorderRadius-DYfkeXdx.js → getBorderRadius-BiGd45jw.js} +1 -1
- package/dist/esm/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +1 -1
- package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
- package/dist/esm/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm/index.js +106 -13
- package/dist/esm/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-BIh-4pc_.js → localization-CXHiWcJp.js} +725 -89
- package/dist/esm/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +5 -5
- package/dist/esm/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +3 -3
- package/dist/esm/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +2 -2
- package/dist/esm/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +19 -0
- package/dist/esm/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +2 -2
- package/dist/esm/taxIdFields-BUKnHMaL.js +139 -0
- package/dist/esm/taxIdRules-xYlx7ZXW.js +47 -0
- package/dist/esm/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +2 -2
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +24 -29
- package/dist/esm/zonos-address-display_2.entry.js +4 -4
- package/dist/esm/zonos-address_4.entry.js +26 -29
- package/dist/esm/zonos-airwallex-payment.entry.js +8 -7
- package/dist/esm/zonos-badge.entry.js +1 -1
- package/dist/esm/zonos-banner.entry.js +1 -1
- package/dist/esm/zonos-button_3.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +9 -8
- package/dist/esm/zonos-cart-items_12.entry.js +90 -85
- package/dist/esm/zonos-checkbox_2.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +15 -14
- package/dist/esm/zonos-collapse.entry.js +1 -1
- package/dist/esm/zonos-collect-cart-items_3.entry.js +7 -6
- package/dist/esm/zonos-collect-finish_6.entry.js +13 -12
- package/dist/esm/zonos-collect.entry.js +10 -9
- package/dist/esm/zonos-controller.entry.js +10 -9
- package/dist/esm/zonos-country-flag.entry.js +3 -3
- package/dist/esm/zonos-country-select_4.entry.js +4 -4
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +5 -5
- package/dist/esm/zonos-hello.entry.js +5 -5
- package/dist/esm/zonos-input.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +9 -8
- package/dist/esm/zonos-invoice-finish_5.entry.js +13 -12
- package/dist/esm/zonos-invoice.entry.js +10 -9
- package/dist/esm/zonos-language-select_2.entry.js +3 -3
- package/dist/esm/zonos-logo.entry.js +1 -1
- package/dist/esm/zonos-policy-consent_2.entry.js +8 -7
- package/dist/esm/zonos-shipping-rich-radio.entry.js +2 -2
- package/dist/esm/zonos-stripe-input.entry.js +2 -2
- package/dist/esm/zonos-text.entry.js +1 -1
- package/dist/esm/zonos-v-stack.entry.js +1 -1
- package/dist/esm/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +2 -1
- package/dist/esm-es5/{TaxId-Cye-evFK.js → TaxId-DMIgN_sT.js} +2 -1
- package/dist/esm-es5/{cart-BoQp8Ema.js → cart-BS5mSI8x.js} +42 -31
- package/dist/esm-es5/{collect-Eo4gtyql.js → collect-B9ZxDDl7.js} +1 -1
- package/dist/esm-es5/{debounce-BR3PaG8X.js → debounce-DHj2iHA1.js} +7 -7
- package/dist/esm-es5/debounce-DWqMT4lo.js +1 -0
- package/dist/esm-es5/getBorderRadius-BiGd45jw.js +8 -0
- package/dist/esm-es5/{getMissingRequiredShippingFields-Ks6_tpjn.js → getMissingRequiredShippingFields-BkEV865q.js} +3 -3
- package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
- package/dist/esm-es5/{hasInclusivePrice-CbEfIhI5.js → hasInclusivePrice-zSvDReDb.js} +1 -1
- package/dist/esm-es5/index.js +30 -12
- package/dist/esm-es5/{invoice-S1KahJ_Z.js → invoice-6iTuS6ek.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-CXHiWcJp.js +345 -0
- package/dist/esm-es5/{paypal-DNfvnuUU.js → paypal-BE_NVBoy.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CQaMKFOg.js → placeTestOrder-BXA9K9Iy.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-C2Tw73uR.js → renderCheckoutCurrency-KMa4HlAf.js} +1 -1
- package/dist/esm-es5/shouldRenderShortAddressCodeInput-Bc8k2vN0.js +8 -0
- package/dist/esm-es5/{shouldShowLanguageSelect-CCD7gpSY.js → shouldShowLanguageSelect-BI_ApEsQ.js} +1 -1
- package/dist/esm-es5/{submitGtag-df9AQ2zL.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm-es5/taxIdFields-BUKnHMaL.js +46 -0
- package/dist/esm-es5/taxIdRules-xYlx7ZXW.js +6 -0
- package/dist/esm-es5/{updateCheckoutSessionAttributes-4Jq6V4pO.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +253 -254
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +8 -9
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-badge.entry.js +1 -1
- package/dist/esm-es5/zonos-banner.entry.js +1 -1
- package/dist/esm-es5/zonos-button_3.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +6 -6
- package/dist/esm-es5/zonos-cart-items_12.entry.js +137 -136
- package/dist/esm-es5/zonos-checkbox_2.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +3 -3
- package/dist/esm-es5/zonos-collapse.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +6 -6
- package/dist/esm-es5/zonos-controller.entry.js +5 -5
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +2 -2
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-input.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +2 -2
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +3 -3
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-logo.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/esm-es5/zonos-shipping-rich-radio.entry.js +1 -1
- package/dist/esm-es5/zonos-stripe-input.entry.js +1 -1
- package/dist/esm-es5/zonos-text.entry.js +1 -1
- package/dist/esm-es5/zonos-v-stack.entry.js +1 -1
- package/dist/esm-es5/{zonosStore-msUlqmSD.js → zonosStore-BXP9FvIt.js} +1 -1
- package/dist/scripts/index.d.ts +103 -1
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-customer-info/zonos-customer-info.d.ts +4 -0
- package/dist/types/components/store/checkout/stripe.d.ts +9 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.base.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.danish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.french.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.german.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.italian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.korean.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.polish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.russian.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +34 -1
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +34 -1
- package/dist/types/components/store/zonosStore.d.ts +2 -1
- package/dist/types/components/stripe/zonos-address/zonos-address.d.ts +4 -1
- package/dist/types/components/stripe/zonos-custom-address/zonos-custom-address.d.ts +4 -1
- package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
- package/dist/types/components/utils/checkout/getCheckoutTaxIdPayload.d.ts +6 -0
- package/dist/types/components/utils/checkout/getTaxIdFieldState.d.ts +18 -0
- package/dist/types/components/utils/checkout/resolveTaxIdSelection.d.ts +12 -0
- package/dist/types/components/utils/checkout/shouldRenderTaxIdInput.d.ts +2 -1
- package/dist/types/components/utils/checkout/taxIdFields.d.ts +11 -0
- package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
- package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
- package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
- package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
- package/dist/types/components/utils/safeStorage.d.ts +4 -0
- package/dist/types/components/utils/taxId/taxIdRules.d.ts +37 -0
- package/dist/types/components/utils/taxIdValidationResult.d.ts +8 -2
- package/dist/types/components.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
- package/dist/types/types/checkout/TaxId.d.ts +45 -0
- package/dist/types/types/checkout/api/CalculateLandedCost.d.ts +11 -0
- package/dist/types/types/checkout/api/CreateParty.d.ts +2 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
- package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
- package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
- package/dist/types/types/generated/graphql.internal.types.ts +341 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +5 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-08b01c96.entry.js +1 -0
- package/dist/zonos-elements/{p-c961caaf.entry.js → p-0909ef77.entry.js} +1 -1
- package/dist/zonos-elements/{p-23352709.system.entry.js → p-13015d34.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-6c41b00c.entry.js → p-13d5b2f9.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b80aff2.system.entry.js → p-150047b3.system.entry.js} +25 -25
- package/dist/zonos-elements/p-1986cc37.entry.js +1 -0
- package/dist/zonos-elements/{p-CBx5nYet.system.js → p-1OG3IJgY.system.js} +1 -1
- package/dist/zonos-elements/{p-d3d0656a.entry.js → p-1a5acbcd.entry.js} +1 -1
- package/dist/zonos-elements/{p-756d303f.system.entry.js → p-20eb00de.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9c33f7ed.system.entry.js → p-30bf4700.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d168023b.entry.js → p-3466bcba.entry.js} +1 -1
- package/dist/zonos-elements/p-383343c7.entry.js +1 -0
- package/dist/zonos-elements/{p-06030d3b.system.entry.js → p-3a506614.system.entry.js} +54 -54
- package/dist/zonos-elements/p-43c0ebe9.entry.js +1 -0
- package/dist/zonos-elements/{p-acd50b0b.entry.js → p-4612facd.entry.js} +1 -1
- package/dist/zonos-elements/{p-244e0302.system.entry.js → p-4715045c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4b65f192.entry.js +1 -0
- package/dist/zonos-elements/{p-5967a1c1.system.entry.js → p-573a4e7c.system.entry.js} +6 -6
- package/dist/zonos-elements/p-59fc32af.entry.js +1 -0
- package/dist/zonos-elements/{p-d82fd8a9.system.entry.js → p-5a296dbc.system.entry.js} +117 -116
- package/dist/zonos-elements/{p-193d9722.entry.js → p-61312d5b.entry.js} +1 -1
- package/dist/zonos-elements/{p-6abec43f.system.entry.js → p-68325c5a.system.entry.js} +4 -4
- package/dist/zonos-elements/{p-0b81f8b9.system.entry.js → p-6db7317a.system.entry.js} +6 -6
- package/dist/zonos-elements/{p-51400242.system.entry.js → p-709d1561.system.entry.js} +3 -3
- package/dist/zonos-elements/p-71d29603.entry.js +1 -0
- package/dist/zonos-elements/{p-7bd99479.system.entry.js → p-7214c953.system.entry.js} +21 -21
- package/dist/zonos-elements/p-74659d88.entry.js +1 -0
- package/dist/zonos-elements/{p-55916c90.entry.js → p-7f1bea9b.entry.js} +1 -1
- package/dist/zonos-elements/{p-0fca452b.entry.js → p-7fe83919.entry.js} +1 -1
- package/dist/zonos-elements/{p-1c150f26.entry.js → p-821e413a.entry.js} +1 -1
- package/dist/zonos-elements/{p-c403f004.system.entry.js → p-82e45d0c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1409de3b.system.entry.js → p-88e20e99.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-195f6e38.system.entry.js → p-89a3c4db.system.entry.js} +1 -1
- package/dist/zonos-elements/p-8ac26831.entry.js +1 -0
- package/dist/zonos-elements/{p-a40fd99b.system.entry.js → p-8f9f859f.system.entry.js} +39 -40
- package/dist/zonos-elements/{p-92fe9a1f.system.entry.js → p-902cca23.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0a4a7742.system.entry.js → p-93860183.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b5882fbb.system.entry.js → p-9449b4f4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-31043c2e.system.entry.js → p-96b250d8.system.entry.js} +298 -299
- package/dist/zonos-elements/p-97729873.entry.js +1 -0
- package/dist/zonos-elements/{p-1bac5ac1.system.entry.js → p-990fcf81.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7f031592.system.entry.js → p-9b3668a4.system.entry.js} +155 -155
- package/dist/zonos-elements/{p-249c1ee1.system.entry.js → p-9df31243.system.entry.js} +3 -3
- package/dist/zonos-elements/p-BD-9rD53.js +1 -0
- package/dist/zonos-elements/p-BI6VAB5B.js +1 -0
- package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
- package/dist/zonos-elements/p-BJ_kE5rM.js +1 -0
- package/dist/zonos-elements/{p-Be3Hpms1.system.js → p-BKUlQxBd.system.js} +1 -1
- package/dist/zonos-elements/p-BUfCTQXY.system.js +528 -0
- package/dist/zonos-elements/{p-CZD8WvyY.system.js → p-BnQyot7Y.system.js} +23 -23
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +2 -2
- package/dist/zonos-elements/{p-0mGRBGcf.js → p-C-zdj7MK.js} +1 -1
- package/dist/zonos-elements/p-C5fs3rIR.js +1 -0
- package/dist/zonos-elements/{p-sz4L-ZnB.js → p-CJmWr75U.js} +1 -1
- package/dist/zonos-elements/{p-XDxdMlQl.system.js → p-CMneHjck.system.js} +15 -15
- package/dist/zonos-elements/p-CP7KnfR3.system.js +245 -0
- package/dist/zonos-elements/p-CVRbGFV3.js +1 -0
- package/dist/zonos-elements/p-CYxMfUL7.system.js +1 -0
- package/dist/zonos-elements/p-Cl5yV0ak.js +1 -0
- package/dist/zonos-elements/{p-kaOxUR9u.system.js → p-Cp1IAJvW.system.js} +5 -5
- package/dist/zonos-elements/{p-W82paT5F.js → p-CqB9AfBf.js} +1 -1
- package/dist/zonos-elements/p-CzKlS3E-.system.js +6 -0
- package/dist/zonos-elements/p-D-Lnf8mS.system.js +345 -0
- package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
- package/dist/zonos-elements/{p-c9QtIdJX.js → p-D4xpkSsK.js} +1 -1
- package/dist/zonos-elements/p-DATNIakn.js +1 -0
- package/dist/zonos-elements/{p-D4MevhAL.system.js → p-DC1OPJDq.system.js} +3 -3
- package/dist/zonos-elements/{p-8PPEbm_0.system.js → p-DIab60nK.system.js} +12 -12
- package/dist/zonos-elements/p-DKnphvmJ.js +1 -0
- package/dist/zonos-elements/{p-Cye-evFK.js → p-DMIgN_sT.js} +1 -1
- package/dist/zonos-elements/{p-BuU_p5DP.system.js → p-DTgUqgwV.system.js} +2 -2
- package/dist/zonos-elements/p-DW7I0zOF.js +1 -0
- package/dist/zonos-elements/{p-DoEHepOc.system.js → p-DXlojp_Y.system.js} +1 -1
- package/dist/zonos-elements/p-DqVePqqx.system.js +8 -0
- package/dist/zonos-elements/{p-B4Ufchqh.system.js → p-DrS-0mk7.system.js} +3 -3
- package/dist/zonos-elements/{p-7abqRc9V.js → p-DrbN3rPL.js} +2 -2
- package/dist/zonos-elements/{p-Cby4EkFu.system.js → p-DsBuZ6ob.system.js} +2 -1
- package/dist/zonos-elements/{p-DI2vXnXc.system.js → p-Dv5a-V6w.system.js} +1 -1
- package/dist/zonos-elements/p-Dwg61Ft_.js +1 -0
- package/dist/zonos-elements/{p-474e8a92.system.entry.js → p-a1022808.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17c7ea4a.system.entry.js → p-a3c147d2.system.entry.js} +3 -3
- package/dist/zonos-elements/p-aK18R41t.js +1 -0
- package/dist/zonos-elements/{p-83aa1c8c.entry.js → p-ad04bba2.entry.js} +1 -1
- package/dist/zonos-elements/p-af4ad54b.entry.js +1 -0
- package/dist/zonos-elements/p-af741506.entry.js +1 -0
- package/dist/zonos-elements/{p-a938c174.entry.js → p-b51010b9.entry.js} +1 -1
- package/dist/zonos-elements/{p-6db7c0b1.system.entry.js → p-b540c636.system.entry.js} +2 -2
- package/dist/zonos-elements/p-bac94956.entry.js +1 -0
- package/dist/zonos-elements/{p-69c3e367.system.entry.js → p-bb1b414a.system.entry.js} +9 -9
- package/dist/zonos-elements/{p-b79036fc.entry.js → p-bfa9e32a.entry.js} +1 -1
- package/dist/zonos-elements/{p-dfc87b10.system.entry.js → p-c33b8f6a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-cf6bf7a4.entry.js +1 -0
- package/dist/zonos-elements/{p-CEK_Wk6v.system.js → p-dJcbnNlE.system.js} +1 -1
- package/dist/zonos-elements/p-db40b9c3.entry.js +1 -0
- package/dist/zonos-elements/p-dd003161.entry.js +1 -0
- package/dist/zonos-elements/{p-2603dce0.entry.js → p-e216cc8c.entry.js} +1 -1
- package/dist/zonos-elements/p-e374aaa4.entry.js +1 -0
- package/dist/zonos-elements/{p-155ed3d3.system.entry.js → p-e43470f7.system.entry.js} +21 -21
- package/dist/zonos-elements/p-ebc7ea54.system.entry.js +13 -0
- package/dist/zonos-elements/{p-11defdca.system.entry.js → p-f2ed52bc.system.entry.js} +8 -8
- package/dist/zonos-elements/{p-d4d2b39e.entry.js → p-fddf3556.entry.js} +1 -1
- package/dist/zonos-elements/p-gEViRqvf.js +1 -0
- package/dist/zonos-elements/{p-BpDCLBwW.js → p-n5PZKz1k.js} +1 -1
- package/dist/zonos-elements/{p-C_z9WL8a.js → p-r-YGHhLa.js} +1 -1
- package/dist/zonos-elements/{p-XqkqjeNV.system.js → p-yv7ekcdG.system.js} +2 -2
- package/dist/zonos-elements/{p-DQZncB2d.system.js → p-zsTASoh2.system.js} +3 -3
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/shouldRenderTaxIdInput-TxekHCp7.js +0 -43
- package/dist/esm/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -40
- package/dist/esm/throttle-Cvlvb-dm.js +0 -85
- package/dist/esm-es5/debounce-CrmpwbEE.js +0 -1
- package/dist/esm-es5/getBorderRadius-DYfkeXdx.js +0 -8
- package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
- package/dist/esm-es5/localization-BIh-4pc_.js +0 -348
- package/dist/esm-es5/shouldRenderTaxIdInput-CKyZ6Zni.js +0 -17
- package/dist/esm-es5/throttle-Cvlvb-dm.js +0 -46
- package/dist/zonos-elements/p-06fe2939.entry.js +0 -1
- package/dist/zonos-elements/p-24f3c547.entry.js +0 -1
- package/dist/zonos-elements/p-30b3c9d3.entry.js +0 -1
- package/dist/zonos-elements/p-39ee1558.entry.js +0 -1
- package/dist/zonos-elements/p-3a2da031.entry.js +0 -1
- package/dist/zonos-elements/p-4679f0ec.entry.js +0 -1
- package/dist/zonos-elements/p-4806b264.system.entry.js +0 -13
- package/dist/zonos-elements/p-5873ab8e.entry.js +0 -1
- package/dist/zonos-elements/p-725e29bb.entry.js +0 -1
- package/dist/zonos-elements/p-BGktDPwA.system.js +0 -1
- package/dist/zonos-elements/p-Bi-s0fp_.system.js +0 -17
- package/dist/zonos-elements/p-CFbfEmjN.js +0 -1
- package/dist/zonos-elements/p-CUaf1cEg.js +0 -1
- package/dist/zonos-elements/p-CXxvn4GX.system.js +0 -227
- package/dist/zonos-elements/p-CcJF6xhQ.js +0 -1
- package/dist/zonos-elements/p-Cxuiqv1I.js +0 -1
- package/dist/zonos-elements/p-D-bZg-Pc.js +0 -1
- package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
- package/dist/zonos-elements/p-DOD2I44l.system.js +0 -348
- package/dist/zonos-elements/p-DS-qw_qc.system.js +0 -517
- package/dist/zonos-elements/p-DZ2mevDK.js +0 -1
- package/dist/zonos-elements/p-DnjGkbEy.js +0 -1
- package/dist/zonos-elements/p-FRWZayxL.js +0 -1
- package/dist/zonos-elements/p-Mrz_lnC1.js +0 -1
- package/dist/zonos-elements/p-ad9ff14c.entry.js +0 -1
- package/dist/zonos-elements/p-bb3546c0.entry.js +0 -1
- package/dist/zonos-elements/p-c1cbfdba.entry.js +0 -1
- package/dist/zonos-elements/p-c47ce656.entry.js +0 -1
- package/dist/zonos-elements/p-c9d5d8f1.entry.js +0 -1
- package/dist/zonos-elements/p-clDfq9AL.js +0 -1
- package/dist/zonos-elements/p-d74bc3e8.entry.js +0 -1
- package/dist/zonos-elements/p-d8b312e5.entry.js +0 -1
- package/dist/zonos-elements/p-db87b0dd.entry.js +0 -1
- package/dist/zonos-elements/p-defc2d18.entry.js +0 -1
- package/dist/zonos-elements/p-rVp8hgWw.js +0 -1
- package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,r,
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function d(e){try{a(o.next(e))}catch(e){i(e)}}function s(e){try{a(o["throw"](e))}catch(e){i(e)}}function a(e){e.done?r(e.value):n(e.value).then(d,s)}a((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,d=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return d.next=s(0),d["throw"]=s(1),d["return"]=s(2),typeof Symbol==="function"&&(d[Symbol.iterator]=function(){return this}),d;function s(e){return function(t){return a([e,t])}}function a(s){if(o)throw new TypeError("Generator is already executing.");while(d&&(d=0,s[0]&&(r=0)),r)try{if(o=1,n&&(i=s[0]&2?n["return"]:s[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;if(n=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:r.label++;return{value:s[1],done:false};case 5:r.label++;n=s[1];s=[0];continue;case 7:s=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(s[0]===6&&r.label<i[1]){r.label=i[1];i=s;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(s);break}if(i[2])r.ops.pop();r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e];n=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++){if(i||!(o in t)){if(!i)i=Array.prototype.slice.call(t,0,o);i[o]=t[o]}}return e.concat(i||Array.prototype.slice.call(t))};import{r as registerInstance,d as createEvent,h,a as Host,g as getElement}from"./index-_lt63o7c.js";import{t as translate,s as storageStore,z as storageStoreOnChange,l as localizationStore}from"./localization-CXHiWcJp.js";import{z as zonosStore,e as getShouldRequirePeruTaxId,a as zonosStoreFontFamily}from"./zonosStore-BXP9FvIt.js";import{M as MIN_POSTAL_CODE_LENGTH}from"./getMissingRequiredShippingFields-BkEV865q.js";import{c as classes}from"./classes-BJHSB96f.js";import{U as extractName,b as stripeStore,w as stripeStorePrefetchLandedCost,t as trackConversionEvent}from"./cart-BS5mSI8x.js";import{R as RemoveIcon$1}from"./RemoveIcon-C2QMVeWW.js";import{i as isTextContainsNonLatinChars,c as containsNonLatinChars}from"./containsNonLatinChars-C04AWRC2.js";import{g as getBorderRadius}from"./getBorderRadius-BiGd45jw.js";import{t as throttle,r as renderTaxIdFields}from"./taxIdFields-BUKnHMaL.js";import{i as isCheckoutMobile}from"./handleFetch-BFVO7oAR.js";import{s as shouldRenderShortAddressCodeInput}from"./shouldRenderShortAddressCodeInput-Bc8k2vN0.js";import{l as log}from"./VarianceTest-BJmZPrZl.js";import{i as inheritAriaAttributes,a as inheritAttributes}from"./helpers-DJIdCwJ5.js";import{i as isDarkColor}from"./isDarkColor-YdrG78th.js";import"./taxIdRules-xYlx7ZXW.js";import"./TaxId-DMIgN_sT.js";import"./debounce-DHj2iHA1.js";import"./ShortAddressCode-nJ6oI8-n.js";var zonosAddressCompletionDialogCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--body{padding:0 24px;position:relative}:host .zonos--dialog-header{margin-bottom:24px;position:-webkit-sticky;position:sticky;padding-top:24px;top:0;z-index:11;background:var(--zonos-elements-gray-0)}:host .zonos--dialog-title{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;margin-bottom:12px}:host .zonos--group{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;padding-bottom:5px;gap:20px;-ms-scroll-chaining:chained;overscroll-behavior:auto}:host .zonos--selected-address{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:8px}:host .zonos--completion-fields{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:16px}:host .zonos--completion-name-row{display:-ms-flexbox;display:flex;gap:8px}:host .zonos--completion-name-row zonos-input{-ms-flex:1;flex:1}:host .zonos--group-btn{position:-webkit-sticky;position:sticky;padding:24px 0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:end;background:var(--zonos-elements-gray-0);z-index:11}:host .zonos--group-btn .zonos--button-wrapper{display:-ms-flexbox;display:flex;gap:8px}:host(.mobile) .zonos--completion-name-row{-ms-flex-direction:column;flex-direction:column}:host(.mobile) .zonos--button-wrapper{-ms-flex-direction:column;flex-direction:column;width:100%}:host(.mobile) .zonos--button-wrapper zonos-button{width:100%}:host(.mobile) .zonos--button-wrapper .zonos--cancel-btn{-ms-flex-order:2;order:2}:host(.mobile) .zonos--button-wrapper .zonos--submit-btn{-ms-flex-order:1;order:1}"};var ZonosAddressCompletionDialog=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.closeCompletionDialog=createEvent(this,"closeCompletionDialog",7);this.completionSubmit=createEvent(this,"completionSubmit",7);
|
|
2
2
|
/**
|
|
3
3
|
* Whether or not the continue button is loading
|
|
4
4
|
*/this.continueLoading=false;
|
|
@@ -21,11 +21,11 @@ var __awaiter=this&&this.__awaiter||function(e,t,r,n){function o(e){return e ins
|
|
|
21
21
|
* A captured field is valid when it has a value. Postal code additionally enforces the same
|
|
22
22
|
* minimum length as the landed-cost readiness / detection check, so the dialog can't emit a
|
|
23
23
|
* too-short postal code that would still be considered "missing" downstream.
|
|
24
|
-
*/this.isFieldValid=function(e){var r,n
|
|
24
|
+
*/this.isFieldValid=function(e){var r,o,n;if(e==="postal_code"){return((o=(r=t.values.postal_code)===null||r===void 0?void 0:r.trim().length)!==null&&o!==void 0?o:0)>=MIN_POSTAL_CODE_LENGTH}return!!((n=t.values[e])===null||n===void 0?void 0:n.trim())};this.getFieldError=function(e){return t.showError&&!t.isFieldValid(e)};this.updateValue=function(e,r){var o;t.values=Object.assign(Object.assign({},t.values),(o={},o[e]=r,o));
|
|
25
25
|
// Once the customer starts fixing the fields, re-evaluate whether errors remain
|
|
26
26
|
if(t.showError){t.showError=!t.isComplete()}};this.isComplete=function(){return t.missingFields.every((function(e){
|
|
27
27
|
// A missing last name also requires a first name (both are edited together).
|
|
28
|
-
if(e.key==="lastName"){return t.isFieldValid("firstName")&&t.isFieldValid("lastName")}return t.isFieldValid(e.key)}))};this.submitHandler=function(){if(!t.isComplete()){t.showError=true;return}t.completionSubmit.emit(t.values)};this.renderInput=function(e){var r=e.key,
|
|
28
|
+
if(e.key==="lastName"){return t.isFieldValid("firstName")&&t.isFieldValid("lastName")}return t.isFieldValid(e.key)}))};this.submitHandler=function(){if(!t.isComplete()){t.showError=true;return}t.completionSubmit.emit(t.values)};this.renderInput=function(e){var r=e.key,o=e.label;return h("zonos-input",{class:"zonos--completion-input zonos--completion-".concat(r),inputLabel:o,inputValue:t.values[r]||"",isError:t.getFieldError(r),onInputChange:function(e){return t.updateValue(r,e.detail)}})};this.renderField=function(e,r){if(!t.isFieldMissing(e)){return null}return t.renderInput({key:e,label:r})};
|
|
29
29
|
/**
|
|
30
30
|
* When the last name is missing, render both first and last name inputs so the customer can
|
|
31
31
|
* correct the full name together (Link's single name input often yields only a first name).
|
|
@@ -37,19 +37,19 @@ if(e.key==="lastName"){return t.isFieldValid("firstName")&&t.isFieldValid("lastN
|
|
|
37
37
|
*/
|
|
38
38
|
// Only reset on open, not on `shippingAddress`: the parent rebuilds that prop object on
|
|
39
39
|
// every render, and watching it would wipe in-progress input while the dialog is open.
|
|
40
|
-
e.prototype.watchDialogOpen=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(
|
|
40
|
+
e.prototype.watchDialogOpen=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r;return __generator(this,(function(o){switch(o.label){case 0:if(!e)return[3/*break*/,2];
|
|
41
41
|
// Wait for shippingAddress prop to be updated before resetting the values
|
|
42
42
|
return[4/*yield*/,new Promise((function(e){return setTimeout(e,100)}))];case 1:
|
|
43
43
|
// Wait for shippingAddress prop to be updated before resetting the values
|
|
44
|
-
|
|
44
|
+
o.sent();r=extractName({name:(t=this.shippingAddress)===null||t===void 0?void 0:t.name}).firstName;this.values=this.isFieldMissing("lastName")?{firstName:r}:{};this.showError=false;o.label=2;case 2:return[2/*return*/]}}))}))};e.prototype.render=function(){var e=this;var t=this.submitBtnColor||zonosStore.appearance.colorSecondary;
|
|
45
45
|
// dialog background is white, so a white button needs an outline to stay visible
|
|
46
46
|
var r=t==="#ffffff"?"outline":this.submitBtnType||"standard";return h(Host,{key:"9a89376022ebd8f5793882fb13a3502deca001f8",class:classes(["zonos--address-completion-dialog zonos--elements",this.isMobile&&"mobile"])},h("zonos-dialog",{key:"00ff3912a7bf8d021441440f0de2825b49f7b78e",isLoading:false,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return e.closeCompletionDialog.emit()},open:this.dialogOpen,width:"568px"},h("div",{key:"1ba1cd333bd1f362a77f1f114ac50c309ed5ccd6",class:"zonos--body"},h("div",{key:"ccf9f54ff4b26e5443ff5c8276e5c5d36aac332b",class:"zonos--dialog-header"},h("div",{key:"01e073aa559c4040a6599aefb3bf8cb967928929",class:"zonos--dialog-title"},h("zonos-text",{key:"8472a72f6274646bb87d150c82722f93c861ae72",type:"title"},translate("Complete your shipping address")),h("zonos-button",{key:"e9a6c2cbc3d64bf87e94850c1126119687f75e7d",class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon$1}),noBackground:true,onClick:function(){return e.closeCompletionDialog.emit()},title:"Close checkout dialog"})),h("zonos-text",{key:"c9ff785b746810f0c266071ee9a3f433ad645a2b"},translate("This saved address is missing information required to ship internationally. Please add the details below."))),h("div",{key:"86e2b0da7dbcd1370b80fc8c53e8a7de4c11ed74",class:"zonos--group"},h("div",{key:"1542bb7f0b9df16f5ce36d38dc9408a1b3e836a7",class:"zonos--selected-address"},h("zonos-text",{key:"2572e3e44a9c81f6694e4939de39951ec659c8fa",class:"zonos--selected-label",type:"semiBoldLabel"},translate("Selected address")),h("zonos-address-display",{key:"8781622b3d057cfbdba59e13d5fabf76f3a7a7dd",addressType:"shipping",currentAddress:this.shippingAddress})),h("div",{key:"ac3a5f6566c2179045a784b661b7e82c7b371a3f",class:"zonos--completion-fields"},this.renderNameFields(),this.renderField("state",translate("State/Province")),this.renderField("postal_code",translate("Postal code")))),h("div",{key:"1007d7f6c671fbd94dd3027332d2d7ac1edeef6e",class:"zonos--group-btn"},h("div",{key:"22fe2c8d03d7b3c680eea2b4afebf1868b5b6c0b",class:"zonos--button-wrapper"},h("zonos-button",{key:"dbcf1aa175992bff762ecc36108bf94090b7df0e",class:"zonos--cancel-btn",onClick:function(){return e.closeCompletionDialog.emit()},variant:"subtle"},translate("Cancel")),h("zonos-button",{key:"63b0f966565e86ea9bac640b2fa690287c94b11f",backgroundColor:this.submitBtnColor,class:"zonos--submit-btn",loading:this.continueLoading,onClick:function(){return e.submitHandler()},size:"sm",variant:r},translate("Save and continue")))))))};Object.defineProperty(e,"watchers",{get:function(){return{dialogOpen:[{watchDialogOpen:0}]}},enumerable:false,configurable:true});return e}();ZonosAddressCompletionDialog.style=zonosAddressCompletionDialogCss();var zonosAddressFormCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--title{margin-bottom:20px}:host .zonos--address-group{display:-ms-flexbox;display:flex;gap:20px;-ms-flex-direction:column;flex-direction:column;margin:1px}:host .zonos--contact{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}:host .zonos--address-row{display:-ms-flexbox;display:flex;gap:8px}:host .zonos--address-row>*{-ms-flex:1;flex:1}:host .zonos--address{display:-ms-flexbox;display:flex;gap:8px;-ms-flex-direction:column;flex-direction:column}"};var ZonosAddressForm=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.addressChange=createEvent(this,"addressChange",7);
|
|
47
47
|
/**
|
|
48
48
|
* Local address to update
|
|
49
|
-
*/this.localAddress=this.currentAddress;this.onInputChange=function(e){var r;var
|
|
49
|
+
*/this.localAddress=this.currentAddress;this.onInputChange=function(e){var r;var o=e.key,n=e.value;t.addressChange.emit(Object.assign(Object.assign({},t.localAddress),(r={},r[o]=n,r)))}}e.prototype.watchCurrentAddress=function(){var e,t,r,o,n,i;var d=this.currentAddress,s=d.city,a=d.line1,u=d.line2,l=d.name,$=d.postal_code,c=d.state;
|
|
50
50
|
// Update the local address when the current address changes
|
|
51
51
|
// If translated address is available, use that instead
|
|
52
|
-
this.localAddress=Object.assign(Object.assign({},this.currentAddress),{city:((e=this.translatedAddress.city)===null||e===void 0?void 0:e[s])||s,line1:((t=this.translatedAddress.line1)===null||t===void 0?void 0:t[a])||a,line2:((r=this.translatedAddress.line2)===null||r===void 0?void 0:r[u])||u,name:((
|
|
52
|
+
this.localAddress=Object.assign(Object.assign({},this.currentAddress),{city:((e=this.translatedAddress.city)===null||e===void 0?void 0:e[s])||s,line1:((t=this.translatedAddress.line1)===null||t===void 0?void 0:t[a])||a,line2:((r=this.translatedAddress.line2)===null||r===void 0?void 0:r[u])||u,name:((o=this.translatedAddress.name)===null||o===void 0?void 0:o[l])||l,postal_code:((n=this.translatedAddress.postal_code)===null||n===void 0?void 0:n[$])||$,state:((i=this.translatedAddress.state)===null||i===void 0?void 0:i[c])||c})};e.prototype.componentWillLoad=function(){this.watchCurrentAddress()};e.prototype.render=function(){var e=this;var t=this.localAddress,r=t.city,o=t.country,n=t.line1,i=t.line2,d=t.name,s=t.phone,a=t.postal_code,u=t.state;var l=extractName({name:d}),$=l.firstName,c=l.lastName;return h(Host,{key:"44edb799473e427b08e17d6d20f08a028a3cc688",class:"zonos--address-form zonos--elements"},h("div",{key:"99c2d5b58464bebd7bb3e5c2a4ac3aa04d80b47f",class:"zonos--title"},h("zonos-text",{key:"5a86048c7d768b795db1416182e2b22458924601",textColor:"gray-700",type:"smallHeader"},this.addressType==="shipping"?translate("Shipping"):translate("Billing"))),h("div",{key:"a907058d970cb6674b403f79c0946e36a0e61f69",class:"zonos--address-group"},h("div",{key:"fad2f71614c6963015f95e74e297c58a4adee95b",class:"zonos--contact"},h("zonos-text",{key:"0c661050b1b95da56af1046fac39c7fa6de18685",type:"label"},translate("Contact")),h("zonos-input",{key:"3e35a5f9d4bca373ef9403da0de53ea895aca61f",class:"zonos--form-email",inputLabel:translate("Email"),inputValue:this.currentAddress.email,isDisabled:true}),h("div",{key:"093cdcc771b4ade381a392a1023d9d037d4e3e35",class:"zonos--name zonos--address-row"},h("zonos-input",{key:"e9d957551070a855179b78da655beaf3b4e731e2",class:"zonos--form-first-name",inputLabel:translate("First name"),inputValue:$,isError:isTextContainsNonLatinChars($),onInputChange:function(t){return e.onInputChange({key:"name",value:"".concat(t.detail," ").concat(c)})}}),h("zonos-input",{key:"0b86805e872607d367446f5e6ef074974f9840c2",class:"zonos--form-last-name",inputLabel:translate("Last name"),inputValue:c,isError:isTextContainsNonLatinChars(c),onInputChange:function(t){return e.onInputChange({key:"name",value:"".concat($," ").concat(t.detail)})}}))),h("div",{key:"6447f55e8d173d18cd46cba829527c4d487631a2",class:"zonos--address"},h("zonos-text",{key:"18ef146cc44f658524c6535e851281b62249fa26",type:"label"},translate("Address")),h("zonos-input",{key:"95cfb115c4304e8a142ab2e952fc8c4bfbe39e43",class:"zonos--form-country",inputLabel:translate("Country"),inputValue:o,isDisabled:true}),h("zonos-input",{key:"e3774713ec0b0e861981aa9f2c62f6749125e174",class:"zonos--form-line1",inputLabel:translate("Address line 1"),inputValue:n,isError:isTextContainsNonLatinChars(n),onInputChange:function(t){return e.onInputChange({key:"line1",value:t.detail})}}),h("zonos-input",{key:"0d1fce85ad42e42b266ad411d4e3a96e4b8b8bf3",class:"zonos--form-line2",inputLabel:translate("Address line 2"),inputValue:i,isError:isTextContainsNonLatinChars(i),onInputChange:function(t){return e.onInputChange({key:"line2",value:t.detail})}}),h("div",{key:"5d5e740b711ff65a0366a6c4891f22684f32c74b",class:"zonos--address-row"},h("zonos-input",{key:"8f124a91865c59096ba5c624ec229a3d1545c985",class:"zonos--form-city",inputLabel:translate("City"),inputValue:r,isError:isTextContainsNonLatinChars(r),onInputChange:function(t){return e.onInputChange({key:"city",value:t.detail})}}),this.currentAddress.state&&h("zonos-input",{key:"50e852953ba88573929a200bce4c67fab2146245",class:"zonos--form-state",inputLabel:translate("State/Province"),inputValue:u,isError:isTextContainsNonLatinChars(u),onInputChange:function(t){return e.onInputChange({key:"state",value:t.detail})}})),h("zonos-input",{key:"74c17f1d1a77af3f90100a6832b2c8fe7bdca24e",class:"zonos--form-postal-code",inputLabel:translate("Postal code"),inputValue:a,isError:isTextContainsNonLatinChars(a),onInputChange:function(t){return e.onInputChange({key:"postal_code",value:t.detail})}}),h("zonos-input",{key:"20775c4a944fe9305446898109637e5b38229a1d",class:"zonos--form-phone",inputLabel:translate("Phone number"),inputValue:s,onInputChange:function(t){return e.onInputChange({key:"phone",value:t.detail})}}))))};Object.defineProperty(e,"watchers",{get:function(){return{translatedAddress:[{watchCurrentAddress:0}]}},enumerable:false,configurable:true});return e}();ZonosAddressForm.style=zonosAddressFormCss();var RemoveIcon='<svg color="var(--zonos-elements-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--zonos-elements-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var zonosAddressSuggestionsCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{position:relative}:host .wrapper{position:absolute;margin-top:4px;top:100%;left:0;right:0;z-index:3;max-height:300px;overflow-y:auto;border-radius:var(--zonos--border-radius, var(--zonos-elements-radius-10));-webkit-box-shadow:var(--zonos-elements-shadow-select-active);box-shadow:var(--zonos-elements-shadow-select-active);display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;list-style:none;padding:0;background-color:var(--zonos-elements-surface-color)}:host .wrapper .option{padding:8px;background-color:var(--zonos-elements-surface-color);outline:none;border:none;text-align:left}:host .wrapper .option.last-hovered{background-color:var(--zonos-elements-gray-100)}:host .wrapper .option .highlight{font-weight:600;color:var(--zonos-elements-gray-1000)}:host .wrapper>.powered-by{padding:8px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}:host .wrapper>.powered-by .powered-by-container{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;gap:5px;-ms-flex:1;flex:1}:host .wrapper>.suggestion{cursor:pointer}:host .wrapper>.suggestion:hover{background-color:var(--zonos-elements-gray-100)}"};var ZonosAddressSuggestions=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.suggestionSelected=createEvent(this,"suggestionSelected",7);
|
|
53
53
|
/**
|
|
54
54
|
* Suggestions to display
|
|
55
55
|
*/this.suggestions=[];
|
|
@@ -66,15 +66,15 @@ this.localAddress=Object.assign(Object.assign({},this.currentAddress),{city:((e=
|
|
|
66
66
|
this.lastHoveredSuggestionId=(t=(e=this.suggestions[0])===null||e===void 0?void 0:e.id)!==null&&t!==void 0?t:null};e.prototype.componentDidLoad=function(){document.addEventListener("click",this.handleClickOutside)};e.prototype.disconnectedCallback=function(){document.removeEventListener("click",this.handleClickOutside)};
|
|
67
67
|
/**
|
|
68
68
|
* Split text into segments based on matches array for highlighting
|
|
69
|
-
*/e.prototype.getHighlightedText=function(e,t){if(!(t===null||t===void 0?void 0:t.length))return[{isMatch:false,text:e}];var r=[];var
|
|
69
|
+
*/e.prototype.getHighlightedText=function(e,t){if(!(t===null||t===void 0?void 0:t.length))return[{isMatch:false,text:e}];var r=[];var o=0;
|
|
70
70
|
// Sort matches by startOffset to process in order
|
|
71
|
-
var
|
|
71
|
+
var n=__spreadArray([],t,true).sort((function(e,t){return e.startOffset-t.startOffset}));n.forEach((function(t){
|
|
72
72
|
// Add non-matching segment before match if exists
|
|
73
|
-
if(t.startOffset>
|
|
73
|
+
if(t.startOffset>o){r.push({isMatch:false,text:e.slice(o,t.startOffset)})}
|
|
74
74
|
// Add matching segment
|
|
75
|
-
r.push({isMatch:true,text:e.slice(t.startOffset,t.endOffset)});
|
|
75
|
+
r.push({isMatch:true,text:e.slice(t.startOffset,t.endOffset)});o=t.endOffset}));
|
|
76
76
|
// Add remaining non-matching text if exists
|
|
77
|
-
if(
|
|
77
|
+
if(o<e.length){r.push({isMatch:false,text:e.slice(o)})}return r};e.prototype.render=function(){var e=this;return h(Host,{key:"34018ecc951c0335041e24102329eb83a8d68439",class:"zonos--address-suggestions",role:"group",style:{"--zonos--border-radius":getBorderRadius()}},h("ul",{key:"80433831c875845e57225a1317c430e2626edf9a","aria-label":"Suggestions",class:"wrapper",role:"listbox"},!!this.localSuggestions.length&&h("li",{key:"3510ef51b56b1cb0a36334e842792bccc2daeca5","aria-selected":false,class:"powered-by option",role:"option"},h("div",{key:"72773af6f9c7e0644ebc5239e4bf585bba6e164a",class:"powered-by-container"},h("zonos-text",{key:"7fabccbe33cbc8d037dfd25f6e5b0a5bdaf97b2f",type:"caption"},"Suggestions powered by"),h("zonos-text",{key:"2d88a3b8d7369a44e910ec60f5c7ac0c3f0ce801",type:"semiBoldLabel"},"Google")),h("zonos-button",{key:"74315c248cc84617d854a3b51d0bad8300c6b762","aria-label":"Clear suggestions",icon:h("zonos-icon",{content:RemoveIcon}),noBackground:true,onClick:function(){e.localSuggestions=[]}})),this.localSuggestions.map((function(t){
|
|
78
78
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
79
79
|
return h("li",{"aria-selected":e.selectedSuggestionId===t.id,class:classes(["suggestion","option",e.lastHoveredSuggestionId===t.id&&"last-hovered"]),key:t.id,onClick:function(){e.selectedSuggestionId=t.id;e.suggestionSelected.emit({placeId:t.id,type:e.type})},onMouseEnter:function(){e.lastHoveredSuggestionId=t.id},role:"option",tabIndex:0},h("zonos-text",null,e.getHighlightedText(t.place,t.matches).map((function(e,t){return h("span",{class:e.isMatch?"highlight":undefined,key:"".concat(t,"-").concat(e.text)},e.text)}))))}))))};Object.defineProperty(e,"assetsDirs",{get:function(){return["assets"]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{suggestions:[{suggestionsChanged:0}]}},enumerable:false,configurable:true});return e}();ZonosAddressSuggestions.style=zonosAddressSuggestionsCss();var zonosAddressUpdateDialogCss=function(){return":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--body{padding:0 24px;position:relative}:host .zonos--dialog-header{margin-bottom:32px;position:-webkit-sticky;position:sticky;padding-top:24px;top:0;z-index:11;background:var(--zonos-elements-gray-0)}:host .zonos--dialog-title{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;margin-bottom:12px}:host .zonos--group{overflow:auto;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:8px;-ms-scroll-chaining:none;overscroll-behavior:contain}:host .zonos--group::-webkit-scrollbar{width:10px}:host .zonos--group::-webkit-scrollbar-track{background:var(--zonos-elements-gray-50)}:host .zonos--group::-webkit-scrollbar-thumb{border-radius:10px;background:#cccccc;border:3px solid transparent;background-clip:content-box}:host .zonos--group::-webkit-scrollbar-thumb:hover{background:#d6d6d6}:host .zonos--group{-ms-scroll-chaining:chained;overscroll-behavior:auto}:host .zonos--address-display-group{display:-ms-flexbox;display:flex;gap:8px;margin-bottom:20px}:host .zonos--address-display-group zonos-address-display{-ms-flex:1;flex:1}:host .zonos--what-you-entered{margin-bottom:8px}:host .zonos--address-form-section{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:24px}:host .zonos--group-btn{position:-webkit-sticky;position:sticky;padding:24px 0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-pack:end;justify-content:end;background:var(--zonos-elements-gray-0);z-index:11}:host .zonos--group-btn .zonos--button-wrapper{display:-ms-flexbox;display:flex;gap:8px}:host(.mobile) .zonos--button-wrapper{-ms-flex-direction:column;flex-direction:column;width:100%}:host(.mobile) .zonos--button-wrapper zonos-button{width:100%}:host(.mobile) .zonos--button-wrapper .zonos--cancel-btn{-ms-flex-order:2;order:2}:host(.mobile) .zonos--button-wrapper .zonos--update-btn{-ms-flex-order:1;order:1}"};var ZonosAddressUpdateDialog=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.closeUpdateDialog=createEvent(this,"closeUpdateDialog",7);this.continueClicked=createEvent(this,"continueClicked",7);
|
|
80
80
|
/**
|
|
@@ -100,18 +100,18 @@ return h("li",{"aria-selected":e.selectedSuggestionId===t.id,class:classes(["sug
|
|
|
100
100
|
*/this.closeUpdateDialogHandler=function(){t.closeUpdateDialog.emit()};
|
|
101
101
|
/**
|
|
102
102
|
* Extract value from translated object
|
|
103
|
-
*/this.getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var n,
|
|
103
|
+
*/this.getTranslatedAddress=function(e){var t=e.currentAddress,r=e.translatedAddress;var o,n,i,d,s,a;var u=t.city,l=t.line1,$=t.line2,c=t.name,f=t.postal_code,h=t.state;return{city:((o=r.city)===null||o===void 0?void 0:o[u])||u,line1:((n=r.line1)===null||n===void 0?void 0:n[l])||l,line2:((i=r.line2)===null||i===void 0?void 0:i[$])||$,name:((d=r.name)===null||d===void 0?void 0:d[c])||c,postal_code:((s=r.postal_code)===null||s===void 0?void 0:s[f])||f,state:((a=r.state)===null||a===void 0?void 0:a[h])||h}};
|
|
104
104
|
/**
|
|
105
105
|
* handler for continue button click
|
|
106
|
-
*/this.continueClickHandler=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,r,n,
|
|
106
|
+
*/this.continueClickHandler=function(){return __awaiter(t,void 0,void 0,(function(){var e,t,r,o,n,i,d,s,a,u,l,$,c;return __generator(this,(function(f){
|
|
107
107
|
// set spinner for the continue button
|
|
108
|
-
this.continueLoading=true;
|
|
108
|
+
this.continueLoading=true;o=this.billingAddress?this.getTranslatedAddress({currentAddress:this.billingAddress,translatedAddress:this.translatedBillingAddressState}):null;n=this.getTranslatedAddress({currentAddress:this.shippingAddress,translatedAddress:this.translatedShippingAddressState});i=containsNonLatinChars(Object.assign(Object.assign({},n),{country:this.shippingAddress.country}));d=o&&this.billingAddress&&containsNonLatinChars(Object.assign(Object.assign({},o),{country:this.billingAddress.country}));s=!!Object.keys(i).length;a=!!d&&!!Object.keys(d).length;
|
|
109
109
|
// if there are non-latin characters in the translated address, scroll to the error input so user can see and fix it
|
|
110
110
|
if(s||a){u=(e=this.el.shadowRoot)===null||e===void 0?void 0:e.querySelectorAll("zonos-address-form");l=u===null||u===void 0?void 0:u[0];$=u===null||u===void 0?void 0:u[1];c=((t=l===null||l===void 0?void 0:l.shadowRoot)===null||t===void 0?void 0:t.querySelector(".has-error"))||((r=$===null||$===void 0?void 0:$.shadowRoot)===null||r===void 0?void 0:r.querySelector(".has-error"));
|
|
111
111
|
// scroll to the first error input
|
|
112
112
|
if(c){c.scrollIntoView({behavior:"smooth",block:"center"})}this.continueLoading=false;return[2/*return*/]}
|
|
113
113
|
// Submit the translated address to the parent component
|
|
114
|
-
this.continueClicked.emit({billingAddress:
|
|
114
|
+
this.continueClicked.emit({billingAddress:o,shippingAddress:n});return[2/*return*/]}))}))};
|
|
115
115
|
/**
|
|
116
116
|
* This function builds a state object for a translated address.
|
|
117
117
|
* It takes the current and translated address as input and returns an object where each field is an object itself.
|
|
@@ -121,11 +121,11 @@ this.continueClicked.emit({billingAddress:n,shippingAddress:o});return[2/*return
|
|
|
121
121
|
* @param {EnteredInfo} params.currentAddress - The current address information.
|
|
122
122
|
* @param {EnteredInfo} params.translatedAddress - The translated address information.
|
|
123
123
|
*
|
|
124
|
-
*/this.buildTranslateAddressState=function(e){var t,r,n,
|
|
124
|
+
*/this.buildTranslateAddressState=function(e){var t,r,o,n,i,d;var s=e.currentAddress,a=e.translatedAddress;var u=s.city,l=s.line1,$=s.line2,c=s.name,f=s.postal_code,h=s.state;return{city:(t={},t[u]=a.city,t),line1:(r={},r[l]=a.line1,r),line2:(o={},o[$]=a.line2,o),name:(n={},n[c]=a.name,n),postal_code:(i={},i[f]=a.postal_code,i),state:(d={},d[h]=a.state,d)}}}e.prototype.watchTranslatedShippingAddress=function(){this.translatedShippingAddressState=this.translatedShippingAddress};e.prototype.watchTranslatedBillingAddress=function(){this.translatedBillingAddressState=this.translatedBillingAddress};e.prototype.componentWillLoad=function(){
|
|
125
125
|
// update the state with the initial props
|
|
126
126
|
this.watchTranslatedBillingAddress();this.watchTranslatedShippingAddress()};e.prototype.render=function(){var e=this;
|
|
127
127
|
// dialog background white, so when the button background is also white, we need to change the button type to outline so it's visible
|
|
128
|
-
var t=this.submitBtnColor||zonosStore.appearance.colorSecondary;var r=t==="#ffffff"?"outline":this.submitBtnType||"standard";var
|
|
128
|
+
var t=this.submitBtnColor||zonosStore.appearance.colorSecondary;var r=t==="#ffffff"?"outline":this.submitBtnType||"standard";var o=this.billingAddress;var n=this.shippingAddress;return h(Host,{key:"655845cef04f4af526b1a1c4e49243c4f2b4c7f6",class:classes(["zonos--address-update-dialog zonos--elements",this.isMobile&&"mobile"])},h("zonos-dialog",{key:"eab429bb78ce6f05ba463d8748d7edd5499402fa",isLoading:this.dialogLoading,mobile:this.isMobile,noBodyPadding:true,noBorder:true,noClickOutside:true,noCloseButton:true,onCloseDialog:function(){return e.closeUpdateDialog.emit()},open:this.dialogOpen,width:"568px"},h("div",{key:"08f0400e62addfcaffd91bf5200999d29bbd2da9",class:"zonos--body"},h("div",{key:"8699df5e2f823e19066fbb552ba2a66c127c05e9",class:"zonos--dialog-header"},h("div",{key:"92e0ff932dcdb0e5b59ea34b688d1ef8e31bfeb3",class:"zonos--dialog-title"},h("zonos-text",{key:"aaac3375526bddb319ce7c8f49bde30da7210264",type:"title"},translate("Update your address")),h("zonos-button",{key:"474cc2421cd3150daa46bfe215da6ae7df9c6087",class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon$1}),noBackground:true,onClick:function(){return e.closeUpdateDialogHandler()},title:"Close checkout dialog"})),h("zonos-text",{key:"6d019250cce57e8b30dd790a184df7273bdb234f"},translate("To ensure delivery all address details must be in Latin characters."))),h("div",{key:"80ee681844f4f4f43fce69d977b634b1fbc3d5f5",class:"zonos--group"},h("zonos-text",{key:"940e510eceec156a74f32de84cf58ffebd796435",class:"zonos--what-you-entered",type:"semiBoldLabel"},translate("What you entered")),h("div",{key:"f626127f5c399c29ab1022deb66aaee8f8a49601",class:"zonos--address-display-group"},h("zonos-address-display",{key:"9dfcba1037325c3a1f9e82b8e4797e7872dd7e3f",addressType:"shipping",currentAddress:n}),o&&h("zonos-address-display",{key:"fee8ae2c6786d735133c2a0a42f3e3d40d7f9ea9",addressType:"billing",currentAddress:o})),h("div",{key:"5a82195018ff8cdfd1126f4424062a26c25ee757",class:"zonos--address-form-section"},h("zonos-text",{key:"f694dfad166697e4c034cea51057133b69b1c144",type:"semiBoldLabel"},translate("Translated address")),h("zonos-address-form",{key:"4a99c841cf4800de43c612cce3d56d956d02c22f",addressType:"shipping",class:"zonos--shipping-address-form",currentAddress:n,onAddressChange:function(t){var r=t.detail;e.translatedShippingAddressState=e.buildTranslateAddressState({currentAddress:n,translatedAddress:r})},translatedAddress:this.translatedShippingAddressState}),o&&h("zonos-address-form",{key:"311fd702d29a9517203597890bd46bd268dfc6d3",addressType:"billing",class:"zonos--billing-address-form",currentAddress:o,onAddressChange:function(t){var r=t.detail;e.translatedBillingAddressState=e.buildTranslateAddressState({currentAddress:o,translatedAddress:r})},translatedAddress:this.translatedBillingAddressState}))),h("div",{key:"918c3271579c3fc7a7efff0473b0ccf48fb575a2",class:"zonos--group-btn"},h("div",{key:"f73be0c1124d3a4d340bc6e8512f6be8356c655d",class:"zonos--button-wrapper"},h("zonos-button",{key:"172a6cc0a7b75afb400802ef6b87faae6e7e2483",class:"zonos--cancel-btn",onClick:function(){return e.closeUpdateDialogHandler()},variant:"subtle"},translate("Cancel")),h("zonos-button",{key:"8fd08bc79b60eb9a0064c06ff9d840b1ecb09123",backgroundColor:this.submitBtnColor,class:"zonos--update-btn",loading:this.continueLoading,onClick:function(){return e.continueClickHandler()},size:"sm",variant:r},translate("Update address")))))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{translatedShippingAddress:[{watchTranslatedShippingAddress:0}],translatedBillingAddress:[{watchTranslatedBillingAddress:0}]}},enumerable:false,configurable:true});return e}();ZonosAddressUpdateDialog.style=zonosAddressUpdateDialogCss();var isValidZip=function(e){var t=e.countryFields,r=e.zip;if(!t){return true}if(!t.zipShow){return true}
|
|
129
129
|
// If zip is not required, zip value can be empty
|
|
130
130
|
if(!t.zipRequired){return true}
|
|
131
131
|
// If zip regex is set, it's always required and must be validated
|
|
@@ -142,12 +142,15 @@ return t.zipRequired&&!!r};var hasCountries=function(e){return!!e&&Object.keys(e
|
|
|
142
142
|
*
|
|
143
143
|
* When the full country list is unavailable we fall back to the shipping zone
|
|
144
144
|
* so the dropdown is never empty.
|
|
145
|
-
*/var getAddressCountryOptions=function(e){var t=e.allCountries,r=e.shippingZoneCountries,
|
|
145
|
+
*/var getAddressCountryOptions=function(e){var t=e.allCountries,r=e.shippingZoneCountries,o=e.type;var n=o==="billing"&&hasCountries(t)?t:r;return Object.values(n||{}).map((function(e){return{label:e.displayName,value:e.code}})).sort((function(e,t){return e.label.localeCompare(t.label)}))};var mergeAddress=function(e){var t=e.addresses,r=e.delimiter,o=r===void 0?" ":r;
|
|
146
146
|
// Remove duplicate addresses
|
|
147
|
-
var
|
|
147
|
+
var n=new Set(t.filter(Boolean));return Array.from(n).join(o)};var zonosCustomAddressCss=function(){return".sc-zonos-custom-address-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-custom-address-h *.sc-zonos-custom-address{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-custom-address-h img.sc-zonos-custom-address{max-width:100%}.sc-zonos-custom-address-h dl.sc-zonos-custom-address,.sc-zonos-custom-address-h dd.sc-zonos-custom-address,.sc-zonos-custom-address-h h1.sc-zonos-custom-address,.sc-zonos-custom-address-h h2.sc-zonos-custom-address,.sc-zonos-custom-address-h h3.sc-zonos-custom-address,.sc-zonos-custom-address-h h4.sc-zonos-custom-address,.sc-zonos-custom-address-h h5.sc-zonos-custom-address,.sc-zonos-custom-address-h h6.sc-zonos-custom-address,.sc-zonos-custom-address-h hr.sc-zonos-custom-address,.sc-zonos-custom-address-h figure.sc-zonos-custom-address,.sc-zonos-custom-address-h p.sc-zonos-custom-address,.sc-zonos-custom-address-h pre.sc-zonos-custom-address{margin:0}.sc-zonos-custom-address-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-custom-address-h .zonos--title.sc-zonos-custom-address{margin-bottom:16px}.sc-zonos-custom-address-h .zonos--company-name-input.sc-zonos-custom-address,.sc-zonos-custom-address-h .zonos--tax-id-input.sc-zonos-custom-address{margin-bottom:8px}.sc-zonos-custom-address-h .zonos--tax-id-input.sc-zonos-custom-address{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:8px}.sc-zonos-custom-address-h zonos-banner.sc-zonos-custom-address{margin-top:8px}.sc-zonos-custom-address-h .zonos--custom-address-form.sc-zonos-custom-address,.sc-zonos-custom-address-h .zonos--custom-address-form-additional-fields.sc-zonos-custom-address{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:8px}.sc-zonos-custom-address-h .zonos--custom-address-form-state-zip-wrapper.sc-zonos-custom-address{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:8px;-ms-flex-wrap:wrap;flex-wrap:wrap}.sc-zonos-custom-address-h .zonos--custom-address-form-state-zip-wrapper.sc-zonos-custom-address>*.sc-zonos-custom-address{-ms-flex:1 1 200px;flex:1 1 200px}.sc-zonos-custom-address-h .zonos--custom-address-form-additional-fields.sc-zonos-custom-address{opacity:0;height:0;overflow:hidden;-webkit-transition:opacity 0.3s ease-in-out, height 0.3s ease-in-out;transition:opacity 0.3s ease-in-out, height 0.3s ease-in-out}.sc-zonos-custom-address-h .zonos--custom-address-form-additional-fields.zonos--show.sc-zonos-custom-address{opacity:1;height:auto}"};var __rest=undefined&&undefined.__rest||function(e,t){var r={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0)r[o]=e[o];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++){if(t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n]))r[o[n]]=e[o[n]]}return r};var ZonosAddress=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.invalidCharacters=createEvent(this,"invalidCharacters",7);this.addressChange=createEvent(this,"addressChange",7);this.onStoreCheckoutSessionIdChangedSubscription=function(){};
|
|
148
148
|
/**
|
|
149
149
|
* Default address for stripe
|
|
150
150
|
*/this.defaultAddress=[];
|
|
151
|
+
/**
|
|
152
|
+
* Which tax id control the error belongs on. Empty when there is no error.
|
|
153
|
+
*/this.taxIdErrorField="";
|
|
151
154
|
/**
|
|
152
155
|
* Error message for tax id input
|
|
153
156
|
*/this.taxIdErrorMessage="";
|
|
@@ -202,13 +205,13 @@ this.throttledGetAddressSuggestions=throttle((function(){if(zonosStore.checkoutA
|
|
|
202
205
|
// Map the custom address form to stripe address event data
|
|
203
206
|
this.setCustomAddressFormToStripeAddressEventData=function(){
|
|
204
207
|
// If the field is not shown, set it to an empty string
|
|
205
|
-
var e=!t.countryField||t.countryField.cityShow?t.city:"";var r=!t.countryField||t.countryField.stateShow?t.state:"";var
|
|
208
|
+
var e=!t.countryField||t.countryField.cityShow?t.city:"";var r=!t.countryField||t.countryField.stateShow?t.state:"";var o=!t.countryField||t.countryField.zipShow?t.postalCode:"";var n={complete:t.getIsComplete(),elementMode:t.type,elementType:"address",empty:!t.getIsComplete(),isNewAddress:true,value:{address:{city:e,country:t.country,line1:t.line1,line2:t.line2,postal_code:o,state:r},firstName:t.firstName,lastName:t.lastName,name:"".concat(t.firstName," ").concat(t.lastName),phone:t.phone}};t.updateAddressEventData({event:n,type:t.type});t.addressChange.emit({errors:t.getCustomAddressErrors(),type:t.type,value:n})};this.getCustomAddressErrors=function(){return t.type==="shipping"?stripeStore.customAddressErrors:stripeStore.customBillingAddressErrors};this.validate=function(e){var r=e.phoneValidateInfo,o=e.type,n=e.value,i=e.valueType;var d,s,a,u,l;var $=Object.assign({},t.getCustomAddressErrors());switch(i){case"city":{var c=!((d=t.countryField)===null||d===void 0?void 0:d.cityRequired)||((s=t.countryField)===null||s===void 0?void 0:s.cityRequired)&&!!(n===null||n===void 0?void 0:n.trim());$.city="";if(!c){$.city=translate("The field is incomplete")}break}case"state":{var c=!((a=t.countryField)===null||a===void 0?void 0:a.stateRequired)||((u=t.countryField)===null||u===void 0?void 0:u.stateRequired)&&!!(n===null||n===void 0?void 0:n.trim());$.state="";if(!c){$.state=translate("The field is incomplete")}break}case"postalCode":{var c=isValidZip({countryFields:t.countryField,zip:n||""});$.postalCode="";if(!c){$.postalCode=translate("Your [zipLabel] is invalid",{zipLabel:((l=t.countryField)===null||l===void 0?void 0:l.zipLabel)||"ZIP"})}break}case"firstName":{var c=!!(n===null||n===void 0?void 0:n.trim());$.firstName="";if(!c){$.firstName=translate("Please provide your first name.")}break}case"lastName":{var c=!!(n===null||n===void 0?void 0:n.trim());$.lastName="";if(!c){$.lastName=translate("Please provide your last name.")}break}case"line1":{var c=!!(n===null||n===void 0?void 0:n.trim());$.line1="";if(!c){$.line1=translate("The field is incomplete")}break}case"phone":{
|
|
206
209
|
// If the phone validate info is not provided, we need to validate the phone number
|
|
207
|
-
if(!r){var c=!!(
|
|
210
|
+
if(!r){var c=!!(n===null||n===void 0?void 0:n.trim());$.phone="";if(!c){$.phone=translate("Please provide a mobile phone number.")}}else{$.phone="";
|
|
208
211
|
// If the phone number is empty, set the error message
|
|
209
|
-
if(r.isEmpty){$.phone=translate("Please provide a mobile phone number.")}else if(r.wrongFormat){$.phone=translate("Your mobile phone number is incomplete.")}}break}}if(
|
|
212
|
+
if(r.isEmpty){$.phone=translate("Please provide a mobile phone number.")}else if(r.wrongFormat){$.phone=translate("Your mobile phone number is incomplete.")}}break}}if(o==="shipping"){stripeStore.customAddressErrors=$}else{stripeStore.customBillingAddressErrors=$}};this.onStoreCheckoutSessionIdChanged=function(){var e=function(){t.checkoutSessionId=storageStore.checkoutSessionId};
|
|
210
213
|
// Trigger it once on init because onChange doesn't get triggered on initial load
|
|
211
|
-
e();t.onStoreCheckoutSessionIdChangedSubscription=storageStoreOnChange("checkoutSessionId",e)}}e.prototype.getCountryOptions=function(){var e=localizationStore.allCountries,t=localizationStore.shippingZoneCountries;var r=this.countryOptionsCache;if(r&&r.allCountries===e&&r.shippingZoneCountries===t&&r.type===this.type){return r.options}var
|
|
214
|
+
e();t.onStoreCheckoutSessionIdChangedSubscription=storageStoreOnChange("checkoutSessionId",e)}}e.prototype.getCountryOptions=function(){var e=localizationStore.allCountries,t=localizationStore.shippingZoneCountries;var r=this.countryOptionsCache;if(r&&r.allCountries===e&&r.shippingZoneCountries===t&&r.type===this.type){return r.options}var o=getAddressCountryOptions({allCountries:e,shippingZoneCountries:t,type:this.type});this.countryOptionsCache={allCountries:e,options:o,shippingZoneCountries:t,type:this.type};return o};e.prototype.getStripeAddressInstance=function(){if(this.type==="billing"){return{stripeAddressElement:stripeStore.stripeBillingAddressElement,stripeAddressEventData:stripeStore.stripeBillingAddressEventData,stripeElements:stripeStore.stripeElementsForBillingAddress}}return{stripeAddressElement:stripeStore.stripeAddressElement,stripeAddressEventData:stripeStore.stripeAddressEventData,stripeElements:stripeStore.stripeElements}};e.prototype.updateAddressEventData=function(e){var t=e.event,r=e.type;switch(r){case"billing":stripeStore.stripeBillingAddressEventData=t;break;default:{stripeStore.stripeAddressEventData=t;
|
|
212
215
|
// send request to prefetch landed cost
|
|
213
216
|
void stripeStorePrefetchLandedCost();break}}};e.prototype.isAddressFilledChanged=function(){
|
|
214
217
|
// Sometimes address elements is loaded with prefilled data before checkout is loaded, need to not send the event if checkout session id is not available, and send the event after checkout is loaded
|
|
@@ -216,24 +219,20 @@ if(!storageStore.checkoutSessionId){return}
|
|
|
216
219
|
// Only need to track the event if the shipping address is filled
|
|
217
220
|
if(this.isAddressFilled&&!this.trackingSent&&this.type==="shipping"){this.trackingSent=true;var e=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:e,eventName:"checkout_customerInfoFilled"})}};e.prototype.defaultAddressChanged=function(e,t){
|
|
218
221
|
// check if stringified json of oldAddress is different from newAddress
|
|
219
|
-
var r=JSON.stringify(t);var
|
|
222
|
+
var r=JSON.stringify(t);var o=JSON.stringify(e);
|
|
220
223
|
// No need to reset address element if the default address is the same
|
|
221
|
-
if(r===
|
|
224
|
+
if(r===o){return}log("Reset address element when default address property is changed","info",{defaultAddress:this.defaultAddress});
|
|
222
225
|
// Reset stripe address event data
|
|
223
|
-
if(this.type==="shipping"){stripeStore.stripeAddressEventData=null}else{stripeStore.stripeBillingAddressEventData=null}this.initDefaultCustomAddressForm()};e.prototype.getIsComplete=function(){var e=this.getCustomAddressErrors(),t=e.city,r=e.firstName,
|
|
226
|
+
if(this.type==="shipping"){stripeStore.stripeAddressEventData=null}else{stripeStore.stripeBillingAddressEventData=null}this.initDefaultCustomAddressForm()};e.prototype.getIsComplete=function(){var e=this.getCustomAddressErrors(),t=e.city,r=e.firstName,o=e.lastName,n=e.line1,i=e.phone,d=e.postalCode,s=e.state;if(!this.line1||!this.firstName||!this.lastName||!this.phone){return false}
|
|
224
227
|
// has any errors from any of the fields
|
|
225
|
-
var a=
|
|
228
|
+
var a=n||d||s||t||r||o||i;return!a};
|
|
226
229
|
/**
|
|
227
230
|
* Render tax id input based on ship to country code
|
|
228
231
|
*/e.prototype.renderTaxIdInput=function(){var e;
|
|
229
232
|
// No need to render tax id input for billing address
|
|
230
233
|
if(this.type==="billing"){return null}var t=(e=stripeStore.stripeAddressEventData)===null||e===void 0?void 0:e.value.address.country;
|
|
231
234
|
// Don't render tax id input if the country is not provided
|
|
232
|
-
if(!t){return null}
|
|
233
|
-
// This just to type guard the countryCode, if it's able to get to this point it should already be in country that has tax id input
|
|
234
|
-
if(!this.isInTaxIdCountry(t)){return null}var r=shouldRenderTaxIdInput({companyName:stripeStore.companyName,countryCode:t});
|
|
235
|
-
// Don't render tax id input if the country doesn't require tax id
|
|
236
|
-
if(!r){return null}var n=shipToTaxIdLabels[t];return h("div",{class:"zonos--tax-id-input"},h("zonos-stripe-input",{error:this.taxIdErrorMessage,inputLabel:translate(n.friendlyName),inputPlaceholder:n.placeholder,inputValue:stripeStore.taxId||"",isError:!!this.taxIdErrorMessage,onInputChange:function(e){stripeStore.taxId=e.detail}}))};
|
|
235
|
+
if(!t){return null}return renderTaxIdFields({companyName:stripeStore.companyName,countryCode:t,errorField:this.taxIdErrorField,errorMessage:this.taxIdErrorMessage,shouldRequirePeruTaxId:getShouldRequirePeruTaxId(),taxId:stripeStore.taxId||"",taxIdType:stripeStore.taxIdType})};
|
|
237
236
|
/**
|
|
238
237
|
* Render short address code input based on ship to country code
|
|
239
238
|
*/e.prototype.renderShortAddressCodeInput=function(){var e;
|
|
@@ -246,11 +245,11 @@ if(!r){return null}return h("div",{class:"zonos--short-address-code-input"},h("z
|
|
|
246
245
|
// No need to render company name for billing address
|
|
247
246
|
if(this.type==="billing"){return null}
|
|
248
247
|
// only render the company input if the setting is enabled
|
|
249
|
-
var e=zonosStore.checkoutSettings.companyFieldsStatus==="ENABLED";if(!e){return null}return h("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:translate("Company name (optional)"),inputValue:stripeStore.companyName,onInputChange:function(e){stripeStore.companyName=e.detail}})};e.prototype.initCountryField=function(e){var t,r,
|
|
248
|
+
var e=zonosStore.checkoutSettings.companyFieldsStatus==="ENABLED";if(!e){return null}return h("zonos-stripe-input",{class:"zonos--company-name-input",inputLabel:translate("Company name (optional)"),inputValue:stripeStore.companyName,onInputChange:function(e){stripeStore.companyName=e.detail}})};e.prototype.initCountryField=function(e){var t,r,o;this.countryField=((t=zonosStore.genericSettings)===null||t===void 0?void 0:t.countryFields)&&e?(o=(r=zonosStore.genericSettings)===null||r===void 0?void 0:r.countryFields)===null||o===void 0?void 0:o[e]:null};e.prototype.initDefaultCustomAddressForm=function(){log("initDefaultCustomAddressForm","info",this.type);var e=this.getStripeAddressInstance().stripeAddressEventData;
|
|
250
249
|
// Use data from Stripe address element if it's available (This may happen when user has already at shipping selection page but go back to customer page)
|
|
251
250
|
if(e){var t=e.value.address.country||localizationStore.selectedCountryCode||"US";this.setFormValues({city:e.value.address.city,country:t,firstName:e.value.firstName||"",lastName:e.value.lastName||"",line1:e.value.address.line1,line2:e.value.address.line2||"",phone:e.value.phone||"",postal_code:e.value.address.postal_code,state:e.value.address.state});this.initCountryField(t);return}
|
|
252
251
|
// Use data from default address if it's available
|
|
253
|
-
var r=this.defaultAddress[0];if(r){var
|
|
252
|
+
var r=this.defaultAddress[0];if(r){var o=extractName({name:r.name}),n=o.firstName,i=o.lastName;var d=r.address.country||localizationStore.selectedCountryCode||"US";this.setFormValues({city:r.address.city,country:d,firstName:n,lastName:i,line1:r.address.line1,line2:r.address.line2||"",phone:r.phone||"",postal_code:r.address.postal_code,state:r.address.state});this.initCountryField(d);return}var s=localizationStore.selectedCountryCode||"US";
|
|
254
253
|
// Set default values
|
|
255
254
|
this.setFormValues({city:"",country:s,firstName:"",lastName:"",line1:"",line2:"",phone:"",postal_code:"",state:""});this.initCountryField(s);
|
|
256
255
|
// Set the first initialization to false when the address element is initialized
|
|
@@ -264,24 +263,24 @@ if(this.suggestionClicked){this.suggestionClicked=false;this.startGooglePlaceSug
|
|
|
264
263
|
// stripe element started with just address line 1, so scroll bar is not yet available. Wait for a moment before scrolling
|
|
265
264
|
setTimeout((function(){if(!e.isAutoCompleteAdjusted){if(isCheckoutMobile()){e.el.scrollIntoView({behavior:"smooth",block:"end"})}else{
|
|
266
265
|
// scroll into the end of the page so the address placeholder won't be hidden
|
|
267
|
-
var t=e.type==="shipping"?100:600;var r=e.el.closest(".zonos--group");var
|
|
266
|
+
var t=e.type==="shipping"?100:600;var r=e.el.closest(".zonos--group");var o=e.el.getBoundingClientRect().top+t;r===null||r===void 0?void 0:r.scrollTo({behavior:"smooth",top:o})}}}),600)}}this.setCustomAddressFormToStripeAddressEventData();
|
|
268
267
|
// Start requesting google place suggestions when address line 1 is more than 3 characters (No need to request suggestions on first initialization if address is pre-filled)
|
|
269
|
-
if(this.startGooglePlaceSuggestions&&zonosStore.checkoutAddressService&&!this.isFirstInitialization){this.throttledGetAddressSuggestions()}};e.prototype.formFieldsChanged=function(){this.setCustomAddressFormToStripeAddressEventData()};e.prototype.addressSuggestionSelected=function(e){var t=e.placeDetails;var r,n,
|
|
268
|
+
if(this.startGooglePlaceSuggestions&&zonosStore.checkoutAddressService&&!this.isFirstInitialization){this.throttledGetAddressSuggestions()}};e.prototype.formFieldsChanged=function(){this.setCustomAddressFormToStripeAddressEventData()};e.prototype.addressSuggestionSelected=function(e){var t=e.placeDetails;var r,o,n,i,d,s,a,u,l,$,c,f,h,p,v;
|
|
270
269
|
// Set the trigger to true when the address suggestion is selected so we won't trigger the suggestion again
|
|
271
|
-
this.suggestionClicked=true;this.startGooglePlaceSuggestions=false;var b=t.addressComponents;var y=mergeAddress({addresses:[(r=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("street_number")})))===null||r===void 0?void 0:r.longText,(
|
|
270
|
+
this.suggestionClicked=true;this.startGooglePlaceSuggestions=false;var b=t.addressComponents;var y=mergeAddress({addresses:[(r=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("street_number")})))===null||r===void 0?void 0:r.longText,(o=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("route")})))===null||o===void 0?void 0:o.longText]});var m=mergeAddress({addresses:[(n=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("premise")})))===null||n===void 0?void 0:n.longText,((i=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("sublocality_level_2")})))===null||i===void 0?void 0:i.longText)||((d=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("sublocality_level_3")})))===null||d===void 0?void 0:d.longText)||((s=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("sublocality_level_4")})))===null||s===void 0?void 0:s.longText)||((a=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("sublocality_level_5")})))===null||a===void 0?void 0:a.longText)]});var g=mergeAddress({addresses:[(u=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("subpremise")})))===null||u===void 0?void 0:u.longText,(l=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("neighborhood")})))===null||l===void 0?void 0:l.longText],delimiter:", "});var _=mergeAddress({addresses:[(($=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("locality")})))===null||$===void 0?void 0:$.longText)||((c=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("sublocality_level_1")})))===null||c===void 0?void 0:c.longText)||((f=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("administrative_area_level_1")})))===null||f===void 0?void 0:f.longText)]});var z=mergeAddress({addresses:[(h=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("administrative_area_level_1")})))===null||h===void 0?void 0:h.shortText]});var N=mergeAddress({addresses:[(p=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("postal_code")})))===null||p===void 0?void 0:p.longText]});var C=mergeAddress({addresses:[(v=b===null||b===void 0?void 0:b.find((function(e){return e.types.includes("country")})))===null||v===void 0?void 0:v.shortText]});this.setFormValues({city:_,country:C,
|
|
272
271
|
// Use the address line 1 from the address suggestion if it's available, otherwise use the address line 1 from the custom address form that the user has entered
|
|
273
272
|
line1:y||m||this.line1,line2:g,postal_code:N,state:z})};e.prototype.setFormValues=function(e){if(e.city!==undefined)this.city=e.city;if(e.country!==undefined)this.country=e.country;if(e.firstName!==undefined)this.firstName=e.firstName;if(e.lastName!==undefined)this.lastName=e.lastName;if(e.line1!==undefined)this.line1=e.line1;if(e.line2!==undefined)this.line2=e.line2;if(e.phone!==undefined)this.phone=e.phone;if(e.postal_code!==undefined)this.postalCode=e.postal_code;if(e.state!==undefined)this.state=e.state};
|
|
274
273
|
/**
|
|
275
274
|
* Initialize the address suggestions
|
|
276
275
|
*/e.prototype.initAddressSuggestions=function(){var e=this;
|
|
277
276
|
// Only initialize the address suggestions if the address service is not already initialized
|
|
278
|
-
if(!zonosStore.checkoutAddressService||!!this.onAddressSuggestionsUnsubscribe&&!!this.onAddressSelectedUnsubscribe){return}log("on initAddressSuggestions","info");this.onAddressSuggestionsUnsubscribe=zonosStore.checkoutAddressService.onAddressSuggestions((function(t){var r=t.suggestions,
|
|
277
|
+
if(!zonosStore.checkoutAddressService||!!this.onAddressSuggestionsUnsubscribe&&!!this.onAddressSelectedUnsubscribe){return}log("on initAddressSuggestions","info");this.onAddressSuggestionsUnsubscribe=zonosStore.checkoutAddressService.onAddressSuggestions((function(t){var r=t.suggestions,o=t.type;
|
|
279
278
|
// Only update the address suggestions if the type matches the current type
|
|
280
|
-
if(
|
|
279
|
+
if(o!==e.type){return}e.addressSuggestions=r}));this.onAddressSelectedUnsubscribe=zonosStore.checkoutAddressService.onAddressSelected((function(t){if(t.type!==e.type){return}e.addressSuggestions=[];e.addressSuggestionSelected(t)}));this.validate({type:this.type,value:this.firstName,valueType:"firstName"});this.validate({type:this.type,value:this.lastName,valueType:"lastName"});this.validate({type:this.type,value:this.line1,valueType:"line1"});this.validate({type:this.type,value:this.phone,valueType:"phone"});this.validate({type:this.type,value:this.postalCode,valueType:"postalCode"});this.validate({type:this.type,value:this.state,valueType:"state"});this.validate({type:this.type,value:this.city,valueType:"city"});this.validate({type:this.type,value:this.phone,valueType:"phone"})};e.prototype.countryChanged=function(e){var t,r;var o=(t=zonosStore.genericSettings)===null||t===void 0?void 0:t.countryFields;var n=o===null||o===void 0?void 0:o[e];
|
|
281
280
|
// If the country code of countryFields are the same as current selected country code, do nothing
|
|
282
|
-
if(((r=this.countryField)===null||r===void 0?void 0:r.countryCode)===this.country){return}if(n
|
|
281
|
+
if(((r=this.countryField)===null||r===void 0?void 0:r.countryCode)===this.country){return}if(o&&n){this.countryField=n;return}this.countryField=null};e.prototype.shouldEnabledCustomAddressChanged=function(){
|
|
283
282
|
// Only initialize the address suggestions if the address service is not already initialized
|
|
284
|
-
this.initAddressSuggestions();this.initDefaultCustomAddressForm()};e.prototype.renderCustomAddressForm=function(){var e=this;var t,r,n,
|
|
283
|
+
this.initAddressSuggestions();this.initDefaultCustomAddressForm()};e.prototype.renderCustomAddressForm=function(){var e=this;var t,r,o,n,i,d,s,a,u,l,$,c,f,p,v,b;var y=this.getCustomAddressErrors(),m=y.showError,g=__rest(y,["showError"]);var _=this.getStripeAddressInstance().stripeAddressEventData;var z=_===null||_===void 0?void 0:_.value.address.country;
|
|
285
284
|
/**
|
|
286
285
|
* Billing addresses are not limited to the shipping zone: a shopper's card
|
|
287
286
|
* can be billed to any country, so restricting it would block them from
|
|
@@ -318,7 +317,7 @@ e.validate({type:e.type,value:"",valueType:"postalCode"});e.validate({type:e.typ
|
|
|
318
317
|
* Therefore, we must update the value after validation to ensure correct error state
|
|
319
318
|
*/e.line1=t.detail},onKeyDown:function(t){
|
|
320
319
|
// Clear the address suggestions when the user presses the escape key
|
|
321
|
-
if(t.key==="Escape"){t.preventDefault();t.stopPropagation();e.addressSuggestions=[]}},required:true}),h("zonos-address-suggestions",{onSuggestionSelected:function(t){var r;var
|
|
320
|
+
if(t.key==="Escape"){t.preventDefault();t.stopPropagation();e.addressSuggestions=[]}},required:true}),h("zonos-address-suggestions",{onSuggestionSelected:function(t){var r;var o=t.detail.placeId;(r=zonosStore.checkoutAddressService)===null||r===void 0?void 0:r.selectAddress({placeId:o,type:e.type})},suggestions:this.addressSuggestions,type:this.type})),h("div",{"aria-label":"Additional address details",class:classes(["zonos--custom-address-form-additional-fields",z&&this.isAddressLine1Entered?"zonos--show":""]),role:"group"},h("zonos-stripe-input",{"aria-required":"false",autoComplete:"".concat(this.type," address-line2"),class:"zonos--custom-address-form-input",inputLabel:translate(((r=this.countryField)===null||r===void 0?void 0:r.address2Label)||"Address line 2"),inputValue:(_===null||_===void 0?void 0:_.value.address.line2)||"",onInputChange:function(t){e.line2=t.detail}}),((o=this.countryField)===null||o===void 0?void 0:o.cityShow)&&h("zonos-stripe-input",{"aria-required":((n=this.countryField)===null||n===void 0?void 0:n.cityRequired)?"true":"false",autoComplete:"".concat(this.type," address-level2"),class:"zonos--custom-address-form-input",error:m?g.city:undefined,inputLabel:translate(((i=this.countryField)===null||i===void 0?void 0:i.cityLabel)||"City"),inputValue:(_===null||_===void 0?void 0:_.value.address.city)||"",name:"locality",onInputChange:function(t){e.validate({type:e.type,value:t.detail,valueType:"city"});
|
|
322
321
|
/**
|
|
323
322
|
* Order of operations is important here:
|
|
324
323
|
* 1. validate() updates all input error states
|
|
@@ -339,16 +338,16 @@ if(t.key==="Escape"){t.preventDefault();t.stopPropagation();e.addressSuggestions
|
|
|
339
338
|
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
340
339
|
* 3. getIsComplete() checks customAddressErrors state
|
|
341
340
|
* Therefore, we must update the value after validation to ensure correct error state
|
|
342
|
-
*/e.postalCode=t.detail},required:(v=this.countryField)===null||v===void 0?void 0:v.zipRequired,title:"".concat(this.type," zip code")})),h("zonos-stripe-phone-input",{autoComplete:"".concat(this.type," tel"),class:"zonos--custom-address-form-input",countryCode:_===null||_===void 0?void 0:_.value.address.country,countryOptions:(b=zonosStore.genericSettings)===null||b===void 0?void 0:b.countryFields,error:m?g.phone:undefined,inputLabel:translate("Phone number"),inputValue:(_===null||_===void 0?void 0:_.value.phone)||"",onInputValueChange:function(t){var r=t.detail,
|
|
341
|
+
*/e.postalCode=t.detail},required:(v=this.countryField)===null||v===void 0?void 0:v.zipRequired,title:"".concat(this.type," zip code")})),h("zonos-stripe-phone-input",{autoComplete:"".concat(this.type," tel"),class:"zonos--custom-address-form-input",countryCode:_===null||_===void 0?void 0:_.value.address.country,countryOptions:(b=zonosStore.genericSettings)===null||b===void 0?void 0:b.countryFields,error:m?g.phone:undefined,inputLabel:translate("Phone number"),inputValue:(_===null||_===void 0?void 0:_.value.phone)||"",onInputValueChange:function(t){var r=t.detail,o=r.isEmpty,n=r.phoneNumber,i=r.valid,d=r.wrongFormat;
|
|
343
342
|
// Validate the phone number
|
|
344
|
-
e.validate({phoneValidateInfo:{isEmpty:
|
|
343
|
+
e.validate({phoneValidateInfo:{isEmpty:o,isValid:i,wrongFormat:d},type:e.type,value:n,valueType:"phone"});
|
|
345
344
|
/**
|
|
346
345
|
* Order of operations is important here:
|
|
347
346
|
* 1. validate() updates all input error states
|
|
348
347
|
* 2. Setting postalCode triggers @Watch('postalCode')
|
|
349
348
|
* 3. getIsComplete() checks customAddressErrors state
|
|
350
349
|
* Therefore, we must update the value after validation to ensure correct error state
|
|
351
|
-
*/e.phone=
|
|
350
|
+
*/e.phone=n}})))};e.prototype.disconnectedCallback=function(){var e,t;
|
|
352
351
|
// destroy the stripe element when this component is removed from the DOM, so that we can re-create the new one with previous value
|
|
353
352
|
var r=this.getStripeAddressInstance().stripeAddressElement;r===null||r===void 0?void 0:r.destroy();
|
|
354
353
|
// unsubscribe from address suggestions when this component is removed from the DOM
|
|
@@ -362,7 +361,7 @@ this.onStoreCheckoutSessionIdChanged();this.countryChanged((e===null||e===void 0
|
|
|
362
361
|
// Only set country if custom address form is enabled
|
|
363
362
|
if(!this.country&&localizationStore.selectedCountryCode){this.country=localizationStore.selectedCountryCode}
|
|
364
363
|
// this component loads iframe from the stripe elements and puts here, so we don't need to do anything here
|
|
365
|
-
return h(Host,{key:"
|
|
364
|
+
return h(Host,{key:"d3bb2635d41dd74ba52ff37034f348fc0a763366",class:classes(["zonos--address zonos--elements","zonos--".concat(this.type,"-address")])},h("zonos-text",{key:"7d3f67988eac13616f3470f46f05060e194c2df7",class:"zonos--title",type:"semiBoldLabel"},this.titleText),h("slot",{key:"1bd63bd015542ec3302f087bcbf3d9549f342c25",name:"below-title"}),this.renderCompanyNameInput(),this.renderTaxIdInput(),this.renderShortAddressCodeInput(),this.renderCustomAddressForm())};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{checkoutSessionId:[{isAddressFilledChanged:0}],isAddressFilled:[{isAddressFilledChanged:0}],defaultAddress:[{defaultAddressChanged:0}],line1:[{line1Changed:0}],city:[{formFieldsChanged:0}],country:[{formFieldsChanged:0},{countryChanged:0}],firstName:[{formFieldsChanged:0}],lastName:[{formFieldsChanged:0}],line2:[{formFieldsChanged:0}],phone:[{formFieldsChanged:0}],postalCode:[{formFieldsChanged:0}],state:[{formFieldsChanged:0}],addressService:[{shouldEnabledCustomAddressChanged:0}]}},enumerable:false,configurable:true});return e}();ZonosAddress.style=zonosCustomAddressCss();
|
|
366
365
|
// This file is a workaround for a bug in web browsers' "native"
|
|
367
366
|
// ES6 importing system which is uncapable of importing "*.json" files.
|
|
368
367
|
// https://github.com/catamphetamine/libphonenumber-js/issues/239
|
|
@@ -378,7 +377,7 @@ function withMetadataArgument(e,t){var r=Array.prototype.slice.call(t);r.push(me
|
|
|
378
377
|
|
|
379
378
|
// Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
|
|
380
379
|
// https://github.com/catamphetamine/libphonenumber-js/issues/381
|
|
381
|
-
function compare(e,t){e=e.split("-");t=t.split("-");var r=e[0].split(".");var
|
|
380
|
+
function compare(e,t){e=e.split("-");t=t.split("-");var r=e[0].split(".");var o=t[0].split(".");for(var n=0;n<3;n++){var i=Number(r[n]);var d=Number(o[n]);if(i>d)return 1;if(d>i)return-1;if(!isNaN(i)&&isNaN(d))return 1;if(isNaN(i)&&!isNaN(d))return-1}if(e[1]&&t[1]){return e[1]>t[1]?1:e[1]<t[1]?-1:0}return!e[1]&&t[1]?1:e[1]&&!t[1]?-1:0}var objectConstructor={}.constructor;function isObject(e){return e!==undefined&&e!==null&&e.constructor===objectConstructor}var CALLING_CODE_REG_EXP=/^\d+$/;function isCallingCode(e){return CALLING_CODE_REG_EXP.test(e)}function _typeof$b(e){"@babel/helpers - typeof";return _typeof$b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$b(e)}function _classCallCheck$8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$7(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$a(o.key),o)}}function _createClass$8(e,t,r){return t&&_defineProperties$7(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$a(e){var t=_toPrimitive$a(e,"string");return"symbol"==_typeof$b(t)?t:t+""}function _toPrimitive$a(e,t){if("object"!=_typeof$b(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$b(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}
|
|
382
381
|
// Added "idd_prefix" and "default_idd_prefix".
|
|
383
382
|
var V3="1.2.0";
|
|
384
383
|
// Moved `001` country code to "nonGeographic" section of metadata.
|
|
@@ -402,13 +401,13 @@ var r=this.countryCallingCodes()[t];if(r&&r.length===1&&r[0]==="001"){return tru
|
|
|
402
401
|
* Selects a telephone numbering plan based on either a country code or a calling code.
|
|
403
402
|
* @param {string} argument — Country code or calling code.
|
|
404
403
|
* @param {string} legacyArgumentCallingCode — Legacy argument: calling code, if the first argument is not passed.
|
|
405
|
-
*/},{key:"selectNumberingPlan",value:function e(t,r){var
|
|
404
|
+
*/},{key:"selectNumberingPlan",value:function e(t,r){var o;var n;if(t){if(isCallingCode(t)){n=t}else{o=t}}
|
|
406
405
|
// Previously, the signature of this method was: `.selectNumberingPlan(country, callingCode)`.
|
|
407
406
|
// And if `country` argument wasn't passed, it looked into the second argument `callingCode`.
|
|
408
407
|
// Now it's preferred to only pass either `country` or `callingCode` as the first argument.
|
|
409
|
-
if(r){
|
|
408
|
+
if(r){n=r}
|
|
410
409
|
// Select a telephone numbering plan.
|
|
411
|
-
if(
|
|
410
|
+
if(o&&o!=="001"){var i=this.getCountryMetadata(o);if(!i){throw new Error("Unknown country: ".concat(o))}this.numberingPlan=new NumberingPlan(i,this)}else if(n){if(!this.hasCallingCode(n)){throw new Error("Unknown calling code: ".concat(n))}this.numberingPlan=new NumberingPlan(this.getNumberingPlanMetadata(n),this)}else{this.numberingPlan=undefined}return this}},{key:"getCountryCodesForCallingCode",value:function e(t){var r=this.countryCallingCodes()[t];if(r){
|
|
412
411
|
// Metadata before V4 included "non-geographic entity" calling codes
|
|
413
412
|
// inside `country_calling_codes` (for example, `"881":["001"]`).
|
|
414
413
|
// Now the semantics of `country_calling_codes` has changed:
|
|
@@ -423,13 +422,13 @@ if(r.length===1&&r[0].length===3){return}return r}}},{key:"getCountryCodeForCall
|
|
|
423
422
|
// of the "default" country for this calling code.
|
|
424
423
|
// For example, if calling code `1` is passed,
|
|
425
424
|
// the telephone numbering plan of `US` will be selected.
|
|
426
|
-
var r=this.getCountryCodeForCallingCode(t);if(r){return this.getCountryMetadata(r)}if(this.nonGeographic()){var
|
|
425
|
+
var r=this.getCountryCodeForCallingCode(t);if(r){return this.getCountryMetadata(r)}if(this.nonGeographic()){var o=this.nonGeographic()[t];if(o){return o}}else{
|
|
427
426
|
// A hacky workaround for old custom metadata (generated before V4).
|
|
428
427
|
// In that metadata, there was no concept of "non-geographic" metadata
|
|
429
428
|
// so metadata for `001` country code was stored along with other countries.
|
|
430
429
|
// The test case can be found by searching for:
|
|
431
430
|
// "should work around `nonGeographic` metadata not existing".
|
|
432
|
-
var
|
|
431
|
+
var n=this.countryCallingCodes()[t];if(n&&n.length===1&&n[0]==="001"){return this.metadata.countries["001"]}}}
|
|
433
432
|
// Deprecated.
|
|
434
433
|
},{key:"countryCallingCode",value:function e(){return this.numberingPlan.callingCode()}
|
|
435
434
|
// Deprecated.
|
|
@@ -590,9 +589,9 @@ return t.countries.hasOwnProperty(e)}
|
|
|
590
589
|
// to check phone number length for that specific `country` rather than the "main" country
|
|
591
590
|
// for the shared "country calling code".
|
|
592
591
|
|
|
593
|
-
function checkNumberLengthForType(e,t,r,
|
|
592
|
+
function checkNumberLengthForType(e,t,r,o){if(r){
|
|
594
593
|
// If a specific `country` is specified, re-create a metadata instance with it.
|
|
595
|
-
|
|
594
|
+
o=new Metadata(o.metadata);o.selectNumberingPlan(r)}var n=o.type(t);
|
|
596
595
|
// There should always be "<possiblePengths/>" set for every type element.
|
|
597
596
|
// This is declared in the XML schema.
|
|
598
597
|
// For size efficiency, where a sub-description (e.g. fixed-line)
|
|
@@ -600,7 +599,7 @@ n=new Metadata(n.metadata);n.selectNumberingPlan(r)}var o=n.type(t);
|
|
|
600
599
|
// so we fall back to the "general description". Where no numbers of the type
|
|
601
600
|
// exist at all, there is one possible length (-1) which is guaranteed
|
|
602
601
|
// not to match the length of any real phone number.
|
|
603
|
-
var i=
|
|
602
|
+
var i=n&&n.possibleLengths()||o.possibleLengths();
|
|
604
603
|
// let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
|
|
605
604
|
// Metadata before version `1.0.18` didn't contain `possible_lengths`.
|
|
606
605
|
if(!i){return"IS_POSSIBLE"}var d=e.length;
|
|
@@ -628,10 +627,10 @@ return i.indexOf(d,1)>=0?"IS_POSSIBLE":"INVALID_LENGTH"}
|
|
|
628
627
|
* @return {string}
|
|
629
628
|
*/function isPossiblePhoneNumber(e,t,r){
|
|
630
629
|
/* istanbul ignore if */
|
|
631
|
-
if(t===undefined){t={}}var
|
|
630
|
+
if(t===undefined){t={}}var o=new Metadata(r);if(t.v2){if(!e.countryCallingCode){throw new Error("Invalid phone number object passed")}o.selectNumberingPlan(e.country||e.countryCallingCode)}else{if(!e.phone){return false}if(e.country){if(!o.hasCountry(e.country)){throw new Error("Unknown country: ".concat(e.country))}o.selectNumberingPlan(e.country)}else{if(!e.countryCallingCode){throw new Error("Invalid phone number object passed")}o.selectNumberingPlan(e.countryCallingCode)}}
|
|
632
631
|
// Old (legacy) metadata (< 1.0.18) had no "possible length" data.
|
|
633
632
|
// So `isPossibleNumber()` function is supported only for non-legacy metadata.
|
|
634
|
-
if(
|
|
633
|
+
if(o.possibleLengths()){return isPossibleNumber$2(e.phone||e.nationalNumber,o)}
|
|
635
634
|
// There was a bug in versions from `1.7.35` to `1.7.37` of `libphonenumber-js`
|
|
636
635
|
// where "possible_lengths" property was missing from "non-geographical" numbering plans' metadata.
|
|
637
636
|
// After that, the bug was noticed and fixed.
|
|
@@ -639,7 +638,7 @@ if(n.possibleLengths()){return isPossibleNumber$2(e.phone||e.nationalNumber,n)}
|
|
|
639
638
|
// The reason is that the bug was noticed relatively quickly (within a day or so)
|
|
640
639
|
// and it's unlikely that anyone generated their custom metadata in that short time span.
|
|
641
640
|
// And if they didn't generate any custom metadata then a follow-up package update would've silently fixed the bug.
|
|
642
|
-
if(e.countryCallingCode&&
|
|
641
|
+
if(e.countryCallingCode&&o.isNonGeographicCallingCode(e.countryCallingCode)){return true}
|
|
643
642
|
// `isPossibleNumber()` function is not supported.
|
|
644
643
|
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.')}
|
|
645
644
|
/**
|
|
@@ -660,7 +659,7 @@ default:return false}}
|
|
|
660
659
|
*/function matchesEntirely(e,t){
|
|
661
660
|
// If the assigning of the `''` default value is moved to the arguments above,
|
|
662
661
|
// the code coverage would decrease for some weird reason.
|
|
663
|
-
e=e||"";return new RegExp("^(?:"+t+")$").test(e)}function _createForOfIteratorHelperLoose$6(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$9(e))||t){r&&(e=r);var
|
|
662
|
+
e=e||"";return new RegExp("^(?:"+t+")$").test(e)}function _createForOfIteratorHelperLoose$6(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$9(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$9(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$9(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$9(e,t):void 0}}function _arrayLikeToArray$9(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}var NON_FIXED_LINE_PHONE_TYPES=["MOBILE","PREMIUM_RATE","TOLL_FREE","SHARED_COST","VOIP","PERSONAL_NUMBER","PAGER","UAN","VOICEMAIL"];
|
|
664
663
|
// Finds out national phone number type (fixed line, mobile, etc)
|
|
665
664
|
function getNumberType(e,t,r){
|
|
666
665
|
// If assigning the `{}` default value is moved to the arguments above,
|
|
@@ -669,17 +668,17 @@ t=t||{};
|
|
|
669
668
|
// When `parse()` returns an empty object — `{}` —
|
|
670
669
|
// that means that the phone number is malformed,
|
|
671
670
|
// so it can't possibly be valid.
|
|
672
|
-
if(!e.country&&!e.countryCallingCode){return}var
|
|
671
|
+
if(!e.country&&!e.countryCallingCode){return}var o=new Metadata(r);o.selectNumberingPlan(e.country||e.countryCallingCode);var n=t.v2?e.nationalNumber:e.phone;
|
|
673
672
|
// The following is copy-pasted from the original function:
|
|
674
673
|
// https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
|
|
675
674
|
// Is this national number even valid for this country
|
|
676
|
-
if(!matchesEntirely(o
|
|
675
|
+
if(!matchesEntirely(n,o.nationalNumberPattern())){return}
|
|
677
676
|
// Is it fixed line number
|
|
678
|
-
if(isNumberTypeEqualTo(
|
|
677
|
+
if(isNumberTypeEqualTo(n,"FIXED_LINE",o)){
|
|
679
678
|
// Because duplicate regular expressions are removed
|
|
680
679
|
// to reduce metadata size, if "mobile" pattern is ""
|
|
681
680
|
// then it means it was removed due to being a duplicate of the fixed-line pattern.
|
|
682
|
-
if(
|
|
681
|
+
if(o.type("MOBILE")&&o.type("MOBILE").pattern()===""){return"FIXED_LINE_OR_MOBILE"}
|
|
683
682
|
// `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
|
|
684
683
|
// For example, for "US" country.
|
|
685
684
|
// Old metadata (< `1.0.18`) had a specific "types" data structure
|
|
@@ -687,17 +686,17 @@ if(n.type("MOBILE")&&n.type("MOBILE").pattern()===""){return"FIXED_LINE_OR_MOBIL
|
|
|
687
686
|
// Newer metadata (>= `1.0.18`) has another data structure that is
|
|
688
687
|
// not `undefined` for `MOBILE` in that case (it's just an empty array).
|
|
689
688
|
// So this `if` is just for backwards compatibility with old metadata.
|
|
690
|
-
if(!
|
|
689
|
+
if(!o.type("MOBILE")){return"FIXED_LINE_OR_MOBILE"}
|
|
691
690
|
// Check if the number happens to qualify as both fixed line and mobile.
|
|
692
691
|
// (no such country in the minimal metadata set)
|
|
693
|
-
/* istanbul ignore if */if(isNumberTypeEqualTo(
|
|
692
|
+
/* istanbul ignore if */if(isNumberTypeEqualTo(n,"MOBILE",o)){return"FIXED_LINE_OR_MOBILE"}return"FIXED_LINE"}for(var i=_createForOfIteratorHelperLoose$6(NON_FIXED_LINE_PHONE_TYPES),d;!(d=i()).done;){var s=d.value;if(isNumberTypeEqualTo(n,s,o)){return s}}}function isNumberTypeEqualTo(e,t,r){var o=r.type(t);if(!o||!o.pattern()){return false}
|
|
694
693
|
// Check if any possible number lengths are present;
|
|
695
694
|
// if so, we use them to avoid checking
|
|
696
695
|
// the validation pattern if they don't match.
|
|
697
696
|
// If they are absent, this means they match
|
|
698
697
|
// the general description, which we have
|
|
699
698
|
// already checked before a specific number type.
|
|
700
|
-
if(
|
|
699
|
+
if(o.possibleLengths()&&o.possibleLengths().indexOf(e.length)<0){return false}return matchesEntirely(e,o.pattern())}
|
|
701
700
|
/**
|
|
702
701
|
* Checks if a given phone number is valid.
|
|
703
702
|
*
|
|
@@ -734,23 +733,23 @@ if(n.possibleLengths()&&n.possibleLengths().indexOf(e.length)<0){return false}re
|
|
|
734
733
|
*/function isValidNumber(e,t,r){
|
|
735
734
|
// If assigning the `{}` default value is moved to the arguments above,
|
|
736
735
|
// code coverage would decrease for some weird reason.
|
|
737
|
-
t=t||{};var
|
|
736
|
+
t=t||{};var o=new Metadata(r);o.selectNumberingPlan(e.country||e.countryCallingCode);
|
|
738
737
|
// By default, countries only have type regexps when it's required for
|
|
739
738
|
// distinguishing different countries having the same `countryCallingCode`.
|
|
740
|
-
if(
|
|
739
|
+
if(o.hasTypes()){return getNumberType(e,t,o.metadata)!==undefined}
|
|
741
740
|
// If there are no type regexps for this country in metadata then use
|
|
742
741
|
// `nationalNumberPattern` as a "better than nothing" replacement.
|
|
743
|
-
var
|
|
742
|
+
var n=t.v2?e.nationalNumber:e.phone;return matchesEntirely(n,o.nationalNumberPattern())}var COUNTRY_CODE_REG_EXP=/^[A-Z]{2}$/;function isCountryCode(e){return COUNTRY_CODE_REG_EXP.test(e)}function getCountryAndCallingCodeFromOneOfThem(e,t){var r;var o;var n=new Metadata(t);
|
|
744
743
|
// If country code is passed then derive `countryCallingCode` from it.
|
|
745
744
|
// Also store the country code as `.country`.
|
|
746
|
-
if(isCountryCode(e)){r=e;
|
|
745
|
+
if(isCountryCode(e)){r=e;n.selectNumberingPlan(r);o=n.countryCallingCode()}else{o=e}return{country:r,callingCode:o}}
|
|
747
746
|
/**
|
|
748
747
|
* Returns a list of countries that the phone number could potentially belong to.
|
|
749
748
|
* @param {string} callingCode — Calling code.
|
|
750
749
|
* @param {string} nationalNumber — National (significant) number.
|
|
751
750
|
* @param {object} metadata — Metadata.
|
|
752
751
|
* @return {string[]} A list of possible countries.
|
|
753
|
-
*/function getPossibleCountriesForNumber(e,t,r){var
|
|
752
|
+
*/function getPossibleCountriesForNumber(e,t,r){var o=new Metadata(r);var n=o.getCountryCodesForCallingCode(e);if(!n){return[]}return n.filter((function(e){return couldNationalNumberBelongToCountry(t,e,r)}))}function couldNationalNumberBelongToCountry(e,t,r){var o=new Metadata(r);o.selectNumberingPlan(t);return o.numberingPlan.possibleLengths().indexOf(e.length)>=0}
|
|
754
753
|
// The minimum length of the national significant number.
|
|
755
754
|
var MIN_LENGTH_FOR_NSN=2;
|
|
756
755
|
// The ITU says the maximum length should be 15,
|
|
@@ -771,9 +770,9 @@ var TILDES="~⁓∼~";
|
|
|
771
770
|
// parentheses and tildes. Full-width variants are also present.
|
|
772
771
|
var VALID_PUNCTUATION="".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);var PLUS_CHARS="++";
|
|
773
772
|
// const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
|
|
774
|
-
var CAPTURING_DIGIT_PATTERN=new RegExp("(["+VALID_DIGITS+"])");function stripIddPrefix(e,t,r,
|
|
773
|
+
var CAPTURING_DIGIT_PATTERN=new RegExp("(["+VALID_DIGITS+"])");function stripIddPrefix(e,t,r,o){if(!t){return}
|
|
775
774
|
// Get the IDD prefix pattern.
|
|
776
|
-
var
|
|
775
|
+
var n=new Metadata(o);n.selectNumberingPlan(t||r);var i=new RegExp(n.IDDPrefix());
|
|
777
776
|
// Check if the number is IDD-prefixed.
|
|
778
777
|
if(e.search(i)!==0){return}
|
|
779
778
|
// Strip IDD prefix.
|
|
@@ -799,7 +798,7 @@ var d=e.match(CAPTURING_DIGIT_PATTERN);if(d&&d[1]!=null&&d[1].length>0){if(d[1]=
|
|
|
799
798
|
// See METADATA.md for the description of
|
|
800
799
|
// `national_prefix_for_parsing` and `national_prefix_transform_rule`.
|
|
801
800
|
// Attempt to parse the first digits as a national prefix.
|
|
802
|
-
var r=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")");var
|
|
801
|
+
var r=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")");var o=r.exec(e);if(o){var n;var i;
|
|
803
802
|
// https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
|
|
804
803
|
// If a `national_prefix_for_parsing` has any "capturing groups"
|
|
805
804
|
// then it means that the national (significant) number is equal to
|
|
@@ -816,10 +815,10 @@ var r=new RegExp("^(?:"+t.numberingPlan.nationalPrefixForParsing()+")");var n=r.
|
|
|
816
815
|
// It's not possible to tell whether there'll be any "capturing gropus"
|
|
817
816
|
// before the matching process, because a `national_prefix_for_parsing`
|
|
818
817
|
// could exhibit both behaviors.
|
|
819
|
-
var d=
|
|
818
|
+
var d=o.length-1;var s=d>0&&o[d];if(t.nationalPrefixTransformRule()&&s){n=e.replace(r,t.nationalPrefixTransformRule());
|
|
820
819
|
// If there's more than one captured group,
|
|
821
820
|
// then carrier code is the second one.
|
|
822
|
-
if(d>1){i=
|
|
821
|
+
if(d>1){i=o[1]}}
|
|
823
822
|
// If there're no "capturing groups",
|
|
824
823
|
// or if there're "capturing groups" but no
|
|
825
824
|
// `national_prefix_transform_rule`,
|
|
@@ -832,23 +831,23 @@ else{
|
|
|
832
831
|
// There seem to be no guarantees that it's just a national prefix.
|
|
833
832
|
// For example, if there's a carrier code, it's gonna be a
|
|
834
833
|
// part of `prefixBeforeNationalNumber` too.
|
|
835
|
-
var a=
|
|
834
|
+
var a=o[0];n=e.slice(a.length);
|
|
836
835
|
// If there's at least one captured group,
|
|
837
836
|
// then carrier code is the first one.
|
|
838
|
-
if(s){i=
|
|
837
|
+
if(s){i=o[1]}}
|
|
839
838
|
// Tries to guess whether a national prefix was present in the input.
|
|
840
839
|
// This is not something copy-pasted from Google's library:
|
|
841
840
|
// they don't seem to have an equivalent for that.
|
|
842
841
|
// So this isn't an "officially approved" way of doing something like that.
|
|
843
842
|
// But since there seems no other existing method, this library uses it.
|
|
844
|
-
var u;if(s){var l=e.indexOf(
|
|
843
|
+
var u;if(s){var l=e.indexOf(o[1]);var $=e.slice(0,l);
|
|
845
844
|
// Example: an Argentinian (AR) phone number `0111523456789`.
|
|
846
845
|
// `prefixMatch[0]` is `01115`, and `$1` is `11`,
|
|
847
846
|
// and the rest of the phone number is `23456789`.
|
|
848
847
|
// The national number is transformed via `9$1` to `91123456789`.
|
|
849
848
|
// National prefix `0` is detected being present at the start.
|
|
850
849
|
// if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
|
|
851
|
-
if($===t.numberingPlan.nationalPrefix()){u=t.numberingPlan.nationalPrefix()}}else{u=
|
|
850
|
+
if($===t.numberingPlan.nationalPrefix()){u=t.numberingPlan.nationalPrefix()}}else{u=o[0]}return{nationalNumber:n,nationalPrefix:u,carrierCode:i}}}return{nationalNumber:e}}function _createForOfIteratorHelperLoose$5(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$8(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$8(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$8(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$8(e,t):void 0}}function _arrayLikeToArray$8(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}
|
|
852
851
|
/**
|
|
853
852
|
* Returns the exact country that a given national (significant) number belongs to
|
|
854
853
|
* in case of ambiguity, i.e. when multiple countries share the same "country calling code".
|
|
@@ -858,9 +857,9 @@ if($===t.numberingPlan.nationalPrefix()){u=t.numberingPlan.nationalPrefix()}}els
|
|
|
858
857
|
* @returns {string?} Returns the exact country this number belongs to, or `undefined` if the exact country couldn't be determined.
|
|
859
858
|
*/function getCountryByNationalNumber(e,t,r){
|
|
860
859
|
// Create a new `metadata` instance because it will be selecting a `country`.
|
|
861
|
-
var
|
|
860
|
+
var o=new Metadata(r);
|
|
862
861
|
// const matchingCountries = []
|
|
863
|
-
for(var
|
|
862
|
+
for(var n=_createForOfIteratorHelperLoose$5(t),i;!(i=n()).done;){var d=i.value;o.selectNumberingPlan(d);
|
|
864
863
|
// "Leading digits" patterns are only defined for about 20% of all countries.
|
|
865
864
|
// By definition, matching "leading digits" is a sufficient but not a necessary
|
|
866
865
|
// condition for a phone number to belong to a country.
|
|
@@ -868,10 +867,10 @@ for(var o=_createForOfIteratorHelperLoose$5(t),i;!(i=o()).done;){var d=i.value;n
|
|
|
868
867
|
// https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
|
|
869
868
|
// I'd suppose that "leading digits" patterns are mutually exclusive for different countries
|
|
870
869
|
// because of the intended use of that feature.
|
|
871
|
-
if(
|
|
870
|
+
if(o.leadingDigits()){if(e&&e.search(o.leadingDigits())===0){return d}}
|
|
872
871
|
// Else perform full validation with all of those
|
|
873
872
|
// fixed-line/mobile/etc regular expressions.
|
|
874
|
-
else if(getNumberType({phone:e,country:d},undefined,
|
|
873
|
+
else if(getNumberType({phone:e,country:d},undefined,o.metadata)){
|
|
875
874
|
// When multiple countries share the same "country calling code",
|
|
876
875
|
// type patterns aren't guaranteed to be unique among them.
|
|
877
876
|
// For example, both `US` and `CA` have the same pattern for `toll_free` numbers.
|
|
@@ -915,10 +914,10 @@ return d;
|
|
|
915
914
|
* @param {string} [options.nationalNumber] — National (significant) number.
|
|
916
915
|
* @param {Metadata} options.metadata — Metadata instance.
|
|
917
916
|
* @returns {string?} Returns the most suitable country for this calling code and national (significant) number.
|
|
918
|
-
*/function getCountryByCallingCode(e,t){var r=t.nationalNumber,
|
|
917
|
+
*/function getCountryByCallingCode(e,t){var r=t.nationalNumber,o=t.metadata;var n=o.getCountryCodesForCallingCode(e);if(!n){return}
|
|
919
918
|
// If there's just one country corresponding to the country code,
|
|
920
919
|
// then just return it, without further phone number digits validation.
|
|
921
|
-
if(
|
|
920
|
+
if(n.length===1){return n[0]}return getCountryByNationalNumber(r,n,o.metadata)}
|
|
922
921
|
/**
|
|
923
922
|
* Strips national prefix and carrier code from a complete phone number.
|
|
924
923
|
* The difference from the non-"FromCompleteNumber" function is that
|
|
@@ -938,7 +937,7 @@ if(o.length===1){return o[0]}return getCountryByNationalNumber(r,o,n.metadata)}
|
|
|
938
937
|
// Google's original library forgives such mistakes
|
|
939
938
|
// and so does this library, because it has been requested:
|
|
940
939
|
// https://github.com/catamphetamine/libphonenumber-js/issues/127
|
|
941
|
-
var
|
|
940
|
+
var o=extractNationalNumberFromPossiblyIncompleteNumber(e,r),n=o.carrierCode,i=o.nationalNumber;if(i!==e){if(!shouldHaveExtractedNationalPrefix(e,i,r)){
|
|
942
941
|
// Don't strip the national prefix.
|
|
943
942
|
return{nationalNumber:e}}
|
|
944
943
|
// Check the national (significant) number length after extracting national prefix and carrier code.
|
|
@@ -957,7 +956,7 @@ if(!t){t=getCountryByCallingCode(r.numberingPlan.callingCode(),{nationalNumber:i
|
|
|
957
956
|
// I guess it's fine not checking that one. It works as is anyway.
|
|
958
957
|
if(!isPossibleIncompleteNationalNumber(i,t,r)){
|
|
959
958
|
// Don't strip the national prefix.
|
|
960
|
-
return{nationalNumber:e}}}}return{nationalNumber:i,carrierCode:
|
|
959
|
+
return{nationalNumber:e}}}}return{nationalNumber:i,carrierCode:n}}
|
|
961
960
|
// In some countries, the same digit could be a national prefix
|
|
962
961
|
// or a leading digit of a valid phone number.
|
|
963
962
|
// For example, in Russia, national prefix is `8`,
|
|
@@ -1010,15 +1009,15 @@ return false;default:return true}}
|
|
|
1010
1009
|
* @param {string} [defaultCallingCode]
|
|
1011
1010
|
* @param {object} metadataJson
|
|
1012
1011
|
* @return {object} `{ countryCallingCode: string?, number: string }`, where `countryCallingCode` is the calling code that was extracted from the input `number` string, and `number` is the originally passed `number` without the extracted calling code.
|
|
1013
|
-
*/function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(e,t,r,n
|
|
1012
|
+
*/function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(e,t,r,o,n){
|
|
1014
1013
|
// Validate arguments.
|
|
1015
1014
|
// The `number` is known to be in a non-international form
|
|
1016
1015
|
// because there's no leading "+" character.
|
|
1017
1016
|
// Therefore, there must be either `country` or `defaultCountry` or `defaultCallingCode`.
|
|
1018
1017
|
// Otherwise, there'd be no source for the calling code to search for in the `number`.
|
|
1019
|
-
if(!(t||r||
|
|
1018
|
+
if(!(t||r||o)){
|
|
1020
1019
|
// There's no source for the calling code to search for in the `number`.
|
|
1021
|
-
return{number:e}}var i=t||r?getCountryCallingCode(t||r,
|
|
1020
|
+
return{number:e}}var i=t||r?getCountryCallingCode(t||r,n):o;if(e.indexOf(i)===0){var d=new Metadata(n);d.selectNumberingPlan(t||r||o);var s=e.slice(i.length);var a=extractNationalNumber(s,undefined,d),u=a.nationalNumber;var l=extractNationalNumber(e,undefined,d),$=l.nationalNumber;
|
|
1022
1021
|
// If the number was not valid before but is valid now,
|
|
1023
1022
|
// or if it was too long before, we consider the number
|
|
1024
1023
|
// with the country calling code stripped to be a better result
|
|
@@ -1051,7 +1050,7 @@ if(!matchesEntirely($,d.nationalNumberPattern())&&matchesEntirely(u,d.nationalNu
|
|
|
1051
1050
|
* extractCountryCallingCode('2133734253', null, null, '1', metadata)
|
|
1052
1051
|
* extractCountryCallingCode('+12133734253', null, null, null, metadata)
|
|
1053
1052
|
* extractCountryCallingCode('+12133734253', null, 'RU', null, metadata)
|
|
1054
|
-
*/function extractCountryCallingCode(e,t,r,n
|
|
1053
|
+
*/function extractCountryCallingCode(e,t,r,o,n){if(!e){return{}}var i;
|
|
1055
1054
|
// If this is not an international phone number,
|
|
1056
1055
|
// then either extract an "IDD" prefix, or extract a
|
|
1057
1056
|
// country calling code from a number by autocorrecting it
|
|
@@ -1062,7 +1061,7 @@ if(!matchesEntirely($,d.nationalNumberPattern())&&matchesEntirely(u,d.nationalNu
|
|
|
1062
1061
|
if(e[0]!=="+"){
|
|
1063
1062
|
// Convert an "out-of-country" dialing phone number
|
|
1064
1063
|
// to a proper international phone number.
|
|
1065
|
-
var d=stripIddPrefix(e,t||r,n
|
|
1064
|
+
var d=stripIddPrefix(e,t||r,o,n);
|
|
1066
1065
|
// If an IDD prefix was stripped then
|
|
1067
1066
|
// convert the number to international one
|
|
1068
1067
|
// for subsequent parsing.
|
|
@@ -1071,13 +1070,13 @@ if(d&&d!==e){i=true;e="+"+d}else{
|
|
|
1071
1070
|
// for the default country. If so, we remove the country calling code,
|
|
1072
1071
|
// and do some checks on the validity of the number before and after.
|
|
1073
1072
|
// https://github.com/catamphetamine/libphonenumber-js/issues/376
|
|
1074
|
-
if(t||r||
|
|
1073
|
+
if(t||r||o){var s=extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(e,t,r,o,n),a=s.countryCallingCode,u=s.number;if(a){return{countryCallingCodeSource:"FROM_NUMBER_WITHOUT_PLUS_SIGN",countryCallingCode:a,number:u}}}return{
|
|
1075
1074
|
// No need to set it to `UNSPECIFIED`. It can be just `undefined`.
|
|
1076
1075
|
// countryCallingCodeSource: 'UNSPECIFIED',
|
|
1077
1076
|
number:e}}}
|
|
1078
1077
|
// `number` can only be international at this point.
|
|
1079
1078
|
// Fast abortion: country codes do not begin with a '0'
|
|
1080
|
-
if(e[1]==="0"){return{}}var l=new Metadata(
|
|
1079
|
+
if(e[1]==="0"){return{}}var l=new Metadata(n);
|
|
1081
1080
|
// The thing with country phone codes
|
|
1082
1081
|
// is that they are orthogonal to each other
|
|
1083
1082
|
// i.e. there's no such country phone code A
|
|
@@ -1158,7 +1157,7 @@ function applyInternationalSeparatorStyle(e){return e.replace(new RegExp("[".con
|
|
|
1158
1157
|
// first group is not used in the national pattern (e.g. Argentina) so the $1
|
|
1159
1158
|
// group does not match correctly. Therefore, we use `\d`, so that the first
|
|
1160
1159
|
// group actually used in the pattern will be matched.
|
|
1161
|
-
var FIRST_GROUP_PATTERN=/(\$\d)/;function formatNationalNumberUsingFormat(e,t,r){var
|
|
1160
|
+
var FIRST_GROUP_PATTERN=/(\$\d)/;function formatNationalNumberUsingFormat(e,t,r){var o=r.useInternationalFormat,n=r.withNationalPrefix;var i=e.replace(new RegExp(t.pattern()),o?t.internationalFormat():
|
|
1162
1161
|
// This library doesn't use `domestic_carrier_code_formatting_rule`,
|
|
1163
1162
|
// because that one is only used when formatting phone numbers
|
|
1164
1163
|
// for dialing from a mobile phone, and this is not a dialing library.
|
|
@@ -1172,7 +1171,7 @@ var FIRST_GROUP_PATTERN=/(\$\d)/;function formatNationalNumberUsingFormat(e,t,r)
|
|
|
1172
1171
|
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
|
|
1173
1172
|
// : format.format()
|
|
1174
1173
|
// )
|
|
1175
|
-
|
|
1174
|
+
n&&t.nationalPrefixFormattingRule()?t.format().replace(FIRST_GROUP_PATTERN,t.nationalPrefixFormattingRule()):t.format());if(o){return applyInternationalSeparatorStyle(i)}return i}
|
|
1176
1175
|
/**
|
|
1177
1176
|
* Pattern that makes it easy to distinguish whether a region has a single
|
|
1178
1177
|
* international dialing prefix or not. If a region has a single international
|
|
@@ -1184,7 +1183,7 @@ o&&t.nationalPrefixFormattingRule()?t.format().replace(FIRST_GROUP_PATTERN,t.nat
|
|
|
1184
1183
|
*/var SINGLE_IDD_PREFIX_REG_EXP=/^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/;
|
|
1185
1184
|
// If the `country` supports IDD calling, it returns a preferred IDD prefix.
|
|
1186
1185
|
// If the `country` doesn't support IDD calling, it returns `undefined`.
|
|
1187
|
-
function getIddPrefix(e,t,r){var
|
|
1186
|
+
function getIddPrefix(e,t,r){var o=new Metadata(r);o.selectNumberingPlan(e||t);if(o.defaultIDDPrefix()){return o.defaultIDDPrefix()}if(SINGLE_IDD_PREFIX_REG_EXP.test(o.IDDPrefix())){return o.IDDPrefix()}}
|
|
1188
1187
|
// The RFC 3966 format for extensions.
|
|
1189
1188
|
var RFC3966_EXTN_PREFIX=";ext=";
|
|
1190
1189
|
/**
|
|
@@ -1207,8 +1206,8 @@ var RFC3966_EXTN_PREFIX=";ext=";
|
|
|
1207
1206
|
/** @type {string} */
|
|
1208
1207
|
var t="20";
|
|
1209
1208
|
/** @type {string} */var r="15";
|
|
1210
|
-
/** @type {string} */var
|
|
1211
|
-
/** @type {string} */var
|
|
1209
|
+
/** @type {string} */var o="9";
|
|
1210
|
+
/** @type {string} */var n="6";
|
|
1212
1211
|
/** @type {string} */var i="[ \\t,]*";
|
|
1213
1212
|
// Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
|
|
1214
1213
|
/** @type {string} */var d="[:\\..]?[ \\t,-]*";
|
|
@@ -1231,10 +1230,10 @@ var t="20";
|
|
|
1231
1230
|
/** @type {string} */var c="(?:,{2}|;)";
|
|
1232
1231
|
/** @type {string} */var f=RFC3966_EXTN_PREFIX+getExtensionDigitsPattern(t);
|
|
1233
1232
|
/** @type {string} */var h=i+a+d+getExtensionDigitsPattern(t)+s;
|
|
1234
|
-
/** @type {string} */var p=i+u+d+getExtensionDigitsPattern(
|
|
1235
|
-
/** @type {string} */var v=l+getExtensionDigitsPattern(
|
|
1233
|
+
/** @type {string} */var p=i+u+d+getExtensionDigitsPattern(o)+s;
|
|
1234
|
+
/** @type {string} */var v=l+getExtensionDigitsPattern(n)+"#";
|
|
1236
1235
|
/** @type {string} */var b=$+c+d+getExtensionDigitsPattern(r)+s;
|
|
1237
|
-
/** @type {string} */var y=$+"(?:,)+"+d+getExtensionDigitsPattern(
|
|
1236
|
+
/** @type {string} */var y=$+"(?:,)+"+d+getExtensionDigitsPattern(o)+s;
|
|
1238
1237
|
// The first regular expression covers RFC 3966 format, where the extension is added
|
|
1239
1238
|
// using ";ext=". The second more generic where extension is mentioned with explicit
|
|
1240
1239
|
// labels like "ext:". In both the above cases we allow more numbers in extension than
|
|
@@ -1320,7 +1319,7 @@ function isViablePhoneNumberStart(e){return VALID_PHONE_NUMBER_START_REG_EXP.tes
|
|
|
1320
1319
|
// `phonenumberutil.js` of December 31th, 2018.
|
|
1321
1320
|
|
|
1322
1321
|
// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
|
|
1323
|
-
var DEFAULT_OPTIONS={formatExtension:function e(t,r,
|
|
1322
|
+
var DEFAULT_OPTIONS={formatExtension:function e(t,r,o){return"".concat(t).concat(o.ext()).concat(r)}};
|
|
1324
1323
|
/**
|
|
1325
1324
|
* Formats a phone number.
|
|
1326
1325
|
*
|
|
@@ -1335,7 +1334,7 @@ var DEFAULT_OPTIONS={formatExtension:function e(t,r,n){return"".concat(t).concat
|
|
|
1335
1334
|
* @param {object} [options]
|
|
1336
1335
|
* @param {object} metadataJson
|
|
1337
1336
|
* @return {string}
|
|
1338
|
-
*/function formatNumber(e,t,r,
|
|
1337
|
+
*/function formatNumber(e,t,r,o){
|
|
1339
1338
|
// Apply default options.
|
|
1340
1339
|
if(r){
|
|
1341
1340
|
// Using ES6 "rest spread" syntax here didn't work with `babel`/`istanbul`
|
|
@@ -1343,7 +1342,7 @@ if(r){
|
|
|
1343
1342
|
// to show as not 100%. That's because `babel`/`istanbul`, for some weird reason,
|
|
1344
1343
|
// apparently doesn't know how to properly exclude Babel polyfills from code coverage.
|
|
1345
1344
|
// options = { ...DEFAULT_OPTIONS, ...options }
|
|
1346
|
-
r=merge({},DEFAULT_OPTIONS,r)}else{r=DEFAULT_OPTIONS}var
|
|
1345
|
+
r=merge({},DEFAULT_OPTIONS,r)}else{r=DEFAULT_OPTIONS}var n=new Metadata(o);
|
|
1347
1346
|
// Normally, the `input` object is supposed to be a `PhoneNumber` class instance.
|
|
1348
1347
|
// Also, according to the `PhoneNumber` class source code, `country` can't be "001".
|
|
1349
1348
|
// It means that normally `input.country` or `input.countryCallingCode` is supposed
|
|
@@ -1354,7 +1353,7 @@ r=merge({},DEFAULT_OPTIONS,r)}else{r=DEFAULT_OPTIONS}var o=new Metadata(n);
|
|
|
1354
1353
|
// So normally, it won't ever return an empty string here.
|
|
1355
1354
|
if(e.country&&e.country!=="001"){
|
|
1356
1355
|
// Validate `input.country`.
|
|
1357
|
-
if(!
|
|
1356
|
+
if(!n.hasCountry(e.country)){throw new Error("Unknown country: ".concat(e.country))}n.selectNumberingPlan(e.country)}else if(e.countryCallingCode){n.selectNumberingPlan(e.countryCallingCode)}else return e.phone||"";var i=n.countryCallingCode();var d=r.v2?e.nationalNumber:e.phone;
|
|
1358
1357
|
// This variable should have been declared inside `case`s
|
|
1359
1358
|
// but Babel has a bug and it says "duplicate variable declaration".
|
|
1360
1359
|
var s;switch(t){case"NATIONAL":
|
|
@@ -1362,10 +1361,10 @@ var s;switch(t){case"NATIONAL":
|
|
|
1362
1361
|
// and a `PhoneNumber` class instance is always required to have a `nationalNumber`.
|
|
1363
1362
|
// This means that the `if (!nationalNumber)` below is just for legacy-compatibility
|
|
1364
1363
|
// and it normally can't really happen, so normally it won't ever return an empty string here.
|
|
1365
|
-
if(!d){return""}s=formatNationalNumber$1(d,e.carrierCode,"NATIONAL",
|
|
1364
|
+
if(!d){return""}s=formatNationalNumber$1(d,e.carrierCode,"NATIONAL",n,r);return addExtension(s,e.ext,n,r.formatExtension);case"INTERNATIONAL":
|
|
1366
1365
|
// Legacy argument support.
|
|
1367
1366
|
// (`{ country: ..., phone: '' }`)
|
|
1368
|
-
if(!d){return"+".concat(i)}s=formatNationalNumber$1(d,null,"INTERNATIONAL",
|
|
1367
|
+
if(!d){return"+".concat(i)}s=formatNationalNumber$1(d,null,"INTERNATIONAL",n,r);s="+".concat(i," ").concat(s);return addExtension(s,e.ext,n,r.formatExtension);case"E.164":
|
|
1369
1368
|
// `E.164` doesn't define "phone number extensions".
|
|
1370
1369
|
return"+".concat(i).concat(d);case"RFC3966":return formatRFC3966({number:"+".concat(i).concat(d),ext:e.ext});
|
|
1371
1370
|
// For reference, here's Google's IDD formatter:
|
|
@@ -1376,9 +1375,9 @@ case"IDD":
|
|
|
1376
1375
|
// If the required `fromCountry` parameter is not passed, it will return `undefined`.
|
|
1377
1376
|
if(!r.fromCountry){return;
|
|
1378
1377
|
// throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
|
|
1379
|
-
}var a=formatIDD(d,e.carrierCode,i,r.fromCountry,
|
|
1378
|
+
}var a=formatIDD(d,e.carrierCode,i,r.fromCountry,n);
|
|
1380
1379
|
// If the country of the phone number doesn't support IDD calling, it will return `undefined`.
|
|
1381
|
-
if(!a){return}return addExtension(a,e.ext,
|
|
1380
|
+
if(!a){return}return addExtension(a,e.ext,n,r.formatExtension);default:throw new Error('Unknown "format" argument passed to "formatNumber()": "'.concat(t,'"'))}}function formatNationalNumber$1(e,t,r,o,n){var i=chooseFormatForNumber(o.formats(),e);if(!i){return e}return formatNationalNumberUsingFormat(e,i,{useInternationalFormat:r==="INTERNATIONAL",withNationalPrefix:i.nationalPrefixIsOptionalWhenFormattingInNationalFormat()&&n&&n.nationalPrefix===false?false:true})}function chooseFormatForNumber(e,t){
|
|
1382
1381
|
// Using a `for ... of` loop here didn't work with `babel`/`istanbul`:
|
|
1383
1382
|
// for some weird reason, it showed code coverage less than 100%.
|
|
1384
1383
|
// That's because `babel`/`istanbul`, for some weird reason,
|
|
@@ -1394,9 +1393,9 @@ var r=e.leadingDigitsPatterns()[e.leadingDigitsPatterns().length-1];
|
|
|
1394
1393
|
// If leading digits don't match then move on to the next phone number format
|
|
1395
1394
|
if(t.search(r)!==0){return false}}
|
|
1396
1395
|
// Check that the national number matches the phone number format regular expression
|
|
1397
|
-
return matchesEntirely(t,e.pattern())}))}function addExtension(e,t,r,
|
|
1396
|
+
return matchesEntirely(t,e.pattern())}))}function addExtension(e,t,r,o){return t?o(e,t,r):e}function formatIDD(e,t,r,o,n){var i=getCountryCallingCode(o,n.metadata);
|
|
1398
1397
|
// When calling within the same country calling code.
|
|
1399
|
-
if(i===r){var d=formatNationalNumber$1(e,t,"NATIONAL",
|
|
1398
|
+
if(i===r){var d=formatNationalNumber$1(e,t,"NATIONAL",n);
|
|
1400
1399
|
// For NANPA regions, return the national format for these regions
|
|
1401
1400
|
// but prefix it with the country calling code.
|
|
1402
1401
|
if(r==="1"){return r+" "+d}
|
|
@@ -1409,31 +1408,31 @@ if(r==="1"){return r+" "+d}
|
|
|
1409
1408
|
// country calling code. Details here:
|
|
1410
1409
|
// http://www.petitfute.com/voyage/225-info-pratiques-reunion
|
|
1411
1410
|
|
|
1412
|
-
return d}var s=getIddPrefix(
|
|
1411
|
+
return d}var s=getIddPrefix(o,undefined,n.metadata);if(s){return"".concat(s," ").concat(r," ").concat(formatNationalNumber$1(e,null,"INTERNATIONAL",n))}}function merge(){var e=1;for(var t=arguments.length,r=new Array(t),o=0;o<t;o++){r[o]=arguments[o]}while(e<r.length){if(r[e]){for(var n in r[e]){r[0][n]=r[e][n]}}e++}return r[0]}function pickFirstMatchingElement(e,t){var r=0;while(r<e.length){if(t(e[r])){return e[r]}r++}}function _typeof$a(e){"@babel/helpers - typeof";return _typeof$a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$a(e)}function ownKeys$3(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread$3(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$3(Object(r),true).forEach((function(t){_defineProperty$3(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$3(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty$3(e,t,r){return(t=_toPropertyKey$9(t))in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function _classCallCheck$7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$6(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$9(o.key),o)}}function _createClass$7(e,t,r){return t&&_defineProperties$6(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$9(e){var t=_toPrimitive$9(e,"string");return"symbol"==_typeof$a(t)?t:t+""}function _toPrimitive$9(e,t){if("object"!=_typeof$a(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$a(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var PhoneNumber=function(){
|
|
1413
1412
|
/**
|
|
1414
1413
|
* @param {string} countryOrCountryCallingCode
|
|
1415
1414
|
* @param {string} nationalNumber
|
|
1416
1415
|
* @param {object} metadata — Metadata JSON
|
|
1417
1416
|
* @return {PhoneNumber}
|
|
1418
1417
|
*/
|
|
1419
|
-
function e(t,r,
|
|
1418
|
+
function e(t,r,o){_classCallCheck$7(this,e);
|
|
1420
1419
|
// Validate `countryOrCountryCallingCode` argument.
|
|
1421
1420
|
if(!t){throw new TypeError("First argument is required")}if(typeof t!=="string"){throw new TypeError("First argument must be a string")}
|
|
1422
1421
|
// In case of public API use: `constructor(number, metadata)`.
|
|
1423
1422
|
// Transform the arguments from `constructor(number, metadata)` to
|
|
1424
1423
|
// `constructor(countryOrCountryCallingCode, nationalNumber, metadata)`.
|
|
1425
|
-
if(t[0]==="+"&&!r){throw new TypeError("`metadata` argument not passed")}if(isObject(r)&&isObject(r.countries)){
|
|
1424
|
+
if(t[0]==="+"&&!r){throw new TypeError("`metadata` argument not passed")}if(isObject(r)&&isObject(r.countries)){o=r;var n=t;if(!E164_NUMBER_REGEXP.test(n)){throw new Error('Invalid `number` argument passed: must consist of a "+" followed by digits')}var i=extractCountryCallingCode(n,undefined,undefined,undefined,o),d=i.countryCallingCode,s=i.number;r=s;t=d;if(!r){throw new Error("Invalid `number` argument passed: too short")}}
|
|
1426
1425
|
// Validate `nationalNumber` argument.
|
|
1427
1426
|
if(!r){throw new TypeError("`nationalNumber` argument is required")}if(typeof r!=="string"){throw new TypeError("`nationalNumber` argument must be a string")}
|
|
1428
1427
|
// Validate `metadata` argument.
|
|
1429
|
-
validateMetadata(
|
|
1428
|
+
validateMetadata(o);
|
|
1430
1429
|
// Initialize properties.
|
|
1431
|
-
var a=getCountryAndCallingCodeFromOneOfThem(t,
|
|
1430
|
+
var a=getCountryAndCallingCodeFromOneOfThem(t,o),u=a.country,l=a.callingCode;this.country=u;this.countryCallingCode=l;this.nationalNumber=r;this.number="+"+this.countryCallingCode+this.nationalNumber;
|
|
1432
1431
|
// Exclude `metadata` property output from `PhoneNumber.toString()`
|
|
1433
1432
|
// so that it doesn't clutter the console output of Node.js.
|
|
1434
1433
|
// Previously, when Node.js did `console.log(new PhoneNumber(...))`,
|
|
1435
1434
|
// it would output the whole internal structure of the `metadata` object.
|
|
1436
|
-
this.getMetadata=function(){return
|
|
1435
|
+
this.getMetadata=function(){return o}}return _createClass$7(e,[{key:"setExt",value:function e(t){this.ext=t}},{key:"getPossibleCountries",value:function e(){if(this.country){return[this.country]}return getPossibleCountriesForNumber(this.countryCallingCode,this.nationalNumber,this.getMetadata())}},{key:"isPossible",value:function e(){return isPossiblePhoneNumber(this,{v2:true},this.getMetadata())}},{key:"isValid",value:function e(){return isValidNumber(this,{v2:true},this.getMetadata())}},{key:"isNonGeographic",value:function e(){var t=new Metadata(this.getMetadata());return t.isNonGeographicCallingCode(this.countryCallingCode)}},{key:"isEqual",value:function e(t){return this.number===t.number&&this.ext===t.ext}
|
|
1437
1436
|
// `validateLength()` method was originally meant to be an equivalent for `validatePhoneNumberLength()`.
|
|
1438
1437
|
|
|
1439
1438
|
// Later, it became apparent that it's not really a true equivalent.
|
|
@@ -1461,7 +1460,7 @@ this.getMetadata=function(){return n}}return _createClass$7(e,[{key:"setExt",val
|
|
|
1461
1460
|
// return result
|
|
1462
1461
|
// }
|
|
1463
1462
|
// }
|
|
1464
|
-
},{key:"getType",value:function e(){return getNumberType(this,{v2:true},this.getMetadata())}},{key:"format",value:function e(t,r){return formatNumber(this,t,r?_objectSpread$3(_objectSpread$3({},r),{},{v2:true}):{v2:true},this.getMetadata())}},{key:"formatNational",value:function e(t){return this.format("NATIONAL",t)}},{key:"formatInternational",value:function e(t){return this.format("INTERNATIONAL",t)}},{key:"getURI",value:function e(t){return this.format("RFC3966",t)}}])}();var E164_NUMBER_REGEXP=/^\+\d+$/;function _typeof$9(e){"@babel/helpers - typeof";return _typeof$9="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$9(e)}function _createClass$6(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function _classCallCheck$6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof$9(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&_setPrototypeOf(e,t)}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function e(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,
|
|
1463
|
+
},{key:"getType",value:function e(){return getNumberType(this,{v2:true},this.getMetadata())}},{key:"format",value:function e(t,r){return formatNumber(this,t,r?_objectSpread$3(_objectSpread$3({},r),{},{v2:true}):{v2:true},this.getMetadata())}},{key:"formatNational",value:function e(t){return this.format("NATIONAL",t)}},{key:"formatInternational",value:function e(t){return this.format("INTERNATIONAL",t)}},{key:"getURI",value:function e(t){return this.format("RFC3966",t)}}])}();var E164_NUMBER_REGEXP=/^\+\d+$/;function _typeof$9(e){"@babel/helpers - typeof";return _typeof$9="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$9(e)}function _createClass$6(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function _classCallCheck$6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof$9(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&_setPrototypeOf(e,t)}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function e(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,o)}function o(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return o.prototype=Object.create(r.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}}),_setPrototypeOf(o,r)},_wrapNativeSuper(e)}function _construct(e,t,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var n=new(e.bind.apply(e,o));return r&&_setPrototypeOf(n,r.prototype),n}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function t(){return!!e})()}function _isNativeFunction(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}
|
|
1465
1464
|
// https://stackoverflow.com/a/46971044/970769
|
|
1466
1465
|
// "Breaking changes in Typescript 2.1"
|
|
1467
1466
|
// "Extending built-ins like Error, Array, and Map may no longer work."
|
|
@@ -1480,7 +1479,7 @@ var EXTN_PATTERN=new RegExp("(?:"+createExtensionPattern()+")$","i");
|
|
|
1480
1479
|
function extractExtension(e){var t=e.search(EXTN_PATTERN);if(t<0){return{}}
|
|
1481
1480
|
// If we find a potential extension, and the number preceding this is a viable
|
|
1482
1481
|
// number, we assume it is an extension.
|
|
1483
|
-
var r=e.slice(0,t);var
|
|
1482
|
+
var r=e.slice(0,t);var o=e.match(EXTN_PATTERN);var n=1;while(n<o.length){if(o[n]){return{number:r,ext:o[n]}}n++}}function _createForOfIteratorHelperLoose$4(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$7(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$7(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$7(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$7(e,t):void 0}}function _arrayLikeToArray$7(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}
|
|
1484
1483
|
// These mappings map a character (key) to a specific digit that should
|
|
1485
1484
|
// replace it for normalization purposes. Non-European digits that
|
|
1486
1485
|
// may be used in phone numbers are mapped to a European equivalent.
|
|
@@ -1565,7 +1564,7 @@ var DIGITS={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0
|
|
|
1565
1564
|
// (the ones consisting of four bytes) but digits
|
|
1566
1565
|
// (including non-European ones) don't fall into that range
|
|
1567
1566
|
// so such "exotic" characters would be discarded anyway.
|
|
1568
|
-
for(var r=_createForOfIteratorHelperLoose$4(e.split("")),
|
|
1567
|
+
for(var r=_createForOfIteratorHelperLoose$4(e.split("")),o;!(o=r()).done;){var n=o.value;var i=parseDigit(n);if(i){t+=i}}return t}function _createForOfIteratorHelperLoose$3(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$6(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$6(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$6(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$6(e,t):void 0}}function _arrayLikeToArray$6(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}
|
|
1569
1568
|
/**
|
|
1570
1569
|
* Parses phone number characters from a string.
|
|
1571
1570
|
* Drops all punctuation leaving only digits and the leading `+` sign (if any).
|
|
@@ -1587,7 +1586,7 @@ for(var r=_createForOfIteratorHelperLoose$4(e.split("")),n;!(n=r()).done;){var o
|
|
|
1587
1586
|
// (the ones consisting of four bytes) but digits
|
|
1588
1587
|
// (including non-European ones) don't fall into that range
|
|
1589
1588
|
// so such "exotic" characters would be discarded anyway.
|
|
1590
|
-
for(var r=_createForOfIteratorHelperLoose$3(e.split("")),
|
|
1589
|
+
for(var r=_createForOfIteratorHelperLoose$3(e.split("")),o;!(o=r()).done;){var n=o.value;t+=parsePhoneNumberCharacter(n,t)||""}return t}
|
|
1591
1590
|
/**
|
|
1592
1591
|
* Parses next character while parsing phone number digits (including a `+`)
|
|
1593
1592
|
* from text: discards everything except `+` and digits, and `+` is only allowed
|
|
@@ -1633,9 +1632,9 @@ var ALPHANUM_=VALID_DIGITS;var RFC3966_DOMAINLABEL_="["+ALPHANUM_+"]+((\\-)*["+A
|
|
|
1633
1632
|
// If no phone-context parameter is present
|
|
1634
1633
|
if(t<0){return null}var r=t+RFC3966_PHONE_CONTEXT_.length;
|
|
1635
1634
|
// If phone-context parameter is empty
|
|
1636
|
-
if(r>=e.length){return""}var
|
|
1635
|
+
if(r>=e.length){return""}var o=e.indexOf(";",r);
|
|
1637
1636
|
// If phone-context is not the last parameter
|
|
1638
|
-
if(
|
|
1637
|
+
if(o>=0){return e.substring(r,o)}else{return e.substring(r)}}
|
|
1639
1638
|
/**
|
|
1640
1639
|
* Returns whether the value of phoneContext follows the syntax defined in RFC3966.
|
|
1641
1640
|
*
|
|
@@ -1648,13 +1647,13 @@ return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(e)||RFC3966_DOMAINNAME_PATTERN
|
|
|
1648
1647
|
* @param {string} numberToParse
|
|
1649
1648
|
* @param {string} nationalNumber
|
|
1650
1649
|
* @return {}
|
|
1651
|
-
*/function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(e,t){var r=t.extractFormattedPhoneNumber;var
|
|
1650
|
+
*/function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(e,t){var r=t.extractFormattedPhoneNumber;var o=extractPhoneContext(e);if(!isPhoneContextValid(o)){throw new ParseError("NOT_A_NUMBER")}var n;if(o===null){
|
|
1652
1651
|
// Extract a possible number from the string passed in.
|
|
1653
1652
|
// (this strips leading characters that could not be the start of a phone number)
|
|
1654
|
-
|
|
1653
|
+
n=r(e)||""}else{n="";
|
|
1655
1654
|
// If the phone context contains a phone number prefix, we need to capture
|
|
1656
1655
|
// it, whereas domains will be ignored.
|
|
1657
|
-
if(
|
|
1656
|
+
if(o.charAt(0)===PLUS_SIGN){n+=o}
|
|
1658
1657
|
// Now append everything between the "tel:" prefix and the phone-context.
|
|
1659
1658
|
// This should include the national number, an optional extension or
|
|
1660
1659
|
// isdn-subaddress component. Note we also handle the case when "tel:" is
|
|
@@ -1663,17 +1662,17 @@ if(n.charAt(0)===PLUS_SIGN){o+=n}
|
|
|
1663
1662
|
var i=e.indexOf(RFC3966_PREFIX_);var d;
|
|
1664
1663
|
// RFC 3966 "tel:" prefix is preset at this stage because
|
|
1665
1664
|
// `isPhoneContextValid()` requires it to be present.
|
|
1666
|
-
/* istanbul ignore else */if(i>=0){d=i+RFC3966_PREFIX_.length}else{d=0}var s=e.indexOf(RFC3966_PHONE_CONTEXT_);
|
|
1665
|
+
/* istanbul ignore else */if(i>=0){d=i+RFC3966_PREFIX_.length}else{d=0}var s=e.indexOf(RFC3966_PHONE_CONTEXT_);n+=e.substring(d,s)}
|
|
1667
1666
|
// Delete the isdn-subaddress and everything after it if it is present.
|
|
1668
1667
|
// Note extension won't appear at the same time with isdn-subaddress
|
|
1669
1668
|
// according to paragraph 5.3 of the RFC3966 spec.
|
|
1670
|
-
var a=
|
|
1669
|
+
var a=n.indexOf(RFC3966_ISDN_SUBADDRESS_);if(a>0){n=n.substring(0,a)}
|
|
1671
1670
|
// If both phone context and isdn-subaddress are absent but other
|
|
1672
1671
|
// parameters are present, the parameters are left in nationalNumber.
|
|
1673
1672
|
// This is because we are concerned about deleting content from a potential
|
|
1674
1673
|
// number string when there is no strong evidence that the number is
|
|
1675
1674
|
// actually written in RFC3966.
|
|
1676
|
-
if(
|
|
1675
|
+
if(n!==""){return n}}
|
|
1677
1676
|
// This is a port of Google Android `libphonenumber`'s
|
|
1678
1677
|
// `phonenumberutil.js` of December 31th, 2018.
|
|
1679
1678
|
|
|
@@ -1712,17 +1711,17 @@ var AFTER_PHONE_NUMBER_END_PATTERN=new RegExp("[^"+VALID_DIGITS+"#"+"]+$");
|
|
|
1712
1711
|
*/function parse(e,t,r){
|
|
1713
1712
|
// If assigning the `{}` default value is moved to the arguments above,
|
|
1714
1713
|
// code coverage would decrease for some weird reason.
|
|
1715
|
-
t=t||{};var
|
|
1714
|
+
t=t||{};var o=new Metadata(r);
|
|
1716
1715
|
// Validate `defaultCountry`.
|
|
1717
|
-
if(t.defaultCountry&&!
|
|
1716
|
+
if(t.defaultCountry&&!o.hasCountry(t.defaultCountry)){if(t.v2){throw new ParseError("INVALID_COUNTRY")}throw new Error("Unknown country: ".concat(t.defaultCountry))}
|
|
1718
1717
|
// Parse the phone number.
|
|
1719
|
-
var
|
|
1718
|
+
var n=parseInput(e,t.v2,t.extract),i=n.number,d=n.ext,s=n.error;
|
|
1720
1719
|
// If the phone number is not viable then return nothing.
|
|
1721
1720
|
if(!i){if(t.v2){if(s==="TOO_SHORT"){throw new ParseError("TOO_SHORT")}throw new ParseError("NOT_A_NUMBER")}return{}}var a=parsePhoneNumber$3(i,t.defaultCountry,t.defaultCallingCode,
|
|
1722
1721
|
// If `country` is returned, its numbering plan will also be selected in `metadata`.
|
|
1723
1722
|
// Otherwise, if `countryCallingCode` is returned, its numbering plan will also be selected in `metadata`.
|
|
1724
1723
|
// Otherwise, if neither `country` nor `countryCallingCode` are returned, no numbering plan will be selected in `metadata`.
|
|
1725
|
-
|
|
1724
|
+
o),u=a.country,l=a.nationalNumber,$=a.countryCallingCode,c=a.countryCallingCodeSource,f=a.carrierCode;if(!o.hasSelectedNumberingPlan()){if(t.v2){throw new ParseError("INVALID_COUNTRY")}return{}}
|
|
1726
1725
|
// Validate national (significant) number length.
|
|
1727
1726
|
if(!l||l.length<MIN_LENGTH_FOR_NSN){
|
|
1728
1727
|
// Won't throw here because the regexp already demands length > 1.
|
|
@@ -1741,13 +1740,13 @@ return{}}
|
|
|
1741
1740
|
|
|
1742
1741
|
if(l.length>MAX_LENGTH_FOR_NSN){if(t.v2){throw new ParseError("TOO_LONG")}
|
|
1743
1742
|
// Google's demo just throws an error in this case.
|
|
1744
|
-
return{}}if(t.v2){var h=new PhoneNumber($,l,
|
|
1743
|
+
return{}}if(t.v2){var h=new PhoneNumber($,l,o.metadata);if(u){h.country=u}if(f){h.carrierCode=f}if(d){h.ext=d}h.__countryCallingCodeSource=c;return h}
|
|
1745
1744
|
// Check if national phone number pattern matches the number.
|
|
1746
1745
|
// National number pattern is different for each country,
|
|
1747
1746
|
// even for those ones which are part of the "NANPA" group.
|
|
1748
|
-
var p=(t.extended?
|
|
1747
|
+
var p=(t.extended?o.hasSelectedNumberingPlan():u)?matchesEntirely(l,o.nationalNumberPattern()):false;if(!t.extended){return p?result(u,l,d):{}}
|
|
1749
1748
|
// isInternational: countryCallingCode !== undefined
|
|
1750
|
-
return{country:u,countryCallingCode:$,carrierCode:f,valid:p,possible:p?true:t.extended===true&&
|
|
1749
|
+
return{country:u,countryCallingCode:$,carrierCode:f,valid:p,possible:p?true:t.extended===true&&o.possibleLengths()&&isPossibleNumber$2(l,o)?true:false,phone:l,ext:d}}
|
|
1751
1750
|
/**
|
|
1752
1751
|
* Extracts a formatted phone number from text.
|
|
1753
1752
|
* Doesn't guarantee that the extracted phone number
|
|
@@ -1761,7 +1760,7 @@ return{country:u,countryCallingCode:$,carrierCode:f,valid:p,possible:p?true:t.ex
|
|
|
1761
1760
|
* extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
|
|
1762
1761
|
*/function _extractFormattedPhoneNumber(e,t,r){if(!e){return}if(e.length>MAX_INPUT_STRING_LENGTH){if(r){throw new ParseError("TOO_LONG")}return}if(t===false){return e}
|
|
1763
1762
|
// Attempt to extract a possible number from the string passed in
|
|
1764
|
-
var
|
|
1763
|
+
var o=e.search(PHONE_NUMBER_START_PATTERN);if(o<0){return}return e.slice(o).replace(AFTER_PHONE_NUMBER_END_PATTERN,"")}
|
|
1765
1764
|
/**
|
|
1766
1765
|
* @param {string} text - Input.
|
|
1767
1766
|
* @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
|
|
@@ -1773,15 +1772,15 @@ var n=e.search(PHONE_NUMBER_START_PATTERN);if(n<0){return}return e.slice(n).repl
|
|
|
1773
1772
|
// return parseRFC3966(text)
|
|
1774
1773
|
// }
|
|
1775
1774
|
// let number = extractFormattedPhoneNumber(text, extract, v2)
|
|
1776
|
-
var
|
|
1775
|
+
var o=extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(e,{extractFormattedPhoneNumber:function e(o){return _extractFormattedPhoneNumber(o,r,t)}});
|
|
1777
1776
|
// If the phone number is not viable, then abort.
|
|
1778
|
-
if(!
|
|
1777
|
+
if(!o){return{}}if(!isViablePhoneNumber(o)){if(isViablePhoneNumberStart(o)){return{error:"TOO_SHORT"}}return{}}
|
|
1779
1778
|
// Attempt to parse extension first, since it doesn't require region-specific
|
|
1780
1779
|
// data and we want to have the non-normalised number here.
|
|
1781
|
-
var
|
|
1780
|
+
var n=extractExtension(o);if(n.ext){return n}return{number:o}}
|
|
1782
1781
|
/**
|
|
1783
1782
|
* Creates `parse()` result object.
|
|
1784
|
-
*/function result(e,t,r){var
|
|
1783
|
+
*/function result(e,t,r){var o={country:e,phone:t};if(r){o.ext=r}return o}
|
|
1785
1784
|
/**
|
|
1786
1785
|
* Parses a viable phone number.
|
|
1787
1786
|
* @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
|
|
@@ -1789,7 +1788,7 @@ var o=extractExtension(n);if(o.ext){return o}return{number:n}}
|
|
|
1789
1788
|
* @param {string} [defaultCallingCode]
|
|
1790
1789
|
* @param {Metadata} metadata — Metadata instance with no pre-selected numbering plan. If `country` is returned, its numbering plan will also be selected in `metadata`. Otherwise, if `countryCallingCode` is returned, its numbering plan will also be selected in `metadata`. Otherwise, if neither `country` nor `countryCallingCode` are returned, no numbering plan will be selected in `metadata`.
|
|
1791
1790
|
* @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
|
|
1792
|
-
*/function parsePhoneNumber$3(e,t,r,
|
|
1791
|
+
*/function parsePhoneNumber$3(e,t,r,o){
|
|
1793
1792
|
// Attempt to extract a calling code from a phone number.
|
|
1794
1793
|
// * If the phone number is found to be "international":
|
|
1795
1794
|
// * It will attempt to identify the calling code part of it and whether that part is complete and valid.
|
|
@@ -1799,24 +1798,24 @@ var o=extractExtension(n);if(o.ext){return o}return{number:n}}
|
|
|
1799
1798
|
// it will return an empty object.
|
|
1800
1799
|
// * Otherwise, i.e. if the phone number is national, there's no callind code to extract
|
|
1801
1800
|
// so it will just return the originally-passed `number` string as the only property.
|
|
1802
|
-
var
|
|
1801
|
+
var n=extractCountryCallingCode(parseIncompletePhoneNumber(e),undefined,
|
|
1803
1802
|
// `defaultCountry` and `defaultCallingCode` are only used to detect
|
|
1804
1803
|
// if it's an "international" phone number or not. They won't be used
|
|
1805
1804
|
// to derive the resulting `countryCallingCode` from them, or anything like that.
|
|
1806
|
-
t,r,
|
|
1805
|
+
t,r,o.metadata),i=n.countryCallingCodeSource,d=n.countryCallingCode,s=n.number;
|
|
1807
1806
|
// The exact country of the phone number
|
|
1808
1807
|
var a;
|
|
1809
1808
|
// If `formattedPhoneNumber` is passed in "international" format,
|
|
1810
1809
|
// choose a country by `countryCallingCode`.
|
|
1811
|
-
if(d){
|
|
1810
|
+
if(d){o.selectNumberingPlan(d)}
|
|
1812
1811
|
// Else, if `formattedPhoneNumber` is passed in "national" format,
|
|
1813
1812
|
// then `number` is defined and `countryCallingCode` is `undefined`.
|
|
1814
|
-
else if(s&&(t||r)){if(t){a=t;
|
|
1813
|
+
else if(s&&(t||r)){if(t){a=t;o.selectNumberingPlan(t);d=o.numberingPlan.callingCode()}else{o.selectNumberingPlan(r);d=r}}else return{};
|
|
1815
1814
|
// At this point, `country` could be `undefined` but `countryCallingCode` is always defined.
|
|
1816
1815
|
|
|
1817
1816
|
// Also, if `country` is defined, its numbering plan is selected in `metadata`.
|
|
1818
1817
|
// Otherwise, the numering plan for the `countryCallingCode` is selected in `metadata`.
|
|
1819
|
-
if(!s){return{countryCallingCodeSource:i,countryCallingCode:d}}var u=extractNationalNumber(parseIncompletePhoneNumber(s),undefined,
|
|
1818
|
+
if(!s){return{countryCallingCodeSource:i,countryCallingCode:d}}var u=extractNationalNumber(parseIncompletePhoneNumber(s),undefined,o),l=u.nationalNumber,$=u.carrierCode;
|
|
1820
1819
|
// Sometimes there are several countries
|
|
1821
1820
|
// corresponding to the same country phone code
|
|
1822
1821
|
// (e.g. NANPA countries all having `1` country phone code).
|
|
@@ -1827,28 +1826,28 @@ if(!s){return{countryCallingCodeSource:i,countryCallingCode:d}}var u=extractNati
|
|
|
1827
1826
|
// get their countries populated with the full set of
|
|
1828
1827
|
// "phone number type" regular expressions.
|
|
1829
1828
|
|
|
1830
|
-
var c=getCountryByCallingCode(d,{nationalNumber:l,metadata:
|
|
1831
|
-
/* istanbul ignore if */if(c==="001");else{
|
|
1829
|
+
var c=getCountryByCallingCode(d,{nationalNumber:l,metadata:o});if(c){a=c;
|
|
1830
|
+
/* istanbul ignore if */if(c==="001");else{o.selectNumberingPlan(a)}}return{country:a,countryCallingCode:d,countryCallingCodeSource:i,nationalNumber:l,carrierCode:$}}function _typeof$8(e){"@babel/helpers - typeof";return _typeof$8="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$8(e)}function ownKeys$2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread$2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$2(Object(r),true).forEach((function(t){_defineProperty$2(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty$2(e,t,r){return(t=_toPropertyKey$8(t))in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function _toPropertyKey$8(e){var t=_toPrimitive$8(e,"string");return"symbol"==_typeof$8(t)?t:t+""}function _toPrimitive$8(e,t){if("object"!=_typeof$8(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$8(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function parsePhoneNumberWithError(e,t,r){return parse(e,_objectSpread$2(_objectSpread$2({},t),{},{v2:true}),r)}function _typeof$7(e){"@babel/helpers - typeof";return _typeof$7="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$7(e)}function ownKeys$1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread$1(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys$1(Object(r),true).forEach((function(t){_defineProperty$1(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty$1(e,t,r){return(t=_toPropertyKey$7(t))in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function _toPropertyKey$7(e){var t=_toPrimitive$7(e,"string");return"symbol"==_typeof$7(t)?t:t+""}function _toPrimitive$7(e,t){if("object"!=_typeof$7(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$7(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _slicedToArray$2(e,t){return _arrayWithHoles$2(e)||_iterableToArrayLimit$2(e,t)||_unsupportedIterableToArray$5(e,t)||_nonIterableRest$2()}function _nonIterableRest$2(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$5(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$5(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$5(e,t):void 0}}function _arrayLikeToArray$5(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _iterableToArrayLimit$2(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,i,d,s=[],a=true,u=false;try{if(i=(r=r.call(e)).next,0===t);else for(;!(a=(o=i.call(r)).done)&&(s.push(o.value),s.length!==t);a=true);}catch(e){u=true,n=e}finally{try{if(!a&&null!=r["return"]&&(d=r["return"](),Object(d)!==d))return}finally{if(u)throw n}}return s}}function _arrayWithHoles$2(e){if(Array.isArray(e))return e}
|
|
1832
1831
|
// Extracts the following properties from function arguments:
|
|
1833
1832
|
// * input `text`
|
|
1834
1833
|
// * `options` object
|
|
1835
1834
|
// * `metadata` JSON
|
|
1836
|
-
function normalizeArguments$1(e){var t=Array.prototype.slice.call(e),r=_slicedToArray$2(t,4),
|
|
1835
|
+
function normalizeArguments$1(e){var t=Array.prototype.slice.call(e),r=_slicedToArray$2(t,4),o=r[0],n=r[1],i=r[2],d=r[3];var s;var a;var u;
|
|
1837
1836
|
// If the phone number is passed as a string.
|
|
1838
1837
|
// `parsePhoneNumber('88005553535', ...)`.
|
|
1839
|
-
if(typeof
|
|
1838
|
+
if(typeof o==="string"){s=o}else throw new TypeError("A text for parsing must be a string.");
|
|
1840
1839
|
// If "default country" argument is being passed then move it to `options`.
|
|
1841
1840
|
// `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
|
|
1842
|
-
if(!
|
|
1841
|
+
if(!n||typeof n==="string"){if(d){a=i;u=d}else{a=undefined;u=i}if(n){a=_objectSpread$1({defaultCountry:n},a)}}
|
|
1843
1842
|
// `defaultCountry` is not passed.
|
|
1844
1843
|
// Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
|
|
1845
|
-
else if(isObject(
|
|
1844
|
+
else if(isObject(n)){if(i){a=n;u=i}else{u=n}}else throw new Error("Invalid second argument: ".concat(n));return{text:s,options:a,metadata:u}}function _typeof$6(e){"@babel/helpers - typeof";return _typeof$6="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$6(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),true).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey$6(t))in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function _toPropertyKey$6(e){var t=_toPrimitive$6(e,"string");return"symbol"==_typeof$6(t)?t:t+""}function _toPrimitive$6(e,t){if("object"!=_typeof$6(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$6(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function parsePhoneNumber$2(e,t,r){
|
|
1846
1845
|
// Validate `defaultCountry`.
|
|
1847
1846
|
if(t&&t.defaultCountry&&!isSupportedCountry(t.defaultCountry,r)){t=_objectSpread(_objectSpread({},t),{},{defaultCountry:undefined})}
|
|
1848
1847
|
// Parse phone number.
|
|
1849
1848
|
try{return parsePhoneNumberWithError(e,t,r)}catch(e){
|
|
1850
1849
|
/* istanbul ignore else */
|
|
1851
|
-
if(e instanceof ParseError);else{throw e}}}function parsePhoneNumber$1(){var e=normalizeArguments$1(arguments),t=e.text,r=e.options,
|
|
1850
|
+
if(e instanceof ParseError);else{throw e}}}function parsePhoneNumber$1(){var e=normalizeArguments$1(arguments),t=e.text,r=e.options,o=e.metadata;return parsePhoneNumber$2(t,r,o)}function _typeof$5(e){"@babel/helpers - typeof";return _typeof$5="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$5(e)}function _classCallCheck$5(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$5(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$5(o.key),o)}}function _createClass$5(e,t,r){return t&&_defineProperties$5(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$5(e){var t=_toPrimitive$5(e,"string");return"symbol"==_typeof$5(t)?t:t+""}function _toPrimitive$5(e,t){if("object"!=_typeof$5(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$5(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}
|
|
1852
1851
|
// This "state" object simply holds the state of the "AsYouType" parser:
|
|
1853
1852
|
|
|
1854
1853
|
// Sidenote:
|
|
@@ -1885,7 +1884,7 @@ if(e instanceof ParseError);else{throw e}}}function parsePhoneNumber$1(){var e=n
|
|
|
1885
1884
|
// For example, when calling within Australia, one could prepend `1831` prefix to hide caller's phone number.
|
|
1886
1885
|
// https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
|
|
1887
1886
|
|
|
1888
|
-
var AsYouTypeState=function(){function e(t){var r=t.onCountryChange,
|
|
1887
|
+
var AsYouTypeState=function(){function e(t){var r=t.onCountryChange,o=t.onCallingCodeChange;_classCallCheck$5(this,e);this.onCountryChange=r;this.onCallingCodeChange=o}return _createClass$5(e,[{key:"reset",value:function e(t){var r=t.country,o=t.callingCode;this.international=false;this.missingPlus=false;this.IDDPrefix=undefined;this.callingCode=undefined;this.digits="";this.resetNationalSignificantNumber();this.initCountryAndCallingCode(r,o)}},{key:"resetNationalSignificantNumber",value:function e(){this.nationalSignificantNumber=this.getNationalDigits();this.nationalSignificantNumberIsModified=false;this.nationalPrefix=undefined;this.carrierCode=undefined;this.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix=undefined}},{key:"update",value:function e(t){for(var r=0,o=Object.keys(t);r<o.length;r++){var n=o[r];this[n]=t[n]}}},{key:"initCountryAndCallingCode",value:function e(t,r){this.setCountry(t);this.setCallingCode(r)}},{key:"setCountry",value:function e(t){this.country=t;this.onCountryChange(t)}},{key:"setCallingCode",value:function e(t){this.callingCode=t;this.onCallingCodeChange(t,this.country)}},{key:"startInternationalNumber",value:function e(t,r){
|
|
1889
1888
|
// Prepend the `+` to parsed input.
|
|
1890
1889
|
this.international=true;
|
|
1891
1890
|
// If a default country was set then reset it
|
|
@@ -1898,24 +1897,24 @@ this.initCountryAndCallingCode(t,r)}},{key:"appendDigits",value:function e(t){th
|
|
|
1898
1897
|
* international prefix and the country calling code part
|
|
1899
1898
|
* (if the number is an international one).
|
|
1900
1899
|
* @return {string}
|
|
1901
|
-
*/},{key:"getNationalDigits",value:function e(){if(this.international){return this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0))}return this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function e(){if(this.international){if(this.IDDPrefix){return this.digits.slice(this.IDDPrefix.length)}}return this.digits}}])}();function _createForOfIteratorHelperLoose$2(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$4(e))||t){r&&(e=r);var
|
|
1900
|
+
*/},{key:"getNationalDigits",value:function e(){if(this.international){return this.digits.slice((this.IDDPrefix?this.IDDPrefix.length:0)+(this.callingCode?this.callingCode.length:0))}return this.digits}},{key:"getDigitsWithoutInternationalPrefix",value:function e(){if(this.international){if(this.IDDPrefix){return this.digits.slice(this.IDDPrefix.length)}}return this.digits}}])}();function _createForOfIteratorHelperLoose$2(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$4(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$4(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$4(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$4(e,t):void 0}}function _arrayLikeToArray$4(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}
|
|
1902
1901
|
// Should be the same as `DIGIT_PLACEHOLDER` in `libphonenumber-metadata-generator`.
|
|
1903
1902
|
var DIGIT_PLACEHOLDER="x";// '\u2008' (punctuation space)
|
|
1904
1903
|
var DIGIT_PLACEHOLDER_MATCHER=new RegExp(DIGIT_PLACEHOLDER);
|
|
1905
1904
|
// Repeats a string (or a symbol) N times.
|
|
1906
1905
|
// http://stackoverflow.com/questions/202605/repeat-string-javascript
|
|
1907
|
-
function repeat(e,t){if(t<1){return""}var r="";while(t>1){if(t&1){r+=e}t>>=1;e+=e}return r+e}function cutAndStripNonPairedParens(e,t){if(e[t]===")"){t++}return stripNonPairedParens(e.slice(0,t))}function stripNonPairedParens(e){var t=[];var r=0;while(r<e.length){if(e[r]==="("){t.push(r)}else if(e[r]===")"){t.pop()}r++}var
|
|
1906
|
+
function repeat(e,t){if(t<1){return""}var r="";while(t>1){if(t&1){r+=e}t>>=1;e+=e}return r+e}function cutAndStripNonPairedParens(e,t){if(e[t]===")"){t++}return stripNonPairedParens(e.slice(0,t))}function stripNonPairedParens(e){var t=[];var r=0;while(r<e.length){if(e[r]==="("){t.push(r)}else if(e[r]===")"){t.pop()}r++}var o=0;var n="";t.push(e.length);for(var i=0,d=t;i<d.length;i++){var s=d[i];n+=e.slice(o,s);o=s+1}return n}function populateTemplateWithDigits(e,t,r){
|
|
1908
1907
|
// Using `.split('')` to iterate through a string here
|
|
1909
1908
|
// to avoid requiring `Symbol.iterator` polyfill.
|
|
1910
1909
|
// `.split('')` is generally not safe for Unicode,
|
|
1911
1910
|
// but in this particular case for `digits` it is safe.
|
|
1912
1911
|
// for (const digit of digits)
|
|
1913
|
-
for(var
|
|
1912
|
+
for(var o=_createForOfIteratorHelperLoose$2(r.split("")),n;!(n=o()).done;){var i=n.value;
|
|
1914
1913
|
// If there is room for more digits in current `template`,
|
|
1915
1914
|
// then set the next digit in the `template`,
|
|
1916
1915
|
// and return the formatted digits so far.
|
|
1917
1916
|
// If more digits are entered than the current format could handle.
|
|
1918
|
-
if(e.slice(t+1).search(DIGIT_PLACEHOLDER_MATCHER)<0){return}t=e.search(DIGIT_PLACEHOLDER_MATCHER);e=e.replace(DIGIT_PLACEHOLDER_MATCHER,i)}return[e,t]}function formatCompleteNumber(e,t,r){var
|
|
1917
|
+
if(e.slice(t+1).search(DIGIT_PLACEHOLDER_MATCHER)<0){return}t=e.search(DIGIT_PLACEHOLDER_MATCHER);e=e.replace(DIGIT_PLACEHOLDER_MATCHER,i)}return[e,t]}function formatCompleteNumber(e,t,r){var o=r.shouldTryNationalPrefixFormattingRule,n=r.getSeparatorAfterNationalPrefix;var i=new RegExp("^(?:".concat(t.pattern(),")$"));if(i.test(e.nationalSignificantNumber)){return formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(e,t,{shouldTryNationalPrefixFormattingRule:o,getSeparatorAfterNationalPrefix:n})}}function canFormatCompleteNumber(e,t){return checkNumberLength(e,undefined,t)==="IS_POSSIBLE"}function formatNationalNumberWithAndWithoutNationalPrefixFormattingRule(e,t,r){var o=r.shouldTryNationalPrefixFormattingRule,n=r.getSeparatorAfterNationalPrefix;
|
|
1919
1918
|
// Format the number with using `national_prefix_formatting_rule`.
|
|
1920
1919
|
// If the resulting formatted number is a valid formatted number, then return it.
|
|
1921
1920
|
|
|
@@ -1926,12 +1925,12 @@ if(e.slice(t+1).search(DIGIT_PLACEHOLDER_MATCHER)<0){return}t=e.search(DIGIT_PLA
|
|
|
1926
1925
|
// The reason is that "national prefix formatting rule" may use parentheses,
|
|
1927
1926
|
// which wouldn't be included has it used the simpler Google's way.
|
|
1928
1927
|
|
|
1929
|
-
if(
|
|
1928
|
+
if(o(t)){var i=formatNationalNumber(e,t,{useNationalPrefixFormattingRule:true,getSeparatorAfterNationalPrefix:n});if(i){return i}}
|
|
1930
1929
|
// Format the number without using `national_prefix_formatting_rule`.
|
|
1931
|
-
return formatNationalNumber(e,t,{useNationalPrefixFormattingRule:false,getSeparatorAfterNationalPrefix:
|
|
1930
|
+
return formatNationalNumber(e,t,{useNationalPrefixFormattingRule:false,getSeparatorAfterNationalPrefix:n})}function formatNationalNumber(e,t,r){var o=r.useNationalPrefixFormattingRule,n=r.getSeparatorAfterNationalPrefix;var i=formatNationalNumberUsingFormat(e.nationalSignificantNumber,t,{useInternationalFormat:e.international,withNationalPrefix:o});if(!o){if(e.nationalPrefix){
|
|
1932
1931
|
// If a national prefix was extracted, then just prepend it,
|
|
1933
1932
|
// followed by a " " character.
|
|
1934
|
-
i=e.nationalPrefix+
|
|
1933
|
+
i=e.nationalPrefix+n(t)+i}else if(e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix){i=e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix+" "+i}}if(isValidFormattedNationalNumber(i,e)){return i}}
|
|
1935
1934
|
// Check that the formatted phone number contains exactly
|
|
1936
1935
|
// the same digits that have been input by the user.
|
|
1937
1936
|
// For example, when "0111523456789" is input for `AR` country,
|
|
@@ -1961,14 +1960,14 @@ i=e.nationalPrefix+o(t)+i}else if(e.prefixBeforeNationalSignificantNumberThatIsN
|
|
|
1961
1960
|
// https://github.com/google/libphonenumber/commit/3e7c1f04f5e7200f87fb131e6f85c6e99d60f510#diff-9149457fa9f5d608a11bb975c6ef4bc5
|
|
1962
1961
|
// https://github.com/google/libphonenumber/commit/3ac88c7106e7dcb553bcc794b15f19185928a1c6#diff-2dcb77e833422ee304da348b905cde0b
|
|
1963
1962
|
|
|
1964
|
-
function isValidFormattedNationalNumber(e,t){return parseDigits(e)===t.getNationalDigits()}function _typeof$4(e){"@babel/helpers - typeof";return _typeof$4="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$4(e)}function _classCallCheck$4(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$4(e,t){for(var r=0;r<t.length;r++){var
|
|
1965
|
-
/* istanbul ignore if */if(
|
|
1963
|
+
function isValidFormattedNationalNumber(e,t){return parseDigits(e)===t.getNationalDigits()}function _typeof$4(e){"@babel/helpers - typeof";return _typeof$4="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$4(e)}function _classCallCheck$4(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$4(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$4(o.key),o)}}function _createClass$4(e,t,r){return t&&_defineProperties$4(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$4(e){var t=_toPrimitive$4(e,"string");return"symbol"==_typeof$4(t)?t:t+""}function _toPrimitive$4(e,t){if("object"!=_typeof$4(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$4(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var PatternParser=function(){function e(){_classCallCheck$4(this,e)}return _createClass$4(e,[{key:"parse",value:function e(t){this.context=[{or:true,instructions:[]}];this.parsePattern(t);if(this.context.length!==1){throw new Error("Non-finalized contexts left when pattern parse ended")}var r=this.context[0],o=r.branches,n=r.instructions;if(o){return{op:"|",args:o.concat([expandSingleElementArray(n)])}}
|
|
1964
|
+
/* istanbul ignore if */if(n.length===0){throw new Error("Pattern is required")}if(n.length===1){return n[0]}return n}},{key:"startContext",value:function e(t){this.context.push(t)}},{key:"endContext",value:function e(){this.context.pop()}},{key:"getContext",value:function e(){return this.context[this.context.length-1]}},{key:"parsePattern",value:function e(t){if(!t){throw new Error("Pattern is required")}var r=t.match(OPERATOR);if(!r){if(ILLEGAL_CHARACTER_REGEXP.test(t)){throw new Error("Illegal characters found in a pattern: ".concat(t))}this.getContext().instructions=this.getContext().instructions.concat(t.split(""));return}var o=r[1];var n=t.slice(0,r.index);var i=t.slice(r.index+o.length);switch(o){case"(?:":if(n){this.parsePattern(n)}this.startContext({or:true,instructions:[],branches:[]});break;case")":if(!this.getContext().or){throw new Error('")" operator must be preceded by "(?:" operator')}if(n){this.parsePattern(n)}if(this.getContext().instructions.length===0){throw new Error('No instructions found after "|" operator in an "or" group')}var d=this.getContext(),s=d.branches;s.push(expandSingleElementArray(this.getContext().instructions));this.endContext();this.getContext().instructions.push({op:"|",args:s});break;case"|":if(!this.getContext().or){throw new Error('"|" operator can only be used inside "or" groups')}if(n){this.parsePattern(n)}
|
|
1966
1965
|
// The top-level is an implicit "or" group, if required.
|
|
1967
1966
|
if(!this.getContext().branches){
|
|
1968
1967
|
// `branches` are not defined only for the root implicit "or" operator.
|
|
1969
1968
|
/* istanbul ignore else */
|
|
1970
|
-
if(this.context.length===1){this.getContext().branches=[]}else{throw new Error('"branches" not found in an "or" group context')}}this.getContext().branches.push(expandSingleElementArray(this.getContext().instructions));this.getContext().instructions=[];break;case"[":if(
|
|
1971
|
-
/* istanbul ignore next */default:throw new Error("Unknown operator: ".concat(
|
|
1969
|
+
if(this.context.length===1){this.getContext().branches=[]}else{throw new Error('"branches" not found in an "or" group context')}}this.getContext().branches.push(expandSingleElementArray(this.getContext().instructions));this.getContext().instructions=[];break;case"[":if(n){this.parsePattern(n)}this.startContext({oneOfSet:true});break;case"]":if(!this.getContext().oneOfSet){throw new Error('"]" operator must be preceded by "[" operator')}this.endContext();this.getContext().instructions.push({op:"[]",args:parseOneOfSet(n)});break;
|
|
1970
|
+
/* istanbul ignore next */default:throw new Error("Unknown operator: ".concat(o))}if(i){this.parsePattern(i)}}}])}();function parseOneOfSet(e){var t=[];var r=0;while(r<e.length){if(e[r]==="-"){if(r===0||r===e.length-1){throw new Error("Couldn't parse a one-of set pattern: ".concat(e))}var o=e[r-1].charCodeAt(0)+1;var n=e[r+1].charCodeAt(0)-1;var i=o;while(i<=n){t.push(String.fromCharCode(i));i++}}else{t.push(e[r])}r++}return t}var ILLEGAL_CHARACTER_REGEXP=/[\(\)\[\]\?\:\|]/;var OPERATOR=new RegExp(
|
|
1972
1971
|
// any of:
|
|
1973
1972
|
"("+
|
|
1974
1973
|
// or operator
|
|
@@ -1988,14 +1987,14 @@ if(this.context.length===1){this.getContext().branches=[]}else{throw new Error('
|
|
|
1988
1987
|
// or
|
|
1989
1988
|
"|"+
|
|
1990
1989
|
// one-of set end
|
|
1991
|
-
"\\]"+")");function expandSingleElementArray(e){if(e.length===1){return e[0]}return e}function _createForOfIteratorHelperLoose$1(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$3(e))||t){r&&(e=r);var
|
|
1990
|
+
"\\]"+")");function expandSingleElementArray(e){if(e.length===1){return e[0]}return e}function _createForOfIteratorHelperLoose$1(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$3(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$3(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$3(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$3(e,t):void 0}}function _arrayLikeToArray$3(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _typeof$3(e){"@babel/helpers - typeof";return _typeof$3="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$3(e)}function _classCallCheck$3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$3(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$3(o.key),o)}}function _createClass$3(e,t,r){return t&&_defineProperties$3(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$3(e){var t=_toPrimitive$3(e,"string");return"symbol"==_typeof$3(t)?t:t+""}function _toPrimitive$3(e,t){if("object"!=_typeof$3(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$3(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var PatternMatcher=function(){function e(t){_classCallCheck$3(this,e);this.matchTree=(new PatternParser).parse(t)}return _createClass$3(e,[{key:"match",value:function e(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},o=r.allowOverflow;if(!t){throw new Error("String is required")}var n=_match(t.split(""),this.matchTree,true);if(n&&n.match){delete n.matchedChars}if(n&&n.overflow){if(!o){return}}return n}}])}();function _match(e,t,r){
|
|
1992
1991
|
// If `tree` is a string, then `tree` is a single character.
|
|
1993
1992
|
// That's because when a pattern is parsed, multi-character-string parts
|
|
1994
1993
|
// of a pattern are compiled into arrays of single characters.
|
|
1995
1994
|
// I still wrote this piece of code for a "general" hypothetical case
|
|
1996
1995
|
// when `tree` could be a string of several characters, even though
|
|
1997
1996
|
// such case is not possible with the current implementation.
|
|
1998
|
-
if(typeof t==="string"){var
|
|
1997
|
+
if(typeof t==="string"){var o=e.join("");if(t.indexOf(o)===0){
|
|
1999
1998
|
// `tree` is always a single character.
|
|
2000
1999
|
// If `tree.indexOf(characterString) === 0`
|
|
2001
2000
|
// then `characters.length === tree.length`.
|
|
@@ -2004,7 +2003,7 @@ if(e.length===t.length){return{match:true,matchedChars:e}}
|
|
|
2004
2003
|
// `tree` is always a single character.
|
|
2005
2004
|
// If `tree.indexOf(characterString) === 0`
|
|
2006
2005
|
// then `characters.length === tree.length`.
|
|
2007
|
-
/* istanbul ignore next */return{partialMatch:true}}if(
|
|
2006
|
+
/* istanbul ignore next */return{partialMatch:true}}if(o.indexOf(t)===0){if(r){
|
|
2008
2007
|
// The `else` path is not possible because `tree` is always a single character.
|
|
2009
2008
|
// The `else` case for `characters.length > tree.length` would be
|
|
2010
2009
|
// `characters.length <= tree.length` which means `characters.length <= 1`.
|
|
@@ -2013,21 +2012,21 @@ if(e.length===t.length){return{match:true,matchedChars:e}}
|
|
|
2013
2012
|
// that the `if (tree.indexOf(characterString) === 0)` condition before this
|
|
2014
2013
|
// `if` condition would be entered, and returned from there, not reaching this code.
|
|
2015
2014
|
/* istanbul ignore else */
|
|
2016
|
-
if(e.length>t.length){return{overflow:true}}}return{match:true,matchedChars:e.slice(0,t.length)}}return}if(Array.isArray(t)){var
|
|
2015
|
+
if(e.length>t.length){return{overflow:true}}}return{match:true,matchedChars:e.slice(0,t.length)}}return}if(Array.isArray(t)){var n=e.slice();var i=0;while(i<t.length){var d=t[i];var s=_match(n,d,r&&i===t.length-1);if(!s){return}else if(s.overflow){return s}else if(s.match){
|
|
2017
2016
|
// Continue with the next subtree with the rest of the characters.
|
|
2018
|
-
|
|
2017
|
+
n=n.slice(s.matchedChars.length);if(n.length===0){if(i===t.length-1){return{match:true,matchedChars:e}}else{return{partialMatch:true}}}}else{
|
|
2019
2018
|
/* istanbul ignore else */
|
|
2020
2019
|
if(s.partialMatch){return{partialMatch:true}}else{throw new Error("Unsupported match result:\n".concat(JSON.stringify(s,null,2)))}}i++}
|
|
2021
2020
|
// If `last` then overflow has already been checked
|
|
2022
2021
|
// by the last element of the `tree` array.
|
|
2023
|
-
/* istanbul ignore if */if(r){return{overflow:true}}return{match:true,matchedChars:e.slice(0,e.length-
|
|
2022
|
+
/* istanbul ignore if */if(r){return{overflow:true}}return{match:true,matchedChars:e.slice(0,e.length-n.length)}}switch(t.op){case"|":var a;for(var u=_createForOfIteratorHelperLoose$1(t.args),l;!(l=u()).done;){var $=l.value;var c=_match(e,$,r);if(c){if(c.overflow){return c}else if(c.match){return{match:true,matchedChars:c.matchedChars}}else{
|
|
2024
2023
|
/* istanbul ignore else */
|
|
2025
2024
|
if(c.partialMatch){a=true}else{throw new Error("Unsupported match result:\n".concat(JSON.stringify(c,null,2)))}}}}if(a){return{partialMatch:true}}
|
|
2026
2025
|
// Not even a partial match.
|
|
2027
2026
|
return;case"[]":for(var f=_createForOfIteratorHelperLoose$1(t.args),h;!(h=f()).done;){var p=h.value;if(e[0]===p){if(e.length===1){return{match:true,matchedChars:e}}if(r){return{overflow:true}}return{match:true,matchedChars:[p]}}}
|
|
2028
2027
|
// No character matches.
|
|
2029
2028
|
return;
|
|
2030
|
-
/* istanbul ignore next */default:throw new Error("Unsupported instruction tree: ".concat(t))}}function _typeof$2(e){"@babel/helpers - typeof";return _typeof$2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$2(e)}function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$2(e))||t){r&&(e=r);var
|
|
2029
|
+
/* istanbul ignore next */default:throw new Error("Unsupported instruction tree: ".concat(t))}}function _typeof$2(e){"@babel/helpers - typeof";return _typeof$2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$2(e)}function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray$2(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:true}:{done:false,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$2(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$2(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$2(e,t):void 0}}function _arrayLikeToArray$2(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _classCallCheck$2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$2(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$2(o.key),o)}}function _createClass$2(e,t,r){return t&&_defineProperties$2(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$2(e){var t=_toPrimitive$2(e,"string");return"symbol"==_typeof$2(t)?t:t+""}function _toPrimitive$2(e,t){if("object"!=_typeof$2(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$2(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}
|
|
2031
2030
|
// Used in phone number format template creation.
|
|
2032
2031
|
// Could be any digit, I guess.
|
|
2033
2032
|
var DUMMY_DIGIT="9";
|
|
@@ -2096,7 +2095,7 @@ var MIN_LEADING_DIGITS_LENGTH=3;var AsYouTypeFormatter=function(){function e(t){
|
|
|
2096
2095
|
* @param {string} nextDigits — Additional phone number digits.
|
|
2097
2096
|
* @param {object} state — `AsYouType` state.
|
|
2098
2097
|
* @return {[string]} Returns undefined if the updated phone number can't be formatted using any of the available formats.
|
|
2099
|
-
*/},{key:"format",value:function e(t,r){var
|
|
2098
|
+
*/},{key:"format",value:function e(t,r){var o=this;
|
|
2100
2099
|
// See if the phone number digits can be formatted as a complete phone number.
|
|
2101
2100
|
// If not, use the results from `formatNationalNumberWithNextDigits()`,
|
|
2102
2101
|
// which formats based on the chosen formatting pattern.
|
|
@@ -2111,7 +2110,7 @@ var MIN_LEADING_DIGITS_LENGTH=3;var AsYouTypeFormatter=function(){function e(t){
|
|
|
2111
2110
|
// If so, we should use this instead of any other formatting template
|
|
2112
2111
|
// whose leadingDigitsPattern also matches the input."
|
|
2113
2112
|
|
|
2114
|
-
if(canFormatCompleteNumber(r.nationalSignificantNumber,this.metadata)){for(var
|
|
2113
|
+
if(canFormatCompleteNumber(r.nationalSignificantNumber,this.metadata)){for(var n=_createForOfIteratorHelperLoose(this.matchingFormats),i;!(i=n()).done;){var d=i.value;var s=formatCompleteNumber(r,d,{shouldTryNationalPrefixFormattingRule:function e(t){return o.shouldTryNationalPrefixFormattingRule(t,{international:r.international,nationalPrefix:r.nationalPrefix})},getSeparatorAfterNationalPrefix:function e(t){return o.getSeparatorAfterNationalPrefix(t)}});if(s){this.resetFormat();this.chosenFormat=d;this.setNationalNumberTemplate(s.replace(/\d/g,DIGIT_PLACEHOLDER),r);this.populatedNationalNumberTemplate=s;
|
|
2115
2114
|
// With a new formatting template, the matched position
|
|
2116
2115
|
// using the old template needs to be reset.
|
|
2117
2116
|
this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(DIGIT_PLACEHOLDER);return s}}}
|
|
@@ -2119,9 +2118,9 @@ this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(DIGIT_PLA
|
|
|
2119
2118
|
// using the previously chosen formatting pattern (or a newly chosen one).
|
|
2120
2119
|
return this.formatNationalNumberWithNextDigits(t,r)}
|
|
2121
2120
|
// Formats the next phone number digits.
|
|
2122
|
-
},{key:"formatNationalNumberWithNextDigits",value:function e(t,r){var
|
|
2121
|
+
},{key:"formatNationalNumberWithNextDigits",value:function e(t,r){var o=this.chosenFormat;
|
|
2123
2122
|
// Choose a format from the list of matching ones.
|
|
2124
|
-
var
|
|
2123
|
+
var n=this.chooseFormat(r);if(n){if(n===o){
|
|
2125
2124
|
// If it can format the next (current) digits
|
|
2126
2125
|
// using the previously chosen phone number format
|
|
2127
2126
|
// then return the updated formatted number.
|
|
@@ -2130,7 +2129,7 @@ return this.formatNextNationalNumberDigits(t)}else{
|
|
|
2130
2129
|
// has been chosen for these "leading digits",
|
|
2131
2130
|
// then re-format the national phone number part
|
|
2132
2131
|
// using the newly selected format.
|
|
2133
|
-
return this.formatNextNationalNumberDigits(r.getNationalDigits())}}}},{key:"narrowDownMatchingFormats",value:function e(t){var r=this;var
|
|
2132
|
+
return this.formatNextNationalNumberDigits(r.getNationalDigits())}}}},{key:"narrowDownMatchingFormats",value:function e(t){var r=this;var o=t.nationalSignificantNumber,n=t.nationalPrefix,i=t.international;var d=o;
|
|
2134
2133
|
// "leading digits" pattern list starts with a
|
|
2135
2134
|
// "leading digits" pattern fitting a maximum of 3 leading digits.
|
|
2136
2135
|
// So, after a user inputs 3 digits of a national (significant) phone number
|
|
@@ -2142,7 +2141,7 @@ return this.formatNextNationalNumberDigits(r.getNationalDigits())}}}},{key:"narr
|
|
|
2142
2141
|
// even if the user has entered less than
|
|
2143
2142
|
// `MIN_LEADING_DIGITS_LENGTH` digits of a national number.
|
|
2144
2143
|
// Because some leading digit patterns already match for a single first digit.
|
|
2145
|
-
var s=d.length-MIN_LEADING_DIGITS_LENGTH;if(s<0){s=0}this.matchingFormats=this.matchingFormats.filter((function(e){return r.formatSuits(e,i,
|
|
2144
|
+
var s=d.length-MIN_LEADING_DIGITS_LENGTH;if(s<0){s=0}this.matchingFormats=this.matchingFormats.filter((function(e){return r.formatSuits(e,i,n)&&r.formatMatches(e,d,s)}));
|
|
2146
2145
|
// If there was a phone number format chosen
|
|
2147
2146
|
// and it no longer holds given the new leading digits then reset it.
|
|
2148
2147
|
// The test for this `if` condition is marked as:
|
|
@@ -2150,7 +2149,7 @@ var s=d.length-MIN_LEADING_DIGITS_LENGTH;if(s<0){s=0}this.matchingFormats=this.m
|
|
|
2150
2149
|
// To construct a valid test case for this one can find a country
|
|
2151
2150
|
// in `PhoneNumberMetadata.xml` yielding one format for 3 `<leadingDigits>`
|
|
2152
2151
|
// and yielding another format for 4 `<leadingDigits>` (Australia in this case).
|
|
2153
|
-
if(this.chosenFormat&&this.matchingFormats.indexOf(this.chosenFormat)===-1){this.resetFormat()}}},{key:"formatSuits",value:function e(t,r,
|
|
2152
|
+
if(this.chosenFormat&&this.matchingFormats.indexOf(this.chosenFormat)===-1){this.resetFormat()}}},{key:"formatSuits",value:function e(t,r,o){
|
|
2154
2153
|
// When a prefix before a national (significant) number is
|
|
2155
2154
|
// simply a national prefix, then it's parsed as `this.nationalPrefix`.
|
|
2156
2155
|
// In more complex cases, a prefix before national (significant) number
|
|
@@ -2161,7 +2160,7 @@ if(this.chosenFormat&&this.matchingFormats.indexOf(this.chosenFormat)===-1){this
|
|
|
2161
2160
|
// and was extracted, then discard such phone number format.
|
|
2162
2161
|
// In Google's "AsYouType" formatter code, the equivalent would be this part:
|
|
2163
2162
|
// https://github.com/google/libphonenumber/blob/0a45cfd96e71cad8edb0e162a70fcc8bd9728933/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L175-L184
|
|
2164
|
-
if(
|
|
2163
|
+
if(o&&!t.usesNationalPrefix()&&
|
|
2165
2164
|
// !format.domesticCarrierCodeFormattingRule() &&
|
|
2166
2165
|
!t.nationalPrefixIsOptionalWhenFormattingInNationalFormat()){return false}
|
|
2167
2166
|
// If national prefix is mandatory for this phone number format
|
|
@@ -2169,16 +2168,16 @@ if(n&&!t.usesNationalPrefix()&&
|
|
|
2169
2168
|
// then discard this phone number format as not suitable.
|
|
2170
2169
|
// In Google's "AsYouType" formatter code, the equivalent would be this part:
|
|
2171
2170
|
// https://github.com/google/libphonenumber/blob/0a45cfd96e71cad8edb0e162a70fcc8bd9728933/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L185-L193
|
|
2172
|
-
if(!r&&!
|
|
2171
|
+
if(!r&&!o&&t.nationalPrefixIsMandatoryWhenFormattingInNationalFormat()){return false}return true}},{key:"formatMatches",value:function e(t,r,o){var n=t.leadingDigitsPatterns().length;
|
|
2173
2172
|
// If this format is not restricted to a certain
|
|
2174
2173
|
// leading digits pattern then it fits.
|
|
2175
2174
|
// The test case could be found by searching for "leadingDigitsPatternsCount === 0".
|
|
2176
|
-
if(
|
|
2175
|
+
if(n===0){return true}
|
|
2177
2176
|
// Start narrowing down the list of possible formats based on the leading digits.
|
|
2178
2177
|
// (only previously matched formats take part in the narrowing down process)
|
|
2179
2178
|
// `leading_digits_patterns` start with 3 digits min
|
|
2180
2179
|
// and then go up from there one digit at a time.
|
|
2181
|
-
|
|
2180
|
+
o=Math.min(o,n-1);var i=t.leadingDigitsPatterns()[o];
|
|
2182
2181
|
// Google imposes a requirement on the leading digits
|
|
2183
2182
|
// to be minimum 3 digits long in order to be eligible
|
|
2184
2183
|
// for checking those with a leading digits pattern.
|
|
@@ -2220,10 +2219,10 @@ console.error(e);return true}}
|
|
|
2220
2219
|
// The whole pattern is wrapped in round brackets (`()`) because
|
|
2221
2220
|
// the pattern can use "or" operator (`|`) at the top level of the pattern.
|
|
2222
2221
|
|
|
2223
|
-
return new RegExp("^(".concat(i,")")).test(r)}},{key:"getFormatFormat",value:function e(t,r){return r?t.internationalFormat():t.format()}},{key:"chooseFormat",value:function e(t){var r=this;var
|
|
2222
|
+
return new RegExp("^(".concat(i,")")).test(r)}},{key:"getFormatFormat",value:function e(t,r){return r?t.internationalFormat():t.format()}},{key:"chooseFormat",value:function e(t){var r=this;var o=function e(){var o=d.value;
|
|
2224
2223
|
// If this format is currently being used
|
|
2225
2224
|
// and is still suitable, then stick to it.
|
|
2226
|
-
if(r.chosenFormat===
|
|
2225
|
+
if(r.chosenFormat===o){return 0;// break
|
|
2227
2226
|
}
|
|
2228
2227
|
// Sometimes, a formatting rule inserts additional digits in a phone number,
|
|
2229
2228
|
// and "as you type" formatter can't do that: it should only use the digits
|
|
@@ -2263,12 +2262,12 @@ if(r.chosenFormat===n){return 0;// break
|
|
|
2263
2262
|
// it's a logical thing in the modern age of mobile phones,
|
|
2264
2263
|
// globalization and the internet.
|
|
2265
2264
|
|
|
2266
|
-
/* istanbul ignore if */if(!NON_ALTERING_FORMAT_REG_EXP.test(r.getFormatFormat(
|
|
2267
|
-
}if(!r.createTemplateForFormat(
|
|
2265
|
+
/* istanbul ignore if */if(!NON_ALTERING_FORMAT_REG_EXP.test(r.getFormatFormat(o,t.international))){return 1;// continue
|
|
2266
|
+
}if(!r.createTemplateForFormat(o,t)){
|
|
2268
2267
|
// Remove the format if it can't generate a template.
|
|
2269
|
-
r.matchingFormats=r.matchingFormats.filter((function(e){return e!==
|
|
2270
|
-
}r.chosenFormat=
|
|
2271
|
-
},
|
|
2268
|
+
r.matchingFormats=r.matchingFormats.filter((function(e){return e!==o}));return 1;// continue
|
|
2269
|
+
}r.chosenFormat=o;return 0;// break
|
|
2270
|
+
},n;
|
|
2272
2271
|
// When there are multiple available formats, the formatter uses the first
|
|
2273
2272
|
// format where a formatting template could be created.
|
|
2274
2273
|
|
|
@@ -2283,7 +2282,7 @@ r.matchingFormats=r.matchingFormats.filter((function(e){return e!==n}));return 1
|
|
|
2283
2282
|
// It doesn't skip the contents of the `for of` loop,
|
|
2284
2283
|
// it just skips the `for of` line.
|
|
2285
2284
|
|
|
2286
|
-
/* istanbul ignore next */for(var i=_createForOfIteratorHelperLoose(this.matchingFormats.slice()),d;!(d=i()).done;){o
|
|
2285
|
+
/* istanbul ignore next */for(var i=_createForOfIteratorHelperLoose(this.matchingFormats.slice()),d;!(d=i()).done;){n=o();if(n===0)break;if(n===1)continue}if(!this.chosenFormat){
|
|
2287
2286
|
// No format matches the national (significant) phone number.
|
|
2288
2287
|
this.resetFormat()}return this.chosenFormat}},{key:"createTemplateForFormat",value:function e(t,r){
|
|
2289
2288
|
// The formatter doesn't format numbers when numberPattern contains '|', e.g.
|
|
@@ -2292,10 +2291,10 @@ this.resetFormat()}return this.chosenFormat}},{key:"createTemplateForFormat",val
|
|
|
2292
2291
|
/* istanbul ignore if */
|
|
2293
2292
|
if(t.pattern().indexOf("|")>=0){return}
|
|
2294
2293
|
// Get formatting template for this phone number format
|
|
2295
|
-
var
|
|
2294
|
+
var o=this.getTemplateForFormat(t,r);
|
|
2296
2295
|
// If the national number entered is too long
|
|
2297
2296
|
// for any phone number format, then abort.
|
|
2298
|
-
if(
|
|
2297
|
+
if(o){this.setNationalNumberTemplate(o,r);return true}}},{key:"getSeparatorAfterNationalPrefix",value:function e(t){
|
|
2299
2298
|
// `US` metadata doesn't have a `national_prefix_formatting_rule`,
|
|
2300
2299
|
// so the `if` condition below doesn't apply to `US`,
|
|
2301
2300
|
// but in reality there shoudl be a separator
|
|
@@ -2310,11 +2309,11 @@ if(t&&t.nationalPrefixFormattingRule()&&NATIONAL_PREFIX_SEPARATORS_PATTERN.test(
|
|
|
2310
2309
|
// At this point, there seems to be no clear evidence that
|
|
2311
2310
|
// there should be a separator between a national prefix
|
|
2312
2311
|
// and a national (significant) number. So don't insert one.
|
|
2313
|
-
return""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function e(t,r){var
|
|
2312
|
+
return""}},{key:"getInternationalPrefixBeforeCountryCallingCode",value:function e(t,r){var o=t.IDDPrefix,n=t.missingPlus;if(o){return r&&r.spacing===false?o:o+" "}if(n){return""}return"+"}},{key:"getTemplate",value:function e(t){if(!this.template){return}
|
|
2314
2313
|
// `this.template` holds the template for a "complete" phone number.
|
|
2315
2314
|
// The currently entered phone number is most likely not "complete",
|
|
2316
2315
|
// so trim all non-populated digits.
|
|
2317
|
-
var r=-1;var
|
|
2316
|
+
var r=-1;var o=0;var n=t.international?this.getInternationalPrefixBeforeCountryCallingCode(t,{spacing:false}):"";while(o<n.length+t.getDigitsWithoutInternationalPrefix().length){r=this.template.indexOf(DIGIT_PLACEHOLDER,r+1);o++}return cutAndStripNonPairedParens(this.template,r+1)}},{key:"setNationalNumberTemplate",value:function e(t,r){this.nationalNumberTemplate=t;this.populatedNationalNumberTemplate=t;
|
|
2318
2317
|
// With a new formatting template, the matched position
|
|
2319
2318
|
// using the old template needs to be reset.
|
|
2320
2319
|
this.populatedNationalNumberTemplatePosition=-1;
|
|
@@ -2330,7 +2329,7 @@ if(r.international){this.template=this.getInternationalPrefixBeforeCountryCallin
|
|
|
2330
2329
|
* @param {Format} format
|
|
2331
2330
|
* @param {string} nationalPrefix
|
|
2332
2331
|
* @return {string}
|
|
2333
|
-
*/},{key:"getTemplateForFormat",value:function e(t,r){var
|
|
2332
|
+
*/},{key:"getTemplateForFormat",value:function e(t,r){var o=r.nationalSignificantNumber,n=r.international,i=r.nationalPrefix,d=r.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix;var s=t.pattern();
|
|
2334
2333
|
/* istanbul ignore else */{s=s.replace(CREATE_CHARACTER_CLASS_PATTERN(),"\\d").replace(CREATE_STANDALONE_DIGIT_PATTERN(),"\\d")}
|
|
2335
2334
|
// Generate a dummy national number (consisting of `9`s)
|
|
2336
2335
|
// that fits this format's `pattern`.
|
|
@@ -2343,7 +2342,7 @@ if(r.international){this.template=this.getInternationalPrefixBeforeCountryCallin
|
|
|
2343
2342
|
var a=LONGEST_DUMMY_PHONE_NUMBER.match(s)[0];
|
|
2344
2343
|
// If the national number entered is too long
|
|
2345
2344
|
// for any phone number format, then abort.
|
|
2346
|
-
if(
|
|
2345
|
+
if(o.length>a.length){return}
|
|
2347
2346
|
// Get a formatting template which can be used to efficiently format
|
|
2348
2347
|
// a partial number where digits are added one by one.
|
|
2349
2348
|
// Below `strictPattern` is used for the
|
|
@@ -2373,11 +2372,11 @@ if(n.length>a.length){return}
|
|
|
2373
2372
|
// The fix is, if `this.nationalSignificantNumber` has already sufficient length
|
|
2374
2373
|
// to satisfy the `pattern` completely then `this.nationalSignificantNumber`
|
|
2375
2374
|
// is used instead of `digits`.
|
|
2376
|
-
var u=new RegExp("^"+s+"$");var l=
|
|
2375
|
+
var u=new RegExp("^"+s+"$");var l=o.replace(/\d/g,DUMMY_DIGIT);
|
|
2377
2376
|
// If `this.nationalSignificantNumber` has already sufficient length
|
|
2378
2377
|
// to satisfy the `pattern` completely then use it
|
|
2379
2378
|
// instead of `digits`.
|
|
2380
|
-
if(u.test(l)){a=l}var $=this.getFormatFormat(t,
|
|
2379
|
+
if(u.test(l)){a=l}var $=this.getFormatFormat(t,n);var c;
|
|
2381
2380
|
// If a user did input a national prefix (and that's guaranteed),
|
|
2382
2381
|
// and if a `format` does have a national prefix formatting rule,
|
|
2383
2382
|
// then see if that national prefix formatting rule
|
|
@@ -2385,7 +2384,7 @@ if(u.test(l)){a=l}var $=this.getFormatFormat(t,o);var c;
|
|
|
2385
2384
|
// If that's the case, then use the `format` with the national prefix formatting rule.
|
|
2386
2385
|
// Otherwise, use the `format` without the national prefix formatting rule,
|
|
2387
2386
|
// and prepend a national prefix manually to it.
|
|
2388
|
-
if(this.shouldTryNationalPrefixFormattingRule(t,{international:
|
|
2387
|
+
if(this.shouldTryNationalPrefixFormattingRule(t,{international:n,nationalPrefix:i})){var f=$.replace(FIRST_GROUP_PATTERN,t.nationalPrefixFormattingRule());
|
|
2389
2388
|
// If `national_prefix_formatting_rule` of a `format` simply prepends
|
|
2390
2389
|
// national prefix at the start of a national (significant) number,
|
|
2391
2390
|
// then such formatting can be used with `AsYouType` formatter.
|
|
@@ -2407,7 +2406,7 @@ if(!c){if(d){
|
|
|
2407
2406
|
// Prepend the prefix to the template manually.
|
|
2408
2407
|
p=repeat(DIGIT_PLACEHOLDER,d.length)+" "+p}else if(i){
|
|
2409
2408
|
// Prepend national prefix to the template manually.
|
|
2410
|
-
p=repeat(DIGIT_PLACEHOLDER,i.length)+this.getSeparatorAfterNationalPrefix(t)+p}}if(
|
|
2409
|
+
p=repeat(DIGIT_PLACEHOLDER,i.length)+this.getSeparatorAfterNationalPrefix(t)+p}}if(n){p=applyInternationalSeparatorStyle(p)}return p}},{key:"formatNextNationalNumberDigits",value:function e(t){var r=populateTemplateWithDigits(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,t);if(!r){
|
|
2411
2410
|
// Reset the format.
|
|
2412
2411
|
this.resetFormat();return}this.populatedNationalNumberTemplate=r[0];this.populatedNationalNumberTemplatePosition=r[1];
|
|
2413
2412
|
// Return the formatted phone number so far.
|
|
@@ -2416,22 +2415,22 @@ return cutAndStripNonPairedParens(this.populatedNationalNumberTemplate,this.popu
|
|
|
2416
2415
|
// for `react-phone-number-input`'s default input (`InputBasic`).
|
|
2417
2416
|
// return closeNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1)
|
|
2418
2417
|
// .replace(new RegExp(DIGIT_PLACEHOLDER, 'g'), ' ')
|
|
2419
|
-
}},{key:"shouldTryNationalPrefixFormattingRule",value:function e(t,r){var
|
|
2418
|
+
}},{key:"shouldTryNationalPrefixFormattingRule",value:function e(t,r){var o=r.international,n=r.nationalPrefix;if(t.nationalPrefixFormattingRule()){
|
|
2420
2419
|
// In some countries, `national_prefix_formatting_rule` is `($1)`,
|
|
2421
2420
|
// so it applies even if the user hasn't input a national prefix.
|
|
2422
2421
|
// `format.usesNationalPrefix()` detects such cases.
|
|
2423
|
-
var i=t.usesNationalPrefix();if(i&&
|
|
2422
|
+
var i=t.usesNationalPrefix();if(i&&n||!i&&!o){return true}}}}])}();function _typeof$1(e){"@babel/helpers - typeof";return _typeof$1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof$1(e)}function _slicedToArray$1(e,t){return _arrayWithHoles$1(e)||_iterableToArrayLimit$1(e,t)||_unsupportedIterableToArray$1(e,t)||_nonIterableRest$1()}function _nonIterableRest$1(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray$1(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray$1(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray$1(e,t):void 0}}function _arrayLikeToArray$1(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _iterableToArrayLimit$1(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,i,d,s=[],a=true,u=false;try{if(i=(r=r.call(e)).next,0===t);else for(;!(a=(o=i.call(r)).done)&&(s.push(o.value),s.length!==t);a=true);}catch(e){u=true,n=e}finally{try{if(!a&&null!=r["return"]&&(d=r["return"](),Object(d)!==d))return}finally{if(u)throw n}}return s}}function _arrayWithHoles$1(e){if(Array.isArray(e))return e}function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$1(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey$1(o.key),o)}}function _createClass$1(e,t,r){return t&&_defineProperties$1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey$1(e){var t=_toPrimitive$1(e,"string");return"symbol"==_typeof$1(t)?t:t+""}function _toPrimitive$1(e,t){if("object"!=_typeof$1(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof$1(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART="["+VALID_PUNCTUATION+VALID_DIGITS+"]+";var VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN=new RegExp("^"+VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART+"$","i");var VALID_FORMATTED_PHONE_NUMBER_PART="(?:"+"["+PLUS_CHARS+"]"+"["+VALID_PUNCTUATION+VALID_DIGITS+"]*"+"|"+"["+VALID_PUNCTUATION+VALID_DIGITS+"]+"+")";var AFTER_PHONE_NUMBER_DIGITS_END_PATTERN=new RegExp("[^"+VALID_PUNCTUATION+VALID_DIGITS+"]+"+".*"+"$");
|
|
2424
2423
|
// Tests whether `national_prefix_for_parsing` could match
|
|
2425
2424
|
// different national prefixes.
|
|
2426
2425
|
// Matches anything that's not a digit or a square bracket.
|
|
2427
|
-
var COMPLEX_NATIONAL_PREFIX=/[^\d\[\]]/;var AsYouTypeParser=function(){function e(t){var r=t.defaultCountry,
|
|
2426
|
+
var COMPLEX_NATIONAL_PREFIX=/[^\d\[\]]/;var AsYouTypeParser=function(){function e(t){var r=t.defaultCountry,o=t.defaultCallingCode,n=t.metadata,i=t.onNationalSignificantNumberChange;_classCallCheck$1(this,e);this.defaultCountry=r;this.defaultCallingCode=o;this.metadata=n;this.onNationalSignificantNumberChange=i}return _createClass$1(e,[{key:"input",value:function e(t,r){var o=extractFormattedDigitsAndPlus(t),n=_slicedToArray$1(o,2),i=n[0],d=n[1];var s=parseDigits(i);
|
|
2428
2427
|
// Checks for a special case: just a leading `+` has been entered.
|
|
2429
2428
|
var a;if(d){if(!r.digits){r.startInternationalNumber(undefined,undefined);if(!s){a=true}}}if(s){this.inputDigits(s,r)}return{digits:s,justLeadingPlus:a}}
|
|
2430
2429
|
/**
|
|
2431
2430
|
* Inputs "next" phone number digits.
|
|
2432
2431
|
* @param {string} digits
|
|
2433
2432
|
* @return {string} [formattedNumber] Formatted national phone number (if it can be formatted at this stage). Returning `undefined` means "don't format the national phone number at this stage".
|
|
2434
|
-
*/},{key:"inputDigits",value:function e(t,r){var
|
|
2433
|
+
*/},{key:"inputDigits",value:function e(t,r){var o=r.digits;var n=o.length<3&&o.length+t.length>=3;
|
|
2435
2434
|
// Append phone number digits.
|
|
2436
2435
|
r.appendDigits(t);
|
|
2437
2436
|
// Attempt to extract IDD prefix:
|
|
@@ -2448,34 +2447,34 @@ r.appendDigits(t);
|
|
|
2448
2447
|
// and it could even be as long as `14880011`.
|
|
2449
2448
|
// An IDD prefix is extracted here, and then every time when
|
|
2450
2449
|
// there's a new digit and the number couldn't be formatted.
|
|
2451
|
-
if(
|
|
2450
|
+
if(n){this.extractIddPrefix(r)}if(this.isWaitingForCountryCallingCode(r)){if(!this.extractCountryCallingCode(r)){return}}else{r.appendNationalSignificantNumberDigits(t)}
|
|
2452
2451
|
// If a phone number is being input in international format,
|
|
2453
2452
|
// then it's not valid for it to have a national prefix.
|
|
2454
2453
|
// Still, some people incorrectly input such numbers with a national prefix.
|
|
2455
2454
|
// In such cases, only attempt to strip a national prefix if the number becomes too long.
|
|
2456
2455
|
// (but that is done later, not here)
|
|
2457
|
-
if(!r.international){if(!this.hasExtractedNationalSignificantNumber){this.extractNationalSignificantNumber(r.getNationalDigits(),(function(e){return r.update(e)}))}}}},{key:"isWaitingForCountryCallingCode",value:function e(t){var r=t.international,
|
|
2456
|
+
if(!r.international){if(!this.hasExtractedNationalSignificantNumber){this.extractNationalSignificantNumber(r.getNationalDigits(),(function(e){return r.update(e)}))}}}},{key:"isWaitingForCountryCallingCode",value:function e(t){var r=t.international,o=t.callingCode;return r&&!o}
|
|
2458
2457
|
// Extracts a country calling code from a number
|
|
2459
2458
|
// being entered in internatonal format.
|
|
2460
|
-
},{key:"extractCountryCallingCode",value:function e(t){var r=extractCountryCallingCode("+"+t.getDigitsWithoutInternationalPrefix(),t.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),
|
|
2459
|
+
},{key:"extractCountryCallingCode",value:function e(t){var r=extractCountryCallingCode("+"+t.getDigitsWithoutInternationalPrefix(),t.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),o=r.countryCallingCode,n=r.number;if(o){t.setCallingCode(o);t.update({nationalSignificantNumber:n});return true}}},{key:"reset",value:function e(t){if(t){this.hasSelectedNumberingPlan=true;var r=t._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=r&&COMPLEX_NATIONAL_PREFIX.test(r)}else{this.hasSelectedNumberingPlan=undefined;this.couldPossiblyExtractAnotherNationalSignificantNumber=undefined}}
|
|
2461
2460
|
/**
|
|
2462
2461
|
* Extracts a national (significant) number from user input.
|
|
2463
2462
|
* Google's library is different in that it only applies `national_prefix_for_parsing`
|
|
2464
2463
|
* and doesn't apply `national_prefix_transform_rule` after that.
|
|
2465
2464
|
* https://github.com/google/libphonenumber/blob/a3d70b0487875475e6ad659af404943211d26456/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L539
|
|
2466
2465
|
* @return {boolean} [extracted]
|
|
2467
|
-
*/},{key:"extractNationalSignificantNumber",value:function e(t,r){if(!this.hasSelectedNumberingPlan){return}var
|
|
2466
|
+
*/},{key:"extractNationalSignificantNumber",value:function e(t,r){if(!this.hasSelectedNumberingPlan){return}var o=extractNationalNumberFromPossiblyIncompleteNumber(t,this.metadata),n=o.nationalPrefix,i=o.nationalNumber,d=o.carrierCode;if(i===t){return}this.onExtractedNationalNumber(n,d,i,t,r);return true}
|
|
2468
2467
|
/**
|
|
2469
2468
|
* In Google's code this function is called "attempt to extract longer NDD".
|
|
2470
2469
|
* "Some national prefixes are a substring of others", they say.
|
|
2471
2470
|
* @return {boolean} [result] — Returns `true` if extracting a national prefix produced different results from what they were.
|
|
2472
|
-
*/},{key:"extractAnotherNationalSignificantNumber",value:function e(t,r,
|
|
2471
|
+
*/},{key:"extractAnotherNationalSignificantNumber",value:function e(t,r,o){if(!this.hasExtractedNationalSignificantNumber){return this.extractNationalSignificantNumber(t,o)}if(!this.couldPossiblyExtractAnotherNationalSignificantNumber){return}var n=extractNationalNumberFromPossiblyIncompleteNumber(t,this.metadata),i=n.nationalPrefix,d=n.nationalNumber,s=n.carrierCode;
|
|
2473
2472
|
// If a national prefix has been extracted previously,
|
|
2474
2473
|
// then it's always extracted as additional digits are added.
|
|
2475
2474
|
// That's assuming `extractNationalNumberFromPossiblyIncompleteNumber()`
|
|
2476
2475
|
// doesn't do anything different from what it currently does.
|
|
2477
2476
|
// So, just in case, here's this check, though it doesn't occur.
|
|
2478
|
-
/* istanbul ignore if */if(d===r){return}this.onExtractedNationalNumber(i,s,d,t,
|
|
2477
|
+
/* istanbul ignore if */if(d===r){return}this.onExtractedNationalNumber(i,s,d,t,o);return true}},{key:"onExtractedNationalNumber",value:function e(t,r,o,n,i){
|
|
2479
2478
|
// Tells if the parsed national (significant) number is present as-is in the input string.
|
|
2480
2479
|
// For example, when inputting "0343515551212999" Argentinian mobile number,
|
|
2481
2480
|
// the parsed national (significant) number is "93435551212999".
|
|
@@ -2492,18 +2491,18 @@ var d=false;
|
|
|
2492
2491
|
// https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
|
|
2493
2492
|
var s;
|
|
2494
2493
|
// `nationalSignificantNumber` could be empty. In that case, `.lastIndexOf()` still works correctly.
|
|
2495
|
-
var a=
|
|
2494
|
+
var a=n.lastIndexOf(o);
|
|
2496
2495
|
// If the parsed national (significant) number is the last substring of the `nationalDigits`,
|
|
2497
2496
|
// then it means that it's present as-is in the input string.
|
|
2498
2497
|
// In any other case, the parsed national (significant) number is "modified" in the input string.
|
|
2499
|
-
if(a<0||a!==
|
|
2498
|
+
if(a<0||a!==n.length-o.length){d=true}else{var u=n.slice(0,a);
|
|
2500
2499
|
// When national (significant) number is equal to the `nationalDigits`,
|
|
2501
2500
|
// this `onExtractedNationalNumber()` function simply doesn't get called.
|
|
2502
2501
|
// This means that at this point, `prefixBeforeNationalNumber` is always non-empty.
|
|
2503
2502
|
// Still, added this `if` check just to prevent potential silly bugs.
|
|
2504
2503
|
// The `!prefixBeforeNationalNumber` case is not really testable
|
|
2505
2504
|
// so this line is exluded from the code coverage.
|
|
2506
|
-
/* istanbul ignore if */if(u){if(u!==t){s=u}}}i({nationalPrefix:t,carrierCode:r,nationalSignificantNumber:
|
|
2505
|
+
/* istanbul ignore if */if(u){if(u!==t){s=u}}}i({nationalPrefix:t,carrierCode:r,nationalSignificantNumber:o,nationalSignificantNumberIsModified:d,prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix:s});
|
|
2507
2506
|
// `onExtractedNationalNumber()` is only called when
|
|
2508
2507
|
// the national (significant) number actually did change.
|
|
2509
2508
|
this.hasExtractedNationalSignificantNumber=true;this.onNationalSignificantNumberChange()}},{key:"reExtractNationalSignificantNumber",value:function e(t){
|
|
@@ -2558,15 +2557,15 @@ if(this.extractIddPrefix(t)){this.extractCallingCodeAndNationalSignificantNumber
|
|
|
2558
2557
|
if(this.fixMissingPlus(t)){this.extractCallingCodeAndNationalSignificantNumber(t);return true}}},{key:"extractIddPrefix",value:function e(t){
|
|
2559
2558
|
// An IDD prefix can't be present in a number written with a `+`.
|
|
2560
2559
|
// Also, don't re-extract an IDD prefix if has already been extracted.
|
|
2561
|
-
var r=t.international,
|
|
2560
|
+
var r=t.international,o=t.IDDPrefix,n=t.digits;if(r||o){return}
|
|
2562
2561
|
// Some users input their phone number in "out-of-country"
|
|
2563
2562
|
// dialing format instead of using the leading `+`.
|
|
2564
2563
|
// https://github.com/catamphetamine/libphonenumber-js/issues/185
|
|
2565
2564
|
// Detect such numbers.
|
|
2566
|
-
var i=stripIddPrefix(
|
|
2565
|
+
var i=stripIddPrefix(n,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);if(i!==undefined&&i!==n){
|
|
2567
2566
|
// If an IDD prefix was stripped then convert the IDD-prefixed number
|
|
2568
2567
|
// to international number for subsequent parsing.
|
|
2569
|
-
t.update({IDDPrefix:
|
|
2568
|
+
t.update({IDDPrefix:n.slice(0,n.length-i.length)});this.startInternationalNumber(t,{country:undefined,callingCode:undefined});return true}}},{key:"fixMissingPlus",value:function e(t){if(!t.international){var r=extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(t.digits,t.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),o=r.countryCallingCode;if(o){t.update({missingPlus:true});this.startInternationalNumber(t,{country:t.country,callingCode:o});return true}}}},{key:"startInternationalNumber",value:function e(t,r){var o=r.country,n=r.callingCode;t.startInternationalNumber(o,n);
|
|
2570
2569
|
// If a national (significant) number has been extracted before, reset it.
|
|
2571
2570
|
if(t.nationalSignificantNumber){t.resetNationalSignificantNumber();this.onNationalSignificantNumberChange();this.hasExtractedNationalSignificantNumber=undefined}}},{key:"extractCallingCodeAndNationalSignificantNumber",value:function e(t){if(this.extractCountryCallingCode(t)){
|
|
2572
2571
|
// `this.extractCallingCode()` is currently called when the number
|
|
@@ -2599,11 +2598,11 @@ if(t[0]==="+"){return[t.slice("+".length),true]}return[t]}
|
|
|
2599
2598
|
* Extracts formatted phone number digits (and a `+`) from text (if there're any).
|
|
2600
2599
|
* @param {string} text
|
|
2601
2600
|
* @return {any[]}
|
|
2602
|
-
*/function extractFormattedDigitsAndPlus(e){var t=_extractFormattedDigitsAndPlus(e),r=_slicedToArray$1(t,2),
|
|
2601
|
+
*/function extractFormattedDigitsAndPlus(e){var t=_extractFormattedDigitsAndPlus(e),r=_slicedToArray$1(t,2),o=r[0],n=r[1];
|
|
2603
2602
|
// If the extracted phone number part
|
|
2604
2603
|
// can possibly be a part of some valid phone number
|
|
2605
2604
|
// then parse phone number characters from a formatted phone number.
|
|
2606
|
-
if(!VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN.test(
|
|
2605
|
+
if(!VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN.test(o)){o=""}return[o,n]}function _typeof(e){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,i,d,s=[],a=true,u=false;try{if(i=(r=r.call(e)).next,0===t);else for(;!(a=(o=i.call(r)).done)&&(s.push(o.value),s.length!==t);a=true);}catch(e){u=true,n=e}finally{try{if(!a&&null!=r["return"]&&(d=r["return"](),Object(d)!==d))return}finally{if(u)throw n}}return s}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||false,o.configurable=true,"value"in o&&(o.writable=true),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var AsYouType$1=function(){
|
|
2607
2606
|
/**
|
|
2608
2607
|
* @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.
|
|
2609
2608
|
* @param {Object} metadata
|
|
@@ -2612,22 +2611,22 @@ function e(t,r){_classCallCheck(this,e);
|
|
|
2612
2611
|
// Metadata instance is created once and stays constant.
|
|
2613
2612
|
// This is required because other utility classes such as `AsYouTypeFormatter`
|
|
2614
2613
|
// will use this metadata instance "reference" and will assume that it stays constant.
|
|
2615
|
-
this.metadata=new Metadata(r);var
|
|
2614
|
+
this.metadata=new Metadata(r);var o=this.getCountryAndCallingCode(t),n=_slicedToArray(o,2),i=n[0],d=n[1];
|
|
2616
2615
|
// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.
|
|
2617
2616
|
// For example, `this.defaultCountry` could be `"AR"` and `this.defaultCallingCode` could be `undefined`.
|
|
2618
2617
|
// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.
|
|
2619
2618
|
this.defaultCountry=i;this.defaultCallingCode=d;this.reset()}return _createClass(e,[{key:"getCountryAndCallingCode",value:function e(t){
|
|
2620
2619
|
// Set `defaultCountry` and `defaultCallingCode` options.
|
|
2621
|
-
var r;var
|
|
2620
|
+
var r;var o;
|
|
2622
2621
|
// Turns out `null` also has type "object". Weird.
|
|
2623
|
-
if(t){if(isObject(t)){r=t.defaultCountry;
|
|
2622
|
+
if(t){if(isObject(t)){r=t.defaultCountry;o=t.defaultCallingCode}else{r=t}}if(r&&!this.metadata.hasCountry(r)){r=undefined}return[r,o]}
|
|
2624
2623
|
/**
|
|
2625
2624
|
* Inputs "next" phone number characters.
|
|
2626
2625
|
* @param {string} text
|
|
2627
2626
|
* @return {string} Formatted phone number characters that have been input so far.
|
|
2628
|
-
*/},{key:"input",value:function e(t){var r=this.parser.input(t,this.state),
|
|
2627
|
+
*/},{key:"input",value:function e(t){var r=this.parser.input(t,this.state),o=r.digits,n=r.justLeadingPlus;if(n){this.formattedOutput="+"}else if(o){this.determineTheCountryIfNeeded();
|
|
2629
2628
|
// Match the available formats by the currently available leading digits.
|
|
2630
|
-
if(this.state.nationalSignificantNumber){this.formatter.narrowDownMatchingFormats(this.state)}var i;if(this.metadata.hasSelectedNumberingPlan()){i=this.formatter.format(
|
|
2629
|
+
if(this.state.nationalSignificantNumber){this.formatter.narrowDownMatchingFormats(this.state)}var i;if(this.metadata.hasSelectedNumberingPlan()){i=this.formatter.format(o,this.state)}if(i===undefined){
|
|
2631
2630
|
// See if another national (significant) number could be re-extracted.
|
|
2632
2631
|
if(this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();
|
|
2633
2632
|
// If it could, then re-try formatting the new national (significant) number.
|
|
@@ -2637,7 +2636,7 @@ var d=this.state.getNationalDigits();if(d){i=this.formatter.format(d,this.state)
|
|
|
2637
2636
|
// Since that property (along with the others) have been moved to
|
|
2638
2637
|
// `this.state`, `this.country` property is emulated for compatibility
|
|
2639
2638
|
// with the old versions.
|
|
2640
|
-
t.country=r},onCallingCodeChange:function e(r,
|
|
2639
|
+
t.country=r},onCallingCodeChange:function e(r,o){t.metadata.selectNumberingPlan(o||r);t.formatter.reset(t.metadata.numberingPlan,t.state);t.parser.reset(t.metadata.numberingPlan)}});this.formatter=new AsYouTypeFormatter({state:this.state,metadata:this.metadata});this.parser=new AsYouTypeParser({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function e(){t.determineTheCountryIfNeeded();t.formatter.reset(t.metadata.numberingPlan,t.state)}});this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode});this.formattedOutput="";return this}
|
|
2641
2640
|
/**
|
|
2642
2641
|
* Returns `true` if the phone number is being input in international format.
|
|
2643
2642
|
* In other words, returns `true` if and only if the parsed phone number starts with a `"+"`.
|
|
@@ -2687,7 +2686,7 @@ if(t){return this._getCountry()}}
|
|
|
2687
2686
|
// `this.country` should be re-derived with each new digit.
|
|
2688
2687
|
if(!this.state.country||this.isCountryCallingCodeAmbiguous()){this.determineTheCountry()}}
|
|
2689
2688
|
// Prepends `+CountryCode ` in case of an international phone number
|
|
2690
|
-
},{key:"getFullNumber",value:function e(t){var r=this;if(this.isInternational()){var
|
|
2689
|
+
},{key:"getFullNumber",value:function e(t){var r=this;if(this.isInternational()){var o=function e(t){return r.formatter.getInternationalPrefixBeforeCountryCallingCode(r.state,{spacing:t?true:false})+t};var n=this.state.callingCode;if(!n){return o("".concat(this.state.getDigitsWithoutInternationalPrefix()))}if(!t){return o(n)}return o("".concat(n," ").concat(t))}return t}},{key:"getNonFormattedNationalNumberWithPrefix",value:function e(){var t=this.state,r=t.nationalSignificantNumber,o=t.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,n=t.nationalPrefix;var i=r;var d=o||n;if(d){i=d+i}return i}},{key:"getNonFormattedNumber",value:function e(){var t=this.state.nationalSignificantNumberIsModified;return this.getFullNumber(t?this.state.getNationalDigits():this.getNonFormattedNationalNumberWithPrefix())}},{key:"getNonFormattedTemplate",value:function e(){var t=this.getNonFormattedNumber();if(t){return t.replace(/[\+\d]/g,DIGIT_PLACEHOLDER)}}},{key:"isCountryCallingCodeAmbiguous",value:function e(){var t=this.state.callingCode;var r=this.metadata.getCountryCodesForCallingCode(t);return r&&r.length>1}
|
|
2691
2690
|
// Determines the exact country of the phone number
|
|
2692
2691
|
// entered so far based on the country phone code
|
|
2693
2692
|
// and the national phone number.
|
|
@@ -2730,15 +2729,15 @@ this.metadata.selectNumberingPlan(t)}}}
|
|
|
2730
2729
|
* default country or default "country calling code" have been set.
|
|
2731
2730
|
*
|
|
2732
2731
|
* @return {string} [value]
|
|
2733
|
-
*/},{key:"getNumberValue",value:function e(){var t=this.state,r=t.digits,
|
|
2732
|
+
*/},{key:"getNumberValue",value:function e(){var t=this.state,r=t.digits,o=t.callingCode,n=t.country,i=t.nationalSignificantNumber;
|
|
2734
2733
|
// Will return `undefined` if no digits have been input.
|
|
2735
|
-
if(!r){return}if(this.isInternational()){if(
|
|
2734
|
+
if(!r){return}if(this.isInternational()){if(o){return"+"+o+i}else{return"+"+r}}else{if(n||o){var d=n?this.metadata.countryCallingCode():o;return"+"+d+i}}}
|
|
2736
2735
|
/**
|
|
2737
2736
|
* Returns an instance of `PhoneNumber` class.
|
|
2738
2737
|
* Will return `undefined` if no national (significant) number
|
|
2739
2738
|
* digits have been entered so far, or if no `defaultCountry` has been
|
|
2740
2739
|
* set and the user enters a phone number not in international format.
|
|
2741
|
-
*/},{key:"getNumber",value:function e(){var t=this.state,r=t.nationalSignificantNumber,
|
|
2740
|
+
*/},{key:"getNumber",value:function e(){var t=this.state,r=t.nationalSignificantNumber,o=t.carrierCode,n=t.callingCode;if(!r){return}
|
|
2742
2741
|
// `this._getCountry()` is basically same as `this.state.country`
|
|
2743
2742
|
// with the only change that it returns `undefined` in case of a
|
|
2744
2743
|
// "non-geographic" numbering plan instead of `"001"` "internal use" value.
|
|
@@ -2747,7 +2746,7 @@ var i=this._getCountry();
|
|
|
2747
2746
|
// `state.callingCode` and `state.country` are somewhat independent from one another
|
|
2748
2747
|
// and there could be situations when one is defined but the other is not.
|
|
2749
2748
|
// See the comment in `AsYouTypeState.js` for more info on when that is possible.
|
|
2750
|
-
if(!i&&!
|
|
2749
|
+
if(!i&&!n){return}
|
|
2751
2750
|
// By default, if `defaultCountry` parameter was passed when
|
|
2752
2751
|
// creating `AsYouType` instance, `state.country` is gonna be
|
|
2753
2752
|
// that `defaultCountry`, which doesn't entirely conform with
|
|
@@ -2778,7 +2777,7 @@ if(i){if(i===this.defaultCountry){
|
|
|
2778
2777
|
// it could simply read it from the existing metadata instance.
|
|
2779
2778
|
var d=this.metadata.numberingPlan.callingCode();
|
|
2780
2779
|
// Attempt to rule out any potential country code ambiguity, if present.
|
|
2781
|
-
var s=getExactCountryForMultiCountryCallingCode(d,r,this.metadata);if(s){i=s}}}var a=new PhoneNumber(i||
|
|
2780
|
+
var s=getExactCountryForMultiCountryCallingCode(d,r,this.metadata);if(s){i=s}}}var a=new PhoneNumber(i||n,r,this.metadata.metadata);if(o){a.carrierCode=o}
|
|
2782
2781
|
// Phone number extensions are not supported by "As You Type" formatter.
|
|
2783
2782
|
return a}
|
|
2784
2783
|
/**
|
|
@@ -2796,13 +2795,13 @@ return a}
|
|
|
2796
2795
|
* If it is, nothing is returned.
|
|
2797
2796
|
* Otherwise, a rejection reason is returned.
|
|
2798
2797
|
* @return {string?}
|
|
2799
|
-
*/},{key:"validateLength",value:function e(){var t=this.state,r=t.digits,
|
|
2798
|
+
*/},{key:"validateLength",value:function e(){var t=this.state,r=t.digits,o=t.nationalSignificantNumber;if(!r){return"NOT_A_NUMBER"}if(!this.metadata.numberingPlan){return"INVALID_COUNTRY"}if(!o){return"TOO_SHORT"}
|
|
2800
2799
|
// `state.callingCode` and `state.country` are somewhat independent from one another
|
|
2801
2800
|
// and there could be situations when one is defined but the other is not.
|
|
2802
2801
|
// See the comment in `AsYouTypeState.js` for more info on when that is possible.
|
|
2803
2802
|
// Here, it uses both: if `country` is defined then it will use that,
|
|
2804
2803
|
// otherwise it will use `callingCode`.
|
|
2805
|
-
var
|
|
2804
|
+
var n=checkNumberLength(o,undefined,this.metadata);if(n!=="IS_POSSIBLE"){return n}}
|
|
2806
2805
|
/**
|
|
2807
2806
|
* @deprecated
|
|
2808
2807
|
* This method is used in `react-phone-number-input/source/input-control.js`
|
|
@@ -2816,7 +2815,7 @@ var o=checkNumberLength(n,undefined,this.metadata);if(o!=="IS_POSSIBLE"){return
|
|
|
2816
2815
|
* Returns the template for the formatted phone number.
|
|
2817
2816
|
* @return {string}
|
|
2818
2817
|
*/},{key:"getTemplate",value:function e(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||""}}])}();// In situations when multiple countries use the same calling code,
|
|
2819
|
-
function getExactCountryForMultiCountryCallingCode(e,t,r){var
|
|
2818
|
+
function getExactCountryForMultiCountryCallingCode(e,t,r){var o=r.getCountryCodesForCallingCode(e);if(o.length>1){return getCountryByNationalNumber(t,o,r.metadata)}}function parsePhoneNumber(){return withMetadataArgument(parsePhoneNumber$1,arguments)}
|
|
2820
2819
|
// Importing from a ".js" file is a workaround for Node.js "ES Modules"
|
|
2821
2820
|
// importing system which is even uncapable of importing "*.json" files.
|
|
2822
2821
|
function AsYouType(e){return AsYouType$1.call(this,e,metadata)}AsYouType.prototype=Object.create(AsYouType$1.prototype,{});AsYouType.prototype.constructor=AsYouType;
|
|
@@ -2827,14 +2826,14 @@ function normalizeArguments(e){
|
|
|
2827
2826
|
// That's because `babel`/`istanbul`, for some weird reason,
|
|
2828
2827
|
// apparently doesn't know how to properly exclude Babel polyfills from code coverage.
|
|
2829
2828
|
// const [arg_1, arg_2, arg_3, arg_4] = Array.prototype.slice.call(args)
|
|
2830
|
-
var t=e[0];var r=e[1];var
|
|
2829
|
+
var t=e[0];var r=e[1];var o=e[2];var n=e[3];var i;var d={};var s;
|
|
2831
2830
|
// If the phone number is passed as a string.
|
|
2832
2831
|
// `getNumberType('88005553535', ...)`.
|
|
2833
2832
|
if(typeof t==="string"){
|
|
2834
2833
|
// If "default country" argument is being passed
|
|
2835
2834
|
// then convert it to an `options` object.
|
|
2836
2835
|
// `getNumberType('88005553535', 'RU', metadata)`.
|
|
2837
|
-
if(!isObject(r)){if(
|
|
2836
|
+
if(!isObject(r)){if(n){d=o;s=n}else{s=o}
|
|
2838
2837
|
// `parse` extracts phone numbers from raw text,
|
|
2839
2838
|
// therefore it will cut off all "garbage" characters,
|
|
2840
2839
|
// while this `validate` function needs to verify
|
|
@@ -2844,7 +2843,7 @@ if(isViablePhoneNumber(t)){i=parse(t,{defaultCountry:r},s)}else{i={}}}
|
|
|
2844
2843
|
// No "resrict country" argument is being passed.
|
|
2845
2844
|
// International phone number is passed.
|
|
2846
2845
|
// `getNumberType('+78005553535', metadata)`.
|
|
2847
|
-
else{if(
|
|
2846
|
+
else{if(o){d=r;s=o}else{s=r}
|
|
2848
2847
|
// `parse` extracts phone numbers from raw text,
|
|
2849
2848
|
// therefore it will cut off all "garbage" characters,
|
|
2850
2849
|
// while this `validate` function needs to verify
|
|
@@ -2853,7 +2852,7 @@ else{if(n){d=r;s=n}else{s=r}
|
|
|
2853
2852
|
if(isViablePhoneNumber(t)){i=parse(t,undefined,s)}else{i={}}}}
|
|
2854
2853
|
// If the phone number is passed as a parsed phone number.
|
|
2855
2854
|
// `getNumberType({ phone: '88005553535', country: 'RU' }, ...)`.
|
|
2856
|
-
else if(isObject(t)){i=t;if(
|
|
2855
|
+
else if(isObject(t)){i=t;if(o){d=r;s=o}else{s=r}}else throw new TypeError("A phone number must either be a string or an object of shape { phone, [country] }.");return{input:i,options:d,metadata:s}}
|
|
2857
2856
|
/**
|
|
2858
2857
|
* Checks if a given phone number is possible.
|
|
2859
2858
|
* Which means it only checks phone number length
|
|
@@ -2867,9 +2866,9 @@ else if(isObject(t)){i=t;if(n){d=r;s=n}else{s=r}}else throw new TypeError("A pho
|
|
|
2867
2866
|
* isPossibleNumber('88005553535', 'RU', metadata)
|
|
2868
2867
|
* isPossibleNumber({ phone: '8005553535', country: 'RU' }, metadata)
|
|
2869
2868
|
* ```
|
|
2870
|
-
*/function isPossibleNumber$1(){var e=normalizeArguments(arguments),t=e.input,r=e.options,
|
|
2869
|
+
*/function isPossibleNumber$1(){var e=normalizeArguments(arguments),t=e.input,r=e.options,o=e.metadata;
|
|
2871
2870
|
// `parseNumber()` would return `{}` when no phone number could be parsed from the input.
|
|
2872
|
-
if(!t.phone&&!(r&&r.v2)){return false}return isPossiblePhoneNumber(t,r,
|
|
2871
|
+
if(!t.phone&&!(r&&r.v2)){return false}return isPossiblePhoneNumber(t,r,o)}
|
|
2873
2872
|
// Deprecated.
|
|
2874
2873
|
function isPossibleNumber(){return withMetadataArgument(isPossibleNumber$1,arguments)}var ChevronDownIcon$1='<svg color="var(--zonos-elements-gray-400)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M6.293 9.293a1 1 0 0 1 1.414 0L12 13.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-4.93 4.93a1.1 1.1 0 0 1-1.555 0l-4.93-4.93a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var zonosStripePhoneInputCss=function(){return'.sc-zonos-stripe-phone-input-h{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}.sc-zonos-stripe-phone-input-h *.sc-zonos-stripe-phone-input{font-family:var(--zonos--font-family, Inter), Inter}.sc-zonos-stripe-phone-input-h img.sc-zonos-stripe-phone-input{max-width:100%}.sc-zonos-stripe-phone-input-h dl.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h dd.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h1.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h2.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h3.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h4.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h5.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h h6.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h hr.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h figure.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h p.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h pre.sc-zonos-stripe-phone-input{margin:0}.sc-zonos-stripe-phone-input-h{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.sc-zonos-stripe-phone-input-h{--zonos--background-color:#f1f1f1;--zonos--local-glowing-color:0 0 0 3px hsla(0, 0%, 100%, 25%), 0 0 0 1px var(--zonos--primary-color);--zonos--border:1px solid #e8e8e8;margin:1px;position:relative;display:block}.dark.sc-zonos-stripe-phone-input-h,[data-theme=DARK].sc-zonos-stripe-phone-input-h{color-scheme:dark;--zonos--background-color:#30313d;--zonos--local-glowing-color:0px 2px 4px rgba(0, 0, 0, 0.5), 0px 1px 6px rgba(0, 0, 0, 0.25), 0 0 0 3px hsla(0, 0%, 100%, 25%), 0 1px 1px 0 rgba(255, 255, 255, 0.12);--zonos--border:1px solid var(--zonos--primary-color)}.sc-zonos-stripe-phone-input-h{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:4px;position:relative;width:100%}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.sc-zonos-stripe-phone-input{position:relative;width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;height:calc(var(--zonos-elements-size-xl) - 2px);background:var(--zonos--background-color);border-radius:var(--zonos--border-radius);border:var(--zonos--border);outline-offset:0;outline-width:2px;overflow:visible}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.sc-zonos-stripe-phone-input .zonos--select.sc-zonos-stripe-phone-input{position:absolute;opacity:0;inset:0;width:100%;cursor:pointer}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.sc-zonos-stripe-phone-input .zonos--input-group.sc-zonos-stripe-phone-input{display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch;width:100%;height:100%;pointer-events:none}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.focused.sc-zonos-stripe-phone-input::after{content:"";position:absolute;left:0;right:0;top:0;bottom:0;border-radius:var(--zonos--border-radius);-webkit-box-shadow:var(--zonos--glowing-color, var(--zonos--local-glowing-color));box-shadow:var(--zonos--glowing-color, var(--zonos--local-glowing-color));pointer-events:none}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.has-error.sc-zonos-stripe-phone-input::after{content:"";position:absolute;left:0;right:0;top:0;bottom:0;border-radius:var(--zonos--border-radius);-webkit-box-shadow:0 0 0 2px #df1b41;box-shadow:0 0 0 2px #df1b41;pointer-events:none}.sc-zonos-stripe-phone-input-h .zonos--label-wrapper.disabled.sc-zonos-stripe-phone-input{opacity:var(--zonos-elements-opacity-disabled);cursor:not-allowed;pointer-events:none}.sc-zonos-stripe-phone-input-h .zonos--select-wrapper.sc-zonos-stripe-phone-input{-ms-flex:0 0 auto;flex:0 0 auto;width:auto;position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer}.sc-zonos-stripe-phone-input-h .zonos--select-wrapper.sc-zonos-stripe-phone-input:hover{background-color:rgba(0, 0, 0, 0.02)}.sc-zonos-stripe-phone-input-h .zonos--input-container.sc-zonos-stripe-phone-input{-ms-flex:1;flex:1;position:relative;z-index:2;pointer-events:all}.sc-zonos-stripe-phone-input-h .zonos--input-container.has-label.sc-zonos-stripe-phone-input .zonos--floated-input.sc-zonos-stripe-phone-input{padding:24px 12px 2px}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input{background:transparent;border:none;width:100%;height:100%;padding:0 12px;font-size:var(--zonos--font-size);color:var(--zonos-elements-text-color);outline:none;-webkit-box-sizing:border-box;box-sizing:border-box}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:disabled{cursor:not-allowed}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input::-webkit-input-placeholder{opacity:0;-webkit-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input::-moz-placeholder{opacity:0;-moz-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:-ms-input-placeholder{opacity:0;-ms-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input::-ms-input-placeholder{opacity:0;-ms-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input::placeholder{opacity:0;-webkit-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:focus::-webkit-input-placeholder{opacity:var(--zonos-elements-opacity-disabled)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:focus::-moz-placeholder{opacity:var(--zonos-elements-opacity-disabled)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:focus:-ms-input-placeholder{opacity:var(--zonos-elements-opacity-disabled)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:focus::-ms-input-placeholder{opacity:var(--zonos-elements-opacity-disabled)}.sc-zonos-stripe-phone-input-h .zonos--floated-input.sc-zonos-stripe-phone-input:focus::placeholder{opacity:var(--zonos-elements-opacity-disabled)}.sc-zonos-stripe-phone-input-h .zonos--floated-label.sc-zonos-stripe-phone-input{display:block;max-height:0;pointer-events:none}.sc-zonos-stripe-phone-input-h .zonos--floated-label.sc-zonos-stripe-phone-input label.sc-zonos-stripe-phone-input{color:var(--zonos-elements-gray-800);position:absolute;font-size:16px;line-height:16px;display:inline-block;-webkit-filter:blur(0);filter:blur(0);-webkit-transform-origin:left top;transform-origin:left top;-webkit-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition);left:12px;top:calc(50% - 8px);z-index:1}.sc-zonos-stripe-phone-input-h .has-content.sc-zonos-stripe-phone-input .zonos--input-container.sc-zonos-stripe-phone-input .zonos--floated-label.sc-zonos-stripe-phone-input label.sc-zonos-stripe-phone-input,.sc-zonos-stripe-phone-input-h .focused.sc-zonos-stripe-phone-input .zonos--input-container.sc-zonos-stripe-phone-input .zonos--floated-label.sc-zonos-stripe-phone-input label.sc-zonos-stripe-phone-input{top:11px;-webkit-transform:scale(0.8);transform:scale(0.8)}.zonos--country-select.sc-zonos-stripe-phone-input{position:relative;height:100%}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--country-select-content.sc-zonos-stripe-phone-input{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding-left:12px;height:100%;z-index:1}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--country-select-selected.sc-zonos-stripe-phone-input{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:8px}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--select-chevron-wrapper.sc-zonos-stripe-phone-input{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding-left:4px}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--select-chevron-wrapper.sc-zonos-stripe-phone-input .zonos--select-chevron.sc-zonos-stripe-phone-input{pointer-events:none;color:var(--zonos-elements-gray-800);padding-left:4px}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--country-flag-wrapper.sc-zonos-stripe-phone-input{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--country-flag.sc-zonos-stripe-phone-input{border-radius:var(--zonos-elements-radius-4);width:20px;height:16px;position:relative;overflow:hidden;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium)}.zonos--country-select.sc-zonos-stripe-phone-input .zonos--country-code.sc-zonos-stripe-phone-input{font-size:var(--zonos--font-size);color:var(--zonos-elements-text-color)}'};var inputId=0;var ZonosStripePhoneInput=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.inputValueChange=createEvent(this,"inputValueChange",7);this.inputId="zonos--phone-input-".concat(++inputId);
|
|
2875
2874
|
/**
|
|
@@ -2886,23 +2885,23 @@ function isPossibleNumber(){return withMetadataArgument(isPossibleNumber$1,argum
|
|
|
2886
2885
|
*/this.disabled=false;
|
|
2887
2886
|
/**
|
|
2888
2887
|
* The country code of the phone input
|
|
2889
|
-
*/this.countryCode=null;this.phoneNumber="";this.isFocused=false;this.isSelectOpen=false;this.handleCountryChange=function(e){var r;var
|
|
2888
|
+
*/this.countryCode=null;this.phoneNumber="";this.isFocused=false;this.isSelectOpen=false;this.handleCountryChange=function(e){var r;var o=e.target;var n=(r=t.countryOptions)===null||r===void 0?void 0:r[o.value];t.selectedCountry=n;
|
|
2890
2889
|
// Update the phone formatter to use the new country code
|
|
2891
|
-
t.updatePhoneFormatter();var i=t.validatePhoneNumber(),d=i.isEmpty,s=i.valid,a=i.wrongFormat;t.inputValueChange.emit({countryCode:(
|
|
2890
|
+
t.updatePhoneFormatter();var i=t.validatePhoneNumber(),d=i.isEmpty,s=i.valid,a=i.wrongFormat;t.inputValueChange.emit({countryCode:(n===null||n===void 0?void 0:n.countryCode)||null,isEmpty:d,phoneNumber:t.phoneNumber,valid:s,wrongFormat:a})};this.handlePhoneChange=function(e){var r,o;var n=e.target;var i=n.value.replace(/[^0-9]/g,"");if(t.asYouType){t.asYouType.reset();var d=t.asYouType.input(i);
|
|
2892
2891
|
// Get the full number (including the country code) from the formatter (e.g. +17022920000)
|
|
2893
|
-
t.phoneNumber=((r=t.asYouType.getNumber())===null||r===void 0?void 0:r.number)||"";
|
|
2892
|
+
t.phoneNumber=((r=t.asYouType.getNumber())===null||r===void 0?void 0:r.number)||"";n.value=d}else{t.phoneNumber=i}var s=t.validatePhoneNumber(),a=s.isEmpty,u=s.valid,l=s.wrongFormat;t.inputValueChange.emit({countryCode:((o=t.selectedCountry)===null||o===void 0?void 0:o.countryCode)||null,isEmpty:a,phoneNumber:t.phoneNumber,valid:u,wrongFormat:l})};this.handleFocus=function(){t.isFocused=true};this.handleBlur=function(){t.isFocused=false};
|
|
2894
2893
|
// Type guard to check if the country code is in the country options
|
|
2895
2894
|
this.isCountryCode=function(e){var r;return((r=t.countryOptions)===null||r===void 0?void 0:r[e])!==undefined};this.initPhoneNumberValue=function(){var e;if(!t.countryOptions){return}
|
|
2896
2895
|
// Guess the country code from the phone number
|
|
2897
2896
|
var r=(e=parsePhoneNumber(t.inputValue||"",{defaultCountry:t.countryCode}))===null||e===void 0?void 0:e.country;
|
|
2898
2897
|
// If the guessed country code is not in the country options, use the provided country code
|
|
2899
|
-
var
|
|
2898
|
+
var o=r&&t.isCountryCode(r)?r:t.countryCode;
|
|
2900
2899
|
// Get the first available country from the options
|
|
2901
|
-
var
|
|
2900
|
+
var n=Object.values(t.countryOptions).find(Boolean);
|
|
2902
2901
|
// If no country code is provided, set the first available country
|
|
2903
|
-
if(!
|
|
2902
|
+
if(!o){t.selectedCountry=n;var i=t.validatePhoneNumber(),d=i.isEmpty,s=i.valid,a=i.wrongFormat;
|
|
2904
2903
|
// Emit the change event so the parent component can update the state to the first country
|
|
2905
|
-
t.inputValueChange.emit({countryCode:(
|
|
2904
|
+
t.inputValueChange.emit({countryCode:(n===null||n===void 0?void 0:n.countryCode)||null,isEmpty:d,phoneNumber:t.phoneNumber,valid:s,wrongFormat:a});return}t.selectedCountry=t.countryOptions[o]||n;t.phoneNumber=t.inputValue||"";
|
|
2906
2905
|
// Update the phone formatter to use the new country code
|
|
2907
2906
|
t.updatePhoneFormatter()}}e.prototype.onCountryCodeChange=function(){
|
|
2908
2907
|
/**
|
|
@@ -2918,11 +2917,11 @@ this.initPhoneNumberValue()};e.prototype.onSelectedCountryChange=function(){this
|
|
|
2918
2917
|
var t=((e=this.asYouType.getNumber())===null||e===void 0?void 0:e.number)||"";var r=isPossibleNumber(t);return{isEmpty:false,valid:r,wrongFormat:!r}};
|
|
2919
2918
|
/**
|
|
2920
2919
|
* Update the phone formatter to use the new country code
|
|
2921
|
-
*/e.prototype.updatePhoneFormatter=function(){var e,t,r,
|
|
2920
|
+
*/e.prototype.updatePhoneFormatter=function(){var e,t,r,o;var n=Object.values(this.countryOptions||[]).find(Boolean);var i=((e=this.selectedCountry)===null||e===void 0?void 0:e.countryCode)||(n===null||n===void 0?void 0:n.countryCode)||"US";this.asYouType=new AsYouType(i);if(this.phoneNumber){
|
|
2922
2921
|
// Re-format existing number with new formatter
|
|
2923
2922
|
this.asYouType.input(this.phoneNumber);if(this.inputRef){this.inputRef.value=((t=this.asYouType.getNumber())===null||t===void 0?void 0:t.formatNational())||"";var d=this.validatePhoneNumber(),s=d.isEmpty,a=d.valid,u=d.wrongFormat;
|
|
2924
2923
|
// emit the change event
|
|
2925
|
-
this.inputValueChange.emit({countryCode:((r=this.selectedCountry)===null||r===void 0?void 0:r.countryCode)||null,isEmpty:s,phoneNumber:((
|
|
2924
|
+
this.inputValueChange.emit({countryCode:((r=this.selectedCountry)===null||r===void 0?void 0:r.countryCode)||null,isEmpty:s,phoneNumber:((o=this.asYouType.getNumber())===null||o===void 0?void 0:o.number)||"",valid:a,wrongFormat:u})}}};e.prototype.componentWillLoad=function(){this.inheritedAttributes=Object.assign(Object.assign({},inheritAriaAttributes(this.el)),inheritAttributes(this.el,["tabindex","title","data-form-type","dir"]));this.initPhoneNumberValue()};e.prototype.componentDidLoad=function(){this.initPhoneNumberValue()};e.prototype.render=function(){var e=this;var t;var r=this.overridePrimaryColor||zonosStore.appearance.colorPrimary;var o=this.overrideSecondaryColor||zonosStore.appearance.colorSecondary;var n=r&&isDarkColor(r);var i=zonosStore.appearance.fontSizeInputValue||16;var d=!!this.phoneNumber;var s=this.countryOptions?Object.values(this.countryOptions).filter(Boolean).sort((function(e,t){return e.displayName.localeCompare(t.displayName)})):[];return h(Host,{key:"e2a1fc4c2e5f57dc1ae904b70b5f7f421297ae0c",class:classes(["zonos--phone-input zonos--elements",n&&"dark"]),"data-theme":n?"DARK":"LIGHT",style:Object.assign({"--zonos--border-radius":getBorderRadius(),"--zonos--font-family":zonosStoreFontFamily(),"--zonos--font-size":"".concat(i,"px"),"--zonos--primary-color":o},this.minWidth?{"--zonos--min-width":this.minWidth}:{})},h("div",{key:"61a2ee1f566234692a80fe68fbc4d171f36263dc",class:classes(["zonos--label-wrapper",this.disabled&&"disabled",this.isFocused&&"focused",d&&"has-content",this.error&&"has-error",this.inputLabel&&"has-label"])},h("select",{key:"32602cf340a06a26c483f049595cdd812826275e",class:"zonos--select",disabled:this.disabled,onBlur:this.handleBlur,onChange:this.handleCountryChange,onFocus:this.handleFocus},s.map((function(t){var r;return h("option",{key:t.countryCode,selected:t.countryCode===((r=e.selectedCountry)===null||r===void 0?void 0:r.countryCode),value:t.countryCode},t.displayName," (+",t.phoneCode,")")}))),h("div",{key:"1a36aa363a853c420303241e75d89e5aa298dee9",class:"zonos--input-group"},h("div",{key:"7f4d30619c8f69b98422bfcab964113d598d45fa",class:"zonos--select-wrapper"},h("div",{key:"44d0f28dde38fc09ce612ad4cb78f9d1fbdbe951",class:"zonos--country-select"},h("div",{key:"c438e242374e303688150aec2c8eae51b6e1427d",class:"zonos--country-select-content"},this.selectedCountry&&h("div",{key:"2aaec2a6315d2ee84244c4458efce6d27c8598ad",class:"zonos--country-select-selected"},h("div",{key:"819a8b6fd270e43992c19a4b96a4ce5335ae166f",class:"zonos--country-flag-wrapper"},h("zonos-country-flag",{key:"090e6ce55541db022a55497b1b3a6fa7ff2b5406",class:"zonos--country-flag",countryCode:this.selectedCountry.countryCode})),h("div",{key:"021bc4bf590fb6dca736478cc8f9914ce764c1ab",class:"zonos--country-code"},"+",this.selectedCountry.phoneCode)),h("div",{key:"f7256f51c803d1b5aedb3b5d646a777cb553aa9d",class:"zonos--select-chevron-wrapper"},h("zonos-icon",{key:"a018c3fffc1c029df874d9be3c938307b4609d82","aria-label":"Expand collapsed section",class:"zonos--select-chevron",content:ChevronDownIcon$1,iconColor:"gray-800"}))))),h("div",{key:"dd20516acf7d5cab10fe91ff4a6f59cc91600732",class:classes(["zonos--input-container",this.inputLabel&&"has-label",d&&"has-content"])},h("input",Object.assign({key:"ed8b536ba7aac9bae8012692ceb9f8573640c5d6"},this.inheritedAttributes,{autoComplete:this.autoComplete,class:"zonos--floated-input",disabled:this.disabled,id:this.inputId,onBlur:this.handleBlur,onFocus:this.handleFocus,onInput:this.handlePhoneChange,placeholder:((t=this.selectedCountry)===null||t===void 0?void 0:t.phonePlaceholder)||"",ref:function(t){return e.inputRef=t},type:"tel"})),this.inputLabel&&h("div",{key:"be2ae82b335dd291d53f48a73f9b23744392daf6",class:"zonos--floated-label"},h("label",{key:"1894a34c3a5ea09b2b45e8dfc9103d944ac69118",htmlFor:this.inputId},this.inputLabel||translate("Phone number")))))),this.error&&h("zonos-text",{key:"ae0ab1f97abbecf8dda4eced5aa139d8c51decaf",textColor:"red-600"},this.error))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{countryCode:[{onCountryCodeChange:0}],countryOptions:[{onCountryOptionsChange:0}],selectedCountry:[{onSelectedCountryChange:0}],inputValue:[{onPhoneNumberChange:0}]}},enumerable:false,configurable:true});return e}();ZonosStripePhoneInput.style=zonosStripePhoneInputCss();var ChevronDownIcon='<svg color="var(--zonos-elements-gray-400)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M6.293 9.293a1 1 0 0 1 1.414 0L12 13.586l4.293-4.293a1 1 0 0 1 1.414 1.414l-4.93 4.93a1.1 1.1 0 0 1-1.555 0l-4.93-4.93a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>';var RemoveLineIcon='<svg color="var(--zonos-elements-gray-1000)" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="var(--zonos-elements-gray-1000)" d="M14.475 10.586a.75.75 0 1 0-1.06-1.06L12 10.938l-1.414-1.414a.75.75 0 0 0-1.06 1.06L10.938 12l-1.414 1.414a.75.75 0 1 0 1.06 1.06L12 13.062l1.414 1.414a.75.75 0 0 0 1.06-1.06L13.062 12l1.414-1.414Z"/><path fill="var(--zonos-elements-gray-1000)" fill-rule="evenodd" d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-6.5 8a6.5 6.5 0 1 1 13 0 6.5 6.5 0 0 1-13 0Z" clip-rule="evenodd"/></svg>';var zonosStripeSelectCss=function(){return':host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{--zonos--background-color:#f1f1f1;--zonos--local-glowing-color:0 0 0 3px hsla(0, 0%, 100%, 25%), 0 0 0 1px var(--zonos--primary-color);--zonos--border:1px solid #e8e8e8}:host(.dark){color-scheme:dark;--zonos--background-color:#30313d;--zonos--local-glowing-color:0px 2px 4px rgba(0, 0, 0, 0.5), 0px 1px 6px rgba(0, 0, 0, 0.25), 0 0 0 3px hsla(0, 0%, 100%, 25%), 0 1px 1px 0 rgba(255, 255, 255, 0.12);--zonos--border:1px solid var(--zonos--primary-color)}:host{margin:1px;position:relative;min-width:var(--zonos--min-width, unset)}:host .zonos--label-wrapper{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;height:calc(var(--zonos-elements-size-xl) - 4px);width:100%;background:var(--zonos--background-color);border-radius:var(--zonos--border-radius);border:var(--zonos--border);outline-offset:0;outline-width:2px}:host .zonos--floated-select{-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;padding:0 36px 0 16px;outline:none;-webkit-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition);width:100%;border-radius:var(--zonos--border-radius);background:var(--zonos--background-color);border:var(--zonos--border);-ms-flex-order:2;order:2;font-weight:400;font-size:var(--zonos--font-size);color:var(--zonos--background-color);-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer}:host .zonos--floated-select.has-label{padding:24px 36px 2px 16px}:host .zonos--floated-select:focus{outline:none;border:var(--zonos--border)}:host .zonos--floated-select:focus~.zonos--floated-label::after{-webkit-box-shadow:var(--zonos--glowing-color, var(--zonos--local-glowing-color));box-shadow:var(--zonos--glowing-color, var(--zonos--local-glowing-color))}:host .zonos--floated-select.has-error+.zonos--floated-label::after{-webkit-box-shadow:0 0 0 2px #df1b41;box-shadow:0 0 0 2px #df1b41}:host .zonos--floated-select.has-content,:host .zonos--floated-select:focus{color:var(--zonos-elements-text-color)}:host .zonos--floated-select.has-content~.zonos--floated-label label,:host .zonos--floated-select:focus~.zonos--floated-label label{top:11px;-webkit-transform:scale(0.8);transform:scale(0.8)}:host .zonos--floated-select:-webkit-autofill,:host .zonos--floated-select:-moz-autofill{background-color:var(--zonos-elements-input-background);color:var(--zonos-elements-text-color)}:host .zonos--floated-select option{background-color:var(--zonos--background-color);color:inherit}:host .zonos--floated-label{display:block;max-height:0;pointer-events:none;-ms-flex-order:1;order:1}:host .zonos--floated-label label{color:var(--zonos-elements-gray-800);position:absolute;font-size:16px;line-height:16px;display:inline-block;-webkit-filter:blur(0);filter:blur(0);-webkit-transform-origin:left top;transform-origin:left top;-webkit-transition:var(--zonos-elements-transition);transition:var(--zonos-elements-transition);margin-left:16px;top:calc(50% - 8px);z-index:1}:host .zonos--floated-label::after{content:"";position:absolute;left:0;right:0;top:0;bottom:0;border-radius:var(--zonos--border-radius)}:host .zonos--actions-wrapper{position:absolute;right:8px;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);z-index:1;pointer-events:none;display:-ms-flexbox;display:flex}:host .zonos--select-chevron{cursor:pointer;color:var(--zonos-elements-gray-800);z-index:1}:host{}:host .disabled .zonos--floated-label{pointer-events:inherit}:host .disabled .zonos--floated-label::after{cursor:not-allowed;z-index:1}:host .disabled .zonos--select-chevron{opacity:0.5}.zonos--clear-button{background:none;border:none;pointer-events:auto;cursor:pointer}.zonos--clear-button:hover{-webkit-filter:brightness(0.8);filter:brightness(0.8)}:host(.dark) .zonos--label-wrapper{background:#30313d}'};var selectId=0;var ZonosStripeSelect=/** @class */function(){function e(e){var t=this;registerInstance(this,e);this.selectChange=createEvent(this,"selectChange",7);
|
|
2926
2925
|
/**
|
|
2927
2926
|
* Inherited attributes from the host element
|
|
2928
2927
|
*/this.inheritedAttributes={};this.selectId="zonos--select-".concat(++selectId);
|
|
@@ -2961,6 +2960,6 @@ this.handleNotFoundOption(e)};e.prototype.onValueChange=function(e){this.interna
|
|
|
2961
2960
|
// If the value is not found in the options, clear the value to force user to select an option
|
|
2962
2961
|
this.handleNotFoundOption(e)};
|
|
2963
2962
|
// If the value is not found in the options, clear the value to force user to select an option
|
|
2964
|
-
e.prototype.handleNotFoundOption=function(e){var t=this.internalOptions.find((function(t){return t.value===e||t.label===e}));if(!t){this.internalValue="";this.selectChange.emit("")}};e.prototype.componentWillLoad=function(){this.inheritedAttributes=Object.assign(Object.assign({},inheritAriaAttributes(this.el)),inheritAttributes(this.el,["tabindex","title","data-form-type","dir"]))};e.prototype.render=function(){var e=this;var t=this.overridePrimaryColor||zonosStore.appearance.colorPrimary;var r=this.overrideSecondaryColor||zonosStore.appearance.colorSecondary;var
|
|
2963
|
+
e.prototype.handleNotFoundOption=function(e){var t=this.internalOptions.find((function(t){return t.value===e||t.label===e}));if(!t){this.internalValue="";this.selectChange.emit("")}};e.prototype.componentWillLoad=function(){this.inheritedAttributes=Object.assign(Object.assign({},inheritAriaAttributes(this.el)),inheritAttributes(this.el,["tabindex","title","data-form-type","dir"]))};e.prototype.render=function(){var e=this;var t=this.overridePrimaryColor||zonosStore.appearance.colorPrimary;var r=this.overrideSecondaryColor||zonosStore.appearance.colorSecondary;var o=t&&isDarkColor(t);var n=zonosStore.appearance.fontSizeInputValue||16;var i=this.internalValue||this.selectPlaceholder;var d=this.isClearable&&this.internalValue&&!this.isDisabled;return h(Host,{key:"c6bf5ed45fd7756985bd97b542933d25a472aa2c",class:classes(["zonos--select zonos--elements",o&&"dark",this.isError&&"has-error"]),"data-theme":o?"DARK":"LIGHT",style:Object.assign({"--zonos--border-radius":getBorderRadius(),"--zonos--font-family":zonosStoreFontFamily(),"--zonos--font-size":"".concat(n,"px"),"--zonos--primary-color":r},this.minWidth?{"--zonos--min-width":this.minWidth}:{})},h("div",{key:"7ff61460b6ac3c5b3e6e35000f3713609a26ebe2",class:classes(["zonos--label-wrapper",this.isDisabled&&"disabled"])},h("select",Object.assign({key:"9d644b04d7b46621245581c5143d7310e1d5396d"},this.inheritedAttributes,{autoComplete:this.autoComplete,class:classes(["zonos--floated-select",!!this.selectLabel&&"has-label",i&&"has-content",this.isError&&"has-error"]),disabled:this.isDisabled,id:this.selectId,name:this.name,onChange:function(t){var r=t.target;e.selectChange.emit(r.value);e.selectedValue=r.value;e.el.dispatchEvent(new Event("change"))},required:this.required}),h("option",{key:"b448bc3c2a083334108afad566feff22bf89547a",disabled:true,selected:!this.internalValue,value:""},this.selectPlaceholder||translate("Select")),this.internalOptions.map((function(t){return h("option",{key:t.value,selected:e.internalValue===t.value||
|
|
2965
2964
|
// Sometimes google returns the label not the code for some countries
|
|
2966
2965
|
e.internalValue===t.label,value:t.value},t.label)}))),h("div",{key:"14b3c9dad1202d432ba2a30d03e8335aebaafa89",class:"zonos--floated-label"},h("label",{key:"4e7870ce3eeaf4ea6fd116e3a486537bebb88c87",htmlFor:this.selectId},this.selectLabel)),h("div",{key:"4567ca19c1e018d483105c23ca781e0bbd1d2c3a",class:"zonos--actions-wrapper"},d&&h("button",{key:"cdceea7255fdd19177b82c42878a6c4a20690a1a","aria-label":"Clear selection",class:"zonos--clear-button",onClick:this.handleClear,tabIndex:0,type:"button"},h("zonos-icon",{key:"099b2f1a4fb475bfa76b0f4aeee9e66f27d473f3",class:"zonos--clear-icon",content:RemoveLineIcon,iconColor:"gray-1200"})),h("zonos-icon",{key:"8c7fdaf2de40a14e4fa0f8f3598851edac1c1ae6","aria-label":"Expand collapsed section",class:"zonos--select-chevron",content:ChevronDownIcon,iconColor:"gray-800"}))),this.error&&h("zonos-text",{key:"1cb569a7feeea85874c852a1c69cf88076fd6856",textColor:"red-600"},this.error))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{options:[{onOptionsChange:0}],selectedValue:[{onSelectedValueChange:0}],value:[{onValueChange:0}]}},enumerable:false,configurable:true});return e}();ZonosStripeSelect.style=zonosStripeSelectCss();export{ZonosAddressCompletionDialog as zonos_address_completion_dialog,ZonosAddressForm as zonos_address_form,ZonosAddressSuggestions as zonos_address_suggestions,ZonosAddressUpdateDialog as zonos_address_update_dialog,ZonosAddress as zonos_custom_address,ZonosStripePhoneInput as zonos_stripe_phone_input,ZonosStripeSelect as zonos_stripe_select};
|