@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.
Files changed (357) hide show
  1. package/dist/cjs/{app-globals-12b7d808.js → app-globals-04e7024b.js} +2 -2
  2. package/dist/cjs/aria-attributes-value-mapper-f58c73f8.js +136 -0
  3. package/dist/cjs/{child-nodes-event-prevent-slimmer-84435957.js → child-nodes-event-prevent-slimmer-cc6d2919.js} +1 -1
  4. package/dist/cjs/{design-token-41baf118.js → design-token-c49717c8.js} +1 -1
  5. package/dist/cjs/{element-appender-slimmer-34e4eb56.js → element-appender-slimmer-38583ca9.js} +2 -2
  6. package/dist/cjs/index.cjs.js +4 -4
  7. package/dist/cjs/legend-input-processor-1e53e5bc.js +2126 -0
  8. package/dist/cjs/loader.cjs.js +4 -4
  9. package/dist/cjs/{responsive-format-facade-ea59bdcd.js → responsive-format-facade-acc39a40.js} +1 -1
  10. package/dist/cjs/{style-formatter-0c3ced39.js → style-formatter-028af284.js} +1 -1
  11. package/dist/cjs/{token-extension-07cac85d.js → token-extension-ffcaeae0.js} +98 -77
  12. package/dist/cjs/vega-accordion.cjs.entry.js +5 -5
  13. package/dist/cjs/vega-app-header-button.cjs.entry.js +18 -143
  14. package/dist/cjs/vega-banner.cjs.entry.js +1 -1
  15. package/dist/cjs/vega-bar-chart.cjs.entry.js +2 -2
  16. package/dist/cjs/vega-box.cjs.entry.js +4 -4
  17. package/dist/cjs/vega-breadcrumb.cjs.entry.js +2 -2
  18. package/dist/cjs/vega-button-circle.cjs.entry.js +21 -6
  19. package/dist/cjs/vega-button-group_2.cjs.entry.js +2 -2
  20. package/dist/cjs/vega-button-link.cjs.entry.js +2 -2
  21. package/dist/cjs/vega-button.cjs.entry.js +3 -3
  22. package/dist/cjs/vega-calendar_4.cjs.entry.js +2 -2
  23. package/dist/cjs/vega-card.cjs.entry.js +3 -3
  24. package/dist/cjs/vega-carousel.cjs.entry.js +2 -2
  25. package/dist/cjs/vega-checkbox_2.cjs.entry.js +2 -2
  26. package/dist/cjs/vega-chip.cjs.entry.js +4 -4
  27. package/dist/cjs/vega-code-block.cjs.entry.js +2 -2
  28. package/dist/cjs/vega-combo-box.cjs.entry.js +2 -2
  29. package/dist/cjs/vega-date-picker_2.cjs.entry.js +29 -7
  30. package/dist/cjs/vega-dialog_2.cjs.entry.js +4 -4
  31. package/dist/cjs/vega-divider.cjs.entry.js +3 -3
  32. package/dist/cjs/vega-dropdown_5.cjs.entry.js +4 -4
  33. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  34. package/dist/cjs/vega-flag-icon.cjs.entry.js +3 -3
  35. package/dist/cjs/vega-flex.cjs.entry.js +4 -4
  36. package/dist/cjs/vega-font.cjs.entry.js +3 -3
  37. package/dist/cjs/vega-form.cjs.entry.js +2 -2
  38. package/dist/cjs/vega-grid.cjs.entry.js +3 -3
  39. package/dist/cjs/vega-icon.cjs.entry.js +3 -3
  40. package/dist/cjs/vega-image-uploader.cjs.entry.js +3 -3
  41. package/dist/cjs/vega-input-credit-card.cjs.entry.js +2 -2
  42. package/dist/cjs/vega-input-numeric.cjs.entry.js +2 -2
  43. package/dist/cjs/vega-input-passcode.cjs.entry.js +2 -2
  44. package/dist/cjs/vega-input-phone-number.cjs.entry.js +4753 -5585
  45. package/dist/cjs/vega-input-range.cjs.entry.js +2 -2
  46. package/dist/cjs/vega-input-select.cjs.entry.js +3 -3
  47. package/dist/cjs/vega-left-nav_5.cjs.entry.js +3 -3
  48. package/dist/cjs/vega-line-chart.cjs.entry.js +325 -23
  49. package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +2 -2
  50. package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +2 -2
  51. package/dist/cjs/vega-pagination.cjs.entry.js +3 -3
  52. package/dist/cjs/vega-pie-chart.cjs.entry.js +5 -88
  53. package/dist/cjs/vega-popover_2.cjs.entry.js +4 -4
  54. package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +2 -2
  55. package/dist/cjs/vega-radio_2.cjs.entry.js +2 -2
  56. package/dist/cjs/vega-rich-text-content.cjs.entry.js +14 -0
  57. package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +2 -2
  58. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +3 -3
  59. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +2 -2
  60. package/dist/cjs/vega-sidenav_3.cjs.entry.js +2 -2
  61. package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -3
  62. package/dist/cjs/vega-stepper.cjs.entry.js +2 -2
  63. package/dist/cjs/vega-tab-group_2.cjs.entry.js +2 -2
  64. package/dist/cjs/vega-table_11.cjs.entry.js +3 -3
  65. package/dist/cjs/vega-textarea.cjs.entry.js +2 -2
  66. package/dist/cjs/vega-time-picker_2.cjs.entry.js +4 -4
  67. package/dist/cjs/vega-tooltip_2.cjs.entry.js +3 -3
  68. package/dist/cjs/vega.cjs.js +4 -4
  69. package/dist/cjs/y-axis-input-processor-54a26515.js +832 -0
  70. package/dist/collection/components/vega-accordion/slimmers/vega-accordion-renderer.js +1 -1
  71. package/dist/collection/components/vega-accordion/vega-accordion.css +5 -0
  72. package/dist/collection/components/vega-button-circle/vega-button-circle.js +17 -3
  73. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.js +16 -2
  74. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.css +184 -207
  75. package/dist/collection/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.js +32 -0
  76. package/dist/collection/components/vega-input-phone-number/slimmers/controllers/country-select-controller.js +1 -1
  77. package/dist/collection/components/vega-input-phone-number/slimmers/controllers/vega-input-phone-number-value-controller.js +1 -1
  78. package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +1 -1
  79. package/dist/collection/components/vega-input-phone-number/slimmers/renderers/phone-number-input-renderer.js +1 -1
  80. package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +4 -4
  81. package/dist/collection/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.js +15 -0
  82. package/dist/collection/components/vega-rich-text-editor/extensions/base-extension-renderer.js +11 -0
  83. package/dist/collection/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.js +15 -1
  84. package/dist/collection/components/vega-rich-text-editor/extensions/extension.abstract.js +2 -0
  85. package/dist/collection/components/vega-rich-text-editor/extensions/functions/function-extension.js +0 -11
  86. package/dist/collection/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.js +23 -23
  87. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-extension.js +0 -10
  88. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.js +7 -17
  89. package/dist/collection/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.js +12 -16
  90. package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.js +31 -0
  91. package/dist/collection/components/vega-rich-text-editor/helpers/extension-context-manager.test.js +19 -0
  92. package/dist/collection/components/vega-rich-text-editor/test/extensions/extension-test-utils.js +41 -0
  93. package/dist/collection/helpers/chart/input-processors/format-time-positions-input-processor.js +2 -2
  94. package/dist/collection/helpers/chart/input-processors/pie-chart-arc-path-input-processor.js +1 -1
  95. package/dist/collection/helpers/chart/input-processors/x-axis-input-processor.js +5 -3
  96. package/dist/collection/helpers/chart/input-processors/x-axis-label-formatter-input-processor.js +2 -1
  97. package/dist/collection/helpers/chart/input-processors/y-axis-input-processor.js +7 -5
  98. package/dist/collection/helpers/chart/interacting-entry-generator/arc-path-hover-generator.js +1 -1
  99. package/dist/collection/helpers/chart/interacting-entry-generator/pie-legend-hover-generator.js +1 -1
  100. package/dist/collection/helpers/chart/renderers/canvas-renderer.js +1 -1
  101. package/dist/collection/helpers/chart/renderers/svg-renderer.js +1 -1
  102. package/dist/collection/helpers/chart/test/drawers/arc-path-drawer.test.js +1 -1
  103. package/dist/collection/helpers/chart/test/input-processors/format-time-positions-input-processor.test.js +1 -1
  104. package/dist/collection/helpers/chart/test/input-processors/sort-positions-input-processor.test.js +1 -1
  105. package/dist/collection/helpers/chart/test/input-processors/x-axis-input-processor.test.js +39 -0
  106. package/dist/collection/helpers/chart/test/input-processors/x-axis-label-formatter-input-processor.test.js +61 -14
  107. package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.js +39 -0
  108. package/dist/collection/helpers/chart/test/input-processors/y-axis-input-processor.test.js +14 -0
  109. package/dist/collection/helpers/chart/test/renderers/svg-renderer.test.js +1 -1
  110. package/dist/collection/helpers/common/test/wait-for-component-did-render.test.js +67 -0
  111. package/dist/collection/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.js +4 -0
  112. package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +1 -1
  113. package/dist/collection/helpers/validator/rules/valid-phone-number-rule.js +1 -1
  114. package/dist/collection/helpers/validator/test/rules/valid-phone-number-rule.test.js +10 -0
  115. package/dist/collection/polyfill/d3/d3-array-polyfill.js +89 -0
  116. package/dist/collection/polyfill/d3/d3-axis-polyfill.js +195 -0
  117. package/dist/collection/polyfill/d3/d3-scale-polyfill.js +582 -0
  118. package/dist/collection/polyfill/d3/d3-selection-polyfill.js +274 -0
  119. package/dist/collection/polyfill/d3/d3-shape-polyfill.js +252 -0
  120. package/dist/collection/polyfill/d3/d3-time-format-polyfill.js +207 -0
  121. package/dist/collection/polyfill/d3/d3-time-polyfill.js +99 -0
  122. package/dist/collection/polyfill/d3/index.js +31 -0
  123. package/dist/collection/polyfill/d3/test/d3-array-polyfill.test.js +72 -0
  124. package/dist/collection/polyfill/d3/test/d3-axis-polyfill.test.js +171 -0
  125. package/dist/collection/polyfill/d3/test/d3-integration.test.js +137 -0
  126. package/dist/collection/polyfill/d3/test/d3-scale-polyfill.test.js +382 -0
  127. package/dist/collection/polyfill/d3/test/d3-selection-polyfill.test.js +239 -0
  128. package/dist/collection/polyfill/d3/test/d3-shape-polyfill.test.js +225 -0
  129. package/dist/collection/polyfill/d3/test/d3-time-format-polyfill.test.js +162 -0
  130. package/dist/collection/polyfill/d3/test/d3-time-polyfill.test.js +76 -0
  131. package/dist/collection/polyfill/d3/test/index.test.js +78 -0
  132. package/dist/collection/polyfill/libphonenumber/as-you-type.js +405 -0
  133. package/dist/collection/polyfill/libphonenumber/format-helpers.js +186 -0
  134. package/dist/collection/polyfill/libphonenumber/index.js +22 -0
  135. package/dist/collection/polyfill/libphonenumber/metadata.js +150 -0
  136. package/dist/collection/polyfill/libphonenumber/metadata.json.js +3900 -0
  137. package/dist/collection/polyfill/libphonenumber/parse-phone-number.js +127 -0
  138. package/dist/collection/polyfill/libphonenumber/phone-number.js +38 -0
  139. package/dist/collection/polyfill/libphonenumber/test/as-you-type.test.js +309 -0
  140. package/dist/collection/polyfill/libphonenumber/test/format-helpers.test.js +192 -0
  141. package/dist/collection/polyfill/libphonenumber/test/index.test.js +16 -0
  142. package/dist/collection/polyfill/libphonenumber/test/metadata.test.js +196 -0
  143. package/dist/collection/polyfill/libphonenumber/test/parse-phone-number.test.js +218 -0
  144. package/dist/collection/polyfill/libphonenumber/test/phone-number.test.js +56 -0
  145. package/dist/collection/polyfill/libphonenumber/types.js +23 -0
  146. package/dist/esm/{app-globals-c0676920.js → app-globals-32055795.js} +2 -2
  147. package/dist/esm/aria-attributes-value-mapper-d4fef46a.js +134 -0
  148. package/dist/esm/{child-nodes-event-prevent-slimmer-649b9d30.js → child-nodes-event-prevent-slimmer-331312b8.js} +1 -1
  149. package/dist/esm/{design-token-4aee1c56.js → design-token-5bc034e1.js} +1 -1
  150. package/dist/esm/{element-appender-slimmer-e4713a72.js → element-appender-slimmer-9ea377d0.js} +2 -2
  151. package/dist/esm/index.js +4 -4
  152. package/dist/esm/legend-input-processor-122008c5.js +2116 -0
  153. package/dist/esm/loader.js +4 -4
  154. package/dist/esm/{responsive-format-facade-7a071174.js → responsive-format-facade-aa705823.js} +1 -1
  155. package/dist/esm/{style-formatter-3d06b72d.js → style-formatter-28138f5c.js} +1 -1
  156. package/dist/esm/{token-extension-e33fd151.js → token-extension-73e4460a.js} +98 -77
  157. package/dist/esm/vega-accordion.entry.js +5 -5
  158. package/dist/esm/vega-app-header-button.entry.js +17 -142
  159. package/dist/esm/vega-banner.entry.js +1 -1
  160. package/dist/esm/vega-bar-chart.entry.js +2 -2
  161. package/dist/esm/vega-box.entry.js +4 -4
  162. package/dist/esm/vega-breadcrumb.entry.js +2 -2
  163. package/dist/esm/vega-button-circle.entry.js +21 -6
  164. package/dist/esm/vega-button-group_2.entry.js +2 -2
  165. package/dist/esm/vega-button-link.entry.js +2 -2
  166. package/dist/esm/vega-button.entry.js +3 -3
  167. package/dist/esm/vega-calendar_4.entry.js +2 -2
  168. package/dist/esm/vega-card.entry.js +3 -3
  169. package/dist/esm/vega-carousel.entry.js +2 -2
  170. package/dist/esm/vega-checkbox_2.entry.js +2 -2
  171. package/dist/esm/vega-chip.entry.js +4 -4
  172. package/dist/esm/vega-code-block.entry.js +2 -2
  173. package/dist/esm/vega-combo-box.entry.js +2 -2
  174. package/dist/esm/vega-date-picker_2.entry.js +29 -7
  175. package/dist/esm/vega-dialog_2.entry.js +4 -4
  176. package/dist/esm/vega-divider.entry.js +3 -3
  177. package/dist/esm/vega-dropdown_5.entry.js +4 -4
  178. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  179. package/dist/esm/vega-flag-icon.entry.js +3 -3
  180. package/dist/esm/vega-flex.entry.js +4 -4
  181. package/dist/esm/vega-font.entry.js +3 -3
  182. package/dist/esm/vega-form.entry.js +2 -2
  183. package/dist/esm/vega-grid.entry.js +3 -3
  184. package/dist/esm/vega-icon.entry.js +3 -3
  185. package/dist/esm/vega-image-uploader.entry.js +3 -3
  186. package/dist/esm/vega-input-credit-card.entry.js +2 -2
  187. package/dist/esm/vega-input-numeric.entry.js +2 -2
  188. package/dist/esm/vega-input-passcode.entry.js +2 -2
  189. package/dist/esm/vega-input-phone-number.entry.js +4753 -5585
  190. package/dist/esm/vega-input-range.entry.js +2 -2
  191. package/dist/esm/vega-input-select.entry.js +3 -3
  192. package/dist/esm/vega-left-nav_5.entry.js +3 -3
  193. package/dist/esm/vega-line-chart.entry.js +311 -9
  194. package/dist/esm/vega-loader-wrapper_2.entry.js +2 -2
  195. package/dist/esm/vega-pagination-page-selector-mobile.entry.js +2 -2
  196. package/dist/esm/vega-pagination.entry.js +3 -3
  197. package/dist/esm/vega-pie-chart.entry.js +5 -88
  198. package/dist/esm/vega-popover_2.entry.js +4 -4
  199. package/dist/esm/vega-progress-tracker_2.entry.js +2 -2
  200. package/dist/esm/vega-radio_2.entry.js +2 -2
  201. package/dist/esm/vega-rich-text-content.entry.js +14 -0
  202. package/dist/esm/vega-rich-text-editor_4.entry.js +2 -2
  203. package/dist/esm/vega-selection-chip_2.entry.js +3 -3
  204. package/dist/esm/vega-selection-tile_2.entry.js +2 -2
  205. package/dist/esm/vega-sidenav_3.entry.js +2 -2
  206. package/dist/esm/vega-signature-capture.entry.js +3 -3
  207. package/dist/esm/vega-stepper.entry.js +2 -2
  208. package/dist/esm/vega-tab-group_2.entry.js +2 -2
  209. package/dist/esm/vega-table_11.entry.js +3 -3
  210. package/dist/esm/vega-textarea.entry.js +2 -2
  211. package/dist/esm/vega-time-picker_2.entry.js +4 -4
  212. package/dist/esm/vega-tooltip_2.entry.js +3 -3
  213. package/dist/esm/vega.js +4 -4
  214. package/dist/esm/y-axis-input-processor-c7e05353.js +826 -0
  215. package/dist/sri/vega-sri-manifest.json +234 -230
  216. package/dist/types/components/vega-button-circle/vega-button-circle.d.ts +2 -0
  217. package/dist/types/components/vega-date-picker/types.d.ts +14 -0
  218. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/slimmers/renderers/vega-date-picker-month-item-renderer.d.ts +3 -0
  219. package/dist/types/components/vega-date-picker/vega-date-picker-calendar/vega-date-picker-calendar.d.ts +9 -1
  220. package/dist/types/components/vega-rich-text-content/slimmers/renderers/vega-rich-text-content-renderer.d.ts +6 -0
  221. package/dist/types/components/vega-rich-text-editor/extensions/base-extension-renderer.d.ts +9 -1
  222. package/dist/types/components/vega-rich-text-editor/extensions/base-toolbar-button-renderer.d.ts +9 -1
  223. package/dist/types/components/vega-rich-text-editor/extensions/functions/function-extension.d.ts +0 -7
  224. package/dist/types/components/vega-rich-text-editor/extensions/functions/renderers/function-toolbar-button-renderer.d.ts +5 -10
  225. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-extension.d.ts +1 -5
  226. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-node-renderer.d.ts +3 -8
  227. package/dist/types/components/vega-rich-text-editor/extensions/tokens/token-toolbar-button-renderer.d.ts +5 -9
  228. package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.d.ts +26 -0
  229. package/dist/types/components/vega-rich-text-editor/helpers/extension-context-manager.test.d.ts +1 -0
  230. package/dist/types/components/vega-rich-text-editor/interface.d.ts +4 -0
  231. package/dist/types/components/vega-rich-text-editor/test/extensions/extension-test-utils.d.ts +21 -0
  232. package/dist/types/components.d.ts +11 -1
  233. package/dist/types/helpers/chart/test/input-processors/y-axis-input-processor.coverage.test.d.ts +1 -0
  234. package/dist/types/helpers/common/test/wait-for-component-did-render.test.d.ts +1 -0
  235. package/dist/types/polyfill/d3/d3-array-polyfill.d.ts +48 -0
  236. package/dist/types/polyfill/d3/d3-axis-polyfill.d.ts +53 -0
  237. package/dist/types/polyfill/d3/d3-scale-polyfill.d.ts +42 -0
  238. package/dist/types/polyfill/d3/d3-selection-polyfill.d.ts +173 -0
  239. package/dist/types/polyfill/d3/d3-shape-polyfill.d.ts +129 -0
  240. package/dist/types/polyfill/d3/d3-time-format-polyfill.d.ts +28 -0
  241. package/dist/types/polyfill/d3/d3-time-polyfill.d.ts +68 -0
  242. package/dist/types/polyfill/d3/index.d.ts +27 -0
  243. package/dist/types/polyfill/d3/test/d3-array-polyfill.test.d.ts +1 -0
  244. package/dist/types/polyfill/d3/test/d3-axis-polyfill.test.d.ts +1 -0
  245. package/dist/types/polyfill/d3/test/d3-integration.test.d.ts +1 -0
  246. package/dist/types/polyfill/d3/test/d3-scale-polyfill.test.d.ts +1 -0
  247. package/dist/types/polyfill/d3/test/d3-selection-polyfill.test.d.ts +1 -0
  248. package/dist/types/polyfill/d3/test/d3-shape-polyfill.test.d.ts +1 -0
  249. package/dist/types/polyfill/d3/test/d3-time-format-polyfill.test.d.ts +1 -0
  250. package/dist/types/polyfill/d3/test/d3-time-polyfill.test.d.ts +1 -0
  251. package/dist/types/polyfill/d3/test/index.test.d.ts +1 -0
  252. package/dist/types/polyfill/libphonenumber/as-you-type.d.ts +154 -0
  253. package/dist/types/polyfill/libphonenumber/format-helpers.d.ts +64 -0
  254. package/dist/types/polyfill/libphonenumber/index.d.ts +22 -0
  255. package/dist/types/polyfill/libphonenumber/metadata.d.ts +45 -0
  256. package/dist/types/polyfill/libphonenumber/metadata.json.d.ts +470 -0
  257. package/dist/types/polyfill/libphonenumber/parse-phone-number.d.ts +26 -0
  258. package/dist/types/polyfill/libphonenumber/phone-number.d.ts +24 -0
  259. package/dist/types/polyfill/libphonenumber/test/as-you-type.test.d.ts +1 -0
  260. package/dist/types/polyfill/libphonenumber/test/format-helpers.test.d.ts +1 -0
  261. package/dist/types/polyfill/libphonenumber/test/index.test.d.ts +1 -0
  262. package/dist/types/polyfill/libphonenumber/test/metadata.test.d.ts +1 -0
  263. package/dist/types/polyfill/libphonenumber/test/parse-phone-number.test.d.ts +1 -0
  264. package/dist/types/polyfill/libphonenumber/test/phone-number.test.d.ts +1 -0
  265. package/dist/types/polyfill/libphonenumber/types.d.ts +77 -0
  266. package/dist/types/types/components.type.d.ts +1 -0
  267. package/dist/types/types/flag.type.d.ts +255 -4
  268. package/dist/types/types/vega-chart.d.ts +10 -11
  269. package/dist/vega/index.esm.js +1 -1
  270. package/dist/vega/{p-d8fadcdc.entry.js → p-0037068c.entry.js} +1 -1
  271. package/dist/vega/{p-3d8122ab.entry.js → p-010ff53d.entry.js} +1 -1
  272. package/dist/vega/{p-bb5e0192.entry.js → p-03004a05.entry.js} +1 -1
  273. package/dist/vega/{p-f05b8f76.entry.js → p-0572c393.entry.js} +1 -1
  274. package/dist/vega/{p-02a7d60c.entry.js → p-0a3a285b.entry.js} +1 -1
  275. package/dist/vega/p-0d4cb1c7.entry.js +1 -0
  276. package/dist/vega/{p-a7a8a4eb.entry.js → p-100b44c3.entry.js} +1 -1
  277. package/dist/vega/{p-8dbdd609.entry.js → p-168bb296.entry.js} +1 -1
  278. package/dist/vega/{p-b136ebba.entry.js → p-1a011d47.entry.js} +1 -1
  279. package/dist/vega/{p-10734a00.js → p-1a51bf6f.js} +1 -1
  280. package/dist/vega/{p-6dcdb580.entry.js → p-1deedff2.entry.js} +1 -1
  281. package/dist/vega/{p-3244c605.entry.js → p-1fa0c7da.entry.js} +1 -1
  282. package/dist/vega/{p-dd3a94f4.entry.js → p-22056609.entry.js} +1 -1
  283. package/dist/vega/{p-c29068fb.entry.js → p-2b142818.entry.js} +1 -1
  284. package/dist/vega/{p-2ba78982.entry.js → p-34bcf4ed.entry.js} +1 -1
  285. package/dist/vega/{p-94a77fbe.entry.js → p-36a09524.entry.js} +1 -1
  286. package/dist/vega/{p-154f9cf7.entry.js → p-3c05abd9.entry.js} +1 -1
  287. package/dist/vega/{p-fd7ddd64.entry.js → p-3ce2b05c.entry.js} +1 -1
  288. package/dist/vega/{p-28ad1864.entry.js → p-43ff48c0.entry.js} +1 -1
  289. package/dist/vega/{p-ca5898dc.entry.js → p-4742feef.entry.js} +1 -1
  290. package/dist/vega/{p-eda988d5.entry.js → p-4aa52ed2.entry.js} +1 -1
  291. package/dist/vega/{p-d555f677.entry.js → p-4aa94940.entry.js} +1 -1
  292. package/dist/vega/p-4bee4202.entry.js +1 -0
  293. package/dist/vega/{p-01d58eb8.entry.js → p-50d074ed.entry.js} +1 -1
  294. package/dist/vega/{p-033c31d8.entry.js → p-5485c387.entry.js} +1 -1
  295. package/dist/vega/{p-f14a5eae.entry.js → p-560d2f48.entry.js} +1 -1
  296. package/dist/vega/{p-bebfbe95.entry.js → p-5833f33b.entry.js} +1 -1
  297. package/dist/vega/{p-b366deff.entry.js → p-592296d7.entry.js} +1 -1
  298. package/dist/vega/{p-5831d6d3.entry.js → p-5cfce62d.entry.js} +1 -1
  299. package/dist/vega/p-5f377954.js +1 -1
  300. package/dist/vega/{p-e1431c14.entry.js → p-60f77f5f.entry.js} +1 -1
  301. package/dist/vega/p-641cdb5c.entry.js +1 -0
  302. package/dist/vega/{p-32183637.entry.js → p-67745549.entry.js} +1 -1
  303. package/dist/vega/{p-087ea379.entry.js → p-70df91fb.entry.js} +1 -1
  304. package/dist/vega/{p-76181a70.entry.js → p-7425cedc.entry.js} +1 -1
  305. package/dist/vega/{p-89f2e16d.entry.js → p-857069a5.entry.js} +1 -1
  306. package/dist/vega/p-8e34b266.js +1 -0
  307. package/dist/vega/{p-32faa460.entry.js → p-9441f2ba.entry.js} +1 -1
  308. package/dist/vega/{p-2b49686d.entry.js → p-9fb877c1.entry.js} +1 -1
  309. package/dist/vega/p-a46e977b.entry.js +1 -0
  310. package/dist/vega/p-ac82b9f9.entry.js +1 -0
  311. package/dist/vega/p-b1773281.entry.js +1 -0
  312. package/dist/vega/{p-6d60b66a.entry.js → p-b54dc37c.entry.js} +1 -1
  313. package/dist/vega/{p-179aad4f.entry.js → p-b5f18f4b.entry.js} +1 -1
  314. package/dist/vega/{p-7181861a.js → p-bff57aa4.js} +1 -1
  315. package/dist/vega/{p-d7a78c5e.entry.js → p-c165232c.entry.js} +1 -1
  316. package/dist/vega/{p-8950987b.entry.js → p-c292ade4.entry.js} +1 -1
  317. package/dist/vega/p-c2d2faa0.js +1 -0
  318. package/dist/vega/{p-fc1fa345.js → p-cc5eaa1b.js} +1 -1
  319. package/dist/vega/p-cccd7648.entry.js +1 -0
  320. package/dist/vega/{p-7958614a.entry.js → p-cfecc1cb.entry.js} +1 -1
  321. package/dist/vega/{p-57927b10.entry.js → p-d07f5d5a.entry.js} +1 -1
  322. package/dist/vega/{p-9a137bab.entry.js → p-d1cfe972.entry.js} +1 -1
  323. package/dist/vega/{p-d6dbbe61.entry.js → p-d2ee5711.entry.js} +1 -1
  324. package/dist/vega/{p-b256b7a4.js → p-d78f6ede.js} +1 -1
  325. package/dist/vega/p-d8180e42.entry.js +1 -0
  326. package/dist/vega/{p-8b153acd.entry.js → p-daa60a59.entry.js} +1 -1
  327. package/dist/vega/{p-249df6d2.entry.js → p-db5fa164.entry.js} +1 -1
  328. package/dist/vega/p-de64f6e6.js +1 -0
  329. package/dist/vega/p-e4917e76.js +1 -0
  330. package/dist/vega/{p-2cc9d126.entry.js → p-e6cf2ace.entry.js} +1 -1
  331. package/dist/vega/p-e7fbef97.js +1 -0
  332. package/dist/vega/p-f3e6483c.js +1 -0
  333. package/dist/vega/{p-a560d8c5.entry.js → p-f428086c.entry.js} +1 -1
  334. package/dist/vega/{p-4e017458.entry.js → p-fc9ac6e9.entry.js} +1 -1
  335. package/dist/vega/{p-e2af0e24.entry.js → p-ffd48e37.entry.js} +1 -1
  336. package/dist/vega/vega.esm.js +1 -1
  337. package/package.json +2 -6
  338. package/dist/cjs/legend-input-processor-27c65353.js +0 -4759
  339. package/dist/cjs/y-axis-input-processor-9fbfd5e7.js +0 -2302
  340. package/dist/esm/legend-input-processor-5ecae3a7.js +0 -4742
  341. package/dist/esm/y-axis-input-processor-bc54314a.js +0 -2290
  342. package/dist/vega/p-1f5e35dc.entry.js +0 -1
  343. package/dist/vega/p-2e91295d.entry.js +0 -1
  344. package/dist/vega/p-32033e7a.js +0 -1
  345. package/dist/vega/p-46b077d9.js +0 -1
  346. package/dist/vega/p-4e4a0228.entry.js +0 -1
  347. package/dist/vega/p-644f701a.js +0 -1
  348. package/dist/vega/p-6a62e476.entry.js +0 -1
  349. package/dist/vega/p-a13a73fa.entry.js +0 -1
  350. package/dist/vega/p-be23bef2.js +0 -1
  351. package/dist/vega/p-c1d13eec.entry.js +0 -1
  352. package/dist/vega/p-e89e3ede.entry.js +0 -1
  353. package/dist/vega/p-f3d0f2dc.js +0 -1
  354. package/dist/vega/p-f5bafc45.entry.js +0 -1
  355. /package/dist/cjs/{feature-flag-controller-04cb1e69.js → feature-flag-controller-9129ef52.js} +0 -0
  356. /package/dist/esm/{feature-flag-controller-09ea7e87.js → feature-flag-controller-30f7b625.js} +0 -0
  357. /package/dist/vega/{p-07cb0243.js → p-18e8d9b7.js} +0 -0
@@ -0,0 +1,127 @@
1
+ import { PARSE_ERROR_NOT_A_NUMBER, PARSE_ERROR_INVALID_COUNTRY } from './types';
2
+ import { META, getCountryCallingCode, detectCallingCode, getCountryByNationalNumber } from './metadata';
3
+ import { PhoneNumber } from './phone-number';
4
+ // ---------------------------------------------------------------------------
5
+ // parseIncompletePhoneNumber
6
+ // ---------------------------------------------------------------------------
7
+ /**
8
+ * Strip everything except digits and a leading +.
9
+ *
10
+ * Mirrors the behavior of libphonenumber-js/core parseIncompletePhoneNumber.
11
+ *
12
+ * @param {string} text - The raw phone number input to sanitize.
13
+ * @returns {string} The sanitized string containing only digits and an optional leading +.
14
+ * @example parseIncompletePhoneNumber('(302) 333-4444') // '3023334444'
15
+ * @example parseIncompletePhoneNumber('+1 (302) 333-4444') // '+13023334444'
16
+ */
17
+ export function parseIncompletePhoneNumber(text) {
18
+ let result = '';
19
+ for (let i = 0; i < text.length; i++) {
20
+ const char = text[i];
21
+ if (char === '+' && result.length === 0) {
22
+ result += '+';
23
+ }
24
+ else if (char >= '0' && char <= '9') {
25
+ result += char;
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ // ---------------------------------------------------------------------------
31
+ // parsePhoneNumber
32
+ // ---------------------------------------------------------------------------
33
+ /**
34
+ * Parse a phone number string into a PhoneNumber instance.
35
+ *
36
+ * @param {string} text - The raw phone number string to parse.
37
+ * @param {VegaCountryCode | ParsePhoneNumberOptions} [optionsOrCountry] - A default country code or parsing options.
38
+ * @returns {PhoneNumber} The parsed PhoneNumber instance.
39
+ * @throws {Error} if the input cannot be parsed.
40
+ */
41
+ export function parsePhoneNumber(text, optionsOrCountry) {
42
+ var _a;
43
+ const options = typeof optionsOrCountry === 'string' ? { defaultCountry: optionsOrCountry } : optionsOrCountry !== null && optionsOrCountry !== void 0 ? optionsOrCountry : {};
44
+ const { defaultCountry, extract = true } = options;
45
+ const cleaned = parseIncompletePhoneNumber(text);
46
+ if (!cleaned || cleaned === '+') {
47
+ throw new Error(PARSE_ERROR_NOT_A_NUMBER);
48
+ }
49
+ if (!extract) {
50
+ const stripped = text.replace(/[\s\-().+]/g, '');
51
+ if (!/^\d*$/.test(stripped)) {
52
+ throw new Error(PARSE_ERROR_NOT_A_NUMBER);
53
+ }
54
+ }
55
+ let callingCode = '';
56
+ let nationalNumber;
57
+ let country;
58
+ if (cleaned.startsWith('+')) {
59
+ const digits = cleaned.substring(1);
60
+ const detected = detectCallingCode(digits);
61
+ callingCode = (_a = detected.callingCode) !== null && _a !== void 0 ? _a : '';
62
+ if (!callingCode) {
63
+ throw new Error(PARSE_ERROR_INVALID_COUNTRY);
64
+ }
65
+ nationalNumber = digits.substring(callingCode.length);
66
+ // For NANPA (calling code '1'), strip the trunk prefix '1' if present.
67
+ // E.g. '+113405100000' → nationalNumber '3405100000' so VI can be detected.
68
+ if (callingCode === '1' && nationalNumber.length === 11 && nationalNumber.startsWith('1')) {
69
+ nationalNumber = nationalNumber.substring(1);
70
+ }
71
+ const possibleCountries = detected.countries;
72
+ if (possibleCountries && possibleCountries.length === 1) {
73
+ country = possibleCountries[0];
74
+ }
75
+ else if (possibleCountries && possibleCountries.length > 1) {
76
+ country = getCountryByNationalNumber(possibleCountries, nationalNumber);
77
+ }
78
+ }
79
+ else {
80
+ if (!defaultCountry) {
81
+ throw new Error(PARSE_ERROR_INVALID_COUNTRY);
82
+ }
83
+ callingCode = getCountryCallingCode(defaultCountry);
84
+ nationalNumber = cleaned;
85
+ // For NANPA countries (calling code '1'), the trunk prefix '1' may
86
+ // need to be stripped. E.g. '13405100000' → '3405100000' so that
87
+ // VI (leadingDigits 340) can be detected.
88
+ if (callingCode === '1' && nationalNumber.length === 11 && nationalNumber.startsWith('1')) {
89
+ nationalNumber = nationalNumber.substring(1);
90
+ }
91
+ // For countries sharing a calling code (e.g., NANPA), check if the
92
+ // national number actually belongs to a different country in the group.
93
+ const siblings = META.countryCallingCode[callingCode];
94
+ if (siblings && siblings.length > 1) {
95
+ const detected = getCountryByNationalNumber(siblings, nationalNumber);
96
+ country = detected !== null && detected !== void 0 ? detected : defaultCountry;
97
+ }
98
+ else {
99
+ country = defaultCountry;
100
+ }
101
+ }
102
+ // Extract the national number by stripping the national prefix, if applicable.
103
+ // Mirrors extractNationalNumber from the original library:
104
+ // 1. Match nationalPrefixForParsing against the beginning of nationalNumber.
105
+ // 2. If the original number already matches the validation pattern, keep it.
106
+ // 3. Otherwise, if the stripped version matches the validation pattern, use it.
107
+ if (country) {
108
+ const entry = META.countries[country];
109
+ if (entry) {
110
+ const prefixPattern = entry[7];
111
+ if (prefixPattern && typeof prefixPattern === 'string') {
112
+ const prefixMatch = nationalNumber.match(new RegExp('^(?:' + prefixPattern + ')'));
113
+ if (prefixMatch && prefixMatch[0].length > 0) {
114
+ const afterPrefix = nationalNumber.substring(prefixMatch[0].length);
115
+ const validPattern = entry[2];
116
+ const validRegex = new RegExp('^(?:' + validPattern + ')$');
117
+ const originalMatches = validRegex.test(nationalNumber);
118
+ const strippedMatches = afterPrefix.length > 0 && validRegex.test(afterPrefix);
119
+ if (!originalMatches && strippedMatches) {
120
+ nationalNumber = afterPrefix;
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return new PhoneNumber(callingCode, nationalNumber, country);
127
+ }
@@ -0,0 +1,38 @@
1
+ import { META } from './metadata';
2
+ /**
3
+ * Represents a parsed phone number.
4
+ */
5
+ export class PhoneNumber {
6
+ /**
7
+ * Creates a new PhoneNumber instance.
8
+ *
9
+ * @param {string} countryCallingCode - The country calling code for the phone number.
10
+ * @param {string} nationalNumber - The national portion of the phone number.
11
+ * @param {VegaCountryCode} country - The optional country code associated with the number.
12
+ */
13
+ constructor(countryCallingCode, nationalNumber, country) {
14
+ this.countryCallingCode = countryCallingCode;
15
+ this.nationalNumber = nationalNumber;
16
+ this.country = country;
17
+ }
18
+ /**
19
+ * Returns true if the national number matches the country's validation
20
+ * pattern and its length is among the expected possible lengths.
21
+ *
22
+ * @returns {boolean} Whether the phone number is valid.
23
+ */
24
+ isValid() {
25
+ if (!this.country)
26
+ return false;
27
+ const entry = META.countries[this.country];
28
+ if (!entry)
29
+ return false;
30
+ const validationPattern = entry[2];
31
+ const possibleLengths = entry[3];
32
+ if (!possibleLengths.includes(this.nationalNumber.length)) {
33
+ return false;
34
+ }
35
+ const regex = new RegExp('^(?:' + validationPattern + ')$');
36
+ return regex.test(this.nationalNumber);
37
+ }
38
+ }
@@ -0,0 +1,309 @@
1
+ import { AsYouType, formatIncompletePhoneNumber } from '../as-you-type';
2
+ function internal(formatter) {
3
+ return formatter;
4
+ }
5
+ // ---------------------------------------------------------------------------
6
+ // formatIncompletePhoneNumber
7
+ // ---------------------------------------------------------------------------
8
+ describe('formatIncompletePhoneNumber', () => {
9
+ it('should format a US number with country', () => {
10
+ expect(formatIncompletePhoneNumber('3023334444', 'US')).toBe('(302) 333-4444');
11
+ });
12
+ it('should format an international number without country', () => {
13
+ const result = formatIncompletePhoneNumber('+13023334444');
14
+ expect(result).toBe('+1 302 333 4444');
15
+ });
16
+ it('should return empty string for empty input', () => {
17
+ expect(formatIncompletePhoneNumber('')).toBe('');
18
+ });
19
+ it('should handle partial US number', () => {
20
+ expect(formatIncompletePhoneNumber('302333', 'US')).toBe('(302) 333');
21
+ });
22
+ it('should format a GB number', () => {
23
+ const result = formatIncompletePhoneNumber('7911123456', 'GB');
24
+ expect(result).toBeDefined();
25
+ expect(result.length).toBeGreaterThan(0);
26
+ });
27
+ });
28
+ // ---------------------------------------------------------------------------
29
+ // AsYouType — basic usage
30
+ // ---------------------------------------------------------------------------
31
+ describe('AsYouType', () => {
32
+ describe('constructor', () => {
33
+ it('should accept a default country', () => {
34
+ const formatter = new AsYouType('US');
35
+ expect(formatter.country).toBe('US');
36
+ });
37
+ it('should work without a default country', () => {
38
+ const formatter = new AsYouType();
39
+ expect(formatter.country).toBeUndefined();
40
+ });
41
+ });
42
+ // -----------------------------------------------------------------------
43
+ // input() — US national mode
44
+ // -----------------------------------------------------------------------
45
+ describe('input (US national)', () => {
46
+ it('should progressively format a US number', () => {
47
+ const formatter = new AsYouType('US');
48
+ expect(formatter.input('3')).toBeDefined();
49
+ expect(formatter.input('0')).toBeDefined();
50
+ expect(formatter.input('2')).toBeDefined();
51
+ // After 6 more digits we should get full format
52
+ const result = formatter.input('3334444');
53
+ expect(result).toBe('(302) 333-4444');
54
+ });
55
+ it('should format a complete US number in one call', () => {
56
+ const formatter = new AsYouType('US');
57
+ expect(formatter.input('3023334444')).toBe('(302) 333-4444');
58
+ });
59
+ it('should handle digit-by-digit input', () => {
60
+ const formatter = new AsYouType('US');
61
+ let result = '';
62
+ for (const char of '3023334444') {
63
+ result = formatter.input(char);
64
+ }
65
+ expect(result).toBe('(302) 333-4444');
66
+ });
67
+ });
68
+ // -----------------------------------------------------------------------
69
+ // input() — international mode
70
+ // -----------------------------------------------------------------------
71
+ describe('input (international)', () => {
72
+ it('should format an international US number', () => {
73
+ const formatter = new AsYouType();
74
+ const result = formatter.input('+13023334444');
75
+ expect(result).toBe('+1 302 333 4444');
76
+ });
77
+ it('should detect calling code when +1 is entered', () => {
78
+ const formatter = new AsYouType();
79
+ formatter.input('+1302');
80
+ // NANPA has many countries; callingCode should be detected even if country is not
81
+ expect(internal(formatter)._callingCode).toBe('1');
82
+ });
83
+ it('should format an international GB number', () => {
84
+ const formatter = new AsYouType();
85
+ const result = formatter.input('+447911123456');
86
+ expect(result).toBeDefined();
87
+ expect(result).toContain('+44');
88
+ });
89
+ it('should return "+" when only + is entered', () => {
90
+ const formatter = new AsYouType();
91
+ expect(formatter.input('+')).toBe('+');
92
+ });
93
+ it('should format digits after calling code', () => {
94
+ const formatter = new AsYouType();
95
+ formatter.input('+1');
96
+ const result = formatter.input('3023334444');
97
+ expect(result).toBe('+1 302 333 4444');
98
+ });
99
+ });
100
+ // -----------------------------------------------------------------------
101
+ // input() — various countries
102
+ // -----------------------------------------------------------------------
103
+ describe('input (various countries)', () => {
104
+ it('should format a CN number nationally', () => {
105
+ const formatter = new AsYouType('CN');
106
+ const result = formatter.input('13812345678');
107
+ expect(result).toBeDefined();
108
+ expect(result.length).toBeGreaterThan(0);
109
+ });
110
+ it('should format a CN 10-digit number with 3-3-4 grouping', () => {
111
+ // Regression test: leading digits pattern 8(?:[1-358]|9[1-7]) must not
112
+ // eliminate the 3-3-4 format before MIN_LEADING_DIGITS_LENGTH digits
113
+ const formatter = new AsYouType('CN');
114
+ let result = '';
115
+ for (const char of '8934324345') {
116
+ result = formatter.input(char);
117
+ }
118
+ expect(result).toBe('893 432 4345');
119
+ });
120
+ it('should format a DE number nationally', () => {
121
+ const formatter = new AsYouType('DE');
122
+ const result = formatter.input('3012345678');
123
+ expect(result).toBeDefined();
124
+ });
125
+ it('should format an AU number', () => {
126
+ const formatter = new AsYouType('AU');
127
+ const result = formatter.input('0412345678');
128
+ expect(result).toBeDefined();
129
+ });
130
+ });
131
+ // -----------------------------------------------------------------------
132
+ // input() — non-digit characters
133
+ // -----------------------------------------------------------------------
134
+ describe('input (non-digit handling)', () => {
135
+ it('should ignore non-digit characters except leading +', () => {
136
+ const formatter = new AsYouType('US');
137
+ const result = formatter.input('(302) 333-4444');
138
+ expect(result).toBe('(302) 333-4444');
139
+ });
140
+ it('should ignore letters', () => {
141
+ const formatter = new AsYouType('US');
142
+ const result = formatter.input('3a0b2c3d3e3f4g4h4i4j');
143
+ expect(result).toBe('(302) 333-4444');
144
+ });
145
+ });
146
+ // -----------------------------------------------------------------------
147
+ // country getter
148
+ // -----------------------------------------------------------------------
149
+ describe('country', () => {
150
+ it('should return default country initially', () => {
151
+ const formatter = new AsYouType('GB');
152
+ expect(formatter.country).toBe('GB');
153
+ });
154
+ it('should detect country from international input', () => {
155
+ const formatter = new AsYouType();
156
+ formatter.input('+49');
157
+ expect(formatter.country).toBe('DE');
158
+ });
159
+ it('should detect NANPA country by leading digits', () => {
160
+ const formatter = new AsYouType();
161
+ formatter.input('+13405100000');
162
+ expect(formatter.country).toBe('VI');
163
+ });
164
+ });
165
+ // -----------------------------------------------------------------------
166
+ // Line-level coverage — each test targets a specific uncovered line
167
+ // -----------------------------------------------------------------------
168
+ describe('non-digit characters are skipped in input loop', () => {
169
+ it('should skip non-digit non-plus characters via continue', () => {
170
+ const formatter = new AsYouType('US');
171
+ // Characters '-' and ' ' are < '0' or > '9', hitting the continue.
172
+ // The result should only format the extracted digits, ignoring separators.
173
+ const result = formatter.input('3-0-2');
174
+ expect(result).toBeDefined();
175
+ // US formatting applies parentheses around the area code
176
+ expect(result).toBe('(302)');
177
+ });
178
+ });
179
+ describe('returns "+" when plus was entered but no digits follow', () => {
180
+ it('should return "+" when subsequent input has only non-digit chars', () => {
181
+ const formatter = new AsYouType();
182
+ expect(formatter.input('+')).toBe('+');
183
+ // Second call with only non-digit text: no digits added so result is still ''.
184
+ // Falls into if (!result) → _hasPlus is true, _allDigits.length === 0 → return '+'
185
+ // eslint-disable-next-line spellcheck/spell-checker
186
+ expect(formatter.input('abc')).toBe('+');
187
+ });
188
+ });
189
+ describe('re-initializes formats and resets when calling code changes for multi-country group', () => {
190
+ it('should re-init formats when calling code changes for a multi-country group', () => {
191
+ // Need: prevCallingCode !== detected.callingCode AND detected.countries.length > 1.
192
+ // Feed '+' then '4' (no calling code detected yet, prevCallingCode = undefined),
193
+ // then '4' → calling code '44' with multiple countries (GB, GG, JE, IM).
194
+ // undefined !== '44' → enters the if-block → initFormats + resetFormat (lines 177-178).
195
+ const formatter = new AsYouType();
196
+ formatter.input('+');
197
+ formatter.input('4');
198
+ const result = formatter.input('4');
199
+ expect(result).toBeDefined();
200
+ const final = formatter.input('7911123456');
201
+ expect(final).toContain('+44');
202
+ });
203
+ });
204
+ describe('chooseFormatAndApply breaks when re-encountering already chosen format', () => {
205
+ it('should break and reset when the chosen format is at the front of matching formats', () => {
206
+ const formatter = new AsYouType('US');
207
+ formatter.input('302');
208
+ // Set _chosenFormat to the first element in _matchingFormats so the
209
+ // for-loop immediately hits the break branch.
210
+ const matchingFormats = internal(formatter)._matchingFormats;
211
+ if (matchingFormats.length > 0) {
212
+ internal(formatter)._chosenFormat = matchingFormats[0];
213
+ }
214
+ const result = internal(formatter).chooseFormatAndApply();
215
+ // After the break the method calls resetFormat() and returns undefined
216
+ expect(result).toBeUndefined();
217
+ });
218
+ });
219
+ describe('chooseFormatAndApply skips altering format rules', () => {
220
+ it('should continue past formats whose replacement inserts extra characters', () => {
221
+ const formatter = new AsYouType('US');
222
+ formatter.input('302');
223
+ // Inject an altering format (replacement starts with '0') at the front
224
+ // of _matchingFormats so the continue branch is taken before reaching
225
+ // the real non-altering formats.
226
+ const alteringFormat = ['(\\d{3})(\\d{3})(\\d{4})', '0$1 $2-$3', ['[2-9]']];
227
+ internal(formatter)._matchingFormats.unshift(alteringFormat);
228
+ internal(formatter)._chosenFormat = undefined;
229
+ const result = internal(formatter).chooseFormatAndApply();
230
+ // The altering format is skipped, a real format is chosen instead
231
+ expect(result).toBeDefined();
232
+ });
233
+ });
234
+ describe('formatNextDigits returns undefined when no template exists', () => {
235
+ it('should return undefined from formatNextDigits when _populatedTemplate is falsy', () => {
236
+ const formatter = new AsYouType('US');
237
+ // Call the private method directly with no template set
238
+ const result = internal(formatter).formatNextDigits('5');
239
+ expect(result).toBeUndefined();
240
+ });
241
+ });
242
+ describe('populateTemplateFull returns undefined when template runs out of placeholders', () => {
243
+ it('should return undefined when digits exceed template placeholders', () => {
244
+ const formatter = new AsYouType('US');
245
+ // Call populateTemplateFull directly with more digits than placeholders
246
+ // Template has 7 placeholders; feed 10 digits to overflow them
247
+ const result = internal(formatter).populateTemplateFull(
248
+ // eslint-disable-next-line spellcheck/spell-checker
249
+ 'xxx-xxxx', '1234567890');
250
+ expect(result).toBeUndefined();
251
+ });
252
+ });
253
+ describe('tryReExtractNationalPrefix returns early when metadata entry is falsy', () => {
254
+ it('should return early when country metadata entry does not exist', () => {
255
+ const formatter = new AsYouType('US');
256
+ // Set _country to a fake value so META.countries[_country] is undefined
257
+ internal(formatter)._country = 'ZZ';
258
+ // tryReExtractNationalPrefix should bail out at line 420: if (!entry) return
259
+ internal(formatter).tryReExtractNationalPrefix();
260
+ // No error thrown, method returned gracefully — _complexPrefix remains its initial value
261
+ expect(internal(formatter)._complexPrefix).toBe('');
262
+ });
263
+ });
264
+ describe('getFullOutput returns "+callingCode" when formattedNational is empty', () => {
265
+ it('should return just "+callingCode" via getFullOutput when formattedNational is falsy', () => {
266
+ const formatter = new AsYouType();
267
+ formatter.input('+1302');
268
+ // Call getFullOutput directly with empty string
269
+ const output = internal(formatter).getFullOutput('');
270
+ expect(output).toBe('+1');
271
+ });
272
+ it('should return "+callingCode" when entering only + and calling code digits', () => {
273
+ const formatter = new AsYouType();
274
+ const result = formatter.input('+1');
275
+ expect(result).toBe('+1');
276
+ });
277
+ });
278
+ describe('getNonFormattedOutput returns complexPrefix concatenated with nationalNumber', () => {
279
+ it('should return complexPrefix + nationalNumber when no format matches', () => {
280
+ const formatter = new AsYouType('CN');
281
+ // CN prefix pattern: (1(?:[12]\d|79)\d\d)|0
282
+ // '0' matches the '0' alternative. After prefix extraction, _complexPrefix = '0'
283
+ // and _nationalNumber = remaining digits.
284
+ // Feed enough digits to exhaust all format templates so getNonFormattedOutput is used.
285
+ const result = formatter.input('099999999999999999');
286
+ expect(result).toContain('0');
287
+ expect(result.length).toBeGreaterThan(1);
288
+ });
289
+ it('should include complexPrefix in output via direct method call', () => {
290
+ const formatter = new AsYouType('CN');
291
+ // Set internal state directly
292
+ internal(formatter)._complexPrefix = '0';
293
+ internal(formatter)._nationalNumber = '12345';
294
+ internal(formatter)._hasPlus = false;
295
+ const output = internal(formatter).getNonFormattedOutput();
296
+ expect(output).toBe('0 12345');
297
+ });
298
+ });
299
+ // -----------------------------------------------------------------------
300
+ // CN national prefix re-extraction
301
+ // -----------------------------------------------------------------------
302
+ describe('CN national prefix re-extraction', () => {
303
+ it('should handle CN digits with national prefix extraction', () => {
304
+ const formatter = new AsYouType('CN');
305
+ const result = formatter.input('123456789');
306
+ expect(result).toBeDefined();
307
+ });
308
+ });
309
+ });
@@ -0,0 +1,192 @@
1
+ /* eslint-disable spellcheck/spell-checker */
2
+ import { isNonAlteringFormat, formatSuits, formatMatchesLeadingDigits, buildTemplate, cutAndStripNonPairedParens, applyInternationalSeparatorStyle, } from '../format-helpers';
3
+ // ---------------------------------------------------------------------------
4
+ // isNonAlteringFormat
5
+ // ---------------------------------------------------------------------------
6
+ describe('isNonAlteringFormat', () => {
7
+ it('should return true for standard group-only replacements', () => {
8
+ expect(isNonAlteringFormat('$1-$2-$3')).toBe(true);
9
+ expect(isNonAlteringFormat('($1) $2-$3')).toBe(true);
10
+ expect(isNonAlteringFormat('$1 $2 $3')).toBe(true);
11
+ expect(isNonAlteringFormat('$1.$2.$3')).toBe(true);
12
+ });
13
+ it('should return true for single group replacements', () => {
14
+ expect(isNonAlteringFormat('$1')).toBe(true);
15
+ expect(isNonAlteringFormat('($1)')).toBe(true);
16
+ });
17
+ it('should return false for replacements that insert extra characters', () => {
18
+ expect(isNonAlteringFormat('0$1 $2')).toBe(false);
19
+ expect(isNonAlteringFormat('8 $1')).toBe(false);
20
+ });
21
+ it('should return false for empty string', () => {
22
+ expect(isNonAlteringFormat('')).toBe(false);
23
+ });
24
+ });
25
+ // ---------------------------------------------------------------------------
26
+ // formatSuits
27
+ // ---------------------------------------------------------------------------
28
+ describe('formatSuits', () => {
29
+ // Format with no nationalPrefixFormattingRule → no national prefix usage
30
+ const formatNoPrefix = ['(\\d{3})(\\d{4})', '$1-$2', ['[2-9]']];
31
+ // Format with a real national prefix rule (e.g., '0$1')
32
+ const formatWithPrefix = ['(\\d{3})(\\d{4})', '$1-$2', ['[2-9]'], '0$1'];
33
+ // Format with prefix rule but marked optional (index [4] truthy)
34
+ const formatOptionalPrefix = ['(\\d{3})(\\d{4})', '$1-$2', ['[2-9]'], '0$1', 1];
35
+ // Format whose rule is just '$1' (doesn't really prepend a prefix)
36
+ const formatPassthroughRule = ['(\\d{3})(\\d{4})', '$1-$2', ['[2-9]'], '$1'];
37
+ describe('when national prefix was entered', () => {
38
+ it('should return true for format with prefix rule', () => {
39
+ expect(formatSuits(formatWithPrefix, false, true)).toBe(true);
40
+ });
41
+ it('should return false for format without any prefix rule and not optional', () => {
42
+ expect(formatSuits(formatNoPrefix, false, true)).toBe(false);
43
+ });
44
+ it('should return true for format with optional prefix', () => {
45
+ expect(formatSuits(formatOptionalPrefix, false, true)).toBe(true);
46
+ });
47
+ it('should return true for passthrough prefix ($1)', () => {
48
+ // $1 means doesn't actually prepend, so formatUsesNationalPrefix is false,
49
+ // but it also doesn't have an optional marker → returns false
50
+ expect(formatSuits(formatPassthroughRule, false, true)).toBe(false);
51
+ });
52
+ });
53
+ describe('when no national prefix and not international', () => {
54
+ it('should return true for format without prefix', () => {
55
+ expect(formatSuits(formatNoPrefix, false, false)).toBe(true);
56
+ });
57
+ it('should return false for format with mandatory prefix', () => {
58
+ expect(formatSuits(formatWithPrefix, false, false)).toBe(false);
59
+ });
60
+ it('should return true for format with optional prefix', () => {
61
+ expect(formatSuits(formatOptionalPrefix, false, false)).toBe(true);
62
+ });
63
+ });
64
+ describe('when international mode', () => {
65
+ it('should return true for any format in international mode', () => {
66
+ expect(formatSuits(formatNoPrefix, true, false)).toBe(true);
67
+ expect(formatSuits(formatWithPrefix, true, false)).toBe(true);
68
+ expect(formatSuits(formatOptionalPrefix, true, false)).toBe(true);
69
+ });
70
+ });
71
+ });
72
+ // ---------------------------------------------------------------------------
73
+ // formatMatchesLeadingDigits
74
+ // ---------------------------------------------------------------------------
75
+ describe('formatMatchesLeadingDigits', () => {
76
+ // Format with leading digits pattern '2[0-9]'
77
+ const formatRule = ['(\\d{3})(\\d{4})', '$1-$2', ['2[0-9]']];
78
+ // Format with no leading digits
79
+ const formatNoLeading = ['(\\d{3})(\\d{4})', '$1-$2', []];
80
+ it('should return true when no leading digits patterns exist', () => {
81
+ expect(formatMatchesLeadingDigits(formatNoLeading, '1234567', 0)).toBe(true);
82
+ });
83
+ it('should match when national number starts with matching digits', () => {
84
+ expect(formatMatchesLeadingDigits(formatRule, '2123456', 0)).toBe(true);
85
+ });
86
+ it('should not match when leading digits do not match', () => {
87
+ expect(formatMatchesLeadingDigits(formatRule, '3123456', 0)).toBe(false);
88
+ });
89
+ it('should return true for short numbers below MIN_LEADING_DIGITS_LENGTH', () => {
90
+ // Both '2' and '3' are 1-char inputs (below MIN_LEADING_DIGITS_LENGTH=3),
91
+ // so all formats are kept regardless of the leading-digits pattern.
92
+ expect(formatMatchesLeadingDigits(formatRule, '2', 0)).toBe(true);
93
+ expect(formatMatchesLeadingDigits(formatRule, '3', 0)).toBe(true);
94
+ });
95
+ it('should use the correct leading digits pattern based on index', () => {
96
+ const formatMulti = ['(\\d{3})(\\d{4})', '$1-$2', ['[2-9]', '2[0-3]']];
97
+ // At index 0, use first pattern '[2-9]' — 3 matches
98
+ expect(formatMatchesLeadingDigits(formatMulti, '312', 0)).toBe(true);
99
+ // At index 1, use second pattern '2[0-3]' — 3 doesn't match
100
+ expect(formatMatchesLeadingDigits(formatMulti, '312', 1)).toBe(false);
101
+ });
102
+ });
103
+ // ---------------------------------------------------------------------------
104
+ // formatMatchesLeadingDigits — short-number early-return coverage
105
+ // (With fewer than MIN_LEADING_DIGITS_LENGTH digits, all formats are kept.)
106
+ // ---------------------------------------------------------------------------
107
+ describe('formatMatchesLeadingDigits (short-number early return)', () => {
108
+ it('should return true for any 1-digit input regardless of pattern', () => {
109
+ const fmt = ['(\\d{3})(\\d{4})', '$1-$2', ['7[2-5]']];
110
+ expect(formatMatchesLeadingDigits(fmt, '9', 0)).toBe(true);
111
+ expect(formatMatchesLeadingDigits(fmt, '7', 0)).toBe(true);
112
+ });
113
+ it('should return true for any 2-digit input regardless of pattern', () => {
114
+ const fmt = ['(\\d{3})(\\d{4})', '$1-$2', ['25']];
115
+ expect(formatMatchesLeadingDigits(fmt, '25', 0)).toBe(true);
116
+ expect(formatMatchesLeadingDigits(fmt, '39', 0)).toBe(true);
117
+ });
118
+ it('should use regex for 3+ digit input', () => {
119
+ const fmt = ['(\\d{3})(\\d{4})', '$1-$2', ['7[2-5]']];
120
+ expect(formatMatchesLeadingDigits(fmt, '730', 0)).toBe(true);
121
+ expect(formatMatchesLeadingDigits(fmt, '910', 0)).toBe(false);
122
+ });
123
+ });
124
+ // ---------------------------------------------------------------------------
125
+ // buildTemplate
126
+ // ---------------------------------------------------------------------------
127
+ describe('buildTemplate', () => {
128
+ it('should build a US-style template', () => {
129
+ // US format: (\\d{3})(\\d{3})(\\d{4}) → ($1) $2-$3
130
+ const formatRule = ['(\\d{3})(\\d{3})(\\d{4})', '($1) $2-$3', ['[2-9]']];
131
+ const template = buildTemplate(formatRule, 10);
132
+ expect(template).toBeDefined();
133
+ // Template should have placeholders like '(xxx) xxx-xxxx'
134
+ expect(template).toBe('(xxx) xxx-xxxx');
135
+ });
136
+ it('should return undefined when pattern cannot match', () => {
137
+ const formatRule = ['(impossible)', '$1', []];
138
+ const template = buildTemplate(formatRule, 5);
139
+ expect(template).toBeUndefined();
140
+ });
141
+ it('should return undefined when national number length exceeds pattern capacity', () => {
142
+ // Format only handles 7 digits
143
+ const formatRule = ['(\\d{3})(\\d{4})', '$1-$2', []];
144
+ const template = buildTemplate(formatRule, 15);
145
+ // The pattern can only match 7 digits
146
+ expect(template).toBeUndefined();
147
+ });
148
+ it('should use digit placeholder character x', () => {
149
+ const formatRule = ['(\\d{3})(\\d{4})', '$1-$2', []];
150
+ const template = buildTemplate(formatRule, 7);
151
+ expect(template).toBeDefined();
152
+ expect(template).toBe('xxx-xxxx');
153
+ });
154
+ });
155
+ // ---------------------------------------------------------------------------
156
+ // cutAndStripNonPairedParens
157
+ // ---------------------------------------------------------------------------
158
+ describe('cutAndStripNonPairedParens', () => {
159
+ it('should cut the string at the given position', () => {
160
+ expect(cutAndStripNonPairedParens('(302) 333-xxxx', 9)).toBe('(302) 333');
161
+ });
162
+ it('should include closing paren if at cut position', () => {
163
+ // Position 4 is ')' — cutAndStripNonPairedParens advances past it
164
+ expect(cutAndStripNonPairedParens('(302) 333-xxxx', 4)).toBe('(302)');
165
+ });
166
+ it('should strip unpaired opening parens', () => {
167
+ expect(cutAndStripNonPairedParens('(302 333', 8)).toBe('302 333');
168
+ });
169
+ it('should keep paired parens', () => {
170
+ expect(cutAndStripNonPairedParens('(302) 333', 9)).toBe('(302) 333');
171
+ });
172
+ });
173
+ // ---------------------------------------------------------------------------
174
+ // applyInternationalSeparatorStyle
175
+ // ---------------------------------------------------------------------------
176
+ describe('applyInternationalSeparatorStyle', () => {
177
+ it('should replace parens with nothing and dashes with spaces', () => {
178
+ expect(applyInternationalSeparatorStyle('(302) 333-4444')).toBe('302 333 4444');
179
+ });
180
+ it('should collapse multiple spaces', () => {
181
+ expect(applyInternationalSeparatorStyle('302 333 4444')).toBe('302 333 4444');
182
+ });
183
+ it('should trim leading and trailing whitespace', () => {
184
+ expect(applyInternationalSeparatorStyle(' 302 333 ')).toBe('302 333');
185
+ });
186
+ it('should handle empty string', () => {
187
+ expect(applyInternationalSeparatorStyle('')).toBe('');
188
+ });
189
+ it('should handle string with only parens/dashes', () => {
190
+ expect(applyInternationalSeparatorStyle('(-)(-)')).toBe('');
191
+ });
192
+ });