igniteui-webcomponents 7.3.2 → 7.4.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 (441) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/animations/easings.d.ts +21 -31
  3. package/animations/easings.js +21 -34
  4. package/animations/easings.js.map +1 -1
  5. package/animations/player.d.ts +8 -16
  6. package/animations/player.js +5 -8
  7. package/animations/player.js.map +1 -1
  8. package/animations/view-transition.d.ts +10 -10
  9. package/animations/view-transition.js +26 -37
  10. package/animations/view-transition.js.map +1 -1
  11. package/components/breadcrumb/breadcrumb.d.ts +74 -0
  12. package/components/breadcrumb/breadcrumb.js +107 -0
  13. package/components/breadcrumb/breadcrumb.js.map +1 -0
  14. package/components/breadcrumb/breadcrumbs.d.ts +60 -0
  15. package/components/breadcrumb/breadcrumbs.js +50 -0
  16. package/components/breadcrumb/breadcrumbs.js.map +1 -0
  17. package/components/breadcrumb/themes/breadcrumb.base.css.js +3 -0
  18. package/components/breadcrumb/themes/breadcrumb.base.css.js.map +1 -0
  19. package/components/breadcrumb/themes/breadcrumbs.base.css.d.ts +1 -0
  20. package/components/{resize-container/themes/resize-container.base.css.js → breadcrumb/themes/breadcrumbs.base.css.js} +2 -2
  21. package/components/breadcrumb/themes/breadcrumbs.base.css.js.map +1 -0
  22. package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.d.ts +1 -0
  23. package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js +3 -0
  24. package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js.map +1 -0
  25. package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.d.ts +1 -0
  26. package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js +3 -0
  27. package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js.map +1 -0
  28. package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.d.ts +1 -0
  29. package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js +3 -0
  30. package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js.map +1 -0
  31. package/components/breadcrumb/themes/dark/breadcrumb.material.css.d.ts +1 -0
  32. package/components/breadcrumb/themes/dark/breadcrumb.material.css.js +3 -0
  33. package/components/breadcrumb/themes/dark/breadcrumb.material.css.js.map +1 -0
  34. package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.d.ts +1 -0
  35. package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js +3 -0
  36. package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js.map +1 -0
  37. package/components/breadcrumb/themes/light/breadcrumb.fluent.css.d.ts +1 -0
  38. package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js +3 -0
  39. package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js.map +1 -0
  40. package/components/breadcrumb/themes/light/breadcrumb.indigo.css.d.ts +1 -0
  41. package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js +3 -0
  42. package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js.map +1 -0
  43. package/components/breadcrumb/themes/light/breadcrumb.material.css.d.ts +1 -0
  44. package/components/breadcrumb/themes/light/breadcrumb.material.css.js +3 -0
  45. package/components/breadcrumb/themes/light/breadcrumb.material.css.js.map +1 -0
  46. package/components/breadcrumb/themes/light/breadcrumb.shared.css.d.ts +1 -0
  47. package/components/breadcrumb/themes/light/breadcrumb.shared.css.js +3 -0
  48. package/components/breadcrumb/themes/light/breadcrumb.shared.css.js.map +1 -0
  49. package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.d.ts +1 -0
  50. package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js +3 -0
  51. package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js.map +1 -0
  52. package/components/breadcrumb/themes/shared/breadcrumb.common.css.d.ts +1 -0
  53. package/components/breadcrumb/themes/shared/breadcrumb.common.css.js +3 -0
  54. package/components/breadcrumb/themes/shared/breadcrumb.common.css.js.map +1 -0
  55. package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.d.ts +1 -0
  56. package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js +3 -0
  57. package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js.map +1 -0
  58. package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.d.ts +1 -0
  59. package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js +3 -0
  60. package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js.map +1 -0
  61. package/components/breadcrumb/themes/shared/breadcrumb.material.css.d.ts +1 -0
  62. package/components/breadcrumb/themes/shared/breadcrumb.material.css.js +3 -0
  63. package/components/breadcrumb/themes/shared/breadcrumb.material.css.js.map +1 -0
  64. package/components/breadcrumb/themes/themes.d.ts +2 -0
  65. package/components/breadcrumb/themes/themes.js +50 -0
  66. package/components/breadcrumb/themes/themes.js.map +1 -0
  67. package/components/button/button.d.ts +0 -2
  68. package/components/button/button.js.map +1 -1
  69. package/components/button-group/button-group.d.ts +42 -12
  70. package/components/button-group/button-group.js +82 -34
  71. package/components/button-group/button-group.js.map +1 -1
  72. package/components/button-group/toggle-button.d.ts +6 -1
  73. package/components/button-group/toggle-button.js +28 -2
  74. package/components/button-group/toggle-button.js.map +1 -1
  75. package/components/calendar/base.js +2 -1
  76. package/components/calendar/base.js.map +1 -1
  77. package/components/calendar/calendar.d.ts +2 -3
  78. package/components/calendar/calendar.js.map +1 -1
  79. package/components/calendar/days-view/days-view.d.ts +2 -2
  80. package/components/calendar/days-view/days-view.js.map +1 -1
  81. package/components/carousel/carousel-indicator.js +1 -0
  82. package/components/carousel/carousel-indicator.js.map +1 -1
  83. package/components/carousel/carousel-slide.d.ts +1 -1
  84. package/components/carousel/carousel-slide.js.map +1 -1
  85. package/components/carousel/carousel.d.ts +3 -3
  86. package/components/carousel/carousel.js.map +1 -1
  87. package/components/chat/chat-input.d.ts +1 -2
  88. package/components/chat/chat-input.js +1 -1
  89. package/components/chat/chat-input.js.map +1 -1
  90. package/components/chat/chat-state.d.ts +8 -9
  91. package/components/chat/chat-state.js.map +1 -1
  92. package/components/chat/chat.d.ts +1 -3
  93. package/components/chat/chat.js +2 -2
  94. package/components/chat/chat.js.map +1 -1
  95. package/components/chat/message-attachments.d.ts +6 -15
  96. package/components/chat/message-attachments.js.map +1 -1
  97. package/components/chat/utils.d.ts +0 -1
  98. package/components/chat/utils.js +1 -1
  99. package/components/chat/utils.js.map +1 -1
  100. package/components/checkbox/checkbox-base.d.ts +1 -1
  101. package/components/checkbox/checkbox.js +1 -1
  102. package/components/checkbox/checkbox.js.map +1 -1
  103. package/components/chip/chip.d.ts +2 -2
  104. package/components/chip/chip.js.map +1 -1
  105. package/components/color-picker/color-picker.d.ts +35 -34
  106. package/components/color-picker/color-picker.js +9 -4
  107. package/components/color-picker/color-picker.js.map +1 -1
  108. package/components/color-picker/common.d.ts +0 -2
  109. package/components/color-picker/common.js +2 -2
  110. package/components/color-picker/common.js.map +1 -1
  111. package/components/color-picker/converters.js.map +1 -1
  112. package/components/color-picker/picker-canvas.js.map +1 -1
  113. package/components/combo/combo.d.ts +18 -20
  114. package/components/combo/combo.js +8 -2
  115. package/components/combo/combo.js.map +1 -1
  116. package/components/combo/controllers/data.d.ts +7 -10
  117. package/components/combo/controllers/data.js.map +1 -1
  118. package/components/date-picker/date-picker.base.d.ts +22 -27
  119. package/components/date-picker/date-picker.base.js +7 -1
  120. package/components/date-picker/date-picker.base.js.map +1 -1
  121. package/components/date-picker/date-picker.d.ts +1 -1
  122. package/components/date-picker/date-picker.js +5 -3
  123. package/components/date-picker/date-picker.js.map +1 -1
  124. package/components/date-range-picker/date-range-input.d.ts +0 -2
  125. package/components/date-range-picker/date-range-input.js +0 -6
  126. package/components/date-range-picker/date-range-input.js.map +1 -1
  127. package/components/date-range-picker/date-range-picker.d.ts +22 -31
  128. package/components/date-range-picker/date-range-picker.js +7 -7
  129. package/components/date-range-picker/date-range-picker.js.map +1 -1
  130. package/components/date-range-picker/i18n.d.ts +21 -0
  131. package/components/date-range-picker/i18n.js +10 -0
  132. package/components/date-range-picker/i18n.js.map +1 -0
  133. package/components/date-range-picker/predefined-ranges-area.d.ts +3 -3
  134. package/components/date-range-picker/predefined-ranges-area.js +2 -5
  135. package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
  136. package/components/date-range-picker/validators.d.ts +0 -4
  137. package/components/date-range-picker/validators.js +4 -4
  138. package/components/date-range-picker/validators.js.map +1 -1
  139. package/components/date-time-input/date-time-input.base.d.ts +39 -37
  140. package/components/date-time-input/date-time-input.base.js +6 -0
  141. package/components/date-time-input/date-time-input.base.js.map +1 -1
  142. package/components/date-time-input/date-time-input.d.ts +1 -11
  143. package/components/date-time-input/date-time-input.js +0 -6
  144. package/components/date-time-input/date-time-input.js.map +1 -1
  145. package/components/date-time-input/datetime-mask-parser.d.ts +0 -10
  146. package/components/date-time-input/datetime-mask-parser.js +1 -1
  147. package/components/date-time-input/datetime-mask-parser.js.map +1 -1
  148. package/components/dialog/dialog.js.map +1 -1
  149. package/components/dropdown/dropdown-group.d.ts +2 -10
  150. package/components/dropdown/dropdown-group.js +2 -27
  151. package/components/dropdown/dropdown-group.js.map +1 -1
  152. package/components/dropdown/dropdown.d.ts +17 -23
  153. package/components/dropdown/dropdown.js +5 -17
  154. package/components/dropdown/dropdown.js.map +1 -1
  155. package/components/file-input/file-input.d.ts +2 -2
  156. package/components/file-input/file-input.js.map +1 -1
  157. package/components/icon/icon.d.ts +1 -1
  158. package/components/icon/icon.registry.d.ts +6 -6
  159. package/components/icon/icon.registry.js.map +1 -1
  160. package/components/input/input.d.ts +3 -3
  161. package/components/input/input.js.map +1 -1
  162. package/components/mask-input/mask-history.d.ts +22 -18
  163. package/components/mask-input/mask-history.js.map +1 -1
  164. package/components/mask-input/mask-input.d.ts +1 -1
  165. package/components/mask-input/mask-parser.d.ts +11 -13
  166. package/components/mask-input/mask-parser.js.map +1 -1
  167. package/components/popover/popover.d.ts +45 -34
  168. package/components/popover/popover.js +54 -122
  169. package/components/popover/popover.js.map +1 -1
  170. package/components/popover/position/arrow.d.ts +19 -0
  171. package/components/popover/position/arrow.js +33 -0
  172. package/components/popover/position/arrow.js.map +1 -0
  173. package/components/popover/position/floating.d.ts +40 -0
  174. package/components/popover/position/floating.js +146 -0
  175. package/components/popover/position/floating.js.map +1 -0
  176. package/components/popover/position/native.d.ts +45 -0
  177. package/components/popover/position/native.js +158 -0
  178. package/components/popover/position/native.js.map +1 -0
  179. package/components/popover/position/strategy.d.ts +37 -0
  180. package/components/popover/position/strategy.js +21 -0
  181. package/components/popover/position/strategy.js.map +1 -0
  182. package/components/popover/position/types.d.ts +26 -0
  183. package/components/popover/position/types.js +15 -0
  184. package/components/popover/position/types.js.map +1 -0
  185. package/components/popover/themes/light/popover.base.css.js +1 -1
  186. package/components/popover/themes/light/popover.base.css.js.map +1 -1
  187. package/components/progress/circular-progress.d.ts +0 -5
  188. package/components/progress/circular-progress.js.map +1 -1
  189. package/components/qr-code/qr-code.d.ts +1 -1
  190. package/components/radio/radio.d.ts +4 -4
  191. package/components/radio/radio.js +17 -14
  192. package/components/radio/radio.js.map +1 -1
  193. package/components/radio-group/radio-group.js.map +1 -1
  194. package/components/rating/rating.d.ts +6 -6
  195. package/components/rating/rating.js.map +1 -1
  196. package/components/select/select-group.d.ts +5 -10
  197. package/components/select/select-group.js +10 -34
  198. package/components/select/select-group.js.map +1 -1
  199. package/components/select/select.d.ts +12 -20
  200. package/components/select/select.js +4 -14
  201. package/components/select/select.js.map +1 -1
  202. package/components/splitter/splitter.d.ts +6 -6
  203. package/components/splitter/splitter.js.map +1 -1
  204. package/components/textarea/textarea.d.ts +1 -1
  205. package/components/textarea/textarea.js.map +1 -1
  206. package/components/tile-manager/tile-manager.d.ts +6 -7
  207. package/components/tile-manager/tile-manager.js.map +1 -1
  208. package/components/tile-manager/tile.d.ts +3 -3
  209. package/components/tile-manager/tile.js.map +1 -1
  210. package/components/toast/toast.d.ts +0 -2
  211. package/components/toast/toast.js.map +1 -1
  212. package/components/tooltip/controller.js.map +1 -1
  213. package/components/tooltip/service.js +4 -5
  214. package/components/tooltip/service.js.map +1 -1
  215. package/components/tooltip/tooltip.d.ts +34 -13
  216. package/components/tooltip/tooltip.js +8 -4
  217. package/components/tooltip/tooltip.js.map +1 -1
  218. package/components/tree/tree-item.d.ts +6 -6
  219. package/components/tree/tree-item.js.map +1 -1
  220. package/components/tree/tree.navigation.d.ts +5 -6
  221. package/components/tree/tree.navigation.js.map +1 -1
  222. package/components/tree/tree.selection.js.map +1 -1
  223. package/components/types.d.ts +1 -1
  224. package/components/types.js.map +1 -1
  225. package/components/validation-container/validation-container.js.map +1 -1
  226. package/components/virtualization/engine.d.ts +5 -5
  227. package/components/virtualization/engine.js.map +1 -1
  228. package/components/virtualization/virtualization.d.ts +61 -63
  229. package/components/virtualization/virtualization.js +6 -5
  230. package/components/virtualization/virtualization.js.map +1 -1
  231. package/custom-elements.json +16280 -19679
  232. package/igniteui-webcomponents.css-data.json +2 -2
  233. package/igniteui-webcomponents.html-data.json +1 -1
  234. package/index.d.ts +2 -0
  235. package/index.js +2 -0
  236. package/index.js.map +1 -1
  237. package/internals/abort-handler.d.ts +13 -25
  238. package/internals/abort-handler.js +4 -6
  239. package/internals/abort-handler.js.map +1 -1
  240. package/internals/context.d.ts +13 -7
  241. package/internals/context.js +2 -1
  242. package/internals/context.js.map +1 -1
  243. package/internals/controllers/adopt-styles.d.ts +19 -20
  244. package/internals/controllers/adopt-styles.js +3 -8
  245. package/internals/controllers/adopt-styles.js.map +1 -1
  246. package/internals/controllers/aria-projection.d.ts +56 -55
  247. package/internals/controllers/aria-projection.js +14 -15
  248. package/internals/controllers/aria-projection.js.map +1 -1
  249. package/internals/controllers/async-consumer.js.map +1 -1
  250. package/internals/controllers/command.d.ts +15 -30
  251. package/internals/controllers/command.js +2 -7
  252. package/internals/controllers/command.js.map +1 -1
  253. package/internals/controllers/context-provider.d.ts +7 -13
  254. package/internals/controllers/context-provider.js.map +1 -1
  255. package/internals/controllers/focus-ring.d.ts +10 -30
  256. package/internals/controllers/focus-ring.js +6 -12
  257. package/internals/controllers/focus-ring.js.map +1 -1
  258. package/internals/controllers/fullscreen.d.ts +7 -23
  259. package/internals/controllers/fullscreen.js +3 -9
  260. package/internals/controllers/fullscreen.js.map +1 -1
  261. package/internals/controllers/gestures.d.ts +10 -29
  262. package/internals/controllers/gestures.js +1 -3
  263. package/internals/controllers/gestures.js.map +1 -1
  264. package/internals/controllers/group.d.ts +13 -30
  265. package/internals/controllers/group.js.map +1 -1
  266. package/internals/controllers/host-listeners.d.ts +28 -0
  267. package/internals/controllers/host-listeners.js +27 -0
  268. package/internals/controllers/host-listeners.js.map +1 -0
  269. package/internals/controllers/id-resolver.d.ts +8 -9
  270. package/internals/controllers/id-resolver.js +6 -14
  271. package/internals/controllers/id-resolver.js.map +1 -1
  272. package/internals/controllers/internals.d.ts +53 -104
  273. package/internals/controllers/internals.js +40 -13
  274. package/internals/controllers/internals.js.map +1 -1
  275. package/internals/controllers/key-bindings.d.ts +61 -158
  276. package/internals/controllers/key-bindings.js +68 -67
  277. package/internals/controllers/key-bindings.js.map +1 -1
  278. package/internals/controllers/keys.d.ts +32 -0
  279. package/internals/controllers/keys.js +20 -0
  280. package/internals/controllers/keys.js.map +1 -0
  281. package/internals/controllers/mutation-observer.d.ts +14 -37
  282. package/internals/controllers/mutation-observer.js +1 -1
  283. package/internals/controllers/mutation-observer.js.map +1 -1
  284. package/internals/controllers/resize-observer.d.ts +9 -19
  285. package/internals/controllers/resize-observer.js.map +1 -1
  286. package/internals/controllers/root-click.d.ts +11 -42
  287. package/internals/controllers/root-click.js +4 -6
  288. package/internals/controllers/root-click.js.map +1 -1
  289. package/internals/controllers/roving-focus.d.ts +16 -35
  290. package/internals/controllers/roving-focus.js.map +1 -1
  291. package/internals/controllers/slot.d.ts +25 -54
  292. package/internals/controllers/slot.js +6 -6
  293. package/internals/controllers/slot.js.map +1 -1
  294. package/internals/controllers/toggle.d.ts +44 -48
  295. package/internals/controllers/toggle.js.map +1 -1
  296. package/internals/date/compare.js.map +1 -1
  297. package/internals/date/converters.d.ts +10 -7
  298. package/internals/date/converters.js.map +1 -1
  299. package/internals/date/model.d.ts +9 -16
  300. package/internals/date/model.js +22 -25
  301. package/internals/date/model.js.map +1 -1
  302. package/internals/decorators/blazorAdditionalDependencies.d.ts +4 -2
  303. package/internals/decorators/blazorAdditionalDependencies.js.map +1 -1
  304. package/internals/decorators/blazorDeepImport.d.ts +1 -3
  305. package/internals/decorators/blazorDeepImport.js.map +1 -1
  306. package/internals/decorators/blazorInclude.d.ts +3 -2
  307. package/internals/decorators/blazorInclude.js.map +1 -1
  308. package/internals/decorators/blazorIndirectRender.d.ts +1 -3
  309. package/internals/decorators/blazorIndirectRender.js.map +1 -1
  310. package/internals/decorators/blazorSuppressComponent.d.ts +1 -3
  311. package/internals/decorators/blazorSuppressComponent.js.map +1 -1
  312. package/internals/decorators/coerced-property.d.ts +14 -20
  313. package/internals/decorators/coerced-property.js.map +1 -1
  314. package/internals/decorators/shadow-options.d.ts +2 -5
  315. package/internals/decorators/shadow-options.js.map +1 -1
  316. package/internals/definitions/defineAllComponents.js +2 -0
  317. package/internals/definitions/defineAllComponents.js.map +1 -1
  318. package/internals/directives/drag.d.ts +51 -81
  319. package/internals/directives/drag.js +27 -89
  320. package/internals/directives/drag.js.map +1 -1
  321. package/internals/directives/pointer-operation.d.ts +75 -0
  322. package/internals/directives/pointer-operation.js +92 -0
  323. package/internals/directives/pointer-operation.js.map +1 -0
  324. package/internals/directives/resize.d.ts +36 -64
  325. package/internals/directives/resize.js +18 -85
  326. package/internals/directives/resize.js.map +1 -1
  327. package/internals/i18n/EN/calendar.resources.d.ts +8 -2
  328. package/internals/i18n/EN/calendar.resources.js +2 -2
  329. package/internals/i18n/EN/calendar.resources.js.map +1 -1
  330. package/internals/i18n/EN/chat.resources.d.ts +8 -2
  331. package/internals/i18n/EN/chat.resources.js +3 -10
  332. package/internals/i18n/EN/chat.resources.js.map +1 -1
  333. package/internals/i18n/EN/date-picker.resources.d.ts +6 -4
  334. package/internals/i18n/EN/date-picker.resources.js +1 -7
  335. package/internals/i18n/EN/date-picker.resources.js.map +1 -1
  336. package/internals/i18n/EN/date-range-picker.resources.d.ts +9 -2
  337. package/internals/i18n/EN/date-range-picker.resources.js +2 -2
  338. package/internals/i18n/EN/date-range-picker.resources.js.map +1 -1
  339. package/internals/i18n/i18n-controller.d.ts +44 -46
  340. package/internals/i18n/i18n-controller.js +46 -33
  341. package/internals/i18n/i18n-controller.js.map +1 -1
  342. package/internals/i18n/utils.d.ts +9 -4
  343. package/internals/i18n/utils.js +4 -27
  344. package/internals/i18n/utils.js.map +1 -1
  345. package/internals/mixins/alert.d.ts +10 -25
  346. package/internals/mixins/alert.js.map +1 -1
  347. package/internals/mixins/combo-box.d.ts +21 -11
  348. package/internals/mixins/combo-box.js +16 -22
  349. package/internals/mixins/combo-box.js.map +1 -1
  350. package/internals/mixins/event-emitter.js +9 -11
  351. package/internals/mixins/event-emitter.js.map +1 -1
  352. package/internals/mixins/forms/associated-required.d.ts +4 -4
  353. package/internals/mixins/forms/associated-required.js.map +1 -1
  354. package/internals/mixins/forms/associated.d.ts +4 -2
  355. package/internals/mixins/forms/associated.js +8 -19
  356. package/internals/mixins/forms/associated.js.map +1 -1
  357. package/internals/mixins/forms/form-transformers.js.map +1 -1
  358. package/internals/mixins/forms/types.d.ts +24 -80
  359. package/internals/mixins/forms/types.js.map +1 -1
  360. package/internals/mixins/group.d.ts +18 -0
  361. package/internals/mixins/group.js +37 -0
  362. package/internals/mixins/group.js.map +1 -0
  363. package/internals/mixins/i18n.d.ts +10 -16
  364. package/internals/mixins/i18n.js.map +1 -1
  365. package/internals/mixins/mask-behavior.d.ts +8 -22
  366. package/internals/mixins/mask-behavior.js +1 -2
  367. package/internals/mixins/mask-behavior.js.map +1 -1
  368. package/internals/mixins/option.d.ts +1 -2
  369. package/internals/mixins/option.js +2 -1
  370. package/internals/mixins/option.js.map +1 -1
  371. package/internals/part-map.d.ts +4 -2
  372. package/internals/part-map.js +1 -1
  373. package/internals/part-map.js.map +1 -1
  374. package/internals/templates/input-shell.d.ts +8 -17
  375. package/internals/templates/input-shell.js +4 -1
  376. package/internals/templates/input-shell.js.map +1 -1
  377. package/internals/templates/masked-input.d.ts +7 -8
  378. package/internals/templates/masked-input.js.map +1 -1
  379. package/internals/templates/slotted-icon.d.ts +7 -12
  380. package/internals/templates/slotted-icon.js.map +1 -1
  381. package/internals/templates/toggle-shell.d.ts +6 -7
  382. package/internals/templates/toggle-shell.js.map +1 -1
  383. package/internals/timing.d.ts +5 -14
  384. package/internals/timing.js.map +1 -1
  385. package/internals/utils/arrays.d.ts +21 -21
  386. package/internals/utils/arrays.js +14 -0
  387. package/internals/utils/arrays.js.map +1 -1
  388. package/internals/utils/dom.d.ts +51 -39
  389. package/internals/utils/dom.js +1 -2
  390. package/internals/utils/dom.js.map +1 -1
  391. package/internals/utils/events.d.ts +29 -16
  392. package/internals/utils/events.js +9 -1
  393. package/internals/utils/events.js.map +1 -1
  394. package/internals/utils/lit.d.ts +5 -2
  395. package/internals/utils/lit.js.map +1 -1
  396. package/internals/utils/math.d.ts +8 -6
  397. package/internals/utils/math.js.map +1 -1
  398. package/internals/utils/objects.d.ts +3 -20
  399. package/internals/utils/objects.js +1 -39
  400. package/internals/utils/objects.js.map +1 -1
  401. package/internals/utils/strings.d.ts +9 -11
  402. package/internals/utils/strings.js.map +1 -1
  403. package/internals/utils/types.d.ts +16 -3
  404. package/internals/utils/types.js +3 -0
  405. package/internals/utils/types.js.map +1 -1
  406. package/internals/validators.d.ts +9 -8
  407. package/internals/validators.js +12 -6
  408. package/internals/validators.js.map +1 -1
  409. package/package.json +1 -1
  410. package/skills/README.md +3 -0
  411. package/skills/igniteui-wc-figma-to-app/SKILL.md +907 -0
  412. package/skills/igniteui-wc-figma-to-app/references/asset-extraction.md +363 -0
  413. package/skills/igniteui-wc-figma-to-app/references/design-token-bridge.md +407 -0
  414. package/skills/igniteui-wc-figma-to-app/references/figma-component-map.md +325 -0
  415. package/skills/igniteui-wc-figma-to-app/references/mcp-setup.md +409 -0
  416. package/skills/igniteui-wc-figma-to-app/references/validation-patterns.md +376 -0
  417. package/theming/config.d.ts +14 -5
  418. package/theming/config.js +38 -18
  419. package/theming/config.js.map +1 -1
  420. package/theming/context.d.ts +1 -23
  421. package/theming/context.js.map +1 -1
  422. package/theming/theming-controller.d.ts +2 -32
  423. package/theming/theming-controller.js +15 -21
  424. package/theming/theming-controller.js.map +1 -1
  425. package/theming/theming-event.d.ts +0 -7
  426. package/theming/theming-event.js +0 -13
  427. package/theming/theming-event.js.map +1 -1
  428. package/theming/types.d.ts +1 -8
  429. package/theming/types.js.map +1 -1
  430. package/web-types.json +3 -3
  431. package/animations/presets/slide/index.d.ts +0 -3
  432. package/animations/presets/slide/index.js +0 -16
  433. package/animations/presets/slide/index.js.map +0 -1
  434. package/components/resize-container/themes/resize-container.base.css.js.map +0 -1
  435. package/internals/controllers/root-scroll.d.ts +0 -31
  436. package/internals/controllers/root-scroll.js +0 -71
  437. package/internals/controllers/root-scroll.js.map +0 -1
  438. package/theming/utils.d.ts +0 -11
  439. package/theming/utils.js +0 -20
  440. package/theming/utils.js.map +0 -1
  441. /package/components/{resize-container/themes/resize-container.base.css.d.ts → breadcrumb/themes/breadcrumb.base.css.d.ts} +0 -0
@@ -1,15 +1,15 @@
1
1
  import type { Theme } from '#theming/types.js';
2
2
  import type { IconCallback, IconMeta, IconReferencePair, RegisterIconOptions, SvgIcon } from './registry/types.js';
3
3
  /**
4
- * Global singleton registry for managing SVG icons and their references.
4
+ * The global registry of SVG icons and their references.
5
5
  *
6
6
  * @remarks
7
- * The registry stores SVG icons in named collections, resolves aliases against
8
- * the active theme, notifies subscribers once per microtask however many icons
9
- * changed, and publishes user-set state to other browsing contexts (see
10
- * {@link IconsStateBroadcast}).
7
+ * The registry keeps the icons in named collections, resolves an alias against
8
+ * the active theme, notifies the subscribers one time per microtask however
9
+ * many icons changed, and publishes user-set state to the other browsing
10
+ * contexts. See {@link IconsStateBroadcast}.
11
11
  *
12
- * @internal Not exposed directly - use the exported functions.
12
+ * @internal Use the exported functions.
13
13
  */
14
14
  declare class IconsRegistry {
15
15
  private readonly _listeners;
@@ -1 +1 @@
1
- {"version":3,"file":"icon.registry.js","sourceRoot":"","sources":["../../../src/components/icon/icon.registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AASrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,SAAS,kBAAkB,CACzB,mBAAkD;IAElD,IAAI,OAAO,mBAAmB,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,UAAU,EAAE,mBAAmB,EAAE,UAAU,IAAI,SAAS;QACxD,SAAS,EAAE,mBAAmB,EAAE,SAAS,IAAI,KAAK;KACnD,CAAC;AACJ,CAAC;AAGD,SAAS,YAAY,CACnB,WAA+B,EAC/B,IAAY;IAEZ,IAAI,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAaD,MAAM,aAAa;IAAnB;QACmB,eAAU,GAAG,IAAI,GAAG,EAAgB,CAAC;QACrC,gBAAW,GAA8B,IAAI,GAAG,EAAE,CAAC;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AAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AA8CD,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,QAAgB,EAChB,mBAAkD;IAElD,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAC1E,eAAe,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAmCD,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,UAAkB,EAAE,IAAc;IACzE,eAAe,EAAE,CAAC,UAAU,CAAC;QAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QAC3B,MAAM,EAAE;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Theme } from '#theming/types.js';\nimport { ICON_REFERENCES } from './icon-references.js';\nimport { IconsStateBroadcast } from './icon-state.broadcast.js';\nimport { internalIcons } from './internal-icons-lib.js';\nimport { SvgIconParser } from './registry/parser.js';\nimport type {\n IconCallback,\n IconMeta,\n IconReferencePair,\n IconsCollection,\n RegisterIconOptions,\n SvgIcon,\n} from './registry/types.js';\nimport { ActionType } from './registry/types.js';\n\n/**\n * Normalizes the third argument of `registerIcon` / `registerIconFromText`,\n * which is either a collection name or a {@link RegisterIconOptions} object.\n */\nfunction resolveIconOptions(\n collectionOrOptions?: string | RegisterIconOptions\n): Required<RegisterIconOptions> {\n if (typeof collectionOrOptions === 'string') {\n return { collection: collectionOrOptions, stripMeta: false };\n }\n\n return {\n collection: collectionOrOptions?.collection ?? 'default',\n stripMeta: collectionOrOptions?.stripMeta ?? false,\n };\n}\n\n/** Returns the named collection, creating it when absent. */\nfunction collectionOf<V>(\n collections: IconsCollection<V>,\n name: string\n): Map<string, V> {\n let collection = collections.get(name);\n\n if (!collection) {\n collection = new Map();\n collections.set(name, collection);\n }\n\n return collection;\n}\n\n/**\n * Global singleton registry for managing SVG icons and their references.\n *\n * @remarks\n * The registry stores SVG icons in named collections, resolves aliases against\n * the active theme, notifies subscribers once per microtask however many icons\n * changed, and publishes user-set state to other browsing contexts (see\n * {@link IconsStateBroadcast}).\n *\n * @internal Not exposed directly - use the exported functions.\n */\nclass IconsRegistry {\n private readonly _listeners = new Set<IconCallback>();\n private readonly _references: IconsCollection<IconMeta> = new Map();\n private readonly _collections: IconsCollection<SvgIcon> = new Map([\n ['internal', internalIcons],\n ]);\n private readonly _svgIconParser = new SvgIconParser();\n private readonly _broadcast = new IconsStateBroadcast(\n this._collections,\n this._references\n );\n private _notificationScheduled = false;\n\n /**\n * Parses and stores an SVG icon, then publishes and notifies.\n *\n * @param stripMeta - See {@link RegisterIconOptions.stripMeta}.\n * @throws If the SVG text is malformed.\n */\n public register(\n name: string,\n iconText: string,\n collection = 'default',\n stripMeta = false\n ): void {\n const svgIcon = this._svgIconParser.parse(iconText, stripMeta);\n collectionOf(this._collections, collection).set(name, svgIcon);\n\n this._broadcast.send({\n actionType: ActionType.RegisterIcon,\n collections: new Map([[collection, new Map([[name, svgIcon]])]]),\n });\n\n this._notify();\n }\n\n /**\n * Subscribes a callback to registry changes. It is invoked once per\n * microtask, however many icons changed, so subscribers re-resolve their\n * own state.\n */\n public subscribe(callback: IconCallback): void {\n this._listeners.add(callback);\n }\n\n /** Unsubscribes a previously subscribed callback. */\n public unsubscribe(callback: IconCallback): void {\n this._listeners.delete(callback);\n }\n\n /**\n * Aliases an icon name to another icon.\n *\n * @remarks\n * `overwrite` stores the reference and notifies subscribers; `external`\n * marks it as user-set, which takes precedence over the built-in theme\n * aliases and is published to other browsing contexts.\n */\n public setIconRef(options: IconReferencePair): void {\n const { alias, target, overwrite } = options;\n\n if (overwrite) {\n collectionOf(this._references, alias.collection).set(alias.name, {\n name: target.name,\n collection: target.collection,\n external: target.external,\n });\n this._notify();\n }\n\n if (target.external) {\n const ref = { name: target.name, collection: target.collection };\n\n this._broadcast.send({\n actionType: ActionType.UpdateIconReference,\n references: new Map([[alias.collection, new Map([[alias.name, ref]])]]),\n });\n }\n }\n\n /**\n * Resolves a name that may be an alias to the icon it points at, for the\n * given theme. The result never carries the internal `external` flag.\n */\n public getIconRef(name: string, collection: string, theme?: Theme): IconMeta {\n // Check for any user-set reference first (external or internal)\n const storedRef = this._references.get(collection)?.get(name);\n if (storedRef) {\n return {\n name: storedRef.name,\n collection: storedRef.collection,\n };\n }\n\n // Resolve theme-based alias for the default collection\n if (collection === 'default' && theme) {\n const targets = ICON_REFERENCES.get(name);\n const target = targets?.get(theme) ?? targets?.get('default');\n\n if (target) {\n return target;\n }\n }\n\n return { name, collection };\n }\n\n /** Retrieves an icon. Resolve aliases with `getIconRef` first. */\n public get(name: string, collection = 'default'): SvgIcon | undefined {\n return this._collections.get(collection)?.get(name);\n }\n\n /**\n * Notifies subscribers, coalescing a burst of changes in the same microtask\n * into a single notification.\n */\n private _notify(): void {\n if (this._notificationScheduled) {\n return;\n }\n\n this._notificationScheduled = true;\n\n queueMicrotask(() => {\n this._notificationScheduled = false;\n\n for (const listener of this._listeners) {\n listener();\n }\n });\n }\n}\n\nconst registry = Symbol.for('igc.icons-registry.instance');\n\ntype IgcIconRegistry = typeof globalThis & {\n [registry]?: IconsRegistry;\n};\n\n/**\n * Gets the icon registry, creating it on first use. The well-known symbol on\n * `globalThis` keeps it a single instance even across multiple bundles.\n */\nexport function getIconRegistry(): IconsRegistry {\n const global = globalThis as IgcIconRegistry;\n global[registry] ??= new IconsRegistry();\n return global[registry];\n}\n\n/**\n * Registers an icon by fetching it from a URL.\n *\n * @param name - The unique name for the icon\n * @param url - The URL to fetch the SVG icon from\n * @param collection - The collection to register the icon in (default: `'default'`)\n *\n * @returns A promise that resolves when the icon is registered\n *\n * @throws If the HTTP request fails or returns a non-OK status\n */\nexport async function registerIcon(\n name: string,\n url: string,\n collection?: string\n): Promise<void>;\n\n/**\n * Registers an icon by fetching it from a URL.\n *\n * @param name - The unique name for the icon\n * @param url - The URL to fetch the SVG icon from\n * @param options - Registration options: target collection and/or `stripMeta`\n *\n * @returns A promise that resolves when the icon is registered\n *\n * @throws If the HTTP request fails or returns a non-OK status\n *\n * @remarks\n * This overload accepts a {@link RegisterIconOptions} object so you can control\n * the target collection **and** opt into SVG meta stripping in one call:\n *\n * ```typescript\n * // Strip <title>/<desc> to prevent browser-native tooltips on hover\n * await registerIcon('home', '/icons/home.svg', { stripMeta: true });\n *\n * // Or with a custom collection:\n * await registerIcon('home', '/icons/home.svg', {\n * collection: 'my-lib',\n * stripMeta: true,\n * });\n * ```\n */\nexport async function registerIcon(\n name: string,\n url: string,\n options?: RegisterIconOptions\n): Promise<void>;\n\nexport async function registerIcon(\n name: string,\n url: string,\n collectionOrOptions?: string | RegisterIconOptions\n): Promise<void> {\n const { collection, stripMeta } = resolveIconOptions(collectionOrOptions);\n const response = await fetch(url);\n\n if (response.ok) {\n const value = await response.text();\n getIconRegistry().register(name, value, collection, stripMeta);\n } else {\n throw new Error(`Icon request failed. Status: ${response.status}.`);\n }\n}\n\n/**\n * Registers an icon from SVG text content.\n *\n * @param name - The unique name for the icon\n * @param iconText - The SVG markup as a string\n * @param collection - The collection to register the icon in (default: `'default'`)\n *\n * @throws If the SVG text is malformed or doesn't contain an SVG element\n */\nexport function registerIconFromText(\n name: string,\n iconText: string,\n collection?: string\n): void;\n\n/**\n * Registers an icon from SVG text content.\n *\n * @param name - The unique name for the icon\n * @param iconText - The SVG markup as a string\n * @param options - Registration options: target collection and/or `stripMeta`\n *\n * @throws If the SVG text is malformed or doesn't contain an SVG element\n *\n * @remarks\n * This overload accepts a {@link RegisterIconOptions} object so you can control\n * the target collection **and** opt into SVG meta stripping in one call:\n *\n * ```typescript\n * const iconSvg = '<svg viewBox=\"0 0 24 24\"><title>Home</title><path d=\"...\"/></svg>';\n *\n * // Strip <title>/<desc> to prevent browser-native tooltips on hover\n * registerIconFromText('home', iconSvg, { stripMeta: true });\n *\n * // Or with a custom collection:\n * registerIconFromText('home', iconSvg, { collection: 'my-lib', stripMeta: true });\n * ```\n */\nexport function registerIconFromText(\n name: string,\n iconText: string,\n options?: RegisterIconOptions\n): void;\n\nexport function registerIconFromText(\n name: string,\n iconText: string,\n collectionOrOptions?: string | RegisterIconOptions\n): void {\n const { collection, stripMeta } = resolveIconOptions(collectionOrOptions);\n getIconRegistry().register(name, iconText, collection, stripMeta);\n}\n\n/**\n * Sets an icon reference/alias that points to another icon.\n *\n * @param name - The alias name\n * @param collection - The collection for the alias\n * @param icon - The target icon metadata (name and collection)\n *\n * @remarks\n * Icon references allow you to create aliases that point to other icons.\n * This is useful for:\n * - Creating semantic names (e.g., 'close' → 'x')\n * - Overriding default icon mappings\n * - Providing fallbacks for missing icons\n *\n * User-set references are marked as external and have higher priority than\n * theme-based aliases. They are also published to other browsing contexts.\n *\n * @example\n * ```typescript\n * // Register target icon\n * registerIconFromText('x-mark', '<svg>...</svg>');\n *\n * // Create an alias\n * setIconRef('close', 'default', {\n * name: 'x-mark',\n * collection: 'default'\n * });\n *\n * // Both work the same way:\n * // <igc-icon name=\"close\"></igc-icon>\n * // <igc-icon name=\"x-mark\"></igc-icon>\n * ```\n */\nexport function setIconRef(name: string, collection: string, icon: IconMeta) {\n getIconRegistry().setIconRef({\n alias: { name, collection },\n target: {\n name: icon.name,\n collection: icon.collection,\n external: true,\n },\n overwrite: true,\n });\n}\n"]}
1
+ {"version":3,"file":"icon.registry.js","sourceRoot":"","sources":["../../../src/components/icon/icon.registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM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Q,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAmCD,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,UAAkB,EAAE,IAAc;IACzE,eAAe,EAAE,CAAC,UAAU,CAAC;QAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QAC3B,MAAM,EAAE;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Theme } from '#theming/types.js';\nimport { ICON_REFERENCES } from './icon-references.js';\nimport { IconsStateBroadcast } from './icon-state.broadcast.js';\nimport { internalIcons } from './internal-icons-lib.js';\nimport { SvgIconParser } from './registry/parser.js';\nimport type {\n IconCallback,\n IconMeta,\n IconReferencePair,\n IconsCollection,\n RegisterIconOptions,\n SvgIcon,\n} from './registry/types.js';\nimport { ActionType } from './registry/types.js';\n\n/**\n * Normalizes the third argument of `registerIcon` / `registerIconFromText`,\n * which is either a collection name or a {@link RegisterIconOptions} object.\n */\nfunction resolveIconOptions(\n collectionOrOptions?: string | RegisterIconOptions\n): Required<RegisterIconOptions> {\n if (typeof collectionOrOptions === 'string') {\n return { collection: collectionOrOptions, stripMeta: false };\n }\n\n return {\n collection: collectionOrOptions?.collection ?? 'default',\n stripMeta: collectionOrOptions?.stripMeta ?? false,\n };\n}\n\n/** Returns the named collection, creating it when absent. */\nfunction collectionOf<V>(\n collections: IconsCollection<V>,\n name: string\n): Map<string, V> {\n let collection = collections.get(name);\n\n if (!collection) {\n collection = new Map();\n collections.set(name, collection);\n }\n\n return collection;\n}\n\n/**\n * The global registry of SVG icons and their references.\n *\n * @remarks\n * The registry keeps the icons in named collections, resolves an alias against\n * the active theme, notifies the subscribers one time per microtask however\n * many icons changed, and publishes user-set state to the other browsing\n * contexts. See {@link IconsStateBroadcast}.\n *\n * @internal Use the exported functions.\n */\nclass IconsRegistry {\n private readonly _listeners = new Set<IconCallback>();\n private readonly _references: IconsCollection<IconMeta> = new Map();\n private readonly _collections: IconsCollection<SvgIcon> = new Map([\n ['internal', internalIcons],\n ]);\n private readonly _svgIconParser = new SvgIconParser();\n private readonly _broadcast = new IconsStateBroadcast(\n this._collections,\n this._references\n );\n private _notificationScheduled = false;\n\n /**\n * Parses and stores an SVG icon, then publishes and notifies.\n *\n * @param stripMeta - See {@link RegisterIconOptions.stripMeta}.\n * @throws If the SVG text is malformed.\n */\n public register(\n name: string,\n iconText: string,\n collection = 'default',\n stripMeta = false\n ): void {\n const svgIcon = this._svgIconParser.parse(iconText, stripMeta);\n collectionOf(this._collections, collection).set(name, svgIcon);\n\n this._broadcast.send({\n actionType: ActionType.RegisterIcon,\n collections: new Map([[collection, new Map([[name, svgIcon]])]]),\n });\n\n this._notify();\n }\n\n /**\n * Subscribes a callback to registry changes. It is invoked once per\n * microtask, however many icons changed, so subscribers re-resolve their\n * own state.\n */\n public subscribe(callback: IconCallback): void {\n this._listeners.add(callback);\n }\n\n /** Unsubscribes a previously subscribed callback. */\n public unsubscribe(callback: IconCallback): void {\n this._listeners.delete(callback);\n }\n\n /**\n * Aliases an icon name to another icon.\n *\n * @remarks\n * `overwrite` stores the reference and notifies subscribers; `external`\n * marks it as user-set, which takes precedence over the built-in theme\n * aliases and is published to other browsing contexts.\n */\n public setIconRef(options: IconReferencePair): void {\n const { alias, target, overwrite } = options;\n\n if (overwrite) {\n collectionOf(this._references, alias.collection).set(alias.name, {\n name: target.name,\n collection: target.collection,\n external: target.external,\n });\n this._notify();\n }\n\n if (target.external) {\n const ref = { name: target.name, collection: target.collection };\n\n this._broadcast.send({\n actionType: ActionType.UpdateIconReference,\n references: new Map([[alias.collection, new Map([[alias.name, ref]])]]),\n });\n }\n }\n\n /**\n * Resolves a name that may be an alias to the icon it points at, for the\n * given theme. The result never carries the internal `external` flag.\n */\n public getIconRef(name: string, collection: string, theme?: Theme): IconMeta {\n // Check for any user-set reference first (external or internal)\n const storedRef = this._references.get(collection)?.get(name);\n if (storedRef) {\n return {\n name: storedRef.name,\n collection: storedRef.collection,\n };\n }\n\n // Resolve theme-based alias for the default collection\n if (collection === 'default' && theme) {\n const targets = ICON_REFERENCES.get(name);\n const target = targets?.get(theme) ?? targets?.get('default');\n\n if (target) {\n return target;\n }\n }\n\n return { name, collection };\n }\n\n /** Retrieves an icon. Resolve aliases with `getIconRef` first. */\n public get(name: string, collection = 'default'): SvgIcon | undefined {\n return this._collections.get(collection)?.get(name);\n }\n\n /**\n * Notifies subscribers, coalescing a burst of changes in the same microtask\n * into a single notification.\n */\n private _notify(): void {\n if (this._notificationScheduled) {\n return;\n }\n\n this._notificationScheduled = true;\n\n queueMicrotask(() => {\n this._notificationScheduled = false;\n\n for (const listener of this._listeners) {\n listener();\n }\n });\n }\n}\n\nconst registry = Symbol.for('igc.icons-registry.instance');\n\ntype IgcIconRegistry = typeof globalThis & {\n [registry]?: IconsRegistry;\n};\n\n/**\n * Gets the icon registry, creating it on first use. The well-known symbol on\n * `globalThis` keeps it a single instance even across multiple bundles.\n */\nexport function getIconRegistry(): IconsRegistry {\n const global = globalThis as IgcIconRegistry;\n global[registry] ??= new IconsRegistry();\n return global[registry];\n}\n\n/**\n * Registers an icon by fetching it from a URL.\n *\n * @param name - The unique name for the icon\n * @param url - The URL to fetch the SVG icon from\n * @param collection - The collection to register the icon in (default: `'default'`)\n *\n * @returns A promise that resolves when the icon is registered\n *\n * @throws If the HTTP request fails or returns a non-OK status\n */\nexport async function registerIcon(\n name: string,\n url: string,\n collection?: string\n): Promise<void>;\n\n/**\n * Registers an icon by fetching it from a URL.\n *\n * @param name - The unique name for the icon\n * @param url - The URL to fetch the SVG icon from\n * @param options - Registration options: target collection and/or `stripMeta`\n *\n * @returns A promise that resolves when the icon is registered\n *\n * @throws If the HTTP request fails or returns a non-OK status\n *\n * @remarks\n * This overload accepts a {@link RegisterIconOptions} object so you can control\n * the target collection **and** opt into SVG meta stripping in one call:\n *\n * ```typescript\n * // Strip <title>/<desc> to prevent browser-native tooltips on hover\n * await registerIcon('home', '/icons/home.svg', { stripMeta: true });\n *\n * // Or with a custom collection:\n * await registerIcon('home', '/icons/home.svg', {\n * collection: 'my-lib',\n * stripMeta: true,\n * });\n * ```\n */\nexport async function registerIcon(\n name: string,\n url: string,\n options?: RegisterIconOptions\n): Promise<void>;\n\nexport async function registerIcon(\n name: string,\n url: string,\n collectionOrOptions?: string | RegisterIconOptions\n): Promise<void> {\n const { collection, stripMeta } = resolveIconOptions(collectionOrOptions);\n const response = await fetch(url);\n\n if (response.ok) {\n const value = await response.text();\n getIconRegistry().register(name, value, collection, stripMeta);\n } else {\n throw new Error(`Icon request failed. Status: ${response.status}.`);\n }\n}\n\n/**\n * Registers an icon from SVG text content.\n *\n * @param name - The unique name for the icon\n * @param iconText - The SVG markup as a string\n * @param collection - The collection to register the icon in (default: `'default'`)\n *\n * @throws If the SVG text is malformed or doesn't contain an SVG element\n */\nexport function registerIconFromText(\n name: string,\n iconText: string,\n collection?: string\n): void;\n\n/**\n * Registers an icon from SVG text content.\n *\n * @param name - The unique name for the icon\n * @param iconText - The SVG markup as a string\n * @param options - Registration options: target collection and/or `stripMeta`\n *\n * @throws If the SVG text is malformed or doesn't contain an SVG element\n *\n * @remarks\n * This overload accepts a {@link RegisterIconOptions} object so you can control\n * the target collection **and** opt into SVG meta stripping in one call:\n *\n * ```typescript\n * const iconSvg = '<svg viewBox=\"0 0 24 24\"><title>Home</title><path d=\"...\"/></svg>';\n *\n * // Strip <title>/<desc> to prevent browser-native tooltips on hover\n * registerIconFromText('home', iconSvg, { stripMeta: true });\n *\n * // Or with a custom collection:\n * registerIconFromText('home', iconSvg, { collection: 'my-lib', stripMeta: true });\n * ```\n */\nexport function registerIconFromText(\n name: string,\n iconText: string,\n options?: RegisterIconOptions\n): void;\n\nexport function registerIconFromText(\n name: string,\n iconText: string,\n collectionOrOptions?: string | RegisterIconOptions\n): void {\n const { collection, stripMeta } = resolveIconOptions(collectionOrOptions);\n getIconRegistry().register(name, iconText, collection, stripMeta);\n}\n\n/**\n * Sets an icon reference/alias that points to another icon.\n *\n * @param name - The alias name\n * @param collection - The collection for the alias\n * @param icon - The target icon metadata (name and collection)\n *\n * @remarks\n * Icon references allow you to create aliases that point to other icons.\n * This is useful for:\n * - Creating semantic names (e.g., 'close' → 'x')\n * - Overriding default icon mappings\n * - Providing fallbacks for missing icons\n *\n * User-set references are marked as external and have higher priority than\n * theme-based aliases. They are also published to other browsing contexts.\n *\n * @example\n * ```typescript\n * // Register target icon\n * registerIconFromText('x-mark', '<svg>...</svg>');\n *\n * // Create an alias\n * setIconRef('close', 'default', {\n * name: 'x-mark',\n * collection: 'default'\n * });\n *\n * // Both work the same way:\n * // <igc-icon name=\"close\"></igc-icon>\n * // <igc-icon name=\"x-mark\"></igc-icon>\n * ```\n */\nexport function setIconRef(name: string, collection: string, icon: IconMeta) {\n getIconRegistry().setIconRef({\n alias: { name, collection },\n target: {\n name: icon.name,\n collection: icon.collection,\n external: true,\n },\n overwrite: true,\n });\n}\n"]}
@@ -10,7 +10,7 @@ import { IgcInputBaseComponent } from './input-base.js';
10
10
  * @slot suffix - Renders content after input.
11
11
  * @slot helper-text - Renders content below the input.
12
12
  * @slot value-missing - Renders content when the required validation fails.
13
- * @slot type-mismatch - Renders content when the a type url/email input pattern validation fails.
13
+ * @slot type-mismatch - Renders content when the url/email type validation fails.
14
14
  * @slot pattern-mismatch - Renders content when the pattern validation fails.
15
15
  * @slot too-long - Renders content when the maxlength validation fails.
16
16
  * @slot too-short - Renders content when the minlength validation fails.
@@ -21,7 +21,7 @@ import { IgcInputBaseComponent } from './input-base.js';
21
21
  * @slot invalid - Renders content when the component is in invalid state (validity.valid = false).
22
22
  *
23
23
  * @fires igcInput - Emitted when the control input receives user input.
24
- * @fires igcChange - Emitted when the control's checked state changes.
24
+ * @fires igcChange - Emitted when the value of the control is committed.
25
25
  *
26
26
  * @csspart container - The main wrapper that holds all main input elements.
27
27
  * @csspart input - The native input element.
@@ -37,7 +37,7 @@ export default class IgcInputComponent extends IgcInputBaseComponent {
37
37
  private static readonly _revalidate;
38
38
  static register(): void;
39
39
  protected readonly _themes: import("#theming/theming-controller.js").ThemingController;
40
- protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "helper-text" | "[default]" | "suffix" | "value-missing" | "too-long" | "too-short" | "custom-error" | "range-overflow" | "range-underflow" | "type-mismatch" | "pattern-mismatch" | "step-mismatch">;
40
+ protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "[default]" | "suffix" | "helper-text" | "value-missing" | "too-long" | "too-short" | "custom-error" | "range-overflow" | "range-underflow" | "type-mismatch" | "pattern-mismatch" | "step-mismatch">;
41
41
  protected readonly _formValue: import("#internals/mixins/forms/form-value.js").FormValue<string>;
42
42
  protected get __validators(): import("../../internals/validators.js").Validator<IgcInputComponent>[];
43
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EACL,eAAe,GAEhB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,w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,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;+CACd;AAOjB;IADf,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACQ;AAO7B;IADN,QAAQ,EAAE;uDACkB;AAUtB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;uDAC3C","sourcesContent":["import { html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { ariaBindings } from '#internals/controllers/aria-projection.js';\nimport { addSlotController, setSlots } from '#internals/controllers/slot.js';\nimport {\n coercedProperty,\n type CoercedPropertyConfig,\n} from '#internals/decorators/coerced-property.js';\nimport { registerComponent } from '#internals/definitions/register.js';\nimport { createFormValueState } from '#internals/mixins/forms/form-value.js';\nimport { partMap } from '#internals/part-map.js';\nimport { bindIf } from '#internals/utils/lit.js';\nimport { addThemingController } from '#theming/theming-controller.js';\nimport type {\n InputType,\n RangeTextSelectMode,\n SelectionRangeDirection,\n} from '../types.js';\nimport IgcValidationContainerComponent from '../validation-container/validation-container.js';\nimport { IgcInputBaseComponent } from './input-base.js';\nimport { styles } from './themes/input.base.css.js';\nimport { styles as shared } from './themes/shared/input.common.css.js';\nimport { all } from './themes/themes.js';\nimport { numberValidators, stringValidators } from './validators.js';\n\nconst Slots = setSlots(\n 'prefix',\n 'suffix',\n 'helper-text',\n 'value-missing',\n 'type-mismatch',\n 'pattern-mismatch',\n 'too-long',\n 'too-short',\n 'range-overflow',\n 'range-underflow',\n 'step-mismatch',\n 'custom-error',\n 'invalid'\n);\n\n/**\n * A highly customizable single-line text field for entering and editing data,\n * with support for prefix/suffix content, helper text, form integration, and built-in validation.\n *\n * @element igc-input\n *\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot helper-text - Renders content below the input.\n * @slot value-missing - Renders content when the required validation fails.\n * @slot type-mismatch - Renders content when the a type url/email input pattern validation fails.\n * @slot pattern-mismatch - Renders content when the pattern validation fails.\n * @slot too-long - Renders content when the maxlength validation fails.\n * @slot too-short - Renders content when the minlength validation fails.\n * @slot range-overflow - Renders content when the max validation fails.\n * @slot range-underflow - Renders content when the min validation fails.\n * @slot step-mismatch - Renders content when the step validation fails.\n * @slot custom-error - Renders content when setCustomValidity(message) is set.\n * @slot invalid - Renders content when the component is in invalid state (validity.valid = false).\n *\n * @fires igcInput - Emitted when the control input receives user input.\n * @fires igcChange - Emitted when the control's checked state changes.\n *\n * @csspart container - The main wrapper that holds all main input elements.\n * @csspart input - The native input element.\n * @csspart label - The native label element.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcInputComponent extends IgcInputBaseComponent {\n public static readonly tagName = 'igc-input';\n public static styles = [styles, shared];\n\n /** Shared config for the constraint properties - a change revalidates. */\n private static readonly _revalidate: CoercedPropertyConfig<\n unknown,\n IgcInputComponent\n > = {\n onChange: ({ host }) => host._validate(),\n };\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcInputComponent, IgcValidationContainerComponent);\n }\n\n protected override readonly _themes = addThemingController(this, all);\n\n protected override readonly _slots = addSlotController(this, {\n slots: Slots,\n });\n\n protected override readonly _formValue = createFormValueState(this, {\n initialValue: '',\n });\n\n protected override get __validators() {\n return this.type !== 'number' ? stringValidators : numberValidators;\n }\n\n /* @tsTwoWayProperty(true, \"igcChange\", \"detail\", false) */\n /**\n * The value of the control.\n * @attr\n */\n @property()\n public set value(value: string) {\n this._formValue.setValueAndFormState(value);\n }\n\n public get value(): string {\n return this._formValue.value;\n }\n\n /* alternateName: displayType */\n /**\n * The type of the control.\n * @attr\n */\n @property({ reflect: true })\n public type: InputType = 'text';\n\n /**\n * Makes the control a readonly field.\n *\n * @attr readonly\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public readOnly = false;\n\n /**\n * A hint to the browser for which virtual keyboard layout to display.\n * See [relevant MDN article](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)\n * @attr inputmode\n */\n @property({ attribute: 'inputmode' })\n public override inputMode!: string;\n\n /**\n * The regular expression the value is validated against.\n * @attr\n */\n @property()\n @coercedProperty(IgcInputComponent._revalidate)\n public pattern?: string = undefined;\n\n /**\n * The minimum string length required by the control.\n * @attr minlength\n */\n @property({ type: Number, attribute: 'minlength' })\n @coercedProperty(IgcInputComponent._revalidate)\n public minLength?: number = undefined;\n\n /**\n * The maximum string length of the control.\n * @attr maxlength\n */\n @property({ type: Number, attribute: 'maxlength' })\n @coercedProperty(IgcInputComponent._revalidate)\n public maxLength?: number = undefined;\n\n /**\n * The minimum value the control accepts.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public min?: number = undefined;\n\n /**\n * The maximum value the control accepts.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public max?: number = undefined;\n\n /**\n * The granularity the value must adhere to.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public step?: number = undefined;\n\n /**\n * Whether the control should receive focus automatically.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /**\n * A hint for the browser on how to autofill the control.\n * @attr\n */\n @property()\n public autocomplete!: string;\n\n /**\n * Enables validation rules to be evaluated without restricting user input. This applies to the `maxLength` property for\n * string-type inputs or allows spin buttons to exceed the predefined `min/max` limits for number-type inputs.\n *\n * @attr validate-only\n * @default false\n */\n @property({ type: Boolean, reflect: true, attribute: 'validate-only' })\n public validateOnly = false;\n\n /* blazorSuppress */\n /** Replaces the selected text in the input. */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode: RangeTextSelectMode = 'preserve'\n ): void {\n this._input?.setRangeText(replacement, start!, end!, selectMode);\n this.value = this._input?.value ?? '';\n }\n\n /* blazorSuppress */\n /** Sets the text selection range of the control */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction: SelectionRangeDirection = 'none'\n ): void {\n this._input?.setSelectionRange(start ?? null, end ?? null, direction);\n }\n\n /** Increments the numeric value of the input by one or more steps. */\n public stepUp(n?: number): void {\n this._input?.stepUp(n);\n this.value = this._input?.value ?? '';\n }\n\n /** Decrements the numeric value of the input by one or more steps. */\n public stepDown(n?: number): void {\n this._input?.stepDown(n);\n this.value = this._input?.value ?? '';\n }\n\n private _handleInput(): void {\n this._commitValue(this._input?.value ?? '', 'igcInput');\n }\n\n private _handleChange(): void {\n this._commitValue(this._input?.value ?? '', 'igcChange');\n }\n\n protected _renderInput() {\n const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';\n\n return html`\n <input\n ${ariaBindings(this._ariaTarget.resolveBindings())}\n id=${this._inputId}\n part=${partMap(this._resolvePartNames('input'))}\n name=${ifDefined(this.name)}\n type=${ifDefined(this.type)}\n pattern=${ifDefined(this.pattern)}\n placeholder=${ifDefined(this.placeholder)}\n .value=${live(this.value)}\n ?readonly=${this.readOnly}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?autofocus=${this.autofocus}\n tabindex=${bindIf(hasNegativeTabIndex, -1)}\n autocomplete=${ifDefined(this.autocomplete as any)}\n inputmode=${ifDefined(this.inputMode)}\n min=${bindIf(!this.validateOnly, this.min)}\n max=${bindIf(!this.validateOnly, this.max)}\n minlength=${ifDefined(this.minLength)}\n maxlength=${bindIf(!this.validateOnly, this.maxLength)}\n step=${ifDefined(this.step)}\n @keydown=${this._handleEnterKeydown}\n @change=${this._handleChange}\n @input=${this._handleInput}\n @blur=${this._handleBlur}\n />\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-input': IgcInputComponent;\n }\n}\n"]}
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/components/input/input.ts"],"names":[],"mappings":";;;;;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AAQ7B;IAFN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAClD,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;oDACT;AAQ/B;IAFN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAClD,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;oDACT;AAQ/B;IAFN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;8CACf;AAQzB;IAFN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;8CACf;AAQzB;IAFN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC;+CACd;AAOjB;IADf,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACQ;AAO7B;IADN,QAAQ,EAAE;uDACkB;AAUtB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;uDAC3C","sourcesContent":["import { html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { ariaBindings } from '#internals/controllers/aria-projection.js';\nimport { addSlotController, setSlots } from '#internals/controllers/slot.js';\nimport {\n coercedProperty,\n type CoercedPropertyConfig,\n} from '#internals/decorators/coerced-property.js';\nimport { registerComponent } from '#internals/definitions/register.js';\nimport { createFormValueState } from '#internals/mixins/forms/form-value.js';\nimport { partMap } from '#internals/part-map.js';\nimport { bindIf } from '#internals/utils/lit.js';\nimport { addThemingController } from '#theming/theming-controller.js';\nimport type {\n InputType,\n RangeTextSelectMode,\n SelectionRangeDirection,\n} from '../types.js';\nimport IgcValidationContainerComponent from '../validation-container/validation-container.js';\nimport { IgcInputBaseComponent } from './input-base.js';\nimport { styles } from './themes/input.base.css.js';\nimport { styles as shared } from './themes/shared/input.common.css.js';\nimport { all } from './themes/themes.js';\nimport { numberValidators, stringValidators } from './validators.js';\n\nconst Slots = setSlots(\n 'prefix',\n 'suffix',\n 'helper-text',\n 'value-missing',\n 'type-mismatch',\n 'pattern-mismatch',\n 'too-long',\n 'too-short',\n 'range-overflow',\n 'range-underflow',\n 'step-mismatch',\n 'custom-error',\n 'invalid'\n);\n\n/**\n * A highly customizable single-line text field for entering and editing data,\n * with support for prefix/suffix content, helper text, form integration, and built-in validation.\n *\n * @element igc-input\n *\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot helper-text - Renders content below the input.\n * @slot value-missing - Renders content when the required validation fails.\n * @slot type-mismatch - Renders content when the url/email type validation fails.\n * @slot pattern-mismatch - Renders content when the pattern validation fails.\n * @slot too-long - Renders content when the maxlength validation fails.\n * @slot too-short - Renders content when the minlength validation fails.\n * @slot range-overflow - Renders content when the max validation fails.\n * @slot range-underflow - Renders content when the min validation fails.\n * @slot step-mismatch - Renders content when the step validation fails.\n * @slot custom-error - Renders content when setCustomValidity(message) is set.\n * @slot invalid - Renders content when the component is in invalid state (validity.valid = false).\n *\n * @fires igcInput - Emitted when the control input receives user input.\n * @fires igcChange - Emitted when the value of the control is committed.\n *\n * @csspart container - The main wrapper that holds all main input elements.\n * @csspart input - The native input element.\n * @csspart label - The native label element.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcInputComponent extends IgcInputBaseComponent {\n public static readonly tagName = 'igc-input';\n public static styles = [styles, shared];\n\n /** Shared config for the constraint properties - a change revalidates. */\n private static readonly _revalidate: CoercedPropertyConfig<\n unknown,\n IgcInputComponent\n > = {\n onChange: ({ host }) => host._validate(),\n };\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcInputComponent, IgcValidationContainerComponent);\n }\n\n protected override readonly _themes = addThemingController(this, all);\n\n protected override readonly _slots = addSlotController(this, {\n slots: Slots,\n });\n\n protected override readonly _formValue = createFormValueState(this, {\n initialValue: '',\n });\n\n protected override get __validators() {\n return this.type !== 'number' ? stringValidators : numberValidators;\n }\n\n /* @tsTwoWayProperty(true, \"igcChange\", \"detail\", false) */\n /**\n * The value of the control.\n * @attr\n */\n @property()\n public set value(value: string) {\n this._formValue.setValueAndFormState(value);\n }\n\n public get value(): string {\n return this._formValue.value;\n }\n\n /* alternateName: displayType */\n /**\n * The type of the control.\n * @attr\n */\n @property({ reflect: true })\n public type: InputType = 'text';\n\n /**\n * Makes the control a readonly field.\n *\n * @attr readonly\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public readOnly = false;\n\n /**\n * A hint to the browser for which virtual keyboard layout to display.\n * See [relevant MDN article](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode)\n * @attr inputmode\n */\n @property({ attribute: 'inputmode' })\n public override inputMode!: string;\n\n /**\n * The regular expression the value is validated against.\n * @attr\n */\n @property()\n @coercedProperty(IgcInputComponent._revalidate)\n public pattern?: string = undefined;\n\n /**\n * The minimum string length required by the control.\n * @attr minlength\n */\n @property({ type: Number, attribute: 'minlength' })\n @coercedProperty(IgcInputComponent._revalidate)\n public minLength?: number = undefined;\n\n /**\n * The maximum string length of the control.\n * @attr maxlength\n */\n @property({ type: Number, attribute: 'maxlength' })\n @coercedProperty(IgcInputComponent._revalidate)\n public maxLength?: number = undefined;\n\n /**\n * The minimum value the control accepts.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public min?: number = undefined;\n\n /**\n * The maximum value the control accepts.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public max?: number = undefined;\n\n /**\n * The granularity the value must adhere to.\n * @attr\n */\n @property({ type: Number })\n @coercedProperty(IgcInputComponent._revalidate)\n public step?: number = undefined;\n\n /**\n * Whether the control should receive focus automatically.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /**\n * A hint for the browser on how to autofill the control.\n * @attr\n */\n @property()\n public autocomplete!: string;\n\n /**\n * Enables validation rules to be evaluated without restricting user input. This applies to the `maxLength` property for\n * string-type inputs or allows spin buttons to exceed the predefined `min/max` limits for number-type inputs.\n *\n * @attr validate-only\n * @default false\n */\n @property({ type: Boolean, reflect: true, attribute: 'validate-only' })\n public validateOnly = false;\n\n /* blazorSuppress */\n /** Replaces the selected text in the input. */\n public setRangeText(\n replacement: string,\n start?: number,\n end?: number,\n selectMode: RangeTextSelectMode = 'preserve'\n ): void {\n this._input?.setRangeText(replacement, start!, end!, selectMode);\n this.value = this._input?.value ?? '';\n }\n\n /* blazorSuppress */\n /** Sets the text selection range of the control */\n public setSelectionRange(\n start?: number,\n end?: number,\n direction: SelectionRangeDirection = 'none'\n ): void {\n this._input?.setSelectionRange(start ?? null, end ?? null, direction);\n }\n\n /** Increments the numeric value of the input by one or more steps. */\n public stepUp(n?: number): void {\n this._input?.stepUp(n);\n this.value = this._input?.value ?? '';\n }\n\n /** Decrements the numeric value of the input by one or more steps. */\n public stepDown(n?: number): void {\n this._input?.stepDown(n);\n this.value = this._input?.value ?? '';\n }\n\n private _handleInput(): void {\n this._commitValue(this._input?.value ?? '', 'igcInput');\n }\n\n private _handleChange(): void {\n this._commitValue(this._input?.value ?? '', 'igcChange');\n }\n\n protected _renderInput() {\n const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';\n\n return html`\n <input\n ${ariaBindings(this._ariaTarget.resolveBindings())}\n id=${this._inputId}\n part=${partMap(this._resolvePartNames('input'))}\n name=${ifDefined(this.name)}\n type=${ifDefined(this.type)}\n pattern=${ifDefined(this.pattern)}\n placeholder=${ifDefined(this.placeholder)}\n .value=${live(this.value)}\n ?readonly=${this.readOnly}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?autofocus=${this.autofocus}\n tabindex=${bindIf(hasNegativeTabIndex, -1)}\n autocomplete=${ifDefined(this.autocomplete as any)}\n inputmode=${ifDefined(this.inputMode)}\n min=${bindIf(!this.validateOnly, this.min)}\n max=${bindIf(!this.validateOnly, this.max)}\n minlength=${ifDefined(this.minLength)}\n maxlength=${bindIf(!this.validateOnly, this.maxLength)}\n step=${ifDefined(this.step)}\n @keydown=${this._handleEnterKeydown}\n @change=${this._handleChange}\n @input=${this._handleInput}\n @blur=${this._handleBlur}\n />\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-input': IgcInputComponent;\n }\n}\n"]}
@@ -15,18 +15,20 @@ type MaskEditKind = 'insert' | 'delete-backward' | 'delete-forward' | 'atomic';
15
15
  /** Resolves the identity of the mask pattern the snapshots were taken against. */
16
16
  type MaskSignature = () => string;
17
17
  /**
18
- * The undo/redo history of a masked editor.
18
+ * The undo and redo history of a masked editor.
19
19
  *
20
- * Masked text is rendered through `.value=${live(...)}`, so every edit reassigns the
21
- * native input's value - which wipes the browser's own undo stack. This replaces it.
20
+ * @remarks
21
+ * `.value=${live(...)}` renders the masked text, so each edit assigns the value
22
+ * of the native input again and clears the undo stack of the browser. This
23
+ * history replaces that stack.
22
24
  *
23
- * It holds no timers: a run is coalesced purely from the caret geometry, so the same
24
- * sequence of edits always produces the same sequence of steps.
25
+ * It holds no timers. The caret geometry alone groups a run, so the same edits
26
+ * always give the same steps.
25
27
  *
26
- * The history is self-invalidating rather than instrumented. Anything that moves the
27
- * masked text without going through it - a programmatic `value`, `clear()`, a form reset -
28
- * is caught by comparing against the text it last observed, and a changed mask pattern is
29
- * caught by the signature. That is why no call site has to announce those changes.
28
+ * The history invalidates itself. It compares against the text it last saw to
29
+ * find a change that did not go through it, such as a `value` from code,
30
+ * `clear()` or a form reset, and the signature finds a changed mask pattern. No
31
+ * call site must report those changes.
30
32
  *
31
33
  * @hidden
32
34
  */
@@ -39,26 +41,28 @@ declare class MaskHistory {
39
41
  private _lastValue;
40
42
  private _pattern;
41
43
  /**
42
- * The state the most recent traversal restored.
44
+ * The state that the last traversal restored.
43
45
  *
44
- * Holding `Ctrl + Z` fires faster than the caret can be written back to the DOM, so the
45
- * live selection is not a trustworthy counterpart entry for the opposite stack. The
46
- * state we know we just restored is.
46
+ * @remarks
47
+ * A held `Ctrl + Z` repeats faster than the caret reaches the DOM, so the live
48
+ * selection is not a reliable entry for the opposite stack. This state holds
49
+ * the value and the caret that the traversal wrote, so it pushes the correct
50
+ * entry.
47
51
  */
48
52
  private _lastRestored;
49
53
  constructor(signature: MaskSignature);
50
54
  get canUndo(): boolean;
51
55
  get canRedo(): boolean;
52
56
  /**
53
- * A run continues only while the caret stays where the previous edit left it, which is
54
- * what makes a click or an arrow key break it without any extra hook. Replacing a
55
- * selection is always a deliberate edit of its own.
57
+ * A run continues only while the caret stays where the last edit left it, so a
58
+ * click or an arrow key breaks it with no extra hook. A replaced selection is
59
+ * always its own edit.
56
60
  */
57
61
  private _shouldCoalesce;
58
62
  private _clear;
59
63
  /**
60
- * Drops everything the history holds when the mask pattern changed or the text moved
61
- * behind our back. Returns whether the snapshots are still usable.
64
+ * Drops all the history if the mask pattern changed, or if the text moved
65
+ * from outside. Returns whether the snapshots are still usable.
62
66
  */
63
67
  private _validate;
64
68
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mask-history.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-history.ts"],"names":[],"mappings":"AAmBA,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAkB7B,MAAM,WAAW;IAmBf,YAAY,SAAwB;QAjBnB,eAAU,GAAuB,EAAE,CAAC;QACpC,eAAU,GAAuB,EAAE,CAAC;QAE7C,cAAS,GAAwB,IAAI,CAAC;QACtC,eAAU,GAAG,CAAC,CAAC,CAAC;QAChB,eAAU,GAAG,EAAE,CAAC;QAChB,aAAQ,GAAG,EAAE,CAAC;QASd,kBAAa,GA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CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CACX,IAAwB,EACxB,EAAsB,EACtB,OAAyB;QAIzB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QAG9C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;QAElC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAcD,MAAM,UAAU,iBAAiB,CAAC,SAAwB;IACxD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/** A snapshot of the editor state as it was *before* an edit was applied. */\ntype MaskHistoryState = {\n value: string;\n start: number;\n end: number;\n};\n\n/**\n * The granularity an edit contributes to the history.\n *\n * The three granular kinds coalesce, so a run of typed characters or of deletions\n * collapses into a single step. Everything else - paste, drop, cut, composition,\n * auto-fill, spinning a date part, `setRangeText` - is `atomic` and gets its own step.\n */\ntype MaskEditKind = 'insert' | 'delete-backward' | 'delete-forward' | 'atomic';\n\n/** Resolves the identity of the mask pattern the snapshots were taken against. */\ntype MaskSignature = () => string;\n\nconst MAX_HISTORY_SIZE = 100;\n\n/**\n * The undo/redo history of a masked editor.\n *\n * Masked text is rendered through `.value=${live(...)}`, so every edit reassigns the\n * native input's value - which wipes the browser's own undo stack. This replaces it.\n *\n * It holds no timers: a run is coalesced purely from the caret geometry, so the same\n * sequence of edits always produces the same sequence of steps.\n *\n * The history is self-invalidating rather than instrumented. Anything that moves the\n * masked text without going through it - a programmatic `value`, `clear()`, a form reset -\n * is caught by comparing against the text it last observed, and a changed mask pattern is\n * caught by the signature. That is why no call site has to announce those changes.\n *\n * @hidden\n */\nclass MaskHistory {\n private readonly _signature: MaskSignature;\n private readonly _undoStack: MaskHistoryState[] = [];\n private readonly _redoStack: MaskHistoryState[] = [];\n\n private _lastKind: MaskEditKind | null = null;\n private _lastCaret = -1;\n private _lastValue = '';\n private _pattern = '';\n\n /**\n * The state the most recent traversal restored.\n *\n * Holding `Ctrl + Z` fires faster than the caret can be written back to the DOM, so the\n * live selection is not a trustworthy counterpart entry for the opposite stack. The\n * state we know we just restored is.\n */\n private _lastRestored: MaskHistoryState | null = null;\n\n constructor(signature: MaskSignature) {\n this._signature = signature;\n }\n\n public get canUndo(): boolean {\n return this._undoStack.length > 0;\n }\n\n public get canRedo(): boolean {\n return this._redoStack.length > 0;\n }\n\n /**\n * A run continues only while the caret stays where the previous edit left it, which is\n * what makes a click or an arrow key break it without any extra hook. Replacing a\n * selection is always a deliberate edit of its own.\n */\n private _shouldCoalesce(\n kind: MaskEditKind,\n state: MaskHistoryState\n ): boolean {\n if (\n kind === 'atomic' ||\n kind !== this._lastKind ||\n !this.canUndo ||\n state.start !== state.end\n ) {\n return false;\n }\n\n return kind === 'insert'\n ? state.start === this._lastCaret\n : state.end === this._lastCaret;\n }\n\n private _clear(): void {\n this._undoStack.length = 0;\n this._redoStack.length = 0;\n this._lastKind = null;\n this._lastCaret = -1;\n this._lastRestored = null;\n }\n\n /**\n * Drops everything the history holds when the mask pattern changed or the text moved\n * behind our back. Returns whether the snapshots are still usable.\n */\n private _validate(value: string): boolean {\n const pattern = this._signature();\n const stale =\n pattern !== this._pattern || (this.canUndo && value !== this._lastValue);\n\n if (stale) {\n this._pattern = pattern;\n this._clear();\n this._lastValue = value;\n }\n\n return !stale;\n }\n\n /**\n * Records the state an edit is about to overwrite. Must be called *before* the mask is\n * mutated, and only once the edit is known to change something.\n */\n public record(kind: MaskEditKind, state: MaskHistoryState): void {\n this._validate(state.value);\n this._redoStack.length = 0;\n this._lastRestored = null;\n\n if (!this._shouldCoalesce(kind, state)) {\n this._undoStack.push({ ...state });\n\n if (this._undoStack.length > MAX_HISTORY_SIZE) {\n this._undoStack.shift();\n }\n }\n\n this._lastKind = kind;\n }\n\n /**\n * Reports the state an edit settled on, so that the next {@link record} can tell\n * whether it continues the run.\n */\n public settle(value: string, caret: number): void {\n this._lastValue = value;\n this._lastCaret = caret;\n }\n\n /**\n * Reconciles the history with the editor's current text, typically on focus where a\n * date editor swaps the display format back for the input format. An unchanged\n * document keeps its history, a changed one drops it, and either way the run ends.\n */\n public resync(value: string): void {\n this._validate(value);\n\n this._lastValue = value;\n this._lastKind = null;\n this._lastCaret = -1;\n this._lastRestored = null;\n }\n\n /** Steps one edit back, handing `current` to the redo stack. */\n public undo(current: MaskHistoryState): MaskHistoryState | null {\n return this._step(this._undoStack, this._redoStack, current);\n }\n\n /** Steps one edit forward, handing `current` back to the undo stack. */\n public redo(current: MaskHistoryState): MaskHistoryState | null {\n return this._step(this._redoStack, this._undoStack, current);\n }\n\n private _step(\n from: MaskHistoryState[],\n to: MaskHistoryState[],\n current: MaskHistoryState\n ): MaskHistoryState | null {\n // Traversing a history whose document has moved on would restore text belonging to a\n // value the component no longer holds.\n if (!this._validate(current.value)) {\n return null;\n }\n\n const state = from.pop();\n\n if (!state) {\n return null;\n }\n\n to.push(this._lastRestored ?? { ...current });\n\n // Typing after an undo must not extend the step that was just restored.\n this._lastKind = null;\n this._lastValue = state.value;\n this._lastCaret = state.start;\n this._lastRestored = { ...state };\n\n return state;\n }\n}\n\n/**\n * Creates a {@link MaskHistory} for a masked editor.\n *\n * @param signature - resolves the identity of the mask pattern the snapshots are taken\n * against. A callback rather than a value because the history is created by the mask\n * behavior mixin, whose fields initialize *before* the parser of the concrete component.\n *\n * @example\n * ```ts\n * const history = createMaskHistory(() => `${parser.mask} ${parser.prompt}`);\n * ```\n */\nexport function createMaskHistory(signature: MaskSignature): MaskHistory {\n return new MaskHistory(signature);\n}\n\nexport type { MaskEditKind, MaskHistory, MaskHistoryState, MaskSignature };\n"]}
1
+ {"version":3,"file":"mask-history.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-history.ts"],"names":[],"mappings":"AAmBA,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAoB7B,MAAM,WAAW;IAqBf,YAAY,SAAwB;QAnBnB,eAAU,GAAuB,EAAE,CAAC;QACpC,eAAU,GAAuB,EAAE,CAAC;QAE7C,cAAS,GAAwB,IAAI,CAAC;QACtC,eAAU,GAAG,CAAC,CAAC,CAAC;QAChB,eAAU,GAAG,EAAE,CAAC;QAChB,aAAQ,GAAG,EAAE,CAAC;QAWd,kBAAa,GAA4B,IAAI,CAAC;QAGpD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;IAOO,eAAe,CACrB,IAAkB,EAClB,KAAuB;QAEvB,IACE,IAAI,KAAK,QAAQ;YACjB,IAAI,KAAK,IAAI,CAAC,SAAS;YACvB,CAAC,IAAI,CAAC,OAAO;YACb,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,GAAG,EACzB,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,UAAU;YACjC,CAAC,CAAC,KAAK,CAAC,GAA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KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;QAElC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAcD,MAAM,UAAU,iBAAiB,CAAC,SAAwB;IACxD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/** A snapshot of the editor state as it was *before* an edit was applied. */\ntype MaskHistoryState = {\n value: string;\n start: number;\n end: number;\n};\n\n/**\n * The granularity an edit contributes to the history.\n *\n * The three granular kinds coalesce, so a run of typed characters or of deletions\n * collapses into a single step. Everything else - paste, drop, cut, composition,\n * auto-fill, spinning a date part, `setRangeText` - is `atomic` and gets its own step.\n */\ntype MaskEditKind = 'insert' | 'delete-backward' | 'delete-forward' | 'atomic';\n\n/** Resolves the identity of the mask pattern the snapshots were taken against. */\ntype MaskSignature = () => string;\n\nconst MAX_HISTORY_SIZE = 100;\n\n/**\n * The undo and redo history of a masked editor.\n *\n * @remarks\n * `.value=${live(...)}` renders the masked text, so each edit assigns the value\n * of the native input again and clears the undo stack of the browser. This\n * history replaces that stack.\n *\n * It holds no timers. The caret geometry alone groups a run, so the same edits\n * always give the same steps.\n *\n * The history invalidates itself. It compares against the text it last saw to\n * find a change that did not go through it, such as a `value` from code,\n * `clear()` or a form reset, and the signature finds a changed mask pattern. No\n * call site must report those changes.\n *\n * @hidden\n */\nclass MaskHistory {\n private readonly _signature: MaskSignature;\n private readonly _undoStack: MaskHistoryState[] = [];\n private readonly _redoStack: MaskHistoryState[] = [];\n\n private _lastKind: MaskEditKind | null = null;\n private _lastCaret = -1;\n private _lastValue = '';\n private _pattern = '';\n\n /**\n * The state that the last traversal restored.\n *\n * @remarks\n * A held `Ctrl + Z` repeats faster than the caret reaches the DOM, so the live\n * selection is not a reliable entry for the opposite stack. This state holds\n * the value and the caret that the traversal wrote, so it pushes the correct\n * entry.\n */\n private _lastRestored: MaskHistoryState | null = null;\n\n constructor(signature: MaskSignature) {\n this._signature = signature;\n }\n\n public get canUndo(): boolean {\n return this._undoStack.length > 0;\n }\n\n public get canRedo(): boolean {\n return this._redoStack.length > 0;\n }\n\n /**\n * A run continues only while the caret stays where the last edit left it, so a\n * click or an arrow key breaks it with no extra hook. A replaced selection is\n * always its own edit.\n */\n private _shouldCoalesce(\n kind: MaskEditKind,\n state: MaskHistoryState\n ): boolean {\n if (\n kind === 'atomic' ||\n kind !== this._lastKind ||\n !this.canUndo ||\n state.start !== state.end\n ) {\n return false;\n }\n\n return kind === 'insert'\n ? state.start === this._lastCaret\n : state.end === this._lastCaret;\n }\n\n private _clear(): void {\n this._undoStack.length = 0;\n this._redoStack.length = 0;\n this._lastKind = null;\n this._lastCaret = -1;\n this._lastRestored = null;\n }\n\n /**\n * Drops all the history if the mask pattern changed, or if the text moved\n * from outside. Returns whether the snapshots are still usable.\n */\n private _validate(value: string): boolean {\n const pattern = this._signature();\n const stale =\n pattern !== this._pattern || (this.canUndo && value !== this._lastValue);\n\n if (stale) {\n this._pattern = pattern;\n this._clear();\n this._lastValue = value;\n }\n\n return !stale;\n }\n\n /**\n * Records the state an edit is about to overwrite. Must be called *before* the mask is\n * mutated, and only once the edit is known to change something.\n */\n public record(kind: MaskEditKind, state: MaskHistoryState): void {\n this._validate(state.value);\n this._redoStack.length = 0;\n this._lastRestored = null;\n\n if (!this._shouldCoalesce(kind, state)) {\n this._undoStack.push({ ...state });\n\n if (this._undoStack.length > MAX_HISTORY_SIZE) {\n this._undoStack.shift();\n }\n }\n\n this._lastKind = kind;\n }\n\n /**\n * Reports the state an edit settled on, so that the next {@link record} can tell\n * whether it continues the run.\n */\n public settle(value: string, caret: number): void {\n this._lastValue = value;\n this._lastCaret = caret;\n }\n\n /**\n * Reconciles the history with the editor's current text, typically on focus where a\n * date editor swaps the display format back for the input format. An unchanged\n * document keeps its history, a changed one drops it, and either way the run ends.\n */\n public resync(value: string): void {\n this._validate(value);\n\n this._lastValue = value;\n this._lastKind = null;\n this._lastCaret = -1;\n this._lastRestored = null;\n }\n\n /** Steps one edit back, handing `current` to the redo stack. */\n public undo(current: MaskHistoryState): MaskHistoryState | null {\n return this._step(this._undoStack, this._redoStack, current);\n }\n\n /** Steps one edit forward, handing `current` back to the undo stack. */\n public redo(current: MaskHistoryState): MaskHistoryState | null {\n return this._step(this._redoStack, this._undoStack, current);\n }\n\n private _step(\n from: MaskHistoryState[],\n to: MaskHistoryState[],\n current: MaskHistoryState\n ): MaskHistoryState | null {\n // Traversing a history whose document has moved on would restore text belonging to a\n // value the component no longer holds.\n if (!this._validate(current.value)) {\n return null;\n }\n\n const state = from.pop();\n\n if (!state) {\n return null;\n }\n\n to.push(this._lastRestored ?? { ...current });\n\n // Typing after an undo must not extend the step that was just restored.\n this._lastKind = null;\n this._lastValue = state.value;\n this._lastCaret = state.start;\n this._lastRestored = { ...state };\n\n return state;\n }\n}\n\n/**\n * Creates a {@link MaskHistory} for a masked editor.\n *\n * @param signature - resolves the identity of the mask pattern the snapshots are taken\n * against. A callback rather than a value because the history is created by the mask\n * behavior mixin, whose fields initialize *before* the parser of the concrete component.\n *\n * @example\n * ```ts\n * const history = createMaskHistory(() => `${parser.mask} ${parser.prompt}`);\n * ```\n */\nexport function createMaskHistory(signature: MaskSignature): MaskHistory {\n return new MaskHistory(signature);\n}\n\nexport type { MaskEditKind, MaskHistory, MaskHistoryState, MaskSignature };\n"]}
@@ -35,7 +35,7 @@ export default class IgcMaskInputComponent extends IgcMaskInputComponent_base {
35
35
  protected readonly _parser: MaskParser;
36
36
  protected get __validators(): import("../../internals/validators.js").Validator<IgcMaskInputComponent>[];
37
37
  protected readonly _themes: import("#theming/theming-controller.js").ThemingController;
38
- protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "helper-text" | "[default]" | "suffix" | "value-missing" | "custom-error" | "bad-input">;
38
+ protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "[default]" | "suffix" | "helper-text" | "value-missing" | "custom-error" | "bad-input">;
39
39
  protected readonly _formValue: import("#internals/mixins/forms/form-value.js").FormValue<string>;
40
40
  protected get _isRawMode(): boolean;
41
41
  /**
@@ -46,9 +46,9 @@ export declare class MaskParser {
46
46
  /** Cached array of required non-literal positions for validation */
47
47
  protected _requiredPositions: number[];
48
48
  /**
49
- * Declared without an initializer on purpose. With `useDefineForClassFields: false`
50
- * nothing is emitted for it, so {@link _invalidate} can safely run from the
51
- * constructor - before subclass fields exist.
49
+ * Declared with no initializer. `useDefineForClassFields: false` emits nothing
50
+ * for it, so {@link _invalidate} can run from the constructor, before the
51
+ * subclass fields exist.
52
52
  */
53
53
  private _emptyMask?;
54
54
  /**
@@ -87,25 +87,23 @@ export declare class MaskParser {
87
87
  constructor(options?: MaskOptions);
88
88
  private _isEscapedFlag;
89
89
  /**
90
- * The pattern the literal parser consumes. Subclasses whose public format is not itself
91
- * a mask pattern - date formats, for instance - translate it here.
90
+ * The pattern for the literal parser. A subclass whose public format is not a
91
+ * mask pattern, such as a date format, converts it here.
92
92
  */
93
93
  protected _toMaskFormat(format: string): string;
94
94
  /**
95
- * Drops everything derived from the mask. Runs on every mask *and* prompt change, and
96
- * from the constructor, so overrides must not touch fields with initializers.
95
+ * Drops all that comes from the mask. Runs on each mask and prompt change, and
96
+ * from the constructor, so an override must not touch an initialized field.
97
97
  */
98
98
  protected _invalidate(): void;
99
99
  /**
100
- * Parses the mask format string to identify literal characters and
101
- * create the escaped mask. This method is called whenever the mask format changes.
100
+ * Finds the literal characters of the mask format and builds the escaped
101
+ * mask. Runs on each mask format change.
102
102
  */
103
103
  protected _parseMaskLiterals(): void;
104
104
  /**
105
- * Computes an array of positions in the escaped mask that correspond to
106
- * required input flags (e.g., '0', 'L') and are not literal characters.
107
- *
108
- * These positions must be filled for the masked string to be valid.
105
+ * The positions of the escaped mask that hold a required input flag, such as
106
+ * '0' or 'L', and are not literals. A valid masked string fills them all.
109
107
  */
110
108
  protected _computeRequiredPositions(): number[];
111
109
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mask-parser.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-parser.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAE7C,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,qBAAqB,GAAG;IAC5B,UAAU;IACV,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAC;AAMX,MAAM,sBAAsB,GAAG,IAAI,GAAG,CACpC,qBAAqB,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACnC,aAAa,GAAG,CAAC;IACjB,MAAM,CAAC,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;CACpC,CAAC,CACH,CACF,CAAC;AAQF,SAAS,eAAe,CAAC,KAAyB,EAAE,OAAe;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACrD,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAY;IACzC,MA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;YACX,CAAC;YAED,IAAI,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,MAAM,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;YAC1C,CAAC;YAGD,UAAU,EAAE,CAAC;QACf,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["/** Options for the {@link MaskParser} */\nexport interface MaskOptions {\n /**\n * The mask format string (e.g., '00/00/0000' for dates, 'AAA-000' for custom IDs).\n *\n * Supported flags: a, A, C, L, 0, 9, #, &, ?.\n *\n * Use `'\\'` to escape a flag character if it should be treated as a literal.\n * @default 'CCCCCCCCCC'\n */\n format?: string;\n\n /**\n * The character used to prompt for input in unfilled mask positions.\n *\n * Only the first character is used, and a mask flag is rejected in favor of the\n * default - the same rules the `prompt` accessor applies.\n * @default '_'\n */\n promptCharacter?: string;\n}\n\n/** Internal options with all required fields */\ninterface MaskOptionsInternal {\n format: string;\n promptCharacter: string;\n}\n\n/**\n * Result type for the replace operation, containing the new masked value and the\n * ideal cursor position.\n */\ntype MaskReplaceResult = {\n value: string;\n end: number;\n};\n\nconst MASK_FLAGS = new Set('aACL09#&?');\nconst MASK_REQUIRED_FLAGS = new Set('0#LA&');\n\nconst ESCAPE_CHAR = '\\\\';\nconst DEFAULT_FORMAT = 'CCCCCCCCCC';\nconst DEFAULT_PROMPT = '_';\n\nconst ASCII_ZERO = 0x0030;\nconst DIGIT_ZERO_CODEPOINTS = [\n ASCII_ZERO, // ASCII\n 0x0660, // Arabic-Indic\n 0x06f0, // Extended Arabic-Indic\n 0x0966, // Devanagari\n 0x09e6, // Bengali\n 0x0a66, // Gurmukhi\n 0x0ae6, // Gujarati\n 0x0b66, // Oriya\n 0x0c66, // Telugu\n 0x0ce6, // Kannada\n 0x0d66, // Malayalam\n 0x0e50, // Thai\n 0x0ed0, // Lao\n 0x0f20, // Tibetan\n 0x1040, // Myanmar\n 0x17e0, // Khmer\n 0x1810, // Mongolian\n 0xff10, // Full-width\n] as const;\n\n/**\n * Precomputed map of Unicode digit codepoints to their ASCII equivalents.\n * This eliminates the need for iteration during conversion.\n */\nconst UNICODE_DIGIT_TO_ASCII = new Map<number, string>(\n DIGIT_ZERO_CODEPOINTS.flatMap((zeroCodePoint) =>\n Array.from({ length: 10 }, (_, i) => [\n zeroCodePoint + i,\n String.fromCharCode(ASCII_ZERO + i),\n ])\n )\n);\n\n/**\n * Narrows a prompt down to the single character the parser will actually use.\n *\n * Falls back to `current` when the prompt is empty or collides with a mask flag - a flag\n * standing in for an unfilled position could not be told apart from one the user typed.\n */\nfunction normalizePrompt(value: string | undefined, current: string): string {\n const char = value ? value.substring(0, 1) : current;\n return MASK_FLAGS.has(char) ? current : char;\n}\n\nfunction replaceUnicodeNumbers(text: string): string {\n const matcher = /\\p{Nd}/gu;\n\n return text.replace(matcher, (digit) => {\n return UNICODE_DIGIT_TO_ASCII.get(digit.charCodeAt(0)) ?? digit;\n });\n}\n\nconst MASK_PATTERNS = new Map<string, RegExp>([\n ['C', /[\\s\\S]/u], // Any single character (including newlines)\n ['&', /[^\\p{Separator}]/u], // Any non-separator character (excludes spaces, line/paragraph separators)\n ['a', /[\\p{Letter}\\p{Number}\\p{Separator}]/u], // Alphanumeric and separator characters (Unicode-aware)\n ['A', /[\\p{Letter}\\p{Number}]/u], // Alphanumeric (Unicode-aware)\n ['?', /[\\p{Letter}\\p{Separator}]/u], // Alphabetic and separator characters (Unicode-aware)\n ['L', /\\p{Letter}/u], // Alphabetic (Unicode-aware)\n ['0', /\\p{Number}/u], // Numeric (Unicode-aware, converted to ASCII 0-9 during processing)\n ['9', /[\\p{Number}\\p{Separator}]/u], // Numeric and separator characters (Unicode-aware)\n ['#', /[\\p{Number}\\-+]/u], // Numeric and sign characters (+, -)\n]);\n\nfunction validate(char: string, flag: string): boolean {\n return MASK_PATTERNS.get(flag)?.test(char) ?? false;\n}\n\n/**\n * A class for parsing and applying masks to strings, typically for input fields.\n * It handles mask definitions, literals, character validation, and cursor positioning.\n */\nexport class MaskParser {\n protected readonly _options: MaskOptionsInternal;\n\n /** Stores literal characters and their original positions in the mask (e.g., '(', ')', '-'). */\n protected readonly _literals = new Map<number, string>();\n\n /** A Set of positions where literals occur in the `_escapedMask`. */\n protected _literalPositions = new Set<number>();\n\n /** The mask format after processing escape characters */\n protected _escapedMask = '';\n\n /** Cached array of required non-literal positions for validation */\n protected _requiredPositions: number[] = [];\n\n /**\n * Declared without an initializer on purpose. With `useDefineForClassFields: false`\n * nothing is emitted for it, so {@link _invalidate} can safely run from the\n * constructor - before subclass fields exist.\n */\n private _emptyMask?: string;\n\n /**\n * Returns a set of the all the literal positions in the mask.\n * These positions are fixed characters that are not part of the input.\n */\n public get literalPositions(): ReadonlySet<number> {\n return this._literalPositions;\n }\n\n /**\n * Returns the escaped mask string.\n * This is the mask after processing any escape sequences.\n */\n public get escapedMask(): string {\n return this._escapedMask;\n }\n\n /**\n * Returns the result of applying an empty string over the mask pattern.\n */\n public get emptyMask(): string {\n this._emptyMask ??= this.apply();\n return this._emptyMask;\n }\n\n /**\n * Gets the unescaped mask string (the original format string).\n * If the mask has no escape sequences, then `mask === escapedMask`.\n */\n public get mask(): string {\n return this._options.format;\n }\n\n /**\n * Sets the mask of the parser.\n * When the mask is set, it triggers a re-parsing of the mask literals and escaped mask.\n */\n public set mask(value: string) {\n this._options.format = value || this._options.format;\n this._parseMaskLiterals();\n }\n\n /**\n * Gets the prompt character used for unfilled mask positions.\n */\n public get prompt(): string {\n return this._options.promptCharacter;\n }\n\n /**\n * Sets the prompt character. Only the first character of the provided string is used.\n * @remarks The prompt character cannot be a mask flag character.\n */\n public set prompt(value: string) {\n this._options.promptCharacter = normalizePrompt(\n value,\n this._options.promptCharacter\n );\n this._invalidate();\n }\n\n constructor(options?: MaskOptions) {\n this._options = {\n format: options?.format || DEFAULT_FORMAT,\n promptCharacter: normalizePrompt(\n options?.promptCharacter,\n DEFAULT_PROMPT\n ),\n };\n this._parseMaskLiterals();\n }\n\n private _isEscapedFlag(char: string, nextChar: string): boolean {\n return char === ESCAPE_CHAR && MASK_FLAGS.has(nextChar);\n }\n\n /**\n * The pattern the literal parser consumes. Subclasses whose public format is not itself\n * a mask pattern - date formats, for instance - translate it here.\n */\n protected _toMaskFormat(format: string): string {\n return format;\n }\n\n /**\n * Drops everything derived from the mask. Runs on every mask *and* prompt change, and\n * from the constructor, so overrides must not touch fields with initializers.\n */\n protected _invalidate(): void {\n this._emptyMask = undefined;\n }\n\n /**\n * Parses the mask format string to identify literal characters and\n * create the escaped mask. This method is called whenever the mask format changes.\n */\n protected _parseMaskLiterals(): void {\n const mask = this._toMaskFormat(this._options.format);\n const length = mask.length;\n const escapedMaskChars: string[] = [];\n\n let currentPos = 0;\n\n this._literals.clear();\n\n for (let i = 0; i < length; i++) {\n const [current, next] = [mask.charAt(i), mask.charAt(i + 1)];\n\n if (this._isEscapedFlag(current, next)) {\n // Escaped character - push next as a literal character and skip processing it\n this._literals.set(currentPos, next);\n escapedMaskChars.push(next);\n i++;\n } else if (MASK_FLAGS.has(current)) {\n // Regular flag character\n escapedMaskChars.push(current);\n } else {\n // Literal character\n this._literals.set(currentPos, current);\n escapedMaskChars.push(current);\n }\n\n currentPos++;\n }\n\n this._escapedMask = escapedMaskChars.join('');\n this._literalPositions = new Set(this._literals.keys());\n this._requiredPositions = this._computeRequiredPositions();\n this._invalidate();\n }\n\n /**\n * Computes an array of positions in the escaped mask that correspond to\n * required input flags (e.g., '0', 'L') and are not literal characters.\n *\n * These positions must be filled for the masked string to be valid.\n */\n protected _computeRequiredPositions(): number[] {\n const literalPositions = this._literalPositions;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n const result: number[] = [];\n\n for (let i = 0; i < length; i++) {\n const char = escapedMask[i];\n if (MASK_REQUIRED_FLAGS.has(char) && !literalPositions.has(i)) {\n result.push(i);\n }\n }\n\n return result;\n }\n\n /**\n * Finds the closest non-literal position in the mask *before* the given start position.\n * Useful for backward navigation (e.g., backspace).\n *\n * @remarks\n * If no non-literal is found before `start`, return 0.\n */\n public getPreviousNonLiteralPosition(start: number): number {\n const literalPositions = this._literalPositions;\n\n for (let i = start - 1; i >= 0; i--) {\n if (!literalPositions.has(i)) {\n return i;\n }\n }\n\n return 0;\n }\n\n /**\n * Finds the closest non-literal position in the mask *after* the given start position.\n * Useful for forward navigation (e.g., arrow keys, delete key or initial cursor placement).\n *\n * @remarks\n * If no non-literal is found after `start`, return the mask length.\n */\n public getNextNonLiteralPosition(start: number): number {\n const literalPositions = this._literalPositions;\n const length = this._escapedMask.length;\n\n for (let i = Math.max(0, start); i < length; i++) {\n if (!literalPositions.has(i)) {\n return i;\n }\n }\n\n return length;\n }\n\n /**\n * Replaces a segment of the masked string with new input, simulating typing or pasting.\n * It handles clearing the selected range and inserting new characters according to the mask.\n *\n * @example\n * ```ts\n * const parser = new MaskParser({ format: '00/00/0000' });\n * const current = '__/__/____';\n * const result = parser.replace(current, '12', 0, 0);\n * // result.value = '12/__/____', result.end = 2\n * ```\n */\n public replace(\n maskString: string,\n value: string,\n start: number,\n end: number\n ): MaskReplaceResult {\n const literalPositions = this.literalPositions;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n const prompt = this.prompt;\n const endBoundary = Math.min(end, length);\n\n // Initialize the array for the masked string or get a fresh mask with prompts and/or literals\n const maskedChars = maskString ? [...maskString] : [...this.emptyMask];\n\n const inputChars = Array.from(replaceUnicodeNumbers(value));\n const inputLength = inputChars.length;\n\n // Clear any non-literal positions from `start` to `endBoundary`\n for (let i = start; i < endBoundary; i++) {\n if (!literalPositions.has(i)) {\n maskedChars[i] = prompt;\n }\n }\n\n let cursor = start;\n let inputIndex = 0;\n let maskPosition = start;\n\n // Iterate through the mask starting at `start` as long as there are input characters and mask positions available\n // and start placing characters or skipping literals and invalid characters\n for (; maskPosition < length && inputIndex < inputLength; maskPosition++) {\n if (literalPositions.has(maskPosition)) {\n cursor = maskPosition + 1;\n continue;\n }\n\n const char = inputChars[inputIndex];\n\n if (validate(char, escapedMask[maskPosition]) && char !== prompt) {\n maskedChars[maskPosition] = char;\n cursor = maskPosition + 1;\n inputIndex++;\n } else {\n inputIndex++;\n maskPosition--;\n }\n }\n\n // Move the cursor to the next non-literal position or the end of the mask\n while (cursor < length && literalPositions.has(cursor)) {\n cursor++;\n }\n\n return {\n value: maskedChars.join(''),\n end: cursor,\n };\n }\n\n /**\n * Parses the masked string, extracting only the valid input characters.\n * This effectively \"unmasks\" the string, removing prompts and literals.\n */\n public parse(masked = ''): string {\n const literalPositions = this.literalPositions;\n const prompt = this.prompt;\n const length = masked.length;\n const result: string[] = [];\n\n for (let i = 0; i < length; i++) {\n const char = masked[i];\n if (!literalPositions.has(i) && char !== prompt) {\n result.push(char);\n }\n }\n\n return result.join('');\n }\n\n /**\n * Checks if the masked string is valid, specifically if all required mask positions are filled\n * with valid, non-prompt characters.\n */\n public isValidString(input = ''): boolean {\n const prompt = this.prompt;\n\n return this._requiredPositions.every((position) => {\n const char = input[position];\n return validate(char, this._escapedMask[position]) && char !== prompt;\n });\n }\n\n /**\n * Applies the mask format to an input string. This attempts to fit the input\n * into the mask from left to right, filling valid positions and skipping invalid\n * input characters.\n *\n * @example\n * ```ts\n * const parser = new MaskParser({ format: '00/00/0000' });\n * parser.apply('12252023'); // Returns '12/25/2023'\n * ```\n */\n public apply(input = ''): string {\n const literals = this._literals;\n const prompt = this.prompt;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n\n // Initialize the result array with prompt characters\n const result = new Array(length).fill(prompt);\n\n // Place all literal characters into the result array\n for (const [position, literal] of literals.entries()) {\n result[position] = literal;\n }\n\n if (!input) {\n return result.join('');\n }\n\n // Normalize Unicode digits to ASCII\n const normalizedInput = replaceUnicodeNumbers(input);\n const inputLength = normalizedInput.length;\n let inputIndex = 0;\n\n // Iterate through the mask placing input characters skipping literals and invalid ones\n for (let i = 0; i < length; i++) {\n if (inputIndex >= inputLength) {\n break;\n }\n\n if (literals.has(i)) {\n continue;\n }\n\n if (validate(normalizedInput[inputIndex], escapedMask[i])) {\n result[i] = normalizedInput[inputIndex];\n }\n\n // Always advance - invalid characters are consumed/skipped\n inputIndex++;\n }\n\n return result.join('');\n }\n}\n"]}
1
+ {"version":3,"file":"mask-parser.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-parser.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AACxC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAE7C,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,qBAAqB,GAAG;IAC5B,UAAU;IACV,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAC;AAMX,MAAM,sBAAsB,GAAG,IAAI,GAAG,CACpC,qBAAqB,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACnC,aAAa,GAAG,CAAC;IACjB,MAAM,CAAC,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;CACpC,CAAC,CACH,CACF,CAAC;AAQF,SAAS,eAAe,CAAC,KAAyB,EAAE,OAAe;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAA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CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;gBAC9B,MAAM;YACR,CAAC;YAED,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,SAAS;YACX,CAAC;YAED,IAAI,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,MAAM,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;YAC1C,CAAC;YAGD,UAAU,EAAE,CAAC;QACf,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["/** Options for the {@link MaskParser} */\nexport interface MaskOptions {\n /**\n * The mask format string (e.g., '00/00/0000' for dates, 'AAA-000' for custom IDs).\n *\n * Supported flags: a, A, C, L, 0, 9, #, &, ?.\n *\n * Use `'\\'` to escape a flag character if it should be treated as a literal.\n * @default 'CCCCCCCCCC'\n */\n format?: string;\n\n /**\n * The character used to prompt for input in unfilled mask positions.\n *\n * Only the first character is used, and a mask flag is rejected in favor of the\n * default - the same rules the `prompt` accessor applies.\n * @default '_'\n */\n promptCharacter?: string;\n}\n\n/** Internal options with all required fields */\ninterface MaskOptionsInternal {\n format: string;\n promptCharacter: string;\n}\n\n/**\n * Result type for the replace operation, containing the new masked value and the\n * ideal cursor position.\n */\ntype MaskReplaceResult = {\n value: string;\n end: number;\n};\n\nconst MASK_FLAGS = new Set('aACL09#&?');\nconst MASK_REQUIRED_FLAGS = new Set('0#LA&');\n\nconst ESCAPE_CHAR = '\\\\';\nconst DEFAULT_FORMAT = 'CCCCCCCCCC';\nconst DEFAULT_PROMPT = '_';\n\nconst ASCII_ZERO = 0x0030;\nconst DIGIT_ZERO_CODEPOINTS = [\n ASCII_ZERO, // ASCII\n 0x0660, // Arabic-Indic\n 0x06f0, // Extended Arabic-Indic\n 0x0966, // Devanagari\n 0x09e6, // Bengali\n 0x0a66, // Gurmukhi\n 0x0ae6, // Gujarati\n 0x0b66, // Oriya\n 0x0c66, // Telugu\n 0x0ce6, // Kannada\n 0x0d66, // Malayalam\n 0x0e50, // Thai\n 0x0ed0, // Lao\n 0x0f20, // Tibetan\n 0x1040, // Myanmar\n 0x17e0, // Khmer\n 0x1810, // Mongolian\n 0xff10, // Full-width\n] as const;\n\n/**\n * Precomputed map of Unicode digit codepoints to their ASCII equivalents.\n * This eliminates the need for iteration during conversion.\n */\nconst UNICODE_DIGIT_TO_ASCII = new Map<number, string>(\n DIGIT_ZERO_CODEPOINTS.flatMap((zeroCodePoint) =>\n Array.from({ length: 10 }, (_, i) => [\n zeroCodePoint + i,\n String.fromCharCode(ASCII_ZERO + i),\n ])\n )\n);\n\n/**\n * Narrows a prompt down to the single character the parser will actually use.\n *\n * Falls back to `current` when the prompt is empty or collides with a mask flag - a flag\n * standing in for an unfilled position could not be told apart from one the user typed.\n */\nfunction normalizePrompt(value: string | undefined, current: string): string {\n const char = value ? value.substring(0, 1) : current;\n return MASK_FLAGS.has(char) ? current : char;\n}\n\nfunction replaceUnicodeNumbers(text: string): string {\n const matcher = /\\p{Nd}/gu;\n\n return text.replace(matcher, (digit) => {\n return UNICODE_DIGIT_TO_ASCII.get(digit.charCodeAt(0)) ?? digit;\n });\n}\n\nconst MASK_PATTERNS = new Map<string, RegExp>([\n ['C', /[\\s\\S]/u], // Any single character (including newlines)\n ['&', /[^\\p{Separator}]/u], // Any non-separator character (excludes spaces, line/paragraph separators)\n ['a', /[\\p{Letter}\\p{Number}\\p{Separator}]/u], // Alphanumeric and separator characters (Unicode-aware)\n ['A', /[\\p{Letter}\\p{Number}]/u], // Alphanumeric (Unicode-aware)\n ['?', /[\\p{Letter}\\p{Separator}]/u], // Alphabetic and separator characters (Unicode-aware)\n ['L', /\\p{Letter}/u], // Alphabetic (Unicode-aware)\n ['0', /\\p{Number}/u], // Numeric (Unicode-aware, converted to ASCII 0-9 during processing)\n ['9', /[\\p{Number}\\p{Separator}]/u], // Numeric and separator characters (Unicode-aware)\n ['#', /[\\p{Number}\\-+]/u], // Numeric and sign characters (+, -)\n]);\n\nfunction validate(char: string, flag: string): boolean {\n return MASK_PATTERNS.get(flag)?.test(char) ?? false;\n}\n\n/**\n * A class for parsing and applying masks to strings, typically for input fields.\n * It handles mask definitions, literals, character validation, and cursor positioning.\n */\nexport class MaskParser {\n protected readonly _options: MaskOptionsInternal;\n\n /** Stores literal characters and their original positions in the mask (e.g., '(', ')', '-'). */\n protected readonly _literals = new Map<number, string>();\n\n /** A Set of positions where literals occur in the `_escapedMask`. */\n protected _literalPositions = new Set<number>();\n\n /** The mask format after processing escape characters */\n protected _escapedMask = '';\n\n /** Cached array of required non-literal positions for validation */\n protected _requiredPositions: number[] = [];\n\n /**\n * Declared with no initializer. `useDefineForClassFields: false` emits nothing\n * for it, so {@link _invalidate} can run from the constructor, before the\n * subclass fields exist.\n */\n private _emptyMask?: string;\n\n /**\n * Returns a set of the all the literal positions in the mask.\n * These positions are fixed characters that are not part of the input.\n */\n public get literalPositions(): ReadonlySet<number> {\n return this._literalPositions;\n }\n\n /**\n * Returns the escaped mask string.\n * This is the mask after processing any escape sequences.\n */\n public get escapedMask(): string {\n return this._escapedMask;\n }\n\n /**\n * Returns the result of applying an empty string over the mask pattern.\n */\n public get emptyMask(): string {\n this._emptyMask ??= this.apply();\n return this._emptyMask;\n }\n\n /**\n * Gets the unescaped mask string (the original format string).\n * If the mask has no escape sequences, then `mask === escapedMask`.\n */\n public get mask(): string {\n return this._options.format;\n }\n\n /**\n * Sets the mask of the parser.\n * When the mask is set, it triggers a re-parsing of the mask literals and escaped mask.\n */\n public set mask(value: string) {\n this._options.format = value || this._options.format;\n this._parseMaskLiterals();\n }\n\n /**\n * Gets the prompt character used for unfilled mask positions.\n */\n public get prompt(): string {\n return this._options.promptCharacter;\n }\n\n /**\n * Sets the prompt character. Only the first character of the provided string is used.\n * @remarks The prompt character cannot be a mask flag character.\n */\n public set prompt(value: string) {\n this._options.promptCharacter = normalizePrompt(\n value,\n this._options.promptCharacter\n );\n this._invalidate();\n }\n\n constructor(options?: MaskOptions) {\n this._options = {\n format: options?.format || DEFAULT_FORMAT,\n promptCharacter: normalizePrompt(\n options?.promptCharacter,\n DEFAULT_PROMPT\n ),\n };\n this._parseMaskLiterals();\n }\n\n private _isEscapedFlag(char: string, nextChar: string): boolean {\n return char === ESCAPE_CHAR && MASK_FLAGS.has(nextChar);\n }\n\n /**\n * The pattern for the literal parser. A subclass whose public format is not a\n * mask pattern, such as a date format, converts it here.\n */\n protected _toMaskFormat(format: string): string {\n return format;\n }\n\n /**\n * Drops all that comes from the mask. Runs on each mask and prompt change, and\n * from the constructor, so an override must not touch an initialized field.\n */\n protected _invalidate(): void {\n this._emptyMask = undefined;\n }\n\n /**\n * Finds the literal characters of the mask format and builds the escaped\n * mask. Runs on each mask format change.\n */\n protected _parseMaskLiterals(): void {\n const mask = this._toMaskFormat(this._options.format);\n const length = mask.length;\n const escapedMaskChars: string[] = [];\n\n let currentPos = 0;\n\n this._literals.clear();\n\n for (let i = 0; i < length; i++) {\n const [current, next] = [mask.charAt(i), mask.charAt(i + 1)];\n\n if (this._isEscapedFlag(current, next)) {\n // Escaped character - push next as a literal character and skip processing it\n this._literals.set(currentPos, next);\n escapedMaskChars.push(next);\n i++;\n } else if (MASK_FLAGS.has(current)) {\n // Regular flag character\n escapedMaskChars.push(current);\n } else {\n // Literal character\n this._literals.set(currentPos, current);\n escapedMaskChars.push(current);\n }\n\n currentPos++;\n }\n\n this._escapedMask = escapedMaskChars.join('');\n this._literalPositions = new Set(this._literals.keys());\n this._requiredPositions = this._computeRequiredPositions();\n this._invalidate();\n }\n\n /**\n * The positions of the escaped mask that hold a required input flag, such as\n * '0' or 'L', and are not literals. A valid masked string fills them all.\n */\n protected _computeRequiredPositions(): number[] {\n const literalPositions = this._literalPositions;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n const result: number[] = [];\n\n for (let i = 0; i < length; i++) {\n const char = escapedMask[i];\n if (MASK_REQUIRED_FLAGS.has(char) && !literalPositions.has(i)) {\n result.push(i);\n }\n }\n\n return result;\n }\n\n /**\n * Finds the closest non-literal position in the mask *before* the given start position.\n * Useful for backward navigation (e.g., backspace).\n *\n * @remarks\n * If no non-literal is found before `start`, return 0.\n */\n public getPreviousNonLiteralPosition(start: number): number {\n const literalPositions = this._literalPositions;\n\n for (let i = start - 1; i >= 0; i--) {\n if (!literalPositions.has(i)) {\n return i;\n }\n }\n\n return 0;\n }\n\n /**\n * Finds the closest non-literal position in the mask *after* the given start position.\n * Useful for forward navigation (e.g., arrow keys, delete key or initial cursor placement).\n *\n * @remarks\n * If no non-literal is found after `start`, return the mask length.\n */\n public getNextNonLiteralPosition(start: number): number {\n const literalPositions = this._literalPositions;\n const length = this._escapedMask.length;\n\n for (let i = Math.max(0, start); i < length; i++) {\n if (!literalPositions.has(i)) {\n return i;\n }\n }\n\n return length;\n }\n\n /**\n * Replaces a segment of the masked string with new input, simulating typing or pasting.\n * It handles clearing the selected range and inserting new characters according to the mask.\n *\n * @example\n * ```ts\n * const parser = new MaskParser({ format: '00/00/0000' });\n * const current = '__/__/____';\n * const result = parser.replace(current, '12', 0, 0);\n * // result.value = '12/__/____', result.end = 2\n * ```\n */\n public replace(\n maskString: string,\n value: string,\n start: number,\n end: number\n ): MaskReplaceResult {\n const literalPositions = this.literalPositions;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n const prompt = this.prompt;\n const endBoundary = Math.min(end, length);\n\n // Initialize the array for the masked string or get a fresh mask with prompts and/or literals\n const maskedChars = maskString ? [...maskString] : [...this.emptyMask];\n\n const inputChars = Array.from(replaceUnicodeNumbers(value));\n const inputLength = inputChars.length;\n\n // Clear any non-literal positions from `start` to `endBoundary`\n for (let i = start; i < endBoundary; i++) {\n if (!literalPositions.has(i)) {\n maskedChars[i] = prompt;\n }\n }\n\n let cursor = start;\n let inputIndex = 0;\n let maskPosition = start;\n\n // Iterate through the mask starting at `start` as long as there are input characters and mask positions available\n // and start placing characters or skipping literals and invalid characters\n for (; maskPosition < length && inputIndex < inputLength; maskPosition++) {\n if (literalPositions.has(maskPosition)) {\n cursor = maskPosition + 1;\n continue;\n }\n\n const char = inputChars[inputIndex];\n\n if (validate(char, escapedMask[maskPosition]) && char !== prompt) {\n maskedChars[maskPosition] = char;\n cursor = maskPosition + 1;\n inputIndex++;\n } else {\n inputIndex++;\n maskPosition--;\n }\n }\n\n // Move the cursor to the next non-literal position or the end of the mask\n while (cursor < length && literalPositions.has(cursor)) {\n cursor++;\n }\n\n return {\n value: maskedChars.join(''),\n end: cursor,\n };\n }\n\n /**\n * Parses the masked string, extracting only the valid input characters.\n * This effectively \"unmasks\" the string, removing prompts and literals.\n */\n public parse(masked = ''): string {\n const literalPositions = this.literalPositions;\n const prompt = this.prompt;\n const length = masked.length;\n const result: string[] = [];\n\n for (let i = 0; i < length; i++) {\n const char = masked[i];\n if (!literalPositions.has(i) && char !== prompt) {\n result.push(char);\n }\n }\n\n return result.join('');\n }\n\n /**\n * Checks if the masked string is valid, specifically if all required mask positions are filled\n * with valid, non-prompt characters.\n */\n public isValidString(input = ''): boolean {\n const prompt = this.prompt;\n\n return this._requiredPositions.every((position) => {\n const char = input[position];\n return validate(char, this._escapedMask[position]) && char !== prompt;\n });\n }\n\n /**\n * Applies the mask format to an input string. This attempts to fit the input\n * into the mask from left to right, filling valid positions and skipping invalid\n * input characters.\n *\n * @example\n * ```ts\n * const parser = new MaskParser({ format: '00/00/0000' });\n * parser.apply('12252023'); // Returns '12/25/2023'\n * ```\n */\n public apply(input = ''): string {\n const literals = this._literals;\n const prompt = this.prompt;\n const escapedMask = this._escapedMask;\n const length = escapedMask.length;\n\n // Initialize the result array with prompt characters\n const result = new Array(length).fill(prompt);\n\n // Place all literal characters into the result array\n for (const [position, literal] of literals.entries()) {\n result[position] = literal;\n }\n\n if (!input) {\n return result.join('');\n }\n\n // Normalize Unicode digits to ASCII\n const normalizedInput = replaceUnicodeNumbers(input);\n const inputLength = normalizedInput.length;\n let inputIndex = 0;\n\n // Iterate through the mask placing input characters skipping literals and invalid ones\n for (let i = 0; i < length; i++) {\n if (inputIndex >= inputLength) {\n break;\n }\n\n if (literals.has(i)) {\n continue;\n }\n\n if (validate(normalizedInput[inputIndex], escapedMask[i])) {\n result[i] = normalizedInput[inputIndex];\n }\n\n // Always advance - invalid characters are consumed/skipped\n inputIndex++;\n }\n\n return result.join('');\n }\n}\n"]}