igniteui-webcomponents 7.3.0-beta.0 → 7.3.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 (375) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/animations/player.d.ts +7 -2
  3. package/animations/player.js +1 -2
  4. package/animations/player.js.map +1 -1
  5. package/components/accordion/accordion.js +4 -16
  6. package/components/accordion/accordion.js.map +1 -1
  7. package/components/avatar/avatar.d.ts +0 -1
  8. package/components/avatar/avatar.js +5 -9
  9. package/components/avatar/avatar.js.map +1 -1
  10. package/components/badge/badge.d.ts +1 -3
  11. package/components/badge/badge.js +4 -8
  12. package/components/badge/badge.js.map +1 -1
  13. package/components/banner/banner.d.ts +6 -5
  14. package/components/banner/banner.js +19 -17
  15. package/components/banner/banner.js.map +1 -1
  16. package/components/button/button-base.d.ts +1 -1
  17. package/components/button/button-base.js.map +1 -1
  18. package/components/button-group/button-group.d.ts +0 -1
  19. package/components/button-group/button-group.js +12 -17
  20. package/components/button-group/button-group.js.map +1 -1
  21. package/components/calendar/base.d.ts +3 -13
  22. package/components/calendar/base.js +10 -31
  23. package/components/calendar/base.js.map +1 -1
  24. package/components/calendar/calendar.d.ts +2 -2
  25. package/components/calendar/months-view/months-view.d.ts +1 -1
  26. package/components/calendar/months-view/months-view.js.map +1 -1
  27. package/components/carousel/carousel-indicator.d.ts +1 -1
  28. package/components/carousel/carousel-indicator.js +13 -13
  29. package/components/carousel/carousel-indicator.js.map +1 -1
  30. package/components/carousel/carousel-slide.d.ts +0 -2
  31. package/components/carousel/carousel-slide.js +7 -9
  32. package/components/carousel/carousel-slide.js.map +1 -1
  33. package/components/carousel/carousel.d.ts +52 -35
  34. package/components/carousel/carousel.js +136 -122
  35. package/components/carousel/carousel.js.map +1 -1
  36. package/components/carousel/themes/carousel.base.css.js +1 -1
  37. package/components/carousel/themes/carousel.base.css.js.map +1 -1
  38. package/components/chat/chat-input.d.ts +1 -1
  39. package/components/chat/chat-input.js +21 -21
  40. package/components/chat/chat-input.js.map +1 -1
  41. package/components/chat/chat.d.ts +0 -2
  42. package/components/chat/chat.js +6 -12
  43. package/components/chat/chat.js.map +1 -1
  44. package/components/checkbox/checkbox-base.d.ts +1 -1
  45. package/components/checkbox/checkbox.d.ts +3 -5
  46. package/components/checkbox/checkbox.js +33 -44
  47. package/components/checkbox/checkbox.js.map +1 -1
  48. package/components/checkbox/switch.d.ts +1 -1
  49. package/components/checkbox/switch.js +23 -34
  50. package/components/checkbox/switch.js.map +1 -1
  51. package/components/chip/chip.d.ts +1 -14
  52. package/components/chip/chip.js +12 -33
  53. package/components/chip/chip.js.map +1 -1
  54. package/components/color-picker/color-picker.d.ts +261 -0
  55. package/components/color-picker/color-picker.js +620 -0
  56. package/components/color-picker/color-picker.js.map +1 -0
  57. package/components/color-picker/common.d.ts +37 -0
  58. package/components/color-picker/common.js +55 -0
  59. package/components/color-picker/common.js.map +1 -0
  60. package/components/color-picker/converters.d.ts +18 -0
  61. package/components/color-picker/converters.js +173 -0
  62. package/components/color-picker/converters.js.map +1 -0
  63. package/components/color-picker/model.d.ts +120 -0
  64. package/components/color-picker/model.js +174 -0
  65. package/components/color-picker/model.js.map +1 -0
  66. package/components/color-picker/picker-canvas.d.ts +95 -0
  67. package/components/color-picker/picker-canvas.js +154 -0
  68. package/components/color-picker/picker-canvas.js.map +1 -0
  69. package/components/color-picker/themes/color-picker.base.css.d.ts +1 -0
  70. package/components/color-picker/themes/color-picker.base.css.js +3 -0
  71. package/components/color-picker/themes/color-picker.base.css.js.map +1 -0
  72. package/components/color-picker/themes/dark/color-picker.bootstrap.css.d.ts +1 -0
  73. package/components/color-picker/themes/dark/color-picker.bootstrap.css.js +3 -0
  74. package/components/color-picker/themes/dark/color-picker.bootstrap.css.js.map +1 -0
  75. package/components/color-picker/themes/dark/color-picker.fluent.css.d.ts +1 -0
  76. package/components/color-picker/themes/dark/color-picker.fluent.css.js +3 -0
  77. package/components/color-picker/themes/dark/color-picker.fluent.css.js.map +1 -0
  78. package/components/color-picker/themes/dark/color-picker.indigo.css.d.ts +1 -0
  79. package/components/color-picker/themes/dark/color-picker.indigo.css.js +3 -0
  80. package/components/color-picker/themes/dark/color-picker.indigo.css.js.map +1 -0
  81. package/components/color-picker/themes/dark/color-picker.material.css.d.ts +1 -0
  82. package/components/color-picker/themes/dark/color-picker.material.css.js +3 -0
  83. package/components/color-picker/themes/dark/color-picker.material.css.js.map +1 -0
  84. package/components/color-picker/themes/light/color-picker.bootstrap.css.d.ts +1 -0
  85. package/components/color-picker/themes/light/color-picker.bootstrap.css.js +3 -0
  86. package/components/color-picker/themes/light/color-picker.bootstrap.css.js.map +1 -0
  87. package/components/color-picker/themes/light/color-picker.fluent.css.d.ts +1 -0
  88. package/components/color-picker/themes/light/color-picker.fluent.css.js +3 -0
  89. package/components/color-picker/themes/light/color-picker.fluent.css.js.map +1 -0
  90. package/components/color-picker/themes/light/color-picker.indigo.css.d.ts +1 -0
  91. package/components/color-picker/themes/light/color-picker.indigo.css.js +3 -0
  92. package/components/color-picker/themes/light/color-picker.indigo.css.js.map +1 -0
  93. package/components/color-picker/themes/light/color-picker.material.css.d.ts +1 -0
  94. package/components/color-picker/themes/light/color-picker.material.css.js +3 -0
  95. package/components/color-picker/themes/light/color-picker.material.css.js.map +1 -0
  96. package/components/color-picker/themes/light/color-picker.shared.css.d.ts +1 -0
  97. package/components/color-picker/themes/light/color-picker.shared.css.js +3 -0
  98. package/components/color-picker/themes/light/color-picker.shared.css.js.map +1 -0
  99. package/components/color-picker/themes/picker-canvas.base.css.d.ts +1 -0
  100. package/components/color-picker/themes/picker-canvas.base.css.js +3 -0
  101. package/components/color-picker/themes/picker-canvas.base.css.js.map +1 -0
  102. package/components/color-picker/themes/shared/color-picker.bootstrap.css.d.ts +1 -0
  103. package/components/color-picker/themes/shared/color-picker.bootstrap.css.js +3 -0
  104. package/components/color-picker/themes/shared/color-picker.bootstrap.css.js.map +1 -0
  105. package/components/color-picker/themes/shared/color-picker.common.css.d.ts +1 -0
  106. package/components/color-picker/themes/shared/color-picker.common.css.js +3 -0
  107. package/components/color-picker/themes/shared/color-picker.common.css.js.map +1 -0
  108. package/components/color-picker/themes/shared/color-picker.fluent.css.d.ts +1 -0
  109. package/components/color-picker/themes/shared/color-picker.fluent.css.js +3 -0
  110. package/components/color-picker/themes/shared/color-picker.fluent.css.js.map +1 -0
  111. package/components/color-picker/themes/shared/color-picker.indigo.css.d.ts +1 -0
  112. package/components/color-picker/themes/shared/color-picker.indigo.css.js +3 -0
  113. package/components/color-picker/themes/shared/color-picker.indigo.css.js.map +1 -0
  114. package/components/color-picker/themes/shared/color-picker.material.css.d.ts +1 -0
  115. package/components/color-picker/themes/shared/color-picker.material.css.js +3 -0
  116. package/components/color-picker/themes/shared/color-picker.material.css.js.map +1 -0
  117. package/components/color-picker/themes/themes.d.ts +2 -0
  118. package/components/color-picker/themes/themes.js +50 -0
  119. package/components/color-picker/themes/themes.js.map +1 -0
  120. package/components/color-picker/validators.d.ts +3 -0
  121. package/components/color-picker/validators.js +5 -0
  122. package/components/color-picker/validators.js.map +1 -0
  123. package/components/combo/combo-item.d.ts +1 -3
  124. package/components/combo/combo-item.js +5 -12
  125. package/components/combo/combo-item.js.map +1 -1
  126. package/components/combo/combo.d.ts +7 -20
  127. package/components/combo/combo.js +59 -81
  128. package/components/combo/combo.js.map +1 -1
  129. package/components/date-picker/date-picker.base.d.ts +12 -9
  130. package/components/date-picker/date-picker.base.js +24 -31
  131. package/components/date-picker/date-picker.base.js.map +1 -1
  132. package/components/date-picker/date-picker.d.ts +1 -1
  133. package/components/date-picker/date-picker.js +3 -5
  134. package/components/date-picker/date-picker.js.map +1 -1
  135. package/components/date-range-picker/date-range-input.d.ts +2 -4
  136. package/components/date-range-picker/date-range-input.js +6 -37
  137. package/components/date-range-picker/date-range-input.js.map +1 -1
  138. package/components/date-range-picker/date-range-picker.d.ts +2 -5
  139. package/components/date-range-picker/date-range-picker.js +15 -28
  140. package/components/date-range-picker/date-range-picker.js.map +1 -1
  141. package/components/date-range-picker/predefined-ranges-area.d.ts +2 -2
  142. package/components/date-range-picker/predefined-ranges-area.js +4 -6
  143. package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
  144. package/components/date-range-picker/validators.d.ts +1 -1
  145. package/components/date-range-picker/validators.js +5 -18
  146. package/components/date-range-picker/validators.js.map +1 -1
  147. package/components/date-time-input/date-part.d.ts +2 -1
  148. package/components/date-time-input/date-part.js +38 -75
  149. package/components/date-time-input/date-part.js.map +1 -1
  150. package/components/date-time-input/date-time-input.base.d.ts +31 -12
  151. package/components/date-time-input/date-time-input.base.js +43 -11
  152. package/components/date-time-input/date-time-input.base.js.map +1 -1
  153. package/components/date-time-input/date-time-input.d.ts +1 -3
  154. package/components/date-time-input/date-time-input.js +7 -40
  155. package/components/date-time-input/date-time-input.js.map +1 -1
  156. package/components/date-time-input/datetime-mask-parser.d.ts +8 -0
  157. package/components/date-time-input/datetime-mask-parser.js +8 -8
  158. package/components/date-time-input/datetime-mask-parser.js.map +1 -1
  159. package/components/date-time-input/validators.js +3 -14
  160. package/components/date-time-input/validators.js.map +1 -1
  161. package/components/dialog/dialog.d.ts +6 -7
  162. package/components/dialog/dialog.js +21 -26
  163. package/components/dialog/dialog.js.map +1 -1
  164. package/components/divider/divider.d.ts +1 -4
  165. package/components/divider/divider.js +8 -17
  166. package/components/divider/divider.js.map +1 -1
  167. package/components/dropdown/dropdown-group.js +1 -6
  168. package/components/dropdown/dropdown-group.js.map +1 -1
  169. package/components/expansion-panel/expansion-panel.d.ts +15 -5
  170. package/components/expansion-panel/expansion-panel.js +23 -34
  171. package/components/expansion-panel/expansion-panel.js.map +1 -1
  172. package/components/file-input/file-input.d.ts +2 -14
  173. package/components/file-input/file-input.js +5 -23
  174. package/components/file-input/file-input.js.map +1 -1
  175. package/components/highlight/highlight.d.ts +6 -8
  176. package/components/highlight/highlight.js +12 -20
  177. package/components/highlight/highlight.js.map +1 -1
  178. package/components/icon/icon-references.js +1 -0
  179. package/components/icon/icon-references.js.map +1 -1
  180. package/components/icon/icon.d.ts +1 -1
  181. package/components/icon/internal-icons-lib.js +3 -0
  182. package/components/icon/internal-icons-lib.js.map +1 -1
  183. package/components/icon/registry/types.d.ts +1 -1
  184. package/components/icon/registry/types.js.map +1 -1
  185. package/components/input/input.d.ts +9 -19
  186. package/components/input/input.js +30 -60
  187. package/components/input/input.js.map +1 -1
  188. package/components/input/themes/shared/input.material.css.js +1 -1
  189. package/components/input/themes/shared/input.material.css.js.map +1 -1
  190. package/components/mask-input/mask-input.d.ts +1 -1
  191. package/components/mask-input/mask-input.js +2 -4
  192. package/components/mask-input/mask-input.js.map +1 -1
  193. package/components/nav-drawer/nav-drawer.d.ts +7 -7
  194. package/components/nav-drawer/nav-drawer.js +12 -23
  195. package/components/nav-drawer/nav-drawer.js.map +1 -1
  196. package/components/progress/base.d.ts +4 -7
  197. package/components/progress/base.js +21 -45
  198. package/components/progress/base.js.map +1 -1
  199. package/components/qr-code/qr-code.d.ts +1 -1
  200. package/components/qr-code/qr-code.js +3 -2
  201. package/components/qr-code/qr-code.js.map +1 -1
  202. package/components/qr-code/types.d.ts +1 -1
  203. package/components/qr-code/types.js.map +1 -1
  204. package/components/radio/controller.d.ts +2 -30
  205. package/components/radio/controller.js +8 -94
  206. package/components/radio/controller.js.map +1 -1
  207. package/components/radio/radio.d.ts +5 -5
  208. package/components/radio/radio.js +48 -58
  209. package/components/radio/radio.js.map +1 -1
  210. package/components/radio-group/radio-group.d.ts +1 -2
  211. package/components/radio-group/radio-group.js +2 -9
  212. package/components/radio-group/radio-group.js.map +1 -1
  213. package/components/rating/rating.d.ts +24 -12
  214. package/components/rating/rating.js +79 -73
  215. package/components/rating/rating.js.map +1 -1
  216. package/components/resize-container/default-ghost.js +4 -3
  217. package/components/resize-container/default-ghost.js.map +1 -1
  218. package/components/resize-container/resize-container.d.ts +1 -1
  219. package/components/resize-container/resize-container.js +5 -3
  220. package/components/resize-container/resize-container.js.map +1 -1
  221. package/components/resize-container/resize-controller.js +4 -3
  222. package/components/resize-container/resize-controller.js.map +1 -1
  223. package/components/select/select-group.d.ts +2 -1
  224. package/components/select/select-group.js +7 -11
  225. package/components/select/select-group.js.map +1 -1
  226. package/components/select/select.d.ts +3 -4
  227. package/components/select/select.js +23 -28
  228. package/components/select/select.js.map +1 -1
  229. package/components/slider/range-slider.d.ts +3 -2
  230. package/components/slider/range-slider.js +22 -70
  231. package/components/slider/range-slider.js.map +1 -1
  232. package/components/slider/slider-base.d.ts +9 -6
  233. package/components/slider/slider-base.js +27 -28
  234. package/components/slider/slider-base.js.map +1 -1
  235. package/components/slider/slider.js +9 -5
  236. package/components/slider/slider.js.map +1 -1
  237. package/components/splitter/splitter.d.ts +1 -1
  238. package/components/splitter/splitter.js.map +1 -1
  239. package/components/stepper/step.d.ts +3 -0
  240. package/components/stepper/step.js +9 -5
  241. package/components/stepper/step.js.map +1 -1
  242. package/components/stepper/stepper.d.ts +0 -11
  243. package/components/stepper/stepper.js +21 -86
  244. package/components/stepper/stepper.js.map +1 -1
  245. package/components/tabs/tab.d.ts +1 -1
  246. package/components/tabs/tab.js +6 -5
  247. package/components/tabs/tab.js.map +1 -1
  248. package/components/tabs/tabs.d.ts +1 -5
  249. package/components/tabs/tabs.js +12 -34
  250. package/components/tabs/tabs.js.map +1 -1
  251. package/components/textarea/textarea.d.ts +6 -7
  252. package/components/textarea/textarea.js +3 -10
  253. package/components/textarea/textarea.js.map +1 -1
  254. package/components/theme-provider/theme-provider.d.ts +2 -4
  255. package/components/theme-provider/theme-provider.js +11 -21
  256. package/components/theme-provider/theme-provider.js.map +1 -1
  257. package/components/tile-manager/tile-manager.d.ts +10 -21
  258. package/components/tile-manager/tile-manager.js +43 -74
  259. package/components/tile-manager/tile-manager.js.map +1 -1
  260. package/components/tile-manager/tile.d.ts +10 -18
  261. package/components/tile-manager/tile.js +50 -67
  262. package/components/tile-manager/tile.js.map +1 -1
  263. package/components/tooltip/tooltip.d.ts +4 -7
  264. package/components/tooltip/tooltip.js +20 -28
  265. package/components/tooltip/tooltip.js.map +1 -1
  266. package/components/tree/tree.d.ts +1 -14
  267. package/components/tree/tree.js +5 -23
  268. package/components/tree/tree.js.map +1 -1
  269. package/components/tree/tree.navigation.d.ts +1 -1
  270. package/components/tree/tree.navigation.js.map +1 -1
  271. package/components/types.d.ts +2 -0
  272. package/components/types.js.map +1 -1
  273. package/components/validation-container/validation-container.d.ts +1 -2
  274. package/components/validation-container/validation-container.js.map +1 -1
  275. package/components/virtualization/engine.d.ts +40 -38
  276. package/components/virtualization/engine.js.map +1 -1
  277. package/components/virtualization/types.d.ts +6 -5
  278. package/components/virtualization/types.js.map +1 -1
  279. package/components/virtualization/virtualization.d.ts +94 -80
  280. package/components/virtualization/virtualization.js +10 -2
  281. package/components/virtualization/virtualization.js.map +1 -1
  282. package/custom-elements.json +31948 -26708
  283. package/igniteui-webcomponents.css-data.json +1 -1
  284. package/igniteui-webcomponents.html-data.json +1 -1
  285. package/index.d.ts +1 -0
  286. package/index.js +1 -0
  287. package/index.js.map +1 -1
  288. package/internals/controllers/aria-projection.d.ts +6 -6
  289. package/internals/controllers/aria-projection.js.map +1 -1
  290. package/internals/controllers/context-provider.d.ts +48 -0
  291. package/internals/controllers/context-provider.js +29 -0
  292. package/internals/controllers/context-provider.js.map +1 -0
  293. package/internals/controllers/drag.js +6 -6
  294. package/internals/controllers/drag.js.map +1 -1
  295. package/internals/controllers/gestures.js +3 -0
  296. package/internals/controllers/gestures.js.map +1 -1
  297. package/internals/controllers/group.d.ts +64 -0
  298. package/internals/controllers/group.js +104 -0
  299. package/internals/controllers/group.js.map +1 -0
  300. package/internals/controllers/internals.d.ts +16 -3
  301. package/internals/controllers/internals.js +10 -3
  302. package/internals/controllers/internals.js.map +1 -1
  303. package/internals/controllers/key-bindings.d.ts +6 -0
  304. package/internals/controllers/key-bindings.js +3 -0
  305. package/internals/controllers/key-bindings.js.map +1 -1
  306. package/internals/controllers/roving-focus.d.ts +72 -0
  307. package/internals/controllers/roving-focus.js +61 -0
  308. package/internals/controllers/roving-focus.js.map +1 -0
  309. package/internals/controllers/slot.d.ts +8 -0
  310. package/internals/controllers/slot.js +4 -0
  311. package/internals/controllers/slot.js.map +1 -1
  312. package/internals/controllers/toggle.d.ts +96 -0
  313. package/internals/controllers/toggle.js +65 -0
  314. package/internals/controllers/toggle.js.map +1 -0
  315. package/internals/date/converters.js +2 -5
  316. package/internals/date/converters.js.map +1 -1
  317. package/internals/date/model.d.ts +4 -0
  318. package/internals/date/model.js +6 -0
  319. package/internals/date/model.js.map +1 -1
  320. package/internals/decorators/coerced-property.d.ts +47 -0
  321. package/internals/decorators/coerced-property.js +36 -0
  322. package/internals/decorators/coerced-property.js.map +1 -0
  323. package/internals/definitions/defineAllComponents.js +2 -0
  324. package/internals/definitions/defineAllComponents.js.map +1 -1
  325. package/internals/i18n/i18n-controller.d.ts +22 -3
  326. package/internals/i18n/i18n-controller.js +28 -6
  327. package/internals/i18n/i18n-controller.js.map +1 -1
  328. package/internals/mixins/alert.d.ts +1 -1
  329. package/internals/mixins/alert.js +5 -3
  330. package/internals/mixins/alert.js.map +1 -1
  331. package/internals/mixins/combo-box.d.ts +3 -12
  332. package/internals/mixins/combo-box.js +6 -32
  333. package/internals/mixins/combo-box.js.map +1 -1
  334. package/internals/mixins/forms/associated.js +18 -0
  335. package/internals/mixins/forms/associated.js.map +1 -1
  336. package/internals/mixins/forms/types.d.ts +20 -1
  337. package/internals/mixins/forms/types.js.map +1 -1
  338. package/internals/mixins/i18n.d.ts +31 -0
  339. package/internals/mixins/i18n.js +36 -0
  340. package/internals/mixins/i18n.js.map +1 -0
  341. package/internals/mixins/mask-behavior.d.ts +6 -5
  342. package/internals/mixins/mask-behavior.js +1 -2
  343. package/internals/mixins/mask-behavior.js.map +1 -1
  344. package/internals/mixins/option.js +4 -2
  345. package/internals/mixins/option.js.map +1 -1
  346. package/internals/templates/masked-input.d.ts +1 -1
  347. package/internals/templates/masked-input.js.map +1 -1
  348. package/internals/templates/slotted-icon.d.ts +32 -0
  349. package/internals/templates/slotted-icon.js +19 -0
  350. package/internals/templates/slotted-icon.js.map +1 -0
  351. package/internals/templates/toggle-shell.d.ts +46 -0
  352. package/internals/templates/toggle-shell.js +38 -0
  353. package/internals/templates/toggle-shell.js.map +1 -0
  354. package/internals/timing.d.ts +32 -0
  355. package/internals/timing.js +20 -0
  356. package/internals/timing.js.map +1 -0
  357. package/internals/utils/arrays.d.ts +2 -2
  358. package/internals/utils/arrays.js.map +1 -1
  359. package/internals/utils/dom.d.ts +22 -0
  360. package/internals/utils/dom.js +15 -1
  361. package/internals/utils/dom.js.map +1 -1
  362. package/internals/utils/math.d.ts +1 -1
  363. package/internals/utils/math.js.map +1 -1
  364. package/internals/utils/types.d.ts +1 -1
  365. package/internals/utils/types.js.map +1 -1
  366. package/internals/validators.d.ts +23 -0
  367. package/internals/validators.js +21 -0
  368. package/internals/validators.js.map +1 -1
  369. package/package.json +3 -1
  370. package/theming/theming-controller.d.ts +3 -3
  371. package/theming/theming-controller.js.map +1 -1
  372. package/web-types.json +2 -2
  373. package/internals/decorators/watch.d.ts +0 -5
  374. package/internals/decorators/watch.js +0 -19
  375. package/internals/decorators/watch.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"predefined-ranges-area.js","sourceRoot":"","sources":["../../../src/components/date-range-picker/predefined-ranges-area.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,O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\n CalendarResourceStringsEN,\n DateRangePickerResourceStringsEN,\n} from 'igniteui-i18n-core';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { CalendarDay } from '#internals/date/model.js';\nimport { watch } from '#internals/decorators/watch.js';\nimport { registerComponent } from '#internals/definitions/register.js';\nimport type { IgcDateRangePickerResourceStrings } from '#internals/i18n/EN/date-range-picker.resources.js';\nimport { addI18nController } from '#internals/i18n/i18n-controller.js';\nimport { addThemingController } from '#theming/theming-controller.js';\nimport IgcChipComponent from '../chip/chip.js';\nimport type {\n CustomDateRange,\n DateRangePickerResourceStringsType,\n DateRangeValue,\n} from './date-range-picker.js';\nimport { styles } from './predefined-ranges-area.base.css.js';\nimport { all } from './themes/ranges-themes.js';\nimport { styles as shared } from './themes/shared/predefined-ranges-area.common.css.js';\n\n/* blazorSuppress */\n/**\n * The predefined ranges area component is used within the date range picker and it\n * displays a set of chips with predefined date ranges. The component allows users to quickly select\n * a predefined date range value. Users can also provide custom ranges to be displayed as chips.\n *\n * @element igc-predefined-ranges-area\n */\nexport default class IgcPredefinedRangesAreaComponent extends LitElement {\n public static readonly tagName = 'igc-predefined-ranges-area';\n public static override styles = [styles, shared];\n\n private readonly _i18nController = addI18nController<\n IgcDateRangePickerResourceStrings | DateRangePickerResourceStringsType\n >(this, {\n defaultEN: Object.assign(\n {},\n DateRangePickerResourceStringsEN,\n CalendarResourceStringsEN\n ),\n resourceMapName: 'date-range-picker',\n });\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcPredefinedRangesAreaComponent, IgcChipComponent);\n }\n\n @state()\n private _predefinedRanges: CustomDateRange[] = [];\n\n /**\n * Whether the control will show chips with predefined ranges.\n * @attr use-predefined-ranges\n */\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'use-predefined-ranges',\n })\n public usePredefinedRanges = false;\n\n /**\n * Renders chips with custom ranges based on the elements of the array.\n */\n @property({ attribute: false })\n public customRanges: CustomDateRange[] = [];\n\n /** The resource strings of the date range area component. */\n @property({ attribute: false })\n public set resourceStrings(\n value:\n | IgcDateRangePickerResourceStrings\n | DateRangePickerResourceStringsType\n ) {\n this._i18nController.resourceStrings = value;\n }\n\n public get resourceStrings(): IgcDateRangePickerResourceStrings &\n DateRangePickerResourceStringsType {\n return this._i18nController.resourceStrings;\n }\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n @watch('resourceStrings')\n protected _updatePredefinedRanges(): void {\n this._predefinedRanges = getPredefinedRanges(this.resourceStrings);\n }\n\n private _handleRangeSelect(range: DateRangeValue): void {\n this.dispatchEvent(new CustomEvent('igcRangeSelect', { detail: range }));\n }\n\n protected *_renderDateRanges() {\n const ranges = this.usePredefinedRanges\n ? [...this._predefinedRanges, ...this.customRanges]\n : this.customRanges;\n\n for (const { label, dateRange } of ranges) {\n yield html`\n <igc-chip @click=${() => this._handleRangeSelect(dateRange)}>\n ${label}\n </igc-chip>\n `;\n }\n }\n\n protected override render() {\n return html`<div part=\"ranges\">${this._renderDateRanges()}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-predefined-ranges-area': IgcPredefinedRangesAreaComponent;\n }\n}\n\ntype PredefinedRangeKey =\n | 'last7Days'\n | 'currentMonth'\n | 'last30Days'\n | 'yearToDate';\n\nfunction getPredefinedRanges(\n resourceStrings: DateRangePickerResourceStringsType\n): CustomDateRange[] {\n const today = CalendarDay.today;\n\n const ranges: {\n key: PredefinedRangeKey;\n resourceKey: keyof DateRangePickerResourceStringsType;\n getDateRange: () => { start: Date; end: Date };\n }[] = [\n {\n key: 'last7Days',\n resourceKey: 'date_range_picker_last7Days',\n getDateRange: () => ({\n start: today.add('day', -7).native,\n end: today.native,\n }),\n },\n {\n key: 'currentMonth',\n resourceKey: 'date_range_picker_currentMonth',\n getDateRange: () => ({\n start: today.set({ date: 1 }).native,\n end: today.set({ date: 1 }).add('month', 1).add('day', -1).native,\n }),\n },\n {\n key: 'last30Days',\n resourceKey: 'date_range_picker_last30Days',\n getDateRange: () => ({\n start: today.add('day', -29).native,\n end: today.native,\n }),\n },\n {\n key: 'yearToDate',\n resourceKey: 'date_range_picker_yearToDate',\n getDateRange: () => ({\n start: today.set({ year: today.year, month: 0, date: 1 }).native,\n end: today.native,\n }),\n },\n ];\n\n return ranges.map((range) => ({\n label: resourceStrings[range.resourceKey]!,\n dateRange: range.getDateRange(),\n }));\n}\n"]}
1
+ {"version":3,"file":"predefined-ranges-area.js","sourceRoot":"","sources":["../../../src/components/date-range-picker/predefined-ranges-area.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAM/C,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,sDAAsD,CAAC;AAUxF,MAAM,CAAC,OAAO,OAAO,gCAAiC,SAAQ,UAAU;aAC/C,YAAO,GAAG,4BAA4B,AAA/B,CAAgC;aACvC,WAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,AAAnB,CAAoB;IAc1C,MAAM,CAAC,QAAQ;QACpB,iBAAiB,CAAC,gCAAgC,EAAE,gBAAgB,CAAC,CAAC;IACxE,CAAC;IAwBD,IAAW,eAAe,CAC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,GAAG,EAAE,CAAC,CAAC;gBACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM;gBACnC,GAAG,EAAE,KAAK,CAAC,MAAM;aAClB,CAAC;SACH;QACD;YACE,GAAG,EAAE,YAAY;YACjB,WAAW,EAAE,8BAA8B;YAC3C,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC;gBACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM;gBAChE,GAAG,EAAE,KAAK,CAAC,MAAM;aAClB,CAAC;SACH;KACF,CAAC;IAEF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5B,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,WAAW,CAAE;QAC1C,SAAS,EAAE,KAAK,CAAC,YAAY,EAAE;KAChC,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {\n CalendarResourceStringsEN,\n DateRangePickerResourceStringsEN,\n} from 'igniteui-i18n-core';\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { CalendarDay } from '#internals/date/model.js';\nimport { registerComponent } from '#internals/definitions/register.js';\nimport type { IgcDateRangePickerResourceStrings } from '#internals/i18n/EN/date-range-picker.resources.js';\nimport { addI18nController } from '#internals/i18n/i18n-controller.js';\nimport { addThemingController } from '#theming/theming-controller.js';\nimport IgcChipComponent from '../chip/chip.js';\nimport type {\n CustomDateRange,\n DateRangePickerResourceStringsType,\n DateRangeValue,\n} from './date-range-picker.js';\nimport { styles } from './predefined-ranges-area.base.css.js';\nimport { all } from './themes/ranges-themes.js';\nimport { styles as shared } from './themes/shared/predefined-ranges-area.common.css.js';\n\n/* blazorSuppress */\n/**\n * The predefined ranges area component is used within the date range picker and it\n * displays a set of chips with predefined date ranges. The component allows users to quickly select\n * a predefined date range value. Users can also provide custom ranges to be displayed as chips.\n *\n * @element igc-predefined-ranges-area\n */\nexport default class IgcPredefinedRangesAreaComponent extends LitElement {\n public static readonly tagName = 'igc-predefined-ranges-area';\n public static override styles = [styles, shared];\n\n private readonly _i18nController = addI18nController<\n IgcDateRangePickerResourceStrings | DateRangePickerResourceStringsType\n >(this, {\n defaultEN: Object.assign(\n {},\n DateRangePickerResourceStringsEN,\n CalendarResourceStringsEN\n ),\n resourceMapName: 'date-range-picker',\n });\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(IgcPredefinedRangesAreaComponent, IgcChipComponent);\n }\n\n @state()\n private _predefinedRanges: CustomDateRange[] = [];\n\n /**\n * Whether the control will show chips with predefined ranges.\n * @attr use-predefined-ranges\n */\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'use-predefined-ranges',\n })\n public usePredefinedRanges = false;\n\n /**\n * Renders chips with custom ranges based on the elements of the array.\n */\n @property({ attribute: false })\n public customRanges: CustomDateRange[] = [];\n\n /** The resource strings of the date range area component. */\n @property({ attribute: false })\n public set resourceStrings(\n value:\n | IgcDateRangePickerResourceStrings\n | DateRangePickerResourceStringsType\n ) {\n this._i18nController.resourceStrings = value;\n }\n\n public get resourceStrings(): IgcDateRangePickerResourceStrings &\n DateRangePickerResourceStringsType {\n return this._i18nController.resourceStrings;\n }\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('resourceStrings')) {\n this._predefinedRanges = getPredefinedRanges(this.resourceStrings);\n }\n }\n\n private _handleRangeSelect(range: DateRangeValue): void {\n this.dispatchEvent(new CustomEvent('igcRangeSelect', { detail: range }));\n }\n\n protected *_renderDateRanges() {\n const ranges = this.usePredefinedRanges\n ? [...this._predefinedRanges, ...this.customRanges]\n : this.customRanges;\n\n for (const { label, dateRange } of ranges) {\n yield html`\n <igc-chip @click=${() => this._handleRangeSelect(dateRange)}>\n ${label}\n </igc-chip>\n `;\n }\n }\n\n protected override render() {\n return html`<div part=\"ranges\">${this._renderDateRanges()}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-predefined-ranges-area': IgcPredefinedRangesAreaComponent;\n }\n}\n\ntype PredefinedRangeKey =\n | 'last7Days'\n | 'currentMonth'\n | 'last30Days'\n | 'yearToDate';\n\nfunction getPredefinedRanges(\n resourceStrings: DateRangePickerResourceStringsType\n): CustomDateRange[] {\n const today = CalendarDay.today;\n\n const ranges: {\n key: PredefinedRangeKey;\n resourceKey: keyof DateRangePickerResourceStringsType;\n getDateRange: () => { start: Date; end: Date };\n }[] = [\n {\n key: 'last7Days',\n resourceKey: 'date_range_picker_last7Days',\n getDateRange: () => ({\n start: today.add('day', -7).native,\n end: today.native,\n }),\n },\n {\n key: 'currentMonth',\n resourceKey: 'date_range_picker_currentMonth',\n getDateRange: () => ({\n start: today.set({ date: 1 }).native,\n end: today.set({ date: 1 }).add('month', 1).add('day', -1).native,\n }),\n },\n {\n key: 'last30Days',\n resourceKey: 'date_range_picker_last30Days',\n getDateRange: () => ({\n start: today.add('day', -29).native,\n end: today.native,\n }),\n },\n {\n key: 'yearToDate',\n resourceKey: 'date_range_picker_yearToDate',\n getDateRange: () => ({\n start: today.set({ year: today.year, month: 0, date: 1 }).native,\n end: today.native,\n }),\n },\n ];\n\n return ranges.map((range) => ({\n label: resourceStrings[range.resourceKey]!,\n dateRange: range.getDateRange(),\n }));\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Validator } from '#internals/validators.js';
1
+ import { type Validator } from '#internals/validators.js';
2
2
  import type { DateRangeValue } from '../types.js';
3
3
  import type IgcDateRangePickerComponent from './date-range-picker.js';
4
4
  export declare const minDateRangeValidator: Validator<IgcDateRangePickerComponent>;
@@ -1,27 +1,14 @@
1
1
  import { ValidationResourceStringsEN } from 'igniteui-i18n-core';
2
- import { isDateExceedingMax, isDateLessThanMin, } from '#internals/date/compare.js';
3
2
  import { calendarRange } from '#internals/date/model.js';
4
3
  import { isEmpty } from '#internals/utils/arrays.js';
5
4
  import { formatString } from '#internals/utils/strings.js';
5
+ import { createMaxDateTimeValidator, createMinDateTimeValidator, } from '#internals/validators.js';
6
6
  import { isDateInRanges } from '../calendar/helpers.js';
7
- function isRangeWithinBounds(host, predicate) {
8
- const { start, end } = host.value ?? {};
9
- return !((start && !predicate(start)) || (end && !predicate(end)));
7
+ function rangeEnds({ value }) {
8
+ return [value?.start, value?.end];
10
9
  }
11
- export const minDateRangeValidator = {
12
- key: 'rangeUnderflow',
13
- message: (host) => formatString(ValidationResourceStringsEN.min_validation_error, host.min),
14
- isValid: (host) => host.min
15
- ? isRangeWithinBounds(host, (date) => !isDateLessThanMin(date, host.min, host.hasTimeParts(), host.hasDateParts()))
16
- : true,
17
- };
18
- export const maxDateRangeValidator = {
19
- key: 'rangeOverflow',
20
- message: (host) => formatString(ValidationResourceStringsEN.max_validation_error, host.max),
21
- isValid: (host) => host.max
22
- ? isRangeWithinBounds(host, (date) => !isDateExceedingMax(date, host.max, host.hasTimeParts(), host.hasDateParts()))
23
- : true,
24
- };
10
+ export const minDateRangeValidator = createMinDateTimeValidator(rangeEnds);
11
+ export const maxDateRangeValidator = createMaxDateTimeValidator(rangeEnds);
25
12
  export const requiredDateRangeValidator = {
26
13
  key: 'valueMissing',
27
14
  message: ValidationResourceStringsEN.required_validation_error,
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/components/date-range-picker/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,M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O,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;AACnE,CAAC","sourcesContent":["import { ValidationResourceStringsEN } from 'igniteui-i18n-core';\nimport {\n isDateExceedingMax,\n isDateLessThanMin,\n} from '#internals/date/compare.js';\nimport { calendarRange } from '#internals/date/model.js';\nimport { isEmpty } from '#internals/utils/arrays.js';\nimport { formatString } from '#internals/utils/strings.js';\nimport type { Validator } from '#internals/validators.js';\nimport { isDateInRanges } from '../calendar/helpers.js';\nimport type { DateRangeValue } from '../types.js';\nimport type IgcDateRangePickerComponent from './date-range-picker.js';\n\n/** Whether both ends of the current range pass `predicate`. */\nfunction isRangeWithinBounds(\n host: IgcDateRangePickerComponent,\n predicate: (date: Date) => boolean\n): boolean {\n const { start, end } = host.value ?? {};\n return !((start && !predicate(start)) || (end && !predicate(end)));\n}\n\nexport const minDateRangeValidator: Validator<IgcDateRangePickerComponent> = {\n key: 'rangeUnderflow',\n message: (host) =>\n formatString(ValidationResourceStringsEN.min_validation_error!, host.min),\n isValid: (host) =>\n host.min\n ? isRangeWithinBounds(\n host,\n (date) =>\n !isDateLessThanMin(\n date,\n host.min!,\n host.hasTimeParts(),\n host.hasDateParts()\n )\n )\n : true,\n};\n\nexport const maxDateRangeValidator: Validator<IgcDateRangePickerComponent> = {\n key: 'rangeOverflow',\n message: (host) =>\n formatString(ValidationResourceStringsEN.max_validation_error!, host.max),\n isValid: (host) =>\n host.max\n ? isRangeWithinBounds(\n host,\n (date) =>\n !isDateExceedingMax(\n date,\n host.max!,\n host.hasTimeParts(),\n host.hasDateParts()\n )\n )\n : true,\n};\n\nexport const requiredDateRangeValidator: Validator<IgcDateRangePickerComponent> =\n {\n key: 'valueMissing',\n message: ValidationResourceStringsEN.required_validation_error!,\n isValid: (host) => {\n return host.required ? isCompleteDateRange(host.value) : true;\n },\n };\n\nexport const badInputDateRangeValidator: Validator<IgcDateRangePickerComponent> =\n {\n key: 'badInput',\n message: (host) =>\n formatString(\n ValidationResourceStringsEN.disabled_date_validation_error!,\n host.value\n ),\n isValid: (host) => {\n const { value, disabledDates } = host;\n\n if (\n !isCompleteDateRange(value) ||\n !disabledDates ||\n isEmpty(disabledDates)\n ) {\n return true;\n }\n\n return Array.from(\n calendarRange({ start: value.start, end: value.end, inclusive: true })\n ).every((date) => !isDateInRanges(date, disabledDates));\n },\n };\n\nexport const dateRangeValidators: Validator<IgcDateRangePickerComponent>[] = [\n requiredDateRangeValidator,\n minDateRangeValidator,\n maxDateRangeValidator,\n badInputDateRangeValidator,\n];\n\nexport function isCompleteDateRange(\n value: DateRangeValue | null\n): value is { start: Date; end: Date } {\n return value != null && value.start != null && value.end != null;\n}\n"]}
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/components/date-range-picker/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAE3B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKxD,SAAS,SAAS,CAAC,EAAE,KAAK,EAA+B;IACvD,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAChC,0BAA0B,CAA8B,SAAS,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,qBAAqB,GAChC,0BAA0B,CAA8B,SAAS,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,0BAA0B,GACrC;IACE,GAAG,EAAE,cAAc;IACnB,OAAO,EAAE,2BAA2B,CAAC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/date/model.js';\nimport { isEmpty } from '#internals/utils/arrays.js';\nimport { formatString } from '#internals/utils/strings.js';\nimport {\n createMaxDateTimeValidator,\n createMinDateTimeValidator,\n type Validator,\n} from '#internals/validators.js';\nimport { isDateInRanges } from '../calendar/helpers.js';\nimport type { DateRangeValue } from '../types.js';\nimport type IgcDateRangePickerComponent from './date-range-picker.js';\n\n/** The ends of the current range, each validated against the bound on its own. */\nfunction rangeEnds({ value }: IgcDateRangePickerComponent) {\n return [value?.start, value?.end];\n}\n\nexport const minDateRangeValidator =\n createMinDateTimeValidator<IgcDateRangePickerComponent>(rangeEnds);\n\nexport const maxDateRangeValidator =\n createMaxDateTimeValidator<IgcDateRangePickerComponent>(rangeEnds);\n\nexport const requiredDateRangeValidator: Validator<IgcDateRangePickerComponent> =\n {\n key: 'valueMissing',\n message: ValidationResourceStringsEN.required_validation_error!,\n isValid: (host) => {\n return host.required ? isCompleteDateRange(host.value) : true;\n },\n };\n\nexport const badInputDateRangeValidator: Validator<IgcDateRangePickerComponent> =\n {\n key: 'badInput',\n message: (host) =>\n formatString(\n ValidationResourceStringsEN.disabled_date_validation_error!,\n host.value\n ),\n isValid: (host) => {\n const { value, disabledDates } = host;\n\n if (\n !isCompleteDateRange(value) ||\n !disabledDates ||\n isEmpty(disabledDates)\n ) {\n return true;\n }\n\n return Array.from(\n calendarRange({ start: value.start, end: value.end, inclusive: true })\n ).every((date) => !isDateInRanges(date, disabledDates));\n },\n };\n\nexport const dateRangeValidators: Validator<IgcDateRangePickerComponent>[] = [\n requiredDateRangeValidator,\n minDateRangeValidator,\n maxDateRangeValidator,\n badInputDateRangeValidator,\n];\n\nexport function isCompleteDateRange(\n value: DateRangeValue | null\n): value is { start: Date; end: Date } {\n return value != null && value.start != null && value.end != null;\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  * Date Part Classes Module
3
3
  *
4
4
  * This module provides structured classes for date/time parts used in date-time input.
5
- * Each part type has its own class with specific validation and spin behavior.
5
+ * Each date part type has its own class with specific validation and spin behavior;
6
+ * the time part types share one class driven by a bounds/accessor lookup.
6
7
  *
7
8
  * Classes are private to this module - only types and factory function are exported.
8
9
  */
@@ -1,3 +1,4 @@
1
+ import { clamp, modulo } from '#internals/utils/math.js';
1
2
  export var DatePart;
2
3
  (function (DatePart) {
3
4
  DatePart["Month"] = "month";
@@ -36,10 +37,26 @@ export const DEFAULT_DATE_PARTS_SPIN_DELTAS = Object.freeze({
36
37
  minutes: 1,
37
38
  seconds: 1,
38
39
  });
39
- const TIME_BOUNDS = {
40
- hours: { min: 0, max: 23 },
41
- minutes: { min: 0, max: 59 },
42
- seconds: { min: 0, max: 59 },
40
+ const TIME_PART_CONFIG = {
41
+ hours: {
42
+ min: 0,
43
+ max: 23,
44
+ get: (date) => date.getHours(),
45
+ set: (date, value) => date.setHours(value),
46
+ display: (value, format) => format.includes('h') ? toTwelveHourFormat(value) : value,
47
+ },
48
+ minutes: {
49
+ min: 0,
50
+ max: 59,
51
+ get: (date) => date.getMinutes(),
52
+ set: (date, value) => date.setMinutes(value),
53
+ },
54
+ seconds: {
55
+ min: 0,
56
+ max: 59,
57
+ get: (date) => date.getSeconds(),
58
+ set: (date, value) => date.setSeconds(value),
59
+ },
43
60
  };
44
61
  const DATE_BOUNDS = {
45
62
  month: { min: 0, max: 11 },
@@ -55,15 +72,10 @@ function toTwelveHourFormat(hours) {
55
72
  const h = hours % 12;
56
73
  return h === 0 ? 12 : h;
57
74
  }
58
- function spinTimePart(date, delta, max, min, setter, getter, spinLoop) {
59
- let value = getter.call(date) + delta;
60
- if (value > max) {
61
- value = spinLoop ? value % (max + 1) : max;
62
- }
63
- else if (value < min) {
64
- value = spinLoop ? max + 1 + (value % (max + 1)) : min;
65
- }
66
- setter.call(date, value);
75
+ function wrapOrClamp(value, min, max, spinLoop) {
76
+ return spinLoop
77
+ ? min + modulo(value - min, max - min + 1)
78
+ : clamp(value, min, max);
67
79
  }
68
80
  class DatePartBase {
69
81
  constructor(type, options) {
@@ -110,14 +122,7 @@ class MonthPart extends DatePartBase {
110
122
  if (date.getDate() > maxDate) {
111
123
  date.setDate(maxDate);
112
124
  }
113
- let month = date.getMonth() + delta;
114
- if (month > max) {
115
- month = spinLoop ? (month % max) - 1 : max;
116
- }
117
- else if (month < min) {
118
- month = spinLoop ? max + (month % max) + 1 : min;
119
- }
120
- date.setMonth(month);
125
+ date.setMonth(wrapOrClamp(date.getMonth() + delta, min, max, spinLoop));
121
126
  }
122
127
  getValue(date) {
123
128
  return padValue(date.getMonth() + 1, this.format.length);
@@ -141,69 +146,29 @@ class DateOfMonthPart extends DatePartBase {
141
146
  const { date, spinLoop } = options;
142
147
  const maxDate = daysInMonth(date.getFullYear(), date.getMonth());
143
148
  const { min } = DATE_BOUNDS.date;
144
- let dayOfMonth = date.getDate() + delta;
145
- if (dayOfMonth > maxDate) {
146
- dayOfMonth = spinLoop ? dayOfMonth % maxDate : maxDate;
147
- }
148
- else if (dayOfMonth < min) {
149
- dayOfMonth = spinLoop ? maxDate + (dayOfMonth % maxDate) : min;
150
- }
151
- date.setDate(dayOfMonth);
149
+ date.setDate(wrapOrClamp(date.getDate() + delta, min, maxDate, spinLoop));
152
150
  }
153
151
  getValue(date) {
154
152
  return padValue(date.getDate(), this.format.length);
155
153
  }
156
154
  }
157
- class HoursPart extends DatePartBase {
158
- constructor(options) {
159
- super(DatePartType.Hours, options);
160
- }
161
- validate(value) {
162
- return value >= TIME_BOUNDS.hours.min && value <= TIME_BOUNDS.hours.max;
163
- }
164
- spin(delta, options) {
165
- const { date, spinLoop } = options;
166
- const { min, max } = TIME_BOUNDS.hours;
167
- spinTimePart(date, delta, max, min, date.setHours, date.getHours, spinLoop);
168
- }
169
- getValue(date) {
170
- const isTwelveHour = this.format.includes('h');
171
- const hours = isTwelveHour
172
- ? toTwelveHourFormat(date.getHours())
173
- : date.getHours();
174
- return padValue(hours, this.format.length);
175
- }
176
- }
177
- class MinutesPart extends DatePartBase {
178
- constructor(options) {
179
- super(DatePartType.Minutes, options);
180
- }
181
- validate(value) {
182
- return value >= TIME_BOUNDS.minutes.min && value <= TIME_BOUNDS.minutes.max;
183
- }
184
- spin(delta, options) {
185
- const { date, spinLoop } = options;
186
- const { min, max } = TIME_BOUNDS.minutes;
187
- spinTimePart(date, delta, max, min, date.setMinutes, date.getMinutes, spinLoop);
188
- }
189
- getValue(date) {
190
- return padValue(date.getMinutes(), this.format.length);
191
- }
192
- }
193
- class SecondsPart extends DatePartBase {
194
- constructor(options) {
195
- super(DatePartType.Seconds, options);
155
+ class TimePart extends DatePartBase {
156
+ constructor(type, options) {
157
+ super(type, options);
158
+ this._config = TIME_PART_CONFIG[type];
196
159
  }
197
160
  validate(value) {
198
- return value >= TIME_BOUNDS.seconds.min && value <= TIME_BOUNDS.seconds.max;
161
+ return value >= this._config.min && value <= this._config.max;
199
162
  }
200
163
  spin(delta, options) {
201
164
  const { date, spinLoop } = options;
202
- const { min, max } = TIME_BOUNDS.seconds;
203
- spinTimePart(date, delta, max, min, date.setSeconds, date.getSeconds, spinLoop);
165
+ const { min, max, get, set } = this._config;
166
+ set(date, wrapOrClamp(get(date) + delta, min, max, spinLoop));
204
167
  }
205
168
  getValue(date) {
206
- return padValue(date.getSeconds(), this.format.length);
169
+ const { get, display } = this._config;
170
+ const value = get(date);
171
+ return padValue(display ? display(value, this.format) : value, this.format.length);
207
172
  }
208
173
  }
209
174
  class AmPmPart extends DatePartBase {
@@ -250,11 +215,9 @@ export function createDatePart(type, options) {
250
215
  case DatePartType.Date:
251
216
  return new DateOfMonthPart(options);
252
217
  case DatePartType.Hours:
253
- return new HoursPart(options);
254
218
  case DatePartType.Minutes:
255
- return new MinutesPart(options);
256
219
  case DatePartType.Seconds:
257
- return new SecondsPart(options);
220
+ return new TimePart(type, options);
258
221
  case DatePartType.AmPm:
259
222
  return new AmPmPart(options);
260
223
  case DatePartType.Literal:
@@ -1 +1 @@
1
- {"version":3,"file":"date-part.js","sourceRoot":"","sources":["../../../src/components/date-time-input/date-part.ts"],"names":[],"mapp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AAQ,CAAC,MAAc;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,MAAc,EAAE,QAAqB;IAE1C,CAAC;IAED,QAAQ,CAAC,KAAW;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAcD,MAAM,UAAU,cAAc,CAC5B,IAAkB,EAClB,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,KAAK,YAAY,CAAC,KAAK;YACrB,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;QAChC,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,YAAY,CAAC,KAAK;YACrB,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;QAChC,KAAK,YAAY,CAAC,OAAO;YACvB,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,YAAY,CAAC,OAAO;YACvB,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,KAAK,YAAY,CAAC,OAAO;YACvB,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC;YACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Date Part Classes Module\n *\n * This module provides structured classes for date/time parts used in date-time input.\n * Each part type has its own class with specific validation and spin behavior.\n *\n * Classes are private to this module - only types and factory function are exported.\n */\n\n//#region Types and Enums\n\nexport enum DatePart {\n Month = 'month',\n Year = 'year',\n Date = 'date',\n Hours = 'hours',\n Minutes = 'minutes',\n Seconds = 'seconds',\n AmPm = 'amPm',\n}\n\n/** Types of date/time parts that can appear in a format string */\nexport const DatePartType = {\n Month: 'month',\n Year: 'year',\n Date: 'date',\n Hours: 'hours',\n Minutes: 'minutes',\n Seconds: 'seconds',\n AmPm: 'amPm',\n Literal: 'literal',\n} as const;\n\nexport type DatePartType = (typeof DatePartType)[keyof typeof DatePartType];\n\n/** The part types that make up a calendar date. */\nexport const DATE_PART_TYPES = new Set<DatePartType>([\n DatePartType.Date,\n DatePartType.Month,\n DatePartType.Year,\n]);\n\n/** The part types that make up a time of day. */\nexport const TIME_PART_TYPES = new Set<DatePartType>([\n DatePartType.Hours,\n DatePartType.Minutes,\n DatePartType.Seconds,\n]);\n\n// Spin delta defaults\nexport const DEFAULT_DATE_PARTS_SPIN_DELTAS = Object.freeze<DatePartDeltas>({\n date: 1,\n month: 1,\n year: 1,\n hours: 1,\n minutes: 1,\n seconds: 1,\n});\n\n/**\n * The amounts by which each date or time part is incremented or decremented on\n * a step action in date-time input; every part defaults to `1`.\n */\nexport interface DatePartDeltas {\n /** The number of days the date part is spun by. */\n date?: number;\n /** The number of months the month part is spun by. */\n month?: number;\n /** The number of years the year part is spun by. */\n year?: number;\n /** The number of hours the hours part is spun by. */\n hours?: number;\n /** The number of minutes the minutes part is spun by. */\n minutes?: number;\n /** The number of seconds the seconds part is spun by. */\n seconds?: number;\n}\n\n/** Options for creating a date part */\nexport interface DatePartOptions {\n /** Start position in the masked string */\n start: number;\n /** End position in the masked string */\n end: number;\n /** The format string for this part (e.g., 'MM', 'yyyy') */\n format: string;\n}\n/* blazorSuppress */\n/** Options for spin operations */\nexport interface SpinOptions {\n /** The current date value */\n date: Date;\n /** Whether to loop values at boundaries */\n spinLoop: boolean;\n /** For AM/PM: the current masked value to determine AM or PM */\n amPmValue?: string;\n /** For AM/PM: the original date (for rollover prevention) */\n originalDate?: Date;\n}\n\n/**\n * Read-only interface for date part information\n * @hidden\n */\nexport interface IDatePart {\n /** The type of date part */\n readonly type: DatePartType;\n /** Start position in the masked string */\n readonly start: number;\n /** End position in the masked string */\n readonly end: number;\n /** The format string for this part */\n readonly format: string;\n\n /**\n * Validates a numeric value for this part.\n * @param value - The value to validate\n * @param context - Optional context (year, month) for date-dependent validation\n * @returns true if the value is valid for this part\n */\n validate(value: number, context?: DateValidationContext): boolean;\n\n /**\n * Spins (increments/decrements) this part's value on the given date.\n * @param delta - The amount to spin (positive = up, negative = down)\n * @param options - Spin options including the date and loop behavior\n */\n spin(delta: number, options: SpinOptions): void;\n\n /**\n * Extracts the value of this part from a Date object.\n * @param date - The date to extract from\n * @returns The formatted string value\n */\n getValue(date: Date): string;\n}\n\n/* blazorSuppress */\n/** Context for date validation (needed for day-of-month validation) */\nexport interface DateValidationContext {\n year?: number;\n month?: number;\n}\n\n//#endregion\n\n//#region Constants\n\n/** Time bounds for validation */\nconst TIME_BOUNDS = {\n hours: { min: 0, max: 23 },\n minutes: { min: 0, max: 59 },\n seconds: { min: 0, max: 59 },\n} as const;\n\n/** Date bounds for validation */\nconst DATE_BOUNDS = {\n month: { min: 0, max: 11 },\n date: { min: 1, max: 31 },\n} as const;\n\n//#endregion\n\n//#region Helper Functions\n\n/**\n * Gets the number of days in a specific month/year.\n */\nfunction daysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/**\n * Pads a value with zeros to the specified length.\n */\nfunction padValue(value: string | number, length: number): string {\n return String(value).padStart(length, '0');\n}\n\n/**\n * Converts 24-hour format to 12-hour format.\n */\nfunction toTwelveHourFormat(hours: number): number {\n const h = hours % 12;\n return h === 0 ? 12 : h;\n}\n\n/**\n * Generic spin helper for time parts.\n */\nfunction spinTimePart(\n date: Date,\n delta: number,\n max: number,\n min: number,\n setter: (value: number) => number,\n getter: () => number,\n spinLoop: boolean\n): void {\n let value = getter.call(date) + delta;\n\n if (value > max) {\n value = spinLoop ? value % (max + 1) : max;\n } else if (value < min) {\n value = spinLoop ? max + 1 + (value % (max + 1)) : min;\n }\n\n setter.call(date, value);\n}\n\n//#endregion\n\n//#region Abstract Base Class\n\n/**\n * Abstract base class for all date parts.\n * Provides common functionality and defines the contract for concrete implementations.\n */\nabstract class DatePartBase implements IDatePart {\n readonly type: DatePartType;\n readonly start: number;\n readonly end: number;\n readonly format: string;\n\n constructor(type: DatePartType, options: DatePartOptions) {\n this.type = type;\n this.start = options.start;\n this.end = options.end;\n this.format = options.format;\n }\n\n abstract validate(value: number, context?: DateValidationContext): boolean;\n abstract spin(delta: number, options: SpinOptions): void;\n abstract getValue(date: Date): string;\n}\n\n//#endregion\n\n//#region Concrete Implementations\n\n/**\n * Year part (yyyy, yy)\n */\nclass YearPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Year, options);\n }\n\n validate(_value: number): boolean {\n // Years are always valid (no upper bound)\n return _value >= 0;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date } = options;\n const maxDate = daysInMonth(date.getFullYear() + delta, date.getMonth());\n\n // Clip to max day to avoid leap year change shifting the entire value\n if (date.getDate() > maxDate) {\n date.setDate(maxDate);\n }\n\n date.setFullYear(date.getFullYear() + delta);\n }\n\n getValue(date: Date): string {\n const length = this.format.length;\n const year =\n length === 2\n ? date.getFullYear().toString().slice(-2)\n : date.getFullYear();\n return padValue(year, length);\n }\n}\n\n/**\n * Month part (MM, M)\n */\nclass MonthPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Month, options);\n }\n\n validate(value: number): boolean {\n // Month is 0-based internally, but 1-12 in display\n return value >= DATE_BOUNDS.month.min && value <= DATE_BOUNDS.month.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max } = DATE_BOUNDS.month;\n\n const maxDate = daysInMonth(date.getFullYear(), date.getMonth() + delta);\n if (date.getDate() > maxDate) {\n date.setDate(maxDate);\n }\n\n let month = date.getMonth() + delta;\n\n if (month > max) {\n month = spinLoop ? (month % max) - 1 : max;\n } else if (month < min) {\n month = spinLoop ? max + (month % max) + 1 : min;\n }\n\n date.setMonth(month);\n }\n\n getValue(date: Date): string {\n return padValue(date.getMonth() + 1, this.format.length);\n }\n}\n\n/**\n * Date (day of month) part (dd, d)\n */\nclass DateOfMonthPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Date, options);\n }\n\n validate(value: number, context?: DateValidationContext): boolean {\n if (value < DATE_BOUNDS.date.min) {\n return false;\n }\n\n if (context?.year !== undefined && context?.month !== undefined) {\n const maxDays = daysInMonth(context.year, context.month);\n return value <= maxDays;\n }\n\n return value <= DATE_BOUNDS.date.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const maxDate = daysInMonth(date.getFullYear(), date.getMonth());\n const { min } = DATE_BOUNDS.date;\n\n let dayOfMonth = date.getDate() + delta;\n\n if (dayOfMonth > maxDate) {\n dayOfMonth = spinLoop ? dayOfMonth % maxDate : maxDate;\n } else if (dayOfMonth < min) {\n dayOfMonth = spinLoop ? maxDate + (dayOfMonth % maxDate) : min;\n }\n\n date.setDate(dayOfMonth);\n }\n\n getValue(date: Date): string {\n return padValue(date.getDate(), this.format.length);\n }\n}\n\n/**\n * Hours part (HH, H, hh, h)\n */\nclass HoursPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Hours, options);\n }\n\n validate(value: number): boolean {\n return value >= TIME_BOUNDS.hours.min && value <= TIME_BOUNDS.hours.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max } = TIME_BOUNDS.hours;\n spinTimePart(date, delta, max, min, date.setHours, date.getHours, spinLoop);\n }\n\n getValue(date: Date): string {\n const isTwelveHour = this.format.includes('h');\n const hours = isTwelveHour\n ? toTwelveHourFormat(date.getHours())\n : date.getHours();\n return padValue(hours, this.format.length);\n }\n}\n\n/**\n * Minutes part (mm, m)\n */\nclass MinutesPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Minutes, options);\n }\n\n validate(value: number): boolean {\n return value >= TIME_BOUNDS.minutes.min && value <= TIME_BOUNDS.minutes.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max } = TIME_BOUNDS.minutes;\n spinTimePart(\n date,\n delta,\n max,\n min,\n date.setMinutes,\n date.getMinutes,\n spinLoop\n );\n }\n\n getValue(date: Date): string {\n return padValue(date.getMinutes(), this.format.length);\n }\n}\n\n/**\n * Seconds part (ss, s)\n */\nclass SecondsPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Seconds, options);\n }\n\n validate(value: number): boolean {\n return value >= TIME_BOUNDS.seconds.min && value <= TIME_BOUNDS.seconds.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max } = TIME_BOUNDS.seconds;\n spinTimePart(\n date,\n delta,\n max,\n min,\n date.setSeconds,\n date.getSeconds,\n spinLoop\n );\n }\n\n getValue(date: Date): string {\n return padValue(date.getSeconds(), this.format.length);\n }\n}\n\n/**\n * AM/PM part (tt, t)\n */\nclass AmPmPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.AmPm, options);\n }\n\n validate(_value: number): boolean {\n // AM/PM doesn't have numeric validation\n return true;\n }\n\n spin(_delta: number, options: SpinOptions): void {\n const { date, amPmValue, originalDate } = options;\n\n if (!amPmValue) return;\n\n const isAM = amPmValue.toLowerCase() === 'am';\n const newHours = date.getHours() + (isAM ? 12 : -12);\n date.setHours(newHours);\n\n // Prevent date rollover\n if (originalDate && date.getDate() !== originalDate.getDate()) {\n date.setTime(originalDate.getTime());\n }\n }\n\n getValue(date: Date): string {\n return date.getHours() >= 12 ? 'PM' : 'AM';\n }\n}\n\n/**\n * Literal part (separators like /, -, :, space, etc.)\n */\nclass LiteralPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Literal, options);\n }\n\n validate(_value: number): boolean {\n // Literals don't have validation\n return true;\n }\n\n spin(_delta: number, _options: SpinOptions): void {\n // Literals can't be spun\n }\n\n getValue(_date: Date): string {\n return this.format;\n }\n}\n\n//#endregion\n\n//#region Factory Function\n\n/**\n * Creates a date part instance based on the type.\n * This is the only way to create date part instances outside this module.\n *\n * @param type - The type of date part to create\n * @param options - The options for the date part\n * @returns A date part instance implementing IDatePart\n */\nexport function createDatePart(\n type: DatePartType,\n options: DatePartOptions\n): IDatePart {\n switch (type) {\n case DatePartType.Year:\n return new YearPart(options);\n case DatePartType.Month:\n return new MonthPart(options);\n case DatePartType.Date:\n return new DateOfMonthPart(options);\n case DatePartType.Hours:\n return new HoursPart(options);\n case DatePartType.Minutes:\n return new MinutesPart(options);\n case DatePartType.Seconds:\n return new SecondsPart(options);\n case DatePartType.AmPm:\n return new AmPmPart(options);\n case DatePartType.Literal:\n return new LiteralPart(options);\n default:\n throw new Error(`Unknown date part type: ${type}`);\n }\n}\n\n//#endregion\n"]}
1
+ {"version":3,"file":"date-part.js","sourceRoot":"","sources":["../../../src/components/date-time-input/date-part.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAIzD,MAAM,CAAN,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,yBAAa,CAAA;AACf,CAAC,EARW,QAAQ,KAAR,QAAQ,QAQnB;AAGD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAC;AAKX,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAe;IACnD,YAAY,CAAC,IAAI;IACjB,YAAY,CAAC,KAAK;IAClB,YA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EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;CACF;AAKD,MAAM,WAAY,SAAQ,YAAY;IACpC,YAAY,OAAwB;QAClC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ,CAAC,MAAc;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,MAAc,EAAE,QAAqB;IAE1C,CAAC;IAED,QAAQ,CAAC,KAAW;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAcD,MAAM,UAAU,cAAc,CAC5B,IAAkB,EAClB,OAAwB;IAExB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,KAAK,YAAY,CAAC,KAAK;YACrB,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;QAChC,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,YAAY,CAAC,KAAK,CAAC;QACxB,KAAK,YAAY,CAAC,OAAO,CAAC;QAC1B,KAAK,YAAY,CAAC,OAAO;YACvB,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,KAAK,YAAY,CAAC,OAAO;YACvB,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC;YACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Date Part Classes Module\n *\n * This module provides structured classes for date/time parts used in date-time input.\n * Each date part type has its own class with specific validation and spin behavior;\n * the time part types share one class driven by a bounds/accessor lookup.\n *\n * Classes are private to this module - only types and factory function are exported.\n */\n\nimport { clamp, modulo } from '#internals/utils/math.js';\n\n//#region Types and Enums\n\nexport enum DatePart {\n Month = 'month',\n Year = 'year',\n Date = 'date',\n Hours = 'hours',\n Minutes = 'minutes',\n Seconds = 'seconds',\n AmPm = 'amPm',\n}\n\n/** Types of date/time parts that can appear in a format string */\nexport const DatePartType = {\n Month: 'month',\n Year: 'year',\n Date: 'date',\n Hours: 'hours',\n Minutes: 'minutes',\n Seconds: 'seconds',\n AmPm: 'amPm',\n Literal: 'literal',\n} as const;\n\nexport type DatePartType = (typeof DatePartType)[keyof typeof DatePartType];\n\n/** The part types that make up a calendar date. */\nexport const DATE_PART_TYPES = new Set<DatePartType>([\n DatePartType.Date,\n DatePartType.Month,\n DatePartType.Year,\n]);\n\n/** The part types that make up a time of day. */\nexport const TIME_PART_TYPES = new Set<DatePartType>([\n DatePartType.Hours,\n DatePartType.Minutes,\n DatePartType.Seconds,\n]);\n\n// Spin delta defaults\nexport const DEFAULT_DATE_PARTS_SPIN_DELTAS = Object.freeze<DatePartDeltas>({\n date: 1,\n month: 1,\n year: 1,\n hours: 1,\n minutes: 1,\n seconds: 1,\n});\n\n/**\n * The amounts by which each date or time part is incremented or decremented on\n * a step action in date-time input; every part defaults to `1`.\n */\nexport interface DatePartDeltas {\n /** The number of days the date part is spun by. */\n date?: number;\n /** The number of months the month part is spun by. */\n month?: number;\n /** The number of years the year part is spun by. */\n year?: number;\n /** The number of hours the hours part is spun by. */\n hours?: number;\n /** The number of minutes the minutes part is spun by. */\n minutes?: number;\n /** The number of seconds the seconds part is spun by. */\n seconds?: number;\n}\n\n/** Options for creating a date part */\nexport interface DatePartOptions {\n /** Start position in the masked string */\n start: number;\n /** End position in the masked string */\n end: number;\n /** The format string for this part (e.g., 'MM', 'yyyy') */\n format: string;\n}\n/* blazorSuppress */\n/** Options for spin operations */\nexport interface SpinOptions {\n /** The current date value */\n date: Date;\n /** Whether to loop values at boundaries */\n spinLoop: boolean;\n /** For AM/PM: the current masked value to determine AM or PM */\n amPmValue?: string;\n /** For AM/PM: the original date (for rollover prevention) */\n originalDate?: Date;\n}\n\n/**\n * Read-only interface for date part information\n * @hidden\n */\nexport interface IDatePart {\n /** The type of date part */\n readonly type: DatePartType;\n /** Start position in the masked string */\n readonly start: number;\n /** End position in the masked string */\n readonly end: number;\n /** The format string for this part */\n readonly format: string;\n\n /**\n * Validates a numeric value for this part.\n * @param value - The value to validate\n * @param context - Optional context (year, month) for date-dependent validation\n * @returns true if the value is valid for this part\n */\n validate(value: number, context?: DateValidationContext): boolean;\n\n /**\n * Spins (increments/decrements) this part's value on the given date.\n * @param delta - The amount to spin (positive = up, negative = down)\n * @param options - Spin options including the date and loop behavior\n */\n spin(delta: number, options: SpinOptions): void;\n\n /**\n * Extracts the value of this part from a Date object.\n * @param date - The date to extract from\n * @returns The formatted string value\n */\n getValue(date: Date): string;\n}\n\n/* blazorSuppress */\n/** Context for date validation (needed for day-of-month validation) */\nexport interface DateValidationContext {\n year?: number;\n month?: number;\n}\n\n//#endregion\n\n//#region Constants\n\ntype TimePartType =\n | typeof DatePartType.Hours\n | typeof DatePartType.Minutes\n | typeof DatePartType.Seconds;\n\n/** Per-part bounds and `Date` accessors driving the shared {@link TimePart}. */\ninterface TimePartConfig {\n /** Inclusive lower bound for validation and spinning. */\n min: number;\n /** Inclusive upper bound for validation and spinning. */\n max: number;\n get(date: Date): number;\n set(date: Date, value: number): void;\n /** Maps the raw value to its rendered form - 12-hour hours, say. */\n display?(value: number, format: string): number;\n}\n\nconst TIME_PART_CONFIG: Record<TimePartType, TimePartConfig> = {\n hours: {\n min: 0,\n max: 23,\n get: (date) => date.getHours(),\n set: (date, value) => date.setHours(value),\n display: (value, format) =>\n format.includes('h') ? toTwelveHourFormat(value) : value,\n },\n minutes: {\n min: 0,\n max: 59,\n get: (date) => date.getMinutes(),\n set: (date, value) => date.setMinutes(value),\n },\n seconds: {\n min: 0,\n max: 59,\n get: (date) => date.getSeconds(),\n set: (date, value) => date.setSeconds(value),\n },\n};\n\n/** Date bounds for validation */\nconst DATE_BOUNDS = {\n month: { min: 0, max: 11 },\n date: { min: 1, max: 31 },\n} as const;\n\n//#endregion\n\n//#region Helper Functions\n\n/**\n * Gets the number of days in a specific month/year.\n */\nfunction daysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/**\n * Pads a value with zeros to the specified length.\n */\nfunction padValue(value: string | number, length: number): string {\n return String(value).padStart(length, '0');\n}\n\n/**\n * Converts 24-hour format to 12-hour format.\n */\nfunction toTwelveHourFormat(hours: number): number {\n const h = hours % 12;\n return h === 0 ? 12 : h;\n}\n\n/**\n * Wraps a spun value around the inclusive `[min, max]` range, or clamps it to\n * the nearest bound when looping is off.\n */\nfunction wrapOrClamp(\n value: number,\n min: number,\n max: number,\n spinLoop: boolean\n): number {\n return spinLoop\n ? min + modulo(value - min, max - min + 1)\n : clamp(value, min, max);\n}\n\n//#endregion\n\n//#region Abstract Base Class\n\n/**\n * Abstract base class for all date parts.\n * Provides common functionality and defines the contract for concrete implementations.\n */\nabstract class DatePartBase implements IDatePart {\n readonly type: DatePartType;\n readonly start: number;\n readonly end: number;\n readonly format: string;\n\n constructor(type: DatePartType, options: DatePartOptions) {\n this.type = type;\n this.start = options.start;\n this.end = options.end;\n this.format = options.format;\n }\n\n abstract validate(value: number, context?: DateValidationContext): boolean;\n abstract spin(delta: number, options: SpinOptions): void;\n abstract getValue(date: Date): string;\n}\n\n//#endregion\n\n//#region Concrete Implementations\n\n/**\n * Year part (yyyy, yy)\n */\nclass YearPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Year, options);\n }\n\n validate(_value: number): boolean {\n // Years are always valid (no upper bound)\n return _value >= 0;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date } = options;\n const maxDate = daysInMonth(date.getFullYear() + delta, date.getMonth());\n\n // Clip to max day to avoid leap year change shifting the entire value\n if (date.getDate() > maxDate) {\n date.setDate(maxDate);\n }\n\n date.setFullYear(date.getFullYear() + delta);\n }\n\n getValue(date: Date): string {\n const length = this.format.length;\n const year =\n length === 2\n ? date.getFullYear().toString().slice(-2)\n : date.getFullYear();\n return padValue(year, length);\n }\n}\n\n/**\n * Month part (MM, M)\n */\nclass MonthPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Month, options);\n }\n\n validate(value: number): boolean {\n // Month is 0-based internally, but 1-12 in display\n return value >= DATE_BOUNDS.month.min && value <= DATE_BOUNDS.month.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max } = DATE_BOUNDS.month;\n\n const maxDate = daysInMonth(date.getFullYear(), date.getMonth() + delta);\n if (date.getDate() > maxDate) {\n date.setDate(maxDate);\n }\n\n date.setMonth(wrapOrClamp(date.getMonth() + delta, min, max, spinLoop));\n }\n\n getValue(date: Date): string {\n return padValue(date.getMonth() + 1, this.format.length);\n }\n}\n\n/**\n * Date (day of month) part (dd, d)\n */\nclass DateOfMonthPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Date, options);\n }\n\n validate(value: number, context?: DateValidationContext): boolean {\n if (value < DATE_BOUNDS.date.min) {\n return false;\n }\n\n if (context?.year !== undefined && context?.month !== undefined) {\n const maxDays = daysInMonth(context.year, context.month);\n return value <= maxDays;\n }\n\n return value <= DATE_BOUNDS.date.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const maxDate = daysInMonth(date.getFullYear(), date.getMonth());\n const { min } = DATE_BOUNDS.date;\n\n date.setDate(wrapOrClamp(date.getDate() + delta, min, maxDate, spinLoop));\n }\n\n getValue(date: Date): string {\n return padValue(date.getDate(), this.format.length);\n }\n}\n\n/**\n * Time part (HH/hh hours, mm minutes, ss seconds) - a single implementation\n * over the per-part bounds and accessors in {@link TIME_PART_CONFIG}.\n */\nclass TimePart extends DatePartBase {\n private readonly _config: TimePartConfig;\n\n constructor(type: TimePartType, options: DatePartOptions) {\n super(type, options);\n this._config = TIME_PART_CONFIG[type];\n }\n\n validate(value: number): boolean {\n return value >= this._config.min && value <= this._config.max;\n }\n\n spin(delta: number, options: SpinOptions): void {\n const { date, spinLoop } = options;\n const { min, max, get, set } = this._config;\n\n set(date, wrapOrClamp(get(date) + delta, min, max, spinLoop));\n }\n\n getValue(date: Date): string {\n const { get, display } = this._config;\n const value = get(date);\n\n return padValue(\n display ? display(value, this.format) : value,\n this.format.length\n );\n }\n}\n\n/**\n * AM/PM part (tt, t)\n */\nclass AmPmPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.AmPm, options);\n }\n\n validate(_value: number): boolean {\n // AM/PM doesn't have numeric validation\n return true;\n }\n\n spin(_delta: number, options: SpinOptions): void {\n const { date, amPmValue, originalDate } = options;\n\n if (!amPmValue) return;\n\n const isAM = amPmValue.toLowerCase() === 'am';\n const newHours = date.getHours() + (isAM ? 12 : -12);\n date.setHours(newHours);\n\n // Prevent date rollover\n if (originalDate && date.getDate() !== originalDate.getDate()) {\n date.setTime(originalDate.getTime());\n }\n }\n\n getValue(date: Date): string {\n return date.getHours() >= 12 ? 'PM' : 'AM';\n }\n}\n\n/**\n * Literal part (separators like /, -, :, space, etc.)\n */\nclass LiteralPart extends DatePartBase {\n constructor(options: DatePartOptions) {\n super(DatePartType.Literal, options);\n }\n\n validate(_value: number): boolean {\n // Literals don't have validation\n return true;\n }\n\n spin(_delta: number, _options: SpinOptions): void {\n // Literals can't be spun\n }\n\n getValue(_date: Date): string {\n return this.format;\n }\n}\n\n//#endregion\n\n//#region Factory Function\n\n/**\n * Creates a date part instance based on the type.\n * This is the only way to create date part instances outside this module.\n *\n * @param type - The type of date part to create\n * @param options - The options for the date part\n * @returns A date part instance implementing IDatePart\n */\nexport function createDatePart(\n type: DatePartType,\n options: DatePartOptions\n): IDatePart {\n switch (type) {\n case DatePartType.Year:\n return new YearPart(options);\n case DatePartType.Month:\n return new MonthPart(options);\n case DatePartType.Date:\n return new DateOfMonthPart(options);\n case DatePartType.Hours:\n case DatePartType.Minutes:\n case DatePartType.Seconds:\n return new TimePart(type, options);\n case DatePartType.AmPm:\n return new AmPmPart(options);\n case DatePartType.Literal:\n return new LiteralPart(options);\n default:\n throw new Error(`Unknown date part type: ${type}`);\n }\n}\n\n//#endregion\n"]}
@@ -1,13 +1,14 @@
1
1
  import { LitElement, type PropertyValues, type TemplateResult } from 'lit';
2
+ import type { FormValue } from '#internals/mixins/forms/form-value.js';
2
3
  import { type MaskSelection } from '#internals/mixins/mask-behavior.js';
3
4
  import type { ThemingController } from '#theming/theming-controller.js';
4
5
  import type { RangeTextSelectMode } from '../types.js';
5
- import type { DatePartDeltas } from './date-part.js';
6
+ import { type DatePartDeltas, type IDatePart } from './date-part.js';
6
7
  export type { MaskSelection };
7
8
  declare const IgcDateTimeInputBaseComponent_base: import("../../internals/mixins/constructor.js").AbstractConstructor<import("#internals/mixins/mask-behavior.js").MaskBehaviorElementInterface> & import("../../internals/mixins/constructor.js").Constructor<import("../../internals/mixins/forms/types.js").FormRequiredInterface & import("../../internals/mixins/forms/types.js").FormAssociatedElementInterface> & typeof LitElement;
8
9
  export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTimeInputBaseComponent_base {
9
10
  protected abstract readonly _themes: ThemingController;
10
- protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "[default]" | "suffix" | "helper-text" | "value-missing" | "custom-error" | "range-overflow" | "range-underflow">;
11
+ protected readonly _slots: import("#internals/controllers/slot.js").SlotController<"invalid" | "prefix" | "helper-text" | "[default]" | "suffix" | "value-missing" | "custom-error" | "range-overflow" | "range-underflow">;
11
12
  protected readonly _inputId: string;
12
13
  protected readonly _input?: HTMLInputElement;
13
14
  /**
@@ -20,10 +21,10 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
20
21
  private readonly _i18nController;
21
22
  protected _min: Date | null;
22
23
  protected _max: Date | null;
23
- protected _defaultMask: string;
24
- protected _defaultDisplayFormat: string;
25
24
  protected _displayFormat?: string;
26
25
  protected _inputFormat?: string;
26
+ /** The locale-default display format, resolved by the i18n controller. */
27
+ protected get _defaultDisplayFormat(): string;
27
28
  /**
28
29
  * Whether the user has an uncommitted edit in progress.
29
30
  *
@@ -43,6 +44,8 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
43
44
  * @hidden @internal
44
45
  */
45
46
  get _uncommittedValue(): T | null;
47
+ /** The spin amount for each date part - the defaults overlaid with `spinDelta`. */
48
+ protected get _datePartDeltas(): DatePartDeltas;
46
49
  protected get _targetDatePart(): unknown;
47
50
  /**
48
51
  * Whether the control will have outlined appearance.
@@ -97,7 +100,8 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
97
100
  */
98
101
  spinLoop: boolean;
99
102
  /**
100
- * Gets/Sets the locale used for formatting the display value.
103
+ * The locale used to format the display value and to resolve the
104
+ * component's resource strings. Falls back to the global locale when not set.
101
105
  * @attr locale
102
106
  */
103
107
  set locale(value: string);
@@ -107,6 +111,7 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
107
111
  private _handleResourceChange;
108
112
  protected _handleDragLeave(): void;
109
113
  protected _handleDragEnter(): void;
114
+ protected _handleFocus(): Promise<void>;
110
115
  protected _handleBlur(): void;
111
116
  /**
112
117
  * Handles wheel events for spinning date parts.
@@ -138,6 +143,22 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
138
143
  * programmatic `stepUp()` - there is no blur coming to commit it.
139
144
  */
140
145
  protected _setDraftValue(value: T): void;
146
+ /**
147
+ * Whether the committed value is empty, i.e. gaining focus should start the
148
+ * edit from the empty mask rather than the formatted value.
149
+ */
150
+ protected _isValueEmpty(): boolean;
151
+ /**
152
+ * Applies a programmatic value assignment: bails when the value is unchanged,
153
+ * cancels any edit in progress, and re-renders the mask from the new value.
154
+ */
155
+ protected _applyValue(value: T | null): void;
156
+ /**
157
+ * Reads the AM/PM designator as currently typed in the mask for the given
158
+ * format part, so spinning it toggles from what the user sees rather than
159
+ * from the underlying date.
160
+ */
161
+ protected _readAmPmFromMask(part?: IDatePart): string | undefined;
141
162
  /** Applies the masked text to the public value without emitting anything. */
142
163
  protected _applyDraft(): void;
143
164
  /**
@@ -160,10 +181,7 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
160
181
  * Applies a mask pattern to the input, parsing the format string into date parts.
161
182
  */
162
183
  protected _applyMask(formatString: string): void;
163
- /**
164
- * Updates the default display format based on current locale.
165
- */
166
- private _updateDefaultDisplayFormat;
184
+ /** Applies the locale-default mask, unless an explicit input format is set. */
167
185
  protected _initializeDefaultMask(): void;
168
186
  /**
169
187
  * Resolves the part names for the container based on the current state.
@@ -185,7 +203,7 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
185
203
  clear(): void;
186
204
  protected _renderInput(): TemplateResult;
187
205
  protected render(): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/cache.js").CacheDirective>;
188
- protected abstract get _datePartDeltas(): DatePartDeltas;
206
+ protected abstract readonly _formValue: FormValue<T | null>;
189
207
  /** Provided by `EventEmitterMixin` in the concrete components. */
190
208
  abstract emitEvent(name: string, init?: CustomEventInit): boolean;
191
209
  /** The committed value of the input. */
@@ -195,7 +213,9 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
195
213
  * Parses the current masked text into the leaf's value type.
196
214
  *
197
215
  * A `strict` parse mirrors the committed value semantics - an incomplete mask has
198
- * no value yet and resolves to `null` rather than to a defaults-filled one.
216
+ * no value yet and resolves to `null` rather than to a defaults-filled one. A lenient
217
+ * parse completes the missing parts from their defaults, an empty mask excepted - that
218
+ * one holds no value to complete and resolves to `null` as well.
199
219
  */
200
220
  protected abstract _parseMask(strict: boolean): T | null;
201
221
  /** Formats a value into the editable mask. */
@@ -204,7 +224,6 @@ export declare abstract class IgcDateTimeInputBaseComponent<T> extends IgcDateTi
204
224
  protected abstract _calculatePartNavigationPosition(value: string, direction: number): number;
205
225
  protected abstract _calculateSpunValue(part: unknown, delta: number | undefined, isDecrement: boolean): T;
206
226
  protected abstract _setCurrentDateTime(): void;
207
- protected abstract _handleFocus(): Promise<void>;
208
227
  protected abstract _getDatePartAtCursor(): unknown;
209
228
  protected abstract _getDefaultDatePart(): unknown;
210
229
  abstract hasDateParts(): boolean;
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { getDateFormatter } from 'igniteui-i18n-core';
8
7
  import { LitElement } from 'lit';
9
8
  import { eventOptions, property, query } from 'lit/decorators.js';
10
9
  import { cache } from 'lit/directives/cache.js';
@@ -14,21 +13,28 @@ import { addSlotController, setSlots } from '#internals/controllers/slot.js';
14
13
  import { convertToDate } from '#internals/date/converters.js';
15
14
  import { blazorDeepImport } from '#internals/decorators/blazorDeepImport.js';
16
15
  import { shadowOptions } from '#internals/decorators/shadow-options.js';
17
- import { addI18nController, getDefaultDateTimeFormat, } from '#internals/i18n/i18n-controller.js';
16
+ import { addI18nController } from '#internals/i18n/i18n-controller.js';
18
17
  import { FormAssociatedRequiredMixin } from '#internals/mixins/forms/associated-required.js';
19
18
  import { MaskBehaviorMixin, } from '#internals/mixins/mask-behavior.js';
20
19
  import { nextInputId, renderInputShell, resolveInputPartNames, } from '#internals/templates/input-shell.js';
21
20
  import { renderMaskedNativeInput } from '#internals/templates/masked-input.js';
22
21
  import { equal } from '#internals/utils/objects.js';
22
+ import { DatePartType, DEFAULT_DATE_PARTS_SPIN_DELTAS, } from './date-part.js';
23
23
  import { dateTimeInputValidators } from './validators.js';
24
24
  const Slots = setSlots('prefix', 'suffix', 'helper-text', 'value-missing', 'range-overflow', 'range-underflow', 'custom-error', 'invalid');
25
25
  let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends MaskBehaviorMixin(FormAssociatedRequiredMixin(LitElement)) {
26
26
  get __validators() {
27
27
  return dateTimeInputValidators;
28
28
  }
29
+ get _defaultDisplayFormat() {
30
+ return this._i18nController.localeDisplayFormat;
31
+ }
29
32
  get _uncommittedValue() {
30
33
  return this._isEditing ? this._parseMask(true) : this.value;
31
34
  }
35
+ get _datePartDeltas() {
36
+ return { ...DEFAULT_DATE_PARTS_SPIN_DELTAS, ...this.spinDelta };
37
+ }
32
38
  get _targetDatePart() {
33
39
  return this._focused
34
40
  ? this._getDatePartAtCursor()
@@ -86,7 +92,6 @@ let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends
86
92
  });
87
93
  this._min = null;
88
94
  this._max = null;
89
- this._defaultDisplayFormat = '';
90
95
  this._isEditing = false;
91
96
  this._oldValue = null;
92
97
  this.outlined = false;
@@ -102,9 +107,6 @@ let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends
102
107
  .set([ctrlKey, arrowRight], this._navigateParts.bind(this, 1));
103
108
  }
104
109
  update(props) {
105
- if (props.has('displayFormat')) {
106
- this._updateDefaultDisplayFormat();
107
- }
108
110
  if (props.has('locale')) {
109
111
  this._initializeDefaultMask();
110
112
  }
@@ -127,6 +129,24 @@ let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends
127
129
  this._maskedValue = this._buildMaskedValue();
128
130
  }
129
131
  }
132
+ async _handleFocus() {
133
+ this._focused = true;
134
+ if (this.readOnly) {
135
+ return;
136
+ }
137
+ this._oldValue = this.value;
138
+ if (this._isValueEmpty()) {
139
+ this._maskedValue = this._parser.emptyMask;
140
+ this._historyResync();
141
+ await this.updateComplete;
142
+ this.select();
143
+ return;
144
+ }
145
+ if (this.displayFormat !== this.inputFormat) {
146
+ this._updateMaskDisplay();
147
+ }
148
+ this._historyResync();
149
+ }
130
150
  _handleBlur() {
131
151
  this._focused = false;
132
152
  this._commitEdit();
@@ -186,6 +206,22 @@ let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends
186
206
  this._maskedValue = next;
187
207
  this.requestUpdate();
188
208
  }
209
+ _isValueEmpty() {
210
+ return !this.value;
211
+ }
212
+ _applyValue(value) {
213
+ if (equal(this._formValue.value, value)) {
214
+ return;
215
+ }
216
+ this._isEditing = false;
217
+ this._formValue.setValueAndFormState(value);
218
+ this._updateMaskDisplay();
219
+ }
220
+ _readAmPmFromMask(part) {
221
+ return part?.type === DatePartType.AmPm
222
+ ? this._maskedValue.substring(part.start, part.end)
223
+ : undefined;
224
+ }
189
225
  _applyDraft() {
190
226
  this._isEditing = false;
191
227
  this.value = this._parseMask(true);
@@ -230,13 +266,9 @@ let IgcDateTimeInputBaseComponent = class IgcDateTimeInputBaseComponent extends
230
266
  this.placeholder = this._parser.mask;
231
267
  }
232
268
  }
233
- _updateDefaultDisplayFormat() {
234
- this._defaultDisplayFormat = getDateFormatter().getLocaleDateTimeFormat(this.locale);
235
- }
236
269
  _initializeDefaultMask() {
237
- this._updateDefaultDisplayFormat();
238
270
  if (!this._inputFormat) {
239
- this._applyMask(getDefaultDateTimeFormat(this.locale));
271
+ this._applyMask(this._i18nController.localeInputFormat);
240
272
  }
241
273
  }
242
274
  _resolvePartNames(base) {