pixel-react 1.15.11 → 1.15.12
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/README.md +75 -75
- package/lib/ThirdPartyPackages/JanusGateway.js +5 -2
- package/lib/ThirdPartyPackages/JanusGateway.js.map +1 -1
- package/lib/_virtual/index10.js +2 -2
- package/lib/_virtual/index11.js +2 -2
- package/lib/_virtual/index12.js +2 -2
- package/lib/_virtual/index9.js +2 -2
- package/lib/assets/icons/spinner.svg.js +1 -1
- package/lib/assets/icons/spinner.svg.js.map +1 -1
- package/lib/components/Editor/VariableDropdown.js +2 -2
- package/lib/index.cjs +7209 -4574
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/node_modules/@date-fns/tz/date/index.js +19 -1
- package/lib/node_modules/@date-fns/tz/date/index.js.map +1 -1
- package/lib/node_modules/@date-fns/tz/date/mini.js +6 -34
- package/lib/node_modules/@date-fns/tz/date/mini.js.map +1 -1
- package/lib/node_modules/@date-fns/tz/tzOffset/index.js +5 -6
- package/lib/node_modules/@date-fns/tz/tzOffset/index.js.map +1 -1
- package/lib/node_modules/janus-gateway/npm/dist/janus.es.js +3241 -0
- package/lib/node_modules/janus-gateway/npm/dist/janus.es.js.map +1 -0
- package/lib/node_modules/js-beautify/js/src/css/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/css/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/html/tokenizer.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/beautifier.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/index.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/options.js +1 -1
- package/lib/node_modules/js-beautify/js/src/javascript/tokenizer.js +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouType.js +82 -115
- package/lib/node_modules/libphonenumber-js/es6/AsYouType.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternMatcher.js +58 -68
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternMatcher.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternParser.js +23 -36
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.PatternParser.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.complete.js +9 -13
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.complete.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.js +187 -226
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.util.js +27 -21
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeFormatter.util.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeParser.js +117 -150
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeParser.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeState.js +38 -57
- package/lib/node_modules/libphonenumber-js/es6/AsYouTypeState.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/ParseError.js +109 -70
- package/lib/node_modules/libphonenumber-js/es6/ParseError.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/PhoneNumber.js +57 -72
- package/lib/node_modules/libphonenumber-js/es6/PhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/constants.js +9 -15
- package/lib/node_modules/libphonenumber-js/es6/constants.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/format.js +93 -67
- package/lib/node_modules/libphonenumber-js/es6/format.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/formatIncompletePhoneNumber.js +1 -0
- package/lib/node_modules/libphonenumber-js/es6/formatIncompletePhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/getCountries.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +1 -0
- package/lib/node_modules/libphonenumber-js/es6/helpers/RFC3966.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +10 -49
- package/lib/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +32 -20
- package/lib/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +4 -5
- package/lib/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +18 -25
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +11 -12
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +11 -13
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +11 -21
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +11 -12
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +12 -15
- package/lib/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +4 -4
- package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +35 -59
- package/lib/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +2 -2
- package/lib/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +36 -38
- package/lib/node_modules/libphonenumber-js/es6/helpers/getNumberType.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +1 -0
- package/lib/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/isObject.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +10 -14
- package/lib/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +4 -4
- package/lib/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +27 -22
- package/lib/node_modules/libphonenumber-js/es6/helpers/parseDigits.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +6 -6
- package/lib/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/isPossible.js +7 -6
- package/lib/node_modules/libphonenumber-js/es6/isPossible.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/isValid.js +5 -6
- package/lib/node_modules/libphonenumber-js/es6/isValid.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/isValidPhoneNumber.js +26 -44
- package/lib/node_modules/libphonenumber-js/es6/isValidPhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/metadata.js +69 -120
- package/lib/node_modules/libphonenumber-js/es6/metadata.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/normalizeArguments.js +68 -87
- package/lib/node_modules/libphonenumber-js/es6/normalizeArguments.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/parse.js +40 -58
- package/lib/node_modules/libphonenumber-js/es6/parse.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +36 -32
- package/lib/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/parsePhoneNumber.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +26 -44
- package/lib/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +28 -46
- package/lib/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/es6/tools/semver-compare.js.map +1 -1
- package/lib/node_modules/libphonenumber-js/metadata.min.json.js +18 -18
- package/lib/node_modules/libphonenumber-js/metadata.min.json.js.map +1 -1
- package/lib/node_modules/prop-types/index.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/DayPicker.js +64 -88
- package/lib/node_modules/react-day-picker/dist/esm/DayPicker.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/UI.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/classes/CalendarDay.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/classes/CalendarMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/classes/CalendarWeek.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/classes/DateLib.js +6 -71
- package/lib/node_modules/react-day-picker/dist/esm/classes/DateLib.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Button.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/CaptionLabel.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Chevron.js +14 -18
- package/lib/node_modules/react-day-picker/dist/esm/components/Chevron.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Day.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/DayButton.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Dropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/DropdownNav.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Footer.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Month.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/MonthCaption.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/MonthGrid.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Months.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/MonthsDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Nav.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/NextMonthButton.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Option.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/PreviousMonthButton.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Root.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Select.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Week.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/WeekNumber.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/WeekNumberHeader.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Weekday.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Weekdays.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/Weeks.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/components/YearsDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js +2 -3
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatCaption.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatDay.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatMonthDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumber.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatWeekNumberHeader.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatWeekdayName.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/formatYearDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/formatters/index.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/calculateFocusTarget.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/createGetModifiers.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/endOfBroadcastWeek.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getBroadcastWeeksInMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getClassNamesForModifiers.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getComponents.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDataAttributes.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDates.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDays.js +4 -4
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDays.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDefaultClassNames.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getDisplayMonths.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getFocusableDate.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getFormatters.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getInitialMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getMonthOptions.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getMonths.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getNavMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getNextFocus.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getNextMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getPreviousMonth.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getStyleForModifiers.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getWeekdays.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js +2 -2
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getWeeks.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js +11 -9
- package/lib/node_modules/react-day-picker/dist/esm/helpers/getYearOptions.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/startOfBroadcastWeek.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/helpers/useControlledValue.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/index.js +2 -2
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelDayButton.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelGrid.js +2 -3
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelGrid.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelGridcell.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelMonthDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelNav.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelNext.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelNext.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelPrevious.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelWeekNumber.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelWeekNumberHeader.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelWeekday.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/labels/labelYearDropdown.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/selection/useMulti.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/selection/useRange.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/selection/useSingle.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useAnimation.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useAnimation.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useCalendar.js +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useCalendar.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useDayPicker.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useFocus.js +0 -6
- package/lib/node_modules/react-day-picker/dist/esm/useFocus.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/useSelection.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/addToRange.js +1 -6
- package/lib/node_modules/react-day-picker/dist/esm/utils/addToRange.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/dateMatchModifiers.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/rangeContainsDayOfWeek.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/rangeContainsModifiers.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/rangeIncludesDate.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/rangeOverlaps.js.map +1 -1
- package/lib/node_modules/react-day-picker/dist/esm/utils/typeguards.js.map +1 -1
- package/lib/node_modules/react-hook-form/dist/index.esm.js +44 -67
- package/lib/node_modules/react-hook-form/dist/index.esm.js.map +1 -1
- package/lib/node_modules/react-virtuoso/dist/index.js +1200 -1246
- package/lib/node_modules/react-virtuoso/dist/index.js.map +1 -1
- package/lib/node_modules/ua-parser-js/src/ua-parser.js +71 -85
- package/lib/node_modules/ua-parser-js/src/ua-parser.js.map +1 -1
- package/lib/styles.css +1 -1
- package/lib/styles.css.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +106 -106
- package/lib/node_modules/@date-fns/tz/tzName/index.js +0 -40
- package/lib/node_modules/@date-fns/tz/tzName/index.js.map +0 -1
- package/lib/node_modules/react-day-picker/node_modules/date-fns/eachYearOfInterval.js +0 -64
- package/lib/node_modules/react-day-picker/node_modules/date-fns/eachYearOfInterval.js.map +0 -1
|
@@ -6,102 +6,84 @@ import { FIRST_GROUP_PATTERN } from './helpers/formatNationalNumberUsingFormat.j
|
|
|
6
6
|
import { VALID_PUNCTUATION } from './constants.js';
|
|
7
7
|
import applyInternationalSeparatorStyle from './helpers/applyInternationalSeparatorStyle.js';
|
|
8
8
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
16
|
-
}, _typeof(o);
|
|
17
|
-
}
|
|
18
|
-
function _createForOfIteratorHelperLoose(r, e) {
|
|
19
|
-
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
20
|
-
if (t) return (t = t.call(r)).next.bind(t);
|
|
21
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
22
|
-
t && (r = t);
|
|
23
|
-
var o = 0;
|
|
9
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
10
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
11
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
12
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) {
|
|
13
|
+
if (it) o = it;
|
|
14
|
+
var i = 0;
|
|
24
15
|
return function () {
|
|
25
|
-
|
|
16
|
+
if (i >= o.length) return {
|
|
26
17
|
done: true
|
|
27
|
-
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
28
20
|
done: false,
|
|
29
|
-
value:
|
|
21
|
+
value: o[i++]
|
|
30
22
|
};
|
|
31
23
|
};
|
|
32
24
|
}
|
|
33
25
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
34
26
|
}
|
|
35
|
-
function _unsupportedIterableToArray(
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
28
|
+
if (!o) return;
|
|
29
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
30
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
32
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
33
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
41
34
|
}
|
|
42
|
-
function _arrayLikeToArray(
|
|
43
|
-
(
|
|
44
|
-
for (var
|
|
45
|
-
|
|
35
|
+
function _arrayLikeToArray(arr, len) {
|
|
36
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
37
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
38
|
+
arr2[i] = arr[i];
|
|
39
|
+
}
|
|
40
|
+
return arr2;
|
|
46
41
|
}
|
|
47
|
-
function _classCallCheck(
|
|
48
|
-
if (!(
|
|
42
|
+
function _classCallCheck(instance, Constructor) {
|
|
43
|
+
if (!(instance instanceof Constructor)) {
|
|
44
|
+
throw new TypeError("Cannot call a class as a function");
|
|
45
|
+
}
|
|
49
46
|
}
|
|
50
|
-
function _defineProperties(
|
|
51
|
-
for (var
|
|
52
|
-
var
|
|
53
|
-
|
|
47
|
+
function _defineProperties(target, props) {
|
|
48
|
+
for (var i = 0; i < props.length; i++) {
|
|
49
|
+
var descriptor = props[i];
|
|
50
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
+
descriptor.configurable = true;
|
|
52
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function _createClass(
|
|
57
|
-
|
|
56
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
57
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
58
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
58
59
|
writable: false
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
function _toPropertyKey(t) {
|
|
62
|
-
var i = _toPrimitive(t, "string");
|
|
63
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
60
|
+
});
|
|
61
|
+
return Constructor;
|
|
64
62
|
}
|
|
65
|
-
function _toPrimitive(t, r) {
|
|
66
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
67
|
-
var e = t[Symbol.toPrimitive];
|
|
68
|
-
if (void 0 !== e) {
|
|
69
|
-
var i = e.call(t, r);
|
|
70
|
-
if ("object" != _typeof(i)) return i;
|
|
71
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
72
|
-
}
|
|
73
|
-
return (String )(t);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Used in phone number format template creation.
|
|
77
63
|
// Could be any digit, I guess.
|
|
78
|
-
|
|
79
|
-
// I don't know why is it exactly `15`
|
|
80
|
-
|
|
81
|
-
// Create a phone number consisting only of the digit 9 that matches the
|
|
64
|
+
|
|
65
|
+
var DUMMY_DIGIT = '9'; // I don't know why is it exactly `15`
|
|
66
|
+
|
|
67
|
+
var LONGEST_NATIONAL_PHONE_NUMBER_LENGTH = 15; // Create a phone number consisting only of the digit 9 that matches the
|
|
82
68
|
// `number_pattern` by applying the pattern to the "longest phone number" string.
|
|
83
|
-
var LONGEST_DUMMY_PHONE_NUMBER = repeat(DUMMY_DIGIT, LONGEST_NATIONAL_PHONE_NUMBER_LENGTH);
|
|
84
69
|
|
|
85
|
-
// A set of characters that, if found in a national prefix formatting rules, are an indicator to
|
|
70
|
+
var LONGEST_DUMMY_PHONE_NUMBER = repeat(DUMMY_DIGIT, LONGEST_NATIONAL_PHONE_NUMBER_LENGTH); // A set of characters that, if found in a national prefix formatting rules, are an indicator to
|
|
86
71
|
// us that we should separate the national prefix from the number when formatting.
|
|
87
|
-
var NATIONAL_PREFIX_SEPARATORS_PATTERN = /[- ]/;
|
|
88
72
|
|
|
89
|
-
//
|
|
73
|
+
var NATIONAL_PREFIX_SEPARATORS_PATTERN = /[- ]/; // Deprecated: Google has removed some formatting pattern related code from their repo.
|
|
90
74
|
// An example of a character class is "[1-4]".
|
|
75
|
+
|
|
91
76
|
var CREATE_CHARACTER_CLASS_PATTERN = function () {
|
|
92
77
|
return /\[([^\[\]])*\]/g;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// Any digit in a regular expression that actually denotes a digit. For
|
|
78
|
+
}; // Any digit in a regular expression that actually denotes a digit. For
|
|
96
79
|
// example, in the regular expression "80[0-2]\d{6,10}", the first 2 digits
|
|
97
80
|
// (8 and 0) are standalone digits, but the rest are not.
|
|
98
81
|
// Two look-aheads are needed because the number following \\d could be a
|
|
99
82
|
// two-digit number, since the phone number can be as long as 15 digits.
|
|
83
|
+
|
|
100
84
|
var CREATE_STANDALONE_DIGIT_PATTERN = function () {
|
|
101
85
|
return /\d(?=[^,}][^,}])/g;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// A regular expression that is used to determine if a `format` is
|
|
86
|
+
}; // A regular expression that is used to determine if a `format` is
|
|
105
87
|
// suitable to be used in the "as you type formatter".
|
|
106
88
|
// A `format` is suitable when the resulting formatted number has
|
|
107
89
|
// the same digits as the user has entered.
|
|
@@ -135,15 +117,15 @@ var CREATE_STANDALONE_DIGIT_PATTERN = function () {
|
|
|
135
117
|
// This regular expression is called `ELIGIBLE_FORMAT_PATTERN` in Google's
|
|
136
118
|
// `libphonenumber` code.
|
|
137
119
|
//
|
|
120
|
+
|
|
138
121
|
var NON_ALTERING_FORMAT_REG_EXP = new RegExp('[' + VALID_PUNCTUATION + ']*' +
|
|
139
122
|
// Google developers say:
|
|
140
123
|
// "We require that the first matching group is present in the
|
|
141
124
|
// output pattern to ensure no data is lost while formatting."
|
|
142
|
-
'\\$1' + '[' + VALID_PUNCTUATION + ']*' + '(\\$\\d[' + VALID_PUNCTUATION + ']*)*' + '$');
|
|
143
|
-
|
|
144
|
-
// This is the minimum length of the leading digits of a phone number
|
|
125
|
+
'\\$1' + '[' + VALID_PUNCTUATION + ']*' + '(\\$\\d[' + VALID_PUNCTUATION + ']*)*' + '$'); // This is the minimum length of the leading digits of a phone number
|
|
145
126
|
// to guarantee the first "leading digits pattern" for a phone number format
|
|
146
127
|
// to be preemptive.
|
|
128
|
+
|
|
147
129
|
var MIN_LEADING_DIGITS_LENGTH = 3;
|
|
148
130
|
var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
149
131
|
function AsYouTypeFormatter(_ref) {
|
|
@@ -153,7 +135,7 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
153
135
|
this.metadata = metadata;
|
|
154
136
|
this.resetFormat();
|
|
155
137
|
}
|
|
156
|
-
|
|
138
|
+
_createClass(AsYouTypeFormatter, [{
|
|
157
139
|
key: "resetFormat",
|
|
158
140
|
value: function resetFormat() {
|
|
159
141
|
this.chosenFormat = undefined;
|
|
@@ -177,7 +159,6 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
177
159
|
this.matchingFormats = [];
|
|
178
160
|
}
|
|
179
161
|
}
|
|
180
|
-
|
|
181
162
|
/**
|
|
182
163
|
* Formats an updated phone number.
|
|
183
164
|
* @param {string} nextDigits — Additional phone number digits.
|
|
@@ -188,6 +169,7 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
188
169
|
key: "format",
|
|
189
170
|
value: function format(nextDigits, state) {
|
|
190
171
|
var _this = this;
|
|
172
|
+
|
|
191
173
|
// See if the phone number digits can be formatted as a complete phone number.
|
|
192
174
|
// If not, use the results from `formatNationalNumberWithNextDigits()`,
|
|
193
175
|
// which formats based on the chosen formatting pattern.
|
|
@@ -202,10 +184,10 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
202
184
|
// If so, we should use this instead of any other formatting template
|
|
203
185
|
// whose leadingDigitsPattern also matches the input."
|
|
204
186
|
//
|
|
205
|
-
if (canFormatCompleteNumber(state.nationalSignificantNumber,
|
|
187
|
+
if (canFormatCompleteNumber(state.nationalSignificantNumber, this.metadata)) {
|
|
206
188
|
for (var _iterator = _createForOfIteratorHelperLoose(this.matchingFormats), _step; !(_step = _iterator()).done;) {
|
|
207
|
-
var
|
|
208
|
-
var formattedCompleteNumber = formatCompleteNumber(state,
|
|
189
|
+
var format = _step.value;
|
|
190
|
+
var formattedCompleteNumber = formatCompleteNumber(state, format, {
|
|
209
191
|
metadata: this.metadata,
|
|
210
192
|
shouldTryNationalPrefixFormattingRule: function shouldTryNationalPrefixFormattingRule(format) {
|
|
211
193
|
return _this.shouldTryNationalPrefixFormattingRule(format, {
|
|
@@ -219,28 +201,25 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
219
201
|
});
|
|
220
202
|
if (formattedCompleteNumber) {
|
|
221
203
|
this.resetFormat();
|
|
222
|
-
this.chosenFormat =
|
|
204
|
+
this.chosenFormat = format;
|
|
223
205
|
this.setNationalNumberTemplate(formattedCompleteNumber.replace(/\d/g, DIGIT_PLACEHOLDER), state);
|
|
224
|
-
this.populatedNationalNumberTemplate = formattedCompleteNumber;
|
|
225
|
-
// With a new formatting template, the matched position
|
|
206
|
+
this.populatedNationalNumberTemplate = formattedCompleteNumber; // With a new formatting template, the matched position
|
|
226
207
|
// using the old template needs to be reset.
|
|
208
|
+
|
|
227
209
|
this.populatedNationalNumberTemplatePosition = this.template.lastIndexOf(DIGIT_PLACEHOLDER);
|
|
228
210
|
return formattedCompleteNumber;
|
|
229
211
|
}
|
|
230
212
|
}
|
|
231
|
-
}
|
|
232
|
-
// Format the digits as a partial (incomplete) phone number
|
|
213
|
+
} // Format the digits as a partial (incomplete) phone number
|
|
233
214
|
// using the previously chosen formatting pattern (or a newly chosen one).
|
|
234
|
-
return this.formatNationalNumberWithNextDigits(nextDigits, state);
|
|
235
|
-
}
|
|
236
215
|
|
|
237
|
-
|
|
216
|
+
return this.formatNationalNumberWithNextDigits(nextDigits, state);
|
|
217
|
+
} // Formats the next phone number digits.
|
|
238
218
|
}, {
|
|
239
219
|
key: "formatNationalNumberWithNextDigits",
|
|
240
220
|
value: function formatNationalNumberWithNextDigits(nextDigits, state) {
|
|
241
|
-
var previouslyChosenFormat = this.chosenFormat;
|
|
221
|
+
var previouslyChosenFormat = this.chosenFormat; // Choose a format from the list of matching ones.
|
|
242
222
|
|
|
243
|
-
// Choose a format from the list of matching ones.
|
|
244
223
|
var newlyChosenFormat = this.chooseFormat(state);
|
|
245
224
|
if (newlyChosenFormat) {
|
|
246
225
|
if (newlyChosenFormat === previouslyChosenFormat) {
|
|
@@ -264,35 +243,32 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
264
243
|
var nationalSignificantNumber = _ref2.nationalSignificantNumber,
|
|
265
244
|
nationalPrefix = _ref2.nationalPrefix,
|
|
266
245
|
international = _ref2.international;
|
|
267
|
-
var leadingDigits = nationalSignificantNumber;
|
|
268
|
-
|
|
269
|
-
// "leading digits" pattern list starts with a
|
|
246
|
+
var leadingDigits = nationalSignificantNumber; // "leading digits" pattern list starts with a
|
|
270
247
|
// "leading digits" pattern fitting a maximum of 3 leading digits.
|
|
271
248
|
// So, after a user inputs 3 digits of a national (significant) phone number
|
|
272
249
|
// this national (significant) number can already be formatted.
|
|
273
250
|
// The next "leading digits" pattern is for 4 leading digits max,
|
|
274
251
|
// and the "leading digits" pattern after it is for 5 leading digits max, etc.
|
|
275
|
-
|
|
276
252
|
// This implementation is different from Google's
|
|
277
253
|
// in that it searches for a fitting format
|
|
278
254
|
// even if the user has entered less than
|
|
279
255
|
// `MIN_LEADING_DIGITS_LENGTH` digits of a national number.
|
|
280
256
|
// Because some leading digit patterns already match for a single first digit.
|
|
257
|
+
|
|
281
258
|
var leadingDigitsPatternIndex = leadingDigits.length - MIN_LEADING_DIGITS_LENGTH;
|
|
282
259
|
if (leadingDigitsPatternIndex < 0) {
|
|
283
260
|
leadingDigitsPatternIndex = 0;
|
|
284
261
|
}
|
|
285
262
|
this.matchingFormats = this.matchingFormats.filter(function (format) {
|
|
286
263
|
return _this2.formatSuits(format, international, nationalPrefix) && _this2.formatMatches(format, leadingDigits, leadingDigitsPatternIndex);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// If there was a phone number format chosen
|
|
264
|
+
}); // If there was a phone number format chosen
|
|
290
265
|
// and it no longer holds given the new leading digits then reset it.
|
|
291
266
|
// The test for this `if` condition is marked as:
|
|
292
267
|
// "Reset a chosen format when it no longer holds given the new leading digits".
|
|
293
268
|
// To construct a valid test case for this one can find a country
|
|
294
269
|
// in `PhoneNumberMetadata.xml` yielding one format for 3 `<leadingDigits>`
|
|
295
270
|
// and yielding another format for 4 `<leadingDigits>` (Australia in this case).
|
|
271
|
+
|
|
296
272
|
if (this.chosenFormat && this.matchingFormats.indexOf(this.chosenFormat) === -1) {
|
|
297
273
|
this.resetFormat();
|
|
298
274
|
}
|
|
@@ -314,12 +290,12 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
314
290
|
// !format.domesticCarrierCodeFormattingRule() &&
|
|
315
291
|
!format.nationalPrefixIsOptionalWhenFormattingInNationalFormat()) {
|
|
316
292
|
return false;
|
|
317
|
-
}
|
|
318
|
-
// If national prefix is mandatory for this phone number format
|
|
293
|
+
} // If national prefix is mandatory for this phone number format
|
|
319
294
|
// and there're no guarantees that a national prefix is present in user input
|
|
320
295
|
// then discard this phone number format as not suitable.
|
|
321
296
|
// In Google's "AsYouType" formatter code, the equivalent would be this part:
|
|
322
297
|
// https://github.com/google/libphonenumber/blob/0a45cfd96e71cad8edb0e162a70fcc8bd9728933/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java#L185-L193
|
|
298
|
+
|
|
323
299
|
if (!international && !nationalPrefix && format.nationalPrefixIsMandatoryWhenFormattingInNationalFormat()) {
|
|
324
300
|
return false;
|
|
325
301
|
}
|
|
@@ -328,24 +304,19 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
328
304
|
}, {
|
|
329
305
|
key: "formatMatches",
|
|
330
306
|
value: function formatMatches(format, leadingDigits, leadingDigitsPatternIndex) {
|
|
331
|
-
var leadingDigitsPatternsCount = format.leadingDigitsPatterns().length;
|
|
332
|
-
|
|
333
|
-
// If this format is not restricted to a certain
|
|
307
|
+
var leadingDigitsPatternsCount = format.leadingDigitsPatterns().length; // If this format is not restricted to a certain
|
|
334
308
|
// leading digits pattern then it fits.
|
|
335
309
|
// The test case could be found by searching for "leadingDigitsPatternsCount === 0".
|
|
310
|
+
|
|
336
311
|
if (leadingDigitsPatternsCount === 0) {
|
|
337
312
|
return true;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Start narrowing down the list of possible formats based on the leading digits.
|
|
313
|
+
} // Start narrowing down the list of possible formats based on the leading digits.
|
|
341
314
|
// (only previously matched formats take part in the narrowing down process)
|
|
342
|
-
|
|
343
315
|
// `leading_digits_patterns` start with 3 digits min
|
|
344
316
|
// and then go up from there one digit at a time.
|
|
345
|
-
leadingDigitsPatternIndex = Math.min(leadingDigitsPatternIndex, leadingDigitsPatternsCount - 1);
|
|
346
|
-
var leadingDigitsPattern = format.leadingDigitsPatterns()[leadingDigitsPatternIndex];
|
|
347
317
|
|
|
348
|
-
|
|
318
|
+
leadingDigitsPatternIndex = Math.min(leadingDigitsPatternIndex, leadingDigitsPatternsCount - 1);
|
|
319
|
+
var leadingDigitsPattern = format.leadingDigitsPatterns()[leadingDigitsPatternIndex]; // Google imposes a requirement on the leading digits
|
|
349
320
|
// to be minimum 3 digits long in order to be eligible
|
|
350
321
|
// for checking those with a leading digits pattern.
|
|
351
322
|
//
|
|
@@ -370,6 +341,7 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
370
341
|
// even when there's only 1 or 2 digits of the national (significant) number.
|
|
371
342
|
// To do that, it uses a non-strict pattern matcher written specifically for that.
|
|
372
343
|
//
|
|
344
|
+
|
|
373
345
|
if (leadingDigits.length < MIN_LEADING_DIGITS_LENGTH) {
|
|
374
346
|
// Before leading digits < 3 matching was implemented:
|
|
375
347
|
// return true
|
|
@@ -379,7 +351,8 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
379
351
|
return new PatternMatcher(leadingDigitsPattern).match(leadingDigits, {
|
|
380
352
|
allowOverflow: true
|
|
381
353
|
}) !== undefined;
|
|
382
|
-
} catch (error) /* istanbul ignore next */
|
|
354
|
+
} catch (error) /* istanbul ignore next */
|
|
355
|
+
{
|
|
383
356
|
// There's a slight possibility that there could be some undiscovered bug
|
|
384
357
|
// in the pattern matcher code. Since the "leading digits < 3 matching"
|
|
385
358
|
// feature is not "essential" for operation, it can fall back to the old way
|
|
@@ -387,14 +360,13 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
387
360
|
console.error(error);
|
|
388
361
|
return true;
|
|
389
362
|
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// If at least `MIN_LEADING_DIGITS_LENGTH` digits of a national number are
|
|
363
|
+
} // If at least `MIN_LEADING_DIGITS_LENGTH` digits of a national number are
|
|
393
364
|
// available then use the usual regular expression matching.
|
|
394
365
|
//
|
|
395
366
|
// The whole pattern is wrapped in round brackets (`()`) because
|
|
396
367
|
// the pattern can use "or" operator (`|`) at the top level of the pattern.
|
|
397
368
|
//
|
|
369
|
+
|
|
398
370
|
return new RegExp("^(".concat(leadingDigitsPattern, ")")).test(leadingDigits);
|
|
399
371
|
}
|
|
400
372
|
}, {
|
|
@@ -407,65 +379,67 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
407
379
|
value: function chooseFormat(state) {
|
|
408
380
|
var _this3 = this;
|
|
409
381
|
var _loop = function _loop() {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
382
|
+
var format = _step2.value;
|
|
383
|
+
|
|
384
|
+
// If this format is currently being used
|
|
385
|
+
// and is still suitable, then stick to it.
|
|
386
|
+
if (_this3.chosenFormat === format) {
|
|
387
|
+
return "break";
|
|
388
|
+
} // Sometimes, a formatting rule inserts additional digits in a phone number,
|
|
389
|
+
// and "as you type" formatter can't do that: it should only use the digits
|
|
390
|
+
// that the user has input.
|
|
391
|
+
//
|
|
392
|
+
// For example, in Argentina, there's a format for mobile phone numbers:
|
|
393
|
+
//
|
|
394
|
+
// {
|
|
395
|
+
// "pattern": "(\\d)(\\d{2})(\\d{4})(\\d{4})",
|
|
396
|
+
// "leading_digits_patterns": ["91"],
|
|
397
|
+
// "national_prefix_formatting_rule": "0$1",
|
|
398
|
+
// "format": "$2 15-$3-$4",
|
|
399
|
+
// "international_format": "$1 $2 $3-$4"
|
|
400
|
+
// }
|
|
401
|
+
//
|
|
402
|
+
// In that format, `international_format` is used instead of `format`
|
|
403
|
+
// because `format` inserts `15` in the formatted number,
|
|
404
|
+
// and `AsYouType` formatter should only use the digits
|
|
405
|
+
// the user has actually input, without adding any extra digits.
|
|
406
|
+
// In this case, it wouldn't make a difference, because the `15`
|
|
407
|
+
// is first stripped when applying `national_prefix_for_parsing`
|
|
408
|
+
// and then re-added when using `format`, so in reality it doesn't
|
|
409
|
+
// add any new digits to the number, but to detect that, the code
|
|
410
|
+
// would have to be more complex: it would have to try formatting
|
|
411
|
+
// the digits using the format and then see if any digits have
|
|
412
|
+
// actually been added or removed, and then, every time a new digit
|
|
413
|
+
// is input, it should re-check whether the chosen format doesn't
|
|
414
|
+
// alter the digits.
|
|
415
|
+
//
|
|
416
|
+
// Google's code doesn't go that far, and so does this library:
|
|
417
|
+
// it simply requires that a `format` doesn't add any additonal
|
|
418
|
+
// digits to user's input.
|
|
419
|
+
//
|
|
420
|
+
// Also, people in general should move from inputting phone numbers
|
|
421
|
+
// in national format (possibly with national prefixes)
|
|
422
|
+
// and use international phone number format instead:
|
|
423
|
+
// it's a logical thing in the modern age of mobile phones,
|
|
424
|
+
// globalization and the internet.
|
|
425
|
+
//
|
|
426
|
+
|
|
427
|
+
/* istanbul ignore if */
|
|
428
|
+
|
|
429
|
+
if (!NON_ALTERING_FORMAT_REG_EXP.test(_this3.getFormatFormat(format, state.international))) {
|
|
430
|
+
return "continue";
|
|
431
|
+
}
|
|
432
|
+
if (!_this3.createTemplateForFormat(format, state)) {
|
|
433
|
+
// Remove the format if it can't generate a template.
|
|
434
|
+
_this3.matchingFormats = _this3.matchingFormats.filter(function (_) {
|
|
435
|
+
return _ !== format;
|
|
436
|
+
});
|
|
437
|
+
return "continue";
|
|
438
|
+
}
|
|
439
|
+
_this3.chosenFormat = format;
|
|
440
|
+
return "break";
|
|
441
|
+
};
|
|
442
|
+
|
|
469
443
|
// When there are multiple available formats, the formatter uses the first
|
|
470
444
|
// format where a formatting template could be created.
|
|
471
445
|
//
|
|
@@ -480,11 +454,12 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
480
454
|
// It doesn't skip the contents of the `for of` loop,
|
|
481
455
|
// it just skips the `for of` line.
|
|
482
456
|
//
|
|
457
|
+
|
|
483
458
|
/* istanbul ignore next */
|
|
484
459
|
for (var _iterator2 = _createForOfIteratorHelperLoose(this.matchingFormats.slice()), _step2; !(_step2 = _iterator2()).done;) {
|
|
485
|
-
_ret = _loop();
|
|
486
|
-
if (_ret ===
|
|
487
|
-
if (_ret ===
|
|
460
|
+
var _ret = _loop();
|
|
461
|
+
if (_ret === "break") break;
|
|
462
|
+
if (_ret === "continue") continue;
|
|
488
463
|
}
|
|
489
464
|
if (!this.chosenFormat) {
|
|
490
465
|
// No format matches the national (significant) phone number.
|
|
@@ -498,14 +473,15 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
498
473
|
// The formatter doesn't format numbers when numberPattern contains '|', e.g.
|
|
499
474
|
// (20|3)\d{4}. In those cases we quickly return.
|
|
500
475
|
// (Though there's no such format in current metadata)
|
|
476
|
+
|
|
501
477
|
/* istanbul ignore if */
|
|
502
478
|
if (format.pattern().indexOf('|') >= 0) {
|
|
503
479
|
return;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
var template = this.getTemplateForFormat(format, state);
|
|
507
|
-
// If the national number entered is too long
|
|
480
|
+
} // Get formatting template for this phone number format
|
|
481
|
+
|
|
482
|
+
var template = this.getTemplateForFormat(format, state); // If the national number entered is too long
|
|
508
483
|
// for any phone number format, then abort.
|
|
484
|
+
|
|
509
485
|
if (template) {
|
|
510
486
|
this.setNationalNumberTemplate(template, state);
|
|
511
487
|
return true;
|
|
@@ -521,17 +497,17 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
521
497
|
// So `US` national prefix separator is a "special" "hardcoded" case.
|
|
522
498
|
if (this.isNANP) {
|
|
523
499
|
return ' ';
|
|
524
|
-
}
|
|
525
|
-
// If a `format` has a `national_prefix_formatting_rule`
|
|
500
|
+
} // If a `format` has a `national_prefix_formatting_rule`
|
|
526
501
|
// and that rule has a separator after a national prefix,
|
|
527
502
|
// then it means that there should be a separator
|
|
528
503
|
// between a national prefix and a national (significant) number.
|
|
504
|
+
|
|
529
505
|
if (format && format.nationalPrefixFormattingRule() && NATIONAL_PREFIX_SEPARATORS_PATTERN.test(format.nationalPrefixFormattingRule())) {
|
|
530
506
|
return ' ';
|
|
531
|
-
}
|
|
532
|
-
// At this point, there seems to be no clear evidence that
|
|
507
|
+
} // At this point, there seems to be no clear evidence that
|
|
533
508
|
// there should be a separator between a national prefix
|
|
534
509
|
// and a national (significant) number. So don't insert one.
|
|
510
|
+
|
|
535
511
|
return '';
|
|
536
512
|
}
|
|
537
513
|
}, {
|
|
@@ -552,10 +528,10 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
552
528
|
value: function getTemplate(state) {
|
|
553
529
|
if (!this.template) {
|
|
554
530
|
return;
|
|
555
|
-
}
|
|
556
|
-
// `this.template` holds the template for a "complete" phone number.
|
|
531
|
+
} // `this.template` holds the template for a "complete" phone number.
|
|
557
532
|
// The currently entered phone number is most likely not "complete",
|
|
558
533
|
// so trim all non-populated digits.
|
|
534
|
+
|
|
559
535
|
var index = -1;
|
|
560
536
|
var i = 0;
|
|
561
537
|
var internationalPrefix = state.international ? this.getInternationalPrefixBeforeCountryCallingCode(state, {
|
|
@@ -571,22 +547,21 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
571
547
|
key: "setNationalNumberTemplate",
|
|
572
548
|
value: function setNationalNumberTemplate(template, state) {
|
|
573
549
|
this.nationalNumberTemplate = template;
|
|
574
|
-
this.populatedNationalNumberTemplate = template;
|
|
575
|
-
// With a new formatting template, the matched position
|
|
550
|
+
this.populatedNationalNumberTemplate = template; // With a new formatting template, the matched position
|
|
576
551
|
// using the old template needs to be reset.
|
|
577
|
-
|
|
578
|
-
// For convenience, the public `.template` property
|
|
552
|
+
|
|
553
|
+
this.populatedNationalNumberTemplatePosition = -1; // For convenience, the public `.template` property
|
|
579
554
|
// contains the whole international number
|
|
580
555
|
// if the phone number being input is international:
|
|
581
556
|
// 'x' for the '+' sign, 'x'es for the country phone code,
|
|
582
557
|
// a spacebar and then the template for the formatted national number.
|
|
558
|
+
|
|
583
559
|
if (state.international) {
|
|
584
560
|
this.template = this.getInternationalPrefixBeforeCountryCallingCode(state).replace(/[\d\+]/g, DIGIT_PLACEHOLDER) + repeat(DIGIT_PLACEHOLDER, state.callingCode.length) + ' ' + template;
|
|
585
561
|
} else {
|
|
586
562
|
this.template = template;
|
|
587
563
|
}
|
|
588
564
|
}
|
|
589
|
-
|
|
590
565
|
/**
|
|
591
566
|
* Generates formatting template for a national phone number,
|
|
592
567
|
* optionally containing a national prefix, for a format.
|
|
@@ -600,19 +575,15 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
600
575
|
var nationalSignificantNumber = _ref4.nationalSignificantNumber,
|
|
601
576
|
international = _ref4.international,
|
|
602
577
|
nationalPrefix = _ref4.nationalPrefix,
|
|
603
|
-
|
|
578
|
+
complexPrefixBeforeNationalSignificantNumber = _ref4.complexPrefixBeforeNationalSignificantNumber;
|
|
604
579
|
var pattern = format.pattern();
|
|
605
|
-
|
|
606
580
|
/* istanbul ignore else */
|
|
581
|
+
|
|
607
582
|
{
|
|
608
|
-
pattern = pattern
|
|
609
|
-
// Replace
|
|
610
|
-
.replace(CREATE_CHARACTER_CLASS_PATTERN(), '\\d')
|
|
611
|
-
// Replace any standalone digit (not the one in `{}`) with \d
|
|
583
|
+
pattern = pattern // Replace anything in the form of [..] with \d
|
|
584
|
+
.replace(CREATE_CHARACTER_CLASS_PATTERN(), '\\d') // Replace any standalone digit (not the one in `{}`) with \d
|
|
612
585
|
.replace(CREATE_STANDALONE_DIGIT_PATTERN(), '\\d');
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// Generate a dummy national number (consisting of `9`s)
|
|
586
|
+
} // Generate a dummy national number (consisting of `9`s)
|
|
616
587
|
// that fits this format's `pattern`.
|
|
617
588
|
//
|
|
618
589
|
// This match will always succeed,
|
|
@@ -620,17 +591,14 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
620
591
|
// has enough length to accomodate any possible
|
|
621
592
|
// national phone number format pattern.
|
|
622
593
|
//
|
|
623
|
-
var digits = LONGEST_DUMMY_PHONE_NUMBER.match(pattern)[0];
|
|
624
594
|
|
|
625
|
-
// If the national number entered is too long
|
|
595
|
+
var digits = LONGEST_DUMMY_PHONE_NUMBER.match(pattern)[0]; // If the national number entered is too long
|
|
626
596
|
// for any phone number format, then abort.
|
|
597
|
+
|
|
627
598
|
if (nationalSignificantNumber.length > digits.length) {
|
|
628
599
|
return;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// Get a formatting template which can be used to efficiently format
|
|
600
|
+
} // Get a formatting template which can be used to efficiently format
|
|
632
601
|
// a partial number where digits are added one by one.
|
|
633
|
-
|
|
634
602
|
// Below `strictPattern` is used for the
|
|
635
603
|
// regular expression (with `^` and `$`).
|
|
636
604
|
// This wasn't originally in Google's `libphonenumber`
|
|
@@ -660,42 +628,41 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
660
628
|
// is used instead of `digits`.
|
|
661
629
|
|
|
662
630
|
var strictPattern = new RegExp('^' + pattern + '$');
|
|
663
|
-
var nationalNumberDummyDigits = nationalSignificantNumber.replace(/\d/g, DUMMY_DIGIT);
|
|
664
|
-
|
|
665
|
-
// If `this.nationalSignificantNumber` has already sufficient length
|
|
631
|
+
var nationalNumberDummyDigits = nationalSignificantNumber.replace(/\d/g, DUMMY_DIGIT); // If `this.nationalSignificantNumber` has already sufficient length
|
|
666
632
|
// to satisfy the `pattern` completely then use it
|
|
667
633
|
// instead of `digits`.
|
|
634
|
+
|
|
668
635
|
if (strictPattern.test(nationalNumberDummyDigits)) {
|
|
669
636
|
digits = nationalNumberDummyDigits;
|
|
670
637
|
}
|
|
671
638
|
var numberFormat = this.getFormatFormat(format, international);
|
|
672
|
-
var nationalPrefixIncludedInTemplate;
|
|
673
|
-
|
|
674
|
-
// If a user did input a national prefix (and that's guaranteed),
|
|
639
|
+
var nationalPrefixIncludedInTemplate; // If a user did input a national prefix (and that's guaranteed),
|
|
675
640
|
// and if a `format` does have a national prefix formatting rule,
|
|
676
641
|
// then see if that national prefix formatting rule
|
|
677
642
|
// prepends exactly the same national prefix the user has input.
|
|
678
643
|
// If that's the case, then use the `format` with the national prefix formatting rule.
|
|
679
644
|
// Otherwise, use the `format` without the national prefix formatting rule,
|
|
680
645
|
// and prepend a national prefix manually to it.
|
|
646
|
+
|
|
681
647
|
if (this.shouldTryNationalPrefixFormattingRule(format, {
|
|
682
648
|
international: international,
|
|
683
649
|
nationalPrefix: nationalPrefix
|
|
684
650
|
})) {
|
|
685
|
-
var numberFormatWithNationalPrefix = numberFormat.replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule());
|
|
686
|
-
// If `national_prefix_formatting_rule` of a `format` simply prepends
|
|
651
|
+
var numberFormatWithNationalPrefix = numberFormat.replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()); // If `national_prefix_formatting_rule` of a `format` simply prepends
|
|
687
652
|
// national prefix at the start of a national (significant) number,
|
|
688
653
|
// then such formatting can be used with `AsYouType` formatter.
|
|
689
654
|
// There seems to be no `else` case: everywhere in metadata,
|
|
690
655
|
// national prefix formatting rule is national prefix + $1,
|
|
691
656
|
// or `($1)`, in which case such format isn't even considered
|
|
692
657
|
// when the user has input a national prefix.
|
|
658
|
+
|
|
693
659
|
/* istanbul ignore else */
|
|
660
|
+
|
|
694
661
|
if (parseDigits(format.nationalPrefixFormattingRule()) === (nationalPrefix || '') + parseDigits('$1')) {
|
|
695
662
|
numberFormat = numberFormatWithNationalPrefix;
|
|
696
|
-
nationalPrefixIncludedInTemplate = true;
|
|
697
|
-
// Replace all digits of the national prefix in the formatting template
|
|
663
|
+
nationalPrefixIncludedInTemplate = true; // Replace all digits of the national prefix in the formatting template
|
|
698
664
|
// with `DIGIT_PLACEHOLDER`s.
|
|
665
|
+
|
|
699
666
|
if (nationalPrefix) {
|
|
700
667
|
var i = nationalPrefix.length;
|
|
701
668
|
while (i > 0) {
|
|
@@ -704,23 +671,19 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
704
671
|
}
|
|
705
672
|
}
|
|
706
673
|
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// Generate formatting template for this phone number format.
|
|
710
|
-
var template = digits
|
|
711
|
-
// Format the dummy phone number according to the format.
|
|
712
|
-
.replace(new RegExp(pattern), numberFormat)
|
|
713
|
-
// Replace each dummy digit with a DIGIT_PLACEHOLDER.
|
|
714
|
-
.replace(new RegExp(DUMMY_DIGIT, 'g'), DIGIT_PLACEHOLDER);
|
|
674
|
+
} // Generate formatting template for this phone number format.
|
|
715
675
|
|
|
716
|
-
|
|
676
|
+
var template = digits // Format the dummy phone number according to the format.
|
|
677
|
+
.replace(new RegExp(pattern), numberFormat) // Replace each dummy digit with a DIGIT_PLACEHOLDER.
|
|
678
|
+
.replace(new RegExp(DUMMY_DIGIT, 'g'), DIGIT_PLACEHOLDER); // If a prefix of a national (significant) number is not as simple
|
|
717
679
|
// as just a basic national prefix, then just prepend such prefix
|
|
718
680
|
// before the national (significant) number, optionally spacing
|
|
719
681
|
// the two with a whitespace.
|
|
682
|
+
|
|
720
683
|
if (!nationalPrefixIncludedInTemplate) {
|
|
721
|
-
if (
|
|
684
|
+
if (complexPrefixBeforeNationalSignificantNumber) {
|
|
722
685
|
// Prepend the prefix to the template manually.
|
|
723
|
-
template = repeat(DIGIT_PLACEHOLDER,
|
|
686
|
+
template = repeat(DIGIT_PLACEHOLDER, complexPrefixBeforeNationalSignificantNumber.length) + ' ' + template;
|
|
724
687
|
} else if (nationalPrefix) {
|
|
725
688
|
// Prepend national prefix to the template manually.
|
|
726
689
|
template = repeat(DIGIT_PLACEHOLDER, nationalPrefix.length) + this.getSeparatorAfterNationalPrefix(format) + template;
|
|
@@ -741,12 +704,9 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
741
704
|
return;
|
|
742
705
|
}
|
|
743
706
|
this.populatedNationalNumberTemplate = result[0];
|
|
744
|
-
this.populatedNationalNumberTemplatePosition = result[1];
|
|
745
|
-
|
|
746
|
-
// Return the formatted phone number so far.
|
|
747
|
-
return cutAndStripNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1);
|
|
707
|
+
this.populatedNationalNumberTemplatePosition = result[1]; // Return the formatted phone number so far.
|
|
748
708
|
|
|
749
|
-
// The old way which was good for `input-format` but is not so good
|
|
709
|
+
return cutAndStripNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1); // The old way which was good for `input-format` but is not so good
|
|
750
710
|
// for `react-phone-number-input`'s default input (`InputBasic`).
|
|
751
711
|
// return closeNonPairedParens(this.populatedNationalNumberTemplate, this.populatedNationalNumberTemplatePosition + 1)
|
|
752
712
|
// .replace(new RegExp(DIGIT_PLACEHOLDER, 'g'), ' ')
|
|
@@ -767,6 +727,7 @@ var AsYouTypeFormatter = /*#__PURE__*/function () {
|
|
|
767
727
|
}
|
|
768
728
|
}
|
|
769
729
|
}]);
|
|
730
|
+
return AsYouTypeFormatter;
|
|
770
731
|
}();
|
|
771
732
|
|
|
772
733
|
export { DIGIT_PLACEHOLDER, AsYouTypeFormatter as default };
|