@heartlandone/vega 2.76.0 → 2.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{app-globals-12b7d808.js → app-globals-04e7024b.js} +2 -2
- package/dist/cjs/aria-attributes-value-mapper-f58c73f8.js +136 -0
- package/dist/cjs/{child-nodes-event-prevent-slimmer-84435957.js → child-nodes-event-prevent-slimmer-cc6d2919.js} +1 -1
- package/dist/cjs/{design-token-41baf118.js → design-token-c49717c8.js} +1 -1
- package/dist/cjs/{element-appender-slimmer-34e4eb56.js → element-appender-slimmer-38583ca9.js} +2 -2
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/legend-input-processor-1e53e5bc.js +2126 -0
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/{responsive-format-facade-ea59bdcd.js → responsive-format-facade-acc39a40.js} +1 -1
- package/dist/cjs/{style-formatter-0c3ced39.js → style-formatter-028af284.js} +1 -1
- package/dist/cjs/{token-extension-07cac85d.js → token-extension-ffcaeae0.js} +98 -77
- package/dist/cjs/vega-accordion.cjs.entry.js +5 -5
- package/dist/cjs/vega-app-header-button.cjs.entry.js +18 -143
- package/dist/cjs/vega-banner.cjs.entry.js +1 -1
- package/dist/cjs/vega-bar-chart.cjs.entry.js +2 -2
- package/dist/cjs/vega-box.cjs.entry.js +4 -4
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +2 -2
- package/dist/cjs/vega-button-circle.cjs.entry.js +21 -6
- package/dist/cjs/vega-button-group_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-button-link.cjs.entry.js +2 -2
- package/dist/cjs/vega-button.cjs.entry.js +3 -3
- package/dist/cjs/vega-calendar_4.cjs.entry.js +2 -2
- package/dist/cjs/vega-card.cjs.entry.js +3 -3
- package/dist/cjs/vega-carousel.cjs.entry.js +2 -2
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-chip.cjs.entry.js +4 -4
- package/dist/cjs/vega-code-block.cjs.entry.js +2 -2
- package/dist/cjs/vega-combo-box.cjs.entry.js +2 -2
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +29 -7
- package/dist/cjs/vega-dialog_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-divider.cjs.entry.js +3 -3
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +4 -4
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-flag-icon.cjs.entry.js +3 -3
- package/dist/cjs/vega-flex.cjs.entry.js +4 -4
- package/dist/cjs/vega-font.cjs.entry.js +3 -3
- package/dist/cjs/vega-form.cjs.entry.js +2 -2
- package/dist/cjs/vega-grid.cjs.entry.js +3 -3
- package/dist/cjs/vega-icon.cjs.entry.js +3 -3
- package/dist/cjs/vega-image-uploader.cjs.entry.js +3 -3
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-numeric.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-passcode.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +4753 -5585
- package/dist/cjs/vega-input-range.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-select.cjs.entry.js +3 -3
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +3 -3
- package/dist/cjs/vega-line-chart.cjs.entry.js +325 -23
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +2 -2
- package/dist/cjs/vega-pagination.cjs.entry.js +3 -3
- package/dist/cjs/vega-pie-chart.cjs.entry.js +5 -88
- package/dist/cjs/vega-popover_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-radio_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +14 -0
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +2 -2
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +2 -2
- package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -3
- package/dist/cjs/vega-stepper.cjs.entry.js +2 -2
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-table_11.cjs.entry.js +3 -3
- package/dist/cjs/vega-textarea.cjs.entry.js +2 -2
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +3 -3
- package/dist/cjs/vega.cjs.js +4 -4
- package/dist/cjs/y-axis-input-processor-54a26515.js +832 -0
- package/dist/collection/components/vega-accordion/slimmers/vega-accordion-renderer.js +1 -1
- package/dist/collection/components/vega-accordion/vega-accordion.css +5 -0
- package/dist/collection/components/vega-button-circle/vega-button-circle.js +17 -3
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.js +16 -2
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.css +184 -207
- package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.js +32 -0
- package/dist/collection/components/vega-input-phone-number/slimmers/controllers/country-select-controller.js +1 -1
- package/dist/collection/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.js +1 -1
- package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +1 -1
- package/dist/collection/components/vega-input-phone-number/slimmers/renderers/phone-number-input-renderer.js +1 -1
- package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +4 -4
- package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +15 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/base-extension-renderer.js +11 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.js +15 -1
- package/dist/collection/components/vega-rich-text-editor/extensions/extension.abstract.js +2 -0
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/function-extension.js +0 -11
- package/dist/collection/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.js +23 -23
- package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-extension.js +0 -10
- package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.js +7 -17
- package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.js +12 -16
- package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.js +31 -0
- package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.test.js +19 -0
- package/dist/collection/components/vega-rich-text-editor/test/extensions/extension-test-utils.js +41 -0
- package/dist/collection/helpers/chart/input-processors/format-time-positions-input-processor.js +2 -2
- package/dist/collection/helpers/chart/input-processors/pie-chart-arc-path-input-processor.js +1 -1
- package/dist/collection/helpers/chart/input-processors/x-axis-input-processor.js +5 -3
- package/dist/collection/helpers/chart/input-processors/x-axis-label-formatter-input-processor.js +2 -1
- package/dist/collection/helpers/chart/input-processors/y-axis-input-processor.js +7 -5
- package/dist/collection/helpers/chart/interacting-entry-generator/arc-path-hover-generator.js +1 -1
- package/dist/collection/helpers/chart/interacting-entry-generator/pie-legend-hover-generator.js +1 -1
- package/dist/collection/helpers/chart/renderers/canvas-renderer.js +1 -1
- package/dist/collection/helpers/chart/renderers/svg-renderer.js +1 -1
- package/dist/collection/helpers/chart/test/drawers/arc-path-drawer.test.js +1 -1
- package/dist/collection/helpers/chart/test/input-processors/format-time-positions-input-processor.test.js +1 -1
- package/dist/collection/helpers/chart/test/input-processors/sort-positions-input-processor.test.js +1 -1
- package/dist/collection/helpers/chart/test/input-processors/x-axis-input-processor.test.js +39 -0
- package/dist/collection/helpers/chart/test/input-processors/x-axis-label-formatter-input-processor.test.js +61 -14
- package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.js +39 -0
- package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.test.js +14 -0
- package/dist/collection/helpers/chart/test/renderers/svg-renderer.test.js +1 -1
- package/dist/collection/helpers/common/test/wait-for-component-did-render.test.js +67 -0
- package/dist/collection/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.js +4 -0
- package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +1 -1
- package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +1 -1
- package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +10 -0
- package/dist/collection/polyfill/d3/d3-array-polyfill.js +89 -0
- package/dist/collection/polyfill/d3/d3-axis-polyfill.js +195 -0
- package/dist/collection/polyfill/d3/d3-scale-polyfill.js +582 -0
- package/dist/collection/polyfill/d3/d3-selection-polyfill.js +274 -0
- package/dist/collection/polyfill/d3/d3-shape-polyfill.js +252 -0
- package/dist/collection/polyfill/d3/d3-time-format-polyfill.js +207 -0
- package/dist/collection/polyfill/d3/d3-time-polyfill.js +99 -0
- package/dist/collection/polyfill/d3/index.js +31 -0
- package/dist/collection/polyfill/d3/test/d3-array-polyfill.test.js +72 -0
- package/dist/collection/polyfill/d3/test/d3-axis-polyfill.test.js +171 -0
- package/dist/collection/polyfill/d3/test/d3-integration.test.js +137 -0
- package/dist/collection/polyfill/d3/test/d3-scale-polyfill.test.js +382 -0
- package/dist/collection/polyfill/d3/test/d3-selection-polyfill.test.js +239 -0
- package/dist/collection/polyfill/d3/test/d3-shape-polyfill.test.js +225 -0
- package/dist/collection/polyfill/d3/test/d3-time-format-polyfill.test.js +162 -0
- package/dist/collection/polyfill/d3/test/d3-time-polyfill.test.js +76 -0
- package/dist/collection/polyfill/d3/test/index.test.js +78 -0
- package/dist/collection/polyfill/libphonenumber/as-you-type.js +405 -0
- package/dist/collection/polyfill/libphonenumber/format-helpers.js +186 -0
- package/dist/collection/polyfill/libphonenumber/index.js +22 -0
- package/dist/collection/polyfill/libphonenumber/metadata.js +150 -0
- package/dist/collection/polyfill/libphonenumber/metadata.json.js +3900 -0
- package/dist/collection/polyfill/libphonenumber/parse-phone-number.js +127 -0
- package/dist/collection/polyfill/libphonenumber/phone-number.js +38 -0
- package/dist/collection/polyfill/libphonenumber/test/as-you-type.test.js +309 -0
- package/dist/collection/polyfill/libphonenumber/test/format-helpers.test.js +192 -0
- package/dist/collection/polyfill/libphonenumber/test/index.test.js +16 -0
- package/dist/collection/polyfill/libphonenumber/test/metadata.test.js +196 -0
- package/dist/collection/polyfill/libphonenumber/test/parse-phone-number.test.js +218 -0
- package/dist/collection/polyfill/libphonenumber/test/phone-number.test.js +56 -0
- package/dist/collection/polyfill/libphonenumber/types.js +23 -0
- package/dist/esm/{app-globals-c0676920.js → app-globals-32055795.js} +2 -2
- package/dist/esm/aria-attributes-value-mapper-d4fef46a.js +134 -0
- package/dist/esm/{child-nodes-event-prevent-slimmer-649b9d30.js → child-nodes-event-prevent-slimmer-331312b8.js} +1 -1
- package/dist/esm/{design-token-4aee1c56.js → design-token-5bc034e1.js} +1 -1
- package/dist/esm/{element-appender-slimmer-e4713a72.js → element-appender-slimmer-9ea377d0.js} +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/legend-input-processor-122008c5.js +2116 -0
- package/dist/esm/loader.js +4 -4
- package/dist/esm/{responsive-format-facade-7a071174.js → responsive-format-facade-aa705823.js} +1 -1
- package/dist/esm/{style-formatter-3d06b72d.js → style-formatter-28138f5c.js} +1 -1
- package/dist/esm/{token-extension-e33fd151.js → token-extension-73e4460a.js} +98 -77
- package/dist/esm/vega-accordion.entry.js +5 -5
- package/dist/esm/vega-app-header-button.entry.js +17 -142
- package/dist/esm/vega-banner.entry.js +1 -1
- package/dist/esm/vega-bar-chart.entry.js +2 -2
- package/dist/esm/vega-box.entry.js +4 -4
- package/dist/esm/vega-breadcrumb.entry.js +2 -2
- package/dist/esm/vega-button-circle.entry.js +21 -6
- package/dist/esm/vega-button-group_2.entry.js +2 -2
- package/dist/esm/vega-button-link.entry.js +2 -2
- package/dist/esm/vega-button.entry.js +3 -3
- package/dist/esm/vega-calendar_4.entry.js +2 -2
- package/dist/esm/vega-card.entry.js +3 -3
- package/dist/esm/vega-carousel.entry.js +2 -2
- package/dist/esm/vega-checkbox_2.entry.js +2 -2
- package/dist/esm/vega-chip.entry.js +4 -4
- package/dist/esm/vega-code-block.entry.js +2 -2
- package/dist/esm/vega-combo-box.entry.js +2 -2
- package/dist/esm/vega-date-picker_2.entry.js +29 -7
- package/dist/esm/vega-dialog_2.entry.js +4 -4
- package/dist/esm/vega-divider.entry.js +3 -3
- package/dist/esm/vega-dropdown_5.entry.js +4 -4
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-flag-icon.entry.js +3 -3
- package/dist/esm/vega-flex.entry.js +4 -4
- package/dist/esm/vega-font.entry.js +3 -3
- package/dist/esm/vega-form.entry.js +2 -2
- package/dist/esm/vega-grid.entry.js +3 -3
- package/dist/esm/vega-icon.entry.js +3 -3
- package/dist/esm/vega-image-uploader.entry.js +3 -3
- package/dist/esm/vega-input-credit-card.entry.js +2 -2
- package/dist/esm/vega-input-numeric.entry.js +2 -2
- package/dist/esm/vega-input-passcode.entry.js +2 -2
- package/dist/esm/vega-input-phone-number.entry.js +4753 -5585
- package/dist/esm/vega-input-range.entry.js +2 -2
- package/dist/esm/vega-input-select.entry.js +3 -3
- package/dist/esm/vega-left-nav_5.entry.js +3 -3
- package/dist/esm/vega-line-chart.entry.js +311 -9
- package/dist/esm/vega-loader-wrapper_2.entry.js +2 -2
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +2 -2
- package/dist/esm/vega-pagination.entry.js +3 -3
- package/dist/esm/vega-pie-chart.entry.js +5 -88
- package/dist/esm/vega-popover_2.entry.js +4 -4
- package/dist/esm/vega-progress-tracker_2.entry.js +2 -2
- package/dist/esm/vega-radio_2.entry.js +2 -2
- package/dist/esm/vega-rich-text-content.entry.js +14 -0
- package/dist/esm/vega-rich-text-editor_4.entry.js +2 -2
- package/dist/esm/vega-selection-chip_2.entry.js +3 -3
- package/dist/esm/vega-selection-tile_2.entry.js +2 -2
- package/dist/esm/vega-sidenav_3.entry.js +2 -2
- package/dist/esm/vega-signature-capture.entry.js +3 -3
- package/dist/esm/vega-stepper.entry.js +2 -2
- package/dist/esm/vega-tab-group_2.entry.js +2 -2
- package/dist/esm/vega-table_11.entry.js +3 -3
- package/dist/esm/vega-textarea.entry.js +2 -2
- package/dist/esm/vega-time-picker_2.entry.js +4 -4
- package/dist/esm/vega-tooltip_2.entry.js +3 -3
- package/dist/esm/vega.js +4 -4
- package/dist/esm/y-axis-input-processor-c7e05353.js +826 -0
- package/dist/sri/vega-sri-manifest.json +234 -230
- package/dist/types/components/vega-button-circle/vega-button-circle.d.ts +2 -0
- package/dist/types/components/vega-date-picker/types.d.ts +14 -0
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.d.ts +3 -0
- package/dist/types/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.d.ts +9 -1
- package/dist/types/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.d.ts +6 -0
- package/dist/types/components/vega-rich-text-editor/extensions/base-extension-renderer.d.ts +9 -1
- package/dist/types/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.d.ts +9 -1
- package/dist/types/components/vega-rich-text-editor/extensions/functions/function-extension.d.ts +0 -7
- package/dist/types/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.d.ts +5 -10
- package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-extension.d.ts +1 -5
- package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.d.ts +3 -8
- package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.d.ts +5 -9
- package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.d.ts +26 -0
- package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/test/extensions/extension-test-utils.d.ts +21 -0
- package/dist/types/components.d.ts +11 -1
- package/dist/types/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.d.ts +1 -0
- package/dist/types/helpers/common/test/wait-for-component-did-render.test.d.ts +1 -0
- package/dist/types/polyfill/d3/d3-array-polyfill.d.ts +48 -0
- package/dist/types/polyfill/d3/d3-axis-polyfill.d.ts +53 -0
- package/dist/types/polyfill/d3/d3-scale-polyfill.d.ts +42 -0
- package/dist/types/polyfill/d3/d3-selection-polyfill.d.ts +173 -0
- package/dist/types/polyfill/d3/d3-shape-polyfill.d.ts +129 -0
- package/dist/types/polyfill/d3/d3-time-format-polyfill.d.ts +28 -0
- package/dist/types/polyfill/d3/d3-time-polyfill.d.ts +68 -0
- package/dist/types/polyfill/d3/index.d.ts +27 -0
- package/dist/types/polyfill/d3/test/d3-array-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-axis-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-integration.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-scale-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-selection-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-shape-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-time-format-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/d3-time-polyfill.test.d.ts +1 -0
- package/dist/types/polyfill/d3/test/index.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/as-you-type.d.ts +154 -0
- package/dist/types/polyfill/libphonenumber/format-helpers.d.ts +64 -0
- package/dist/types/polyfill/libphonenumber/index.d.ts +22 -0
- package/dist/types/polyfill/libphonenumber/metadata.d.ts +45 -0
- package/dist/types/polyfill/libphonenumber/metadata.json.d.ts +470 -0
- package/dist/types/polyfill/libphonenumber/parse-phone-number.d.ts +26 -0
- package/dist/types/polyfill/libphonenumber/phone-number.d.ts +24 -0
- package/dist/types/polyfill/libphonenumber/test/as-you-type.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/test/format-helpers.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/test/index.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/test/metadata.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/test/parse-phone-number.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/test/phone-number.test.d.ts +1 -0
- package/dist/types/polyfill/libphonenumber/types.d.ts +77 -0
- package/dist/types/types/components.type.d.ts +1 -0
- package/dist/types/types/flag.type.d.ts +255 -4
- package/dist/types/types/vega-chart.d.ts +10 -11
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-d8fadcdc.entry.js → p-0037068c.entry.js} +1 -1
- package/dist/vega/{p-3d8122ab.entry.js → p-010ff53d.entry.js} +1 -1
- package/dist/vega/{p-bb5e0192.entry.js → p-03004a05.entry.js} +1 -1
- package/dist/vega/{p-f05b8f76.entry.js → p-0572c393.entry.js} +1 -1
- package/dist/vega/{p-02a7d60c.entry.js → p-0a3a285b.entry.js} +1 -1
- package/dist/vega/p-0d4cb1c7.entry.js +1 -0
- package/dist/vega/{p-a7a8a4eb.entry.js → p-100b44c3.entry.js} +1 -1
- package/dist/vega/{p-8dbdd609.entry.js → p-168bb296.entry.js} +1 -1
- package/dist/vega/{p-b136ebba.entry.js → p-1a011d47.entry.js} +1 -1
- package/dist/vega/{p-10734a00.js → p-1a51bf6f.js} +1 -1
- package/dist/vega/{p-6dcdb580.entry.js → p-1deedff2.entry.js} +1 -1
- package/dist/vega/{p-3244c605.entry.js → p-1fa0c7da.entry.js} +1 -1
- package/dist/vega/{p-dd3a94f4.entry.js → p-22056609.entry.js} +1 -1
- package/dist/vega/{p-c29068fb.entry.js → p-2b142818.entry.js} +1 -1
- package/dist/vega/{p-2ba78982.entry.js → p-34bcf4ed.entry.js} +1 -1
- package/dist/vega/{p-94a77fbe.entry.js → p-36a09524.entry.js} +1 -1
- package/dist/vega/{p-154f9cf7.entry.js → p-3c05abd9.entry.js} +1 -1
- package/dist/vega/{p-fd7ddd64.entry.js → p-3ce2b05c.entry.js} +1 -1
- package/dist/vega/{p-28ad1864.entry.js → p-43ff48c0.entry.js} +1 -1
- package/dist/vega/{p-ca5898dc.entry.js → p-4742feef.entry.js} +1 -1
- package/dist/vega/{p-eda988d5.entry.js → p-4aa52ed2.entry.js} +1 -1
- package/dist/vega/{p-d555f677.entry.js → p-4aa94940.entry.js} +1 -1
- package/dist/vega/p-4bee4202.entry.js +1 -0
- package/dist/vega/{p-01d58eb8.entry.js → p-50d074ed.entry.js} +1 -1
- package/dist/vega/{p-033c31d8.entry.js → p-5485c387.entry.js} +1 -1
- package/dist/vega/{p-f14a5eae.entry.js → p-560d2f48.entry.js} +1 -1
- package/dist/vega/{p-bebfbe95.entry.js → p-5833f33b.entry.js} +1 -1
- package/dist/vega/{p-b366deff.entry.js → p-592296d7.entry.js} +1 -1
- package/dist/vega/{p-5831d6d3.entry.js → p-5cfce62d.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-e1431c14.entry.js → p-60f77f5f.entry.js} +1 -1
- package/dist/vega/p-641cdb5c.entry.js +1 -0
- package/dist/vega/{p-32183637.entry.js → p-67745549.entry.js} +1 -1
- package/dist/vega/{p-087ea379.entry.js → p-70df91fb.entry.js} +1 -1
- package/dist/vega/{p-76181a70.entry.js → p-7425cedc.entry.js} +1 -1
- package/dist/vega/{p-89f2e16d.entry.js → p-857069a5.entry.js} +1 -1
- package/dist/vega/p-8e34b266.js +1 -0
- package/dist/vega/{p-32faa460.entry.js → p-9441f2ba.entry.js} +1 -1
- package/dist/vega/{p-2b49686d.entry.js → p-9fb877c1.entry.js} +1 -1
- package/dist/vega/p-a46e977b.entry.js +1 -0
- package/dist/vega/p-ac82b9f9.entry.js +1 -0
- package/dist/vega/p-b1773281.entry.js +1 -0
- package/dist/vega/{p-6d60b66a.entry.js → p-b54dc37c.entry.js} +1 -1
- package/dist/vega/{p-179aad4f.entry.js → p-b5f18f4b.entry.js} +1 -1
- package/dist/vega/{p-7181861a.js → p-bff57aa4.js} +1 -1
- package/dist/vega/{p-d7a78c5e.entry.js → p-c165232c.entry.js} +1 -1
- package/dist/vega/{p-8950987b.entry.js → p-c292ade4.entry.js} +1 -1
- package/dist/vega/p-c2d2faa0.js +1 -0
- package/dist/vega/{p-fc1fa345.js → p-cc5eaa1b.js} +1 -1
- package/dist/vega/p-cccd7648.entry.js +1 -0
- package/dist/vega/{p-7958614a.entry.js → p-cfecc1cb.entry.js} +1 -1
- package/dist/vega/{p-57927b10.entry.js → p-d07f5d5a.entry.js} +1 -1
- package/dist/vega/{p-9a137bab.entry.js → p-d1cfe972.entry.js} +1 -1
- package/dist/vega/{p-d6dbbe61.entry.js → p-d2ee5711.entry.js} +1 -1
- package/dist/vega/{p-b256b7a4.js → p-d78f6ede.js} +1 -1
- package/dist/vega/p-d8180e42.entry.js +1 -0
- package/dist/vega/{p-8b153acd.entry.js → p-daa60a59.entry.js} +1 -1
- package/dist/vega/{p-249df6d2.entry.js → p-db5fa164.entry.js} +1 -1
- package/dist/vega/p-de64f6e6.js +1 -0
- package/dist/vega/p-e4917e76.js +1 -0
- package/dist/vega/{p-2cc9d126.entry.js → p-e6cf2ace.entry.js} +1 -1
- package/dist/vega/p-e7fbef97.js +1 -0
- package/dist/vega/p-f3e6483c.js +1 -0
- package/dist/vega/{p-a560d8c5.entry.js → p-f428086c.entry.js} +1 -1
- package/dist/vega/{p-4e017458.entry.js → p-fc9ac6e9.entry.js} +1 -1
- package/dist/vega/{p-e2af0e24.entry.js → p-ffd48e37.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +2 -6
- package/dist/cjs/legend-input-processor-27c65353.js +0 -4759
- package/dist/cjs/y-axis-input-processor-9fbfd5e7.js +0 -2302
- package/dist/esm/legend-input-processor-5ecae3a7.js +0 -4742
- package/dist/esm/y-axis-input-processor-bc54314a.js +0 -2290
- package/dist/vega/p-1f5e35dc.entry.js +0 -1
- package/dist/vega/p-2e91295d.entry.js +0 -1
- package/dist/vega/p-32033e7a.js +0 -1
- package/dist/vega/p-46b077d9.js +0 -1
- package/dist/vega/p-4e4a0228.entry.js +0 -1
- package/dist/vega/p-644f701a.js +0 -1
- package/dist/vega/p-6a62e476.entry.js +0 -1
- package/dist/vega/p-a13a73fa.entry.js +0 -1
- package/dist/vega/p-be23bef2.js +0 -1
- package/dist/vega/p-c1d13eec.entry.js +0 -1
- package/dist/vega/p-e89e3ede.entry.js +0 -1
- package/dist/vega/p-f3d0f2dc.js +0 -1
- package/dist/vega/p-f5bafc45.entry.js +0 -1
- /package/dist/cjs/{feature-flag-controller-04cb1e69.js → feature-flag-controller-9129ef52.js} +0 -0
- /package/dist/esm/{feature-flag-controller-09ea7e87.js → feature-flag-controller-30f7b625.js} +0 -0
- /package/dist/vega/{p-07cb0243.js → p-18e8d9b7.js} +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { DIGIT_PLACEHOLDER, DUMMY_DIGIT, FIRST_GROUP_ONLY_PREFIX_PATTERN, LONGEST_NATIONAL_NUMBER_LENGTH, MIN_LEADING_DIGITS_LENGTH, } from './types';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Format-rule inspection
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
/**
|
|
6
|
+
* Check whether a format's replacement template only uses captured groups
|
|
7
|
+
* (doesn't insert extra digits). This mirrors NON_ALTERING_FORMAT_REG_EXP
|
|
8
|
+
* in the original library.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} replacement - the replacement string to test
|
|
11
|
+
* @returns {boolean} true if the format is non-altering
|
|
12
|
+
*/
|
|
13
|
+
export function isNonAlteringFormat(replacement) {
|
|
14
|
+
return /^[\s\-().]*\$1[\s\-().]*(\$\d[\s\-().]*)*$/.test(replacement);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if the format actually uses a national prefix when formatting.
|
|
18
|
+
* A format "uses" a national prefix if it has a nationalPrefixFormattingRule
|
|
19
|
+
* that is NOT just ($1) or $1.
|
|
20
|
+
*
|
|
21
|
+
* @param {FormatRule} formatRule - the format rule to inspect
|
|
22
|
+
* @returns {boolean} true if the format uses a national prefix
|
|
23
|
+
*/
|
|
24
|
+
function formatUsesNationalPrefix(formatRule) {
|
|
25
|
+
const rule = formatRule[3];
|
|
26
|
+
if (!rule)
|
|
27
|
+
return false;
|
|
28
|
+
if (FIRST_GROUP_ONLY_PREFIX_PATTERN.test(rule))
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if the national prefix is optional when formatting.
|
|
34
|
+
* In the metadata, format[4] being truthy indicates optional.
|
|
35
|
+
*
|
|
36
|
+
* @param {FormatRule} formatRule - the format rule to inspect
|
|
37
|
+
* @returns {boolean} true if the national prefix is optional
|
|
38
|
+
*/
|
|
39
|
+
function formatNationalPrefixIsOptional(formatRule) {
|
|
40
|
+
return !!formatRule[4];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns true if the national prefix is mandatory for this format.
|
|
44
|
+
* Mandatory = uses national prefix AND it's not optional.
|
|
45
|
+
*
|
|
46
|
+
* @param {FormatRule} formatRule - the format rule to inspect
|
|
47
|
+
* @returns {boolean} true if the national prefix is mandatory
|
|
48
|
+
*/
|
|
49
|
+
function formatNationalPrefixIsMandatory(formatRule) {
|
|
50
|
+
return formatUsesNationalPrefix(formatRule) && !formatNationalPrefixIsOptional(formatRule);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a format is suitable given the current formatting context.
|
|
54
|
+
* Mirrors formatSuits() from the original library's AsYouTypeFormatter.
|
|
55
|
+
*
|
|
56
|
+
* @param {FormatRule} formatRule - the format rule to check
|
|
57
|
+
* @param {boolean} international - whether the number is international
|
|
58
|
+
* @param {boolean} nationalPrefix - whether a national prefix is present
|
|
59
|
+
* @returns {boolean} true if the format is suitable
|
|
60
|
+
*/
|
|
61
|
+
export function formatSuits(formatRule, international, nationalPrefix) {
|
|
62
|
+
if (nationalPrefix &&
|
|
63
|
+
!formatUsesNationalPrefix(formatRule) &&
|
|
64
|
+
!formatNationalPrefixIsOptional(formatRule)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (!international && !nationalPrefix && formatNationalPrefixIsMandatory(formatRule)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Leading-digits matching
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* Check whether a format's leading digits match the given national number.
|
|
77
|
+
*
|
|
78
|
+
* @param {FormatRule} formatRule - the format rule to check
|
|
79
|
+
* @param {string} nationalNumber - the national number digits
|
|
80
|
+
* @param {number} leadingDigitsPatternIndex - index into the leading digits patterns
|
|
81
|
+
* @returns {boolean} true if the leading digits match
|
|
82
|
+
*/
|
|
83
|
+
export function formatMatchesLeadingDigits(formatRule, nationalNumber, leadingDigitsPatternIndex) {
|
|
84
|
+
const leadingDigitsPatterns = formatRule[2];
|
|
85
|
+
if (!leadingDigitsPatterns || leadingDigitsPatterns.length === 0) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
// Don't narrow down formats until we have enough leading digits.
|
|
89
|
+
// This matches the original libphonenumber-js behavior where formats are
|
|
90
|
+
// kept as candidates until MIN_LEADING_DIGITS_LENGTH digits are available.
|
|
91
|
+
if (nationalNumber.length < MIN_LEADING_DIGITS_LENGTH) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const index = Math.min(leadingDigitsPatternIndex, leadingDigitsPatterns.length - 1);
|
|
95
|
+
const pattern = leadingDigitsPatterns[index];
|
|
96
|
+
return new RegExp('^(' + pattern + ')').test(nationalNumber);
|
|
97
|
+
}
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Template building and population
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
/**
|
|
102
|
+
* Build a formatting template for a given format rule and national number.
|
|
103
|
+
*
|
|
104
|
+
* This replicates the template-generation logic from the original library:
|
|
105
|
+
* 1. Generate a dummy number of 9s matching the format pattern.
|
|
106
|
+
* 2. Format it with the replacement template.
|
|
107
|
+
* 3. Replace each 9 with the DIGIT_PLACEHOLDER.
|
|
108
|
+
*
|
|
109
|
+
* @param {FormatRule} formatRule - the format rule to build a template from
|
|
110
|
+
* @param {number} nationalSignificantNumberLength - length of the national significant number
|
|
111
|
+
* @returns {string | undefined} the built template, or undefined if no match
|
|
112
|
+
*/
|
|
113
|
+
export function buildTemplate(formatRule, nationalSignificantNumberLength) {
|
|
114
|
+
const [patternSrc, replacement] = formatRule;
|
|
115
|
+
let pattern = patternSrc;
|
|
116
|
+
// Simplify character classes and standalone digits to \d
|
|
117
|
+
pattern = pattern.replace(/\[([^\]]*)\]/g, '\\d');
|
|
118
|
+
pattern = pattern.replace(/\d(?=[^,}][^,}])/g, '\\d');
|
|
119
|
+
const longestDummy = DUMMY_DIGIT.repeat(LONGEST_NATIONAL_NUMBER_LENGTH);
|
|
120
|
+
const match = longestDummy.match(new RegExp(pattern));
|
|
121
|
+
if (!match)
|
|
122
|
+
return undefined;
|
|
123
|
+
let digits = match[0];
|
|
124
|
+
const strictPattern = new RegExp('^' + pattern + '$');
|
|
125
|
+
const nationalDummy = DUMMY_DIGIT.repeat(nationalSignificantNumberLength);
|
|
126
|
+
if (strictPattern.test(nationalDummy)) {
|
|
127
|
+
digits = nationalDummy;
|
|
128
|
+
}
|
|
129
|
+
if (nationalSignificantNumberLength > digits.length) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const template = digits
|
|
133
|
+
.replace(new RegExp(patternSrc), replacement)
|
|
134
|
+
.replace(new RegExp(DUMMY_DIGIT, 'g'), DIGIT_PLACEHOLDER);
|
|
135
|
+
return template;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Cut a template at a given position, handling closing parentheses.
|
|
139
|
+
* Matches the cut-and-strip logic from the original library.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} str - the template string to cut
|
|
142
|
+
* @param {number} cutBefore - the position to cut before
|
|
143
|
+
* @returns {string} the cut and stripped template
|
|
144
|
+
*/
|
|
145
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
146
|
+
export function cutAndStripNonPairedParens(str, cutBefore) {
|
|
147
|
+
if (str[cutBefore] === ')') {
|
|
148
|
+
cutBefore++;
|
|
149
|
+
}
|
|
150
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
151
|
+
return stripNonPairedParens(str.substring(0, cutBefore));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Remove unpaired ( from a string.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} str - the string to strip unpaired parentheses from
|
|
157
|
+
* @returns {string} the string with unpaired open parentheses removed
|
|
158
|
+
*/
|
|
159
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
160
|
+
function stripNonPairedParens(str) {
|
|
161
|
+
const unmatchedOpenPositions = [];
|
|
162
|
+
for (let i = 0; i < str.length; i++) {
|
|
163
|
+
if (str[i] === '(') {
|
|
164
|
+
unmatchedOpenPositions.push(i);
|
|
165
|
+
}
|
|
166
|
+
else if (str[i] === ')') {
|
|
167
|
+
unmatchedOpenPositions.pop();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
let result = str;
|
|
171
|
+
for (let i = unmatchedOpenPositions.length - 1; i >= 0; i--) {
|
|
172
|
+
const position = unmatchedOpenPositions[i];
|
|
173
|
+
result = result.substring(0, position) + result.substring(position + 1);
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Apply international separator style: replace parentheses and dashes with spaces.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} template - the template string to transform
|
|
181
|
+
* @returns {string} the template with international separator style applied
|
|
182
|
+
*/
|
|
183
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
184
|
+
export function applyInternationalSeparatorStyle(template) {
|
|
185
|
+
return template.replace(/[()]/g, '').replace(/[-]/g, ' ').replace(/ +/g, ' ').trim();
|
|
186
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal libphonenumber-js polyfill
|
|
3
|
+
*
|
|
4
|
+
* This module provides a zero-dependency replacement for the subset of
|
|
5
|
+
* `libphonenumber-js` used by `vega-input-phone-number`.
|
|
6
|
+
*
|
|
7
|
+
* Exported API surface:
|
|
8
|
+
* - getCountryCallingCode(country)
|
|
9
|
+
* - getCountries()
|
|
10
|
+
* - parseIncompletePhoneNumber(text)
|
|
11
|
+
* - formatIncompletePhoneNumber(number, country?)
|
|
12
|
+
* - parsePhoneNumber(text, optionsOrCountry?)
|
|
13
|
+
* - PhoneNumber (class)
|
|
14
|
+
* - AsYouType (class)
|
|
15
|
+
* - PARSE_ERROR_NOT_A_NUMBER (constant)
|
|
16
|
+
* - PARSE_ERROR_INVALID_COUNTRY (constant)
|
|
17
|
+
*/
|
|
18
|
+
export { getCountryCallingCode, getCountries } from './metadata';
|
|
19
|
+
export { parseIncompletePhoneNumber, parsePhoneNumber } from './parse-phone-number';
|
|
20
|
+
export { formatIncompletePhoneNumber, AsYouType } from './as-you-type';
|
|
21
|
+
export { PhoneNumber } from './phone-number';
|
|
22
|
+
export { PARSE_ERROR_NOT_A_NUMBER, PARSE_ERROR_INVALID_COUNTRY } from './types';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata singleton and accessor helpers for the libphonenumber polyfill.
|
|
3
|
+
*/
|
|
4
|
+
import rawMetadata from './metadata.json';
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Metadata singleton
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
export const META = rawMetadata;
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
11
|
+
// Metadata accessors
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Return the calling code string for a given country code.
|
|
15
|
+
*
|
|
16
|
+
* @param {VegaCountryCode} country - the country code to look up
|
|
17
|
+
* @returns {string} the calling code for the given country
|
|
18
|
+
* @example getCountryCallingCode('US') // '1'
|
|
19
|
+
*/
|
|
20
|
+
export function getCountryCallingCode(country) {
|
|
21
|
+
const entry = META.countries[country];
|
|
22
|
+
if (!entry) {
|
|
23
|
+
throw new Error('Unknown country: ' + country);
|
|
24
|
+
}
|
|
25
|
+
return entry[0];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Return an array of all supported country codes.
|
|
29
|
+
*
|
|
30
|
+
* @returns {VegaCountryCode[]} an array of supported country codes
|
|
31
|
+
*/
|
|
32
|
+
export function getCountries() {
|
|
33
|
+
return Object.keys(META.countries);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the list of format rules for a country. Returns undefined if none.
|
|
37
|
+
*
|
|
38
|
+
* @param {VegaCountryCode} country - the country code to retrieve formats for
|
|
39
|
+
* @returns {FormatRule[] | undefined} the format rules or undefined
|
|
40
|
+
*/
|
|
41
|
+
export function getFormats(country) {
|
|
42
|
+
const entry = META.countries[country];
|
|
43
|
+
if (!entry)
|
|
44
|
+
return undefined;
|
|
45
|
+
const formats = entry[4];
|
|
46
|
+
if (formats && Array.isArray(formats))
|
|
47
|
+
return formats;
|
|
48
|
+
// Country has no own formats — inherit from the primary country
|
|
49
|
+
// sharing the same calling code (e.g., CA/VI inherit from US).
|
|
50
|
+
const callingCode = entry[0];
|
|
51
|
+
const siblings = META.countryCallingCode[callingCode];
|
|
52
|
+
if (siblings) {
|
|
53
|
+
for (const sibling of siblings) {
|
|
54
|
+
if (sibling === country)
|
|
55
|
+
continue;
|
|
56
|
+
const siblingEntry = META.countries[sibling];
|
|
57
|
+
if (siblingEntry) {
|
|
58
|
+
const siblingFormats = siblingEntry[4];
|
|
59
|
+
if (siblingFormats && Array.isArray(siblingFormats))
|
|
60
|
+
return siblingFormats;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Country detection
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* Given digits (without leading +), detect which calling code prefix matches.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} digits - the digit string to detect a calling code from
|
|
73
|
+
* @returns {{ countries: string[] | undefined; callingCode: string | undefined }} the matched countries and calling code
|
|
74
|
+
*/
|
|
75
|
+
export function detectCallingCode(digits) {
|
|
76
|
+
for (let length = Math.min(3, digits.length); length >= 1; length--) {
|
|
77
|
+
const candidate = digits.substring(0, length);
|
|
78
|
+
const countries = META.countryCallingCode[candidate];
|
|
79
|
+
if (countries && countries.length > 0) {
|
|
80
|
+
return { countries, callingCode: candidate };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { countries: undefined, callingCode: undefined };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Determine the specific country from a set of countries sharing the same
|
|
87
|
+
* calling code, by checking leading digits patterns and validation patterns.
|
|
88
|
+
*
|
|
89
|
+
* Mirrors getCountryByNationalNumber from the original library.
|
|
90
|
+
*
|
|
91
|
+
* @param {string[]} possibleCountries - the candidate country codes
|
|
92
|
+
* @param {string} nationalNumber - the national number to match against
|
|
93
|
+
* @returns {VegaCountryCode | undefined} the matched country or undefined
|
|
94
|
+
*/
|
|
95
|
+
export function getCountryByNationalNumber(possibleCountries, nationalNumber) {
|
|
96
|
+
// First pass: check countries with leadingDigits (most specific).
|
|
97
|
+
for (const country of possibleCountries) {
|
|
98
|
+
const entry = META.countries[country];
|
|
99
|
+
if (!entry)
|
|
100
|
+
continue;
|
|
101
|
+
const leadingDigits = entry[10];
|
|
102
|
+
if (leadingDigits && typeof leadingDigits === 'string') {
|
|
103
|
+
const prefixMatch = new RegExp('^(?:' + leadingDigits + ')').test(nationalNumber);
|
|
104
|
+
if (nationalNumber && prefixMatch) {
|
|
105
|
+
return country;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Second pass: check countries by type patterns (without leadingDigits).
|
|
110
|
+
for (const country of possibleCountries) {
|
|
111
|
+
const entry = META.countries[country];
|
|
112
|
+
if (!entry)
|
|
113
|
+
continue;
|
|
114
|
+
const leadingDigits = entry[10];
|
|
115
|
+
if (leadingDigits && typeof leadingDigits === 'string') {
|
|
116
|
+
// Already handled in first pass.
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const types = entry[11];
|
|
120
|
+
if (types && Array.isArray(types)) {
|
|
121
|
+
if (matchesAnyType(nationalNumber, types)) {
|
|
122
|
+
return country;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check if a national number matches any of the type patterns.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} nationalNumber - the national number to test
|
|
132
|
+
* @param {unknown[]} types - the type pattern entries to match against
|
|
133
|
+
* @returns {boolean} whether the national number matches any type pattern
|
|
134
|
+
*/
|
|
135
|
+
function matchesAnyType(nationalNumber, types) {
|
|
136
|
+
for (const typeEntry of types) {
|
|
137
|
+
if (!typeEntry || typeEntry === 0)
|
|
138
|
+
continue;
|
|
139
|
+
if (Array.isArray(typeEntry)) {
|
|
140
|
+
const pattern = typeEntry[0];
|
|
141
|
+
if (typeof pattern === 'string' && pattern) {
|
|
142
|
+
const isMatch = new RegExp('^(?:' + pattern + ')$').test(nationalNumber);
|
|
143
|
+
if (isMatch) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|