@nldd/design-system 0.8.69 → 0.8.70

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 (252) hide show
  1. package/custom-elements.json +29536 -0
  2. package/dist/components/actions/button/button.d.ts +2 -0
  3. package/dist/components/actions/button/button.d.ts.map +1 -1
  4. package/dist/components/actions/button/button.js +2 -0
  5. package/dist/components/actions/button/button.js.map +1 -1
  6. package/dist/components/actions/button/button.styles.d.ts.map +1 -1
  7. package/dist/components/actions/button/button.styles.js +1 -0
  8. package/dist/components/actions/button/button.styles.js.map +1 -1
  9. package/dist/components/actions/icon-button/icon-button.d.ts +2 -0
  10. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  11. package/dist/components/actions/icon-button/icon-button.js +2 -0
  12. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  13. package/dist/components/actions/icon-button/icon-button.styles.d.ts.map +1 -1
  14. package/dist/components/actions/icon-button/icon-button.styles.js +1 -0
  15. package/dist/components/actions/icon-button/icon-button.styles.js.map +1 -1
  16. package/dist/components/actions/menu/menu.styles.d.ts.map +1 -1
  17. package/dist/components/actions/menu/menu.styles.js +1 -0
  18. package/dist/components/actions/menu/menu.styles.js.map +1 -1
  19. package/dist/components/actions/toolbar/toolbar.d.ts +4 -0
  20. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  21. package/dist/components/actions/toolbar/toolbar.js +4 -0
  22. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  23. package/dist/components/components.js +85 -82
  24. package/dist/components/content/avatar/avatar.styles.d.ts.map +1 -1
  25. package/dist/components/content/avatar/avatar.styles.js +2 -1
  26. package/dist/components/content/avatar/avatar.styles.js.map +1 -1
  27. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  28. package/dist/components/content/code-viewer/code-viewer.js +2 -0
  29. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  30. package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
  31. package/dist/components/content/icon/icon-aliases.js +19 -2
  32. package/dist/components/content/icon/icon-aliases.js.map +1 -1
  33. package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
  34. package/dist/components/content/icon/icon-registry.js +34 -5
  35. package/dist/components/content/icon/icon-registry.js.map +1 -1
  36. package/dist/components/content/image/image.d.ts +2 -0
  37. package/dist/components/content/image/image.d.ts.map +1 -1
  38. package/dist/components/content/image/image.js +2 -0
  39. package/dist/components/content/image/image.js.map +1 -1
  40. package/dist/components/content/image/lqip-encoder-element.d.ts.map +1 -1
  41. package/dist/components/content/image/lqip-encoder-element.js +1 -0
  42. package/dist/components/content/image/lqip-encoder-element.js.map +1 -1
  43. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts +4 -0
  44. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts.map +1 -1
  45. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +4 -0
  46. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  47. package/dist/components/content/token/token.styles.d.ts.map +1 -1
  48. package/dist/components/content/token/token.styles.js +1 -0
  49. package/dist/components/content/token/token.styles.js.map +1 -1
  50. package/dist/components/{index-BfOpap4b.js → index-BP0XMTYa.js} +1 -1
  51. package/dist/components/{index-CXC-Objp.js → index-Bh_hMHn8.js} +1 -1
  52. package/dist/components/{index-VwuVCCal.js → index-BuLJAwiB.js} +7750 -5496
  53. package/dist/components/{index-CfvgUB5p.js → index-CTUlN5qN.js} +1 -1
  54. package/dist/components/{index-DZo3DrGQ.js → index-DS-RnHMu.js} +1 -1
  55. package/dist/components/{index-Bf4pa5Bp.js → index-Dgxr-sEe.js} +1 -1
  56. package/dist/components/{index-DB-i084x.js → index-sa60dMt-.js} +1 -1
  57. package/dist/components/index.d.ts +3 -0
  58. package/dist/components/index.d.ts.map +1 -1
  59. package/dist/components/index.js +3 -0
  60. package/dist/components/index.js.map +1 -1
  61. package/dist/components/inputs/checkbox/checkbox.styles.d.ts.map +1 -1
  62. package/dist/components/inputs/checkbox/checkbox.styles.js +1 -0
  63. package/dist/components/inputs/checkbox/checkbox.styles.js.map +1 -1
  64. package/dist/components/inputs/date-field/date-field.d.ts +226 -0
  65. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -0
  66. package/dist/components/inputs/date-field/date-field.i18n.d.ts +11 -0
  67. package/dist/components/inputs/date-field/date-field.i18n.d.ts.map +1 -0
  68. package/dist/components/inputs/date-field/date-field.i18n.js +17 -0
  69. package/dist/components/inputs/date-field/date-field.i18n.js.map +1 -0
  70. package/dist/components/inputs/date-field/date-field.js +589 -0
  71. package/dist/components/inputs/date-field/date-field.js.map +1 -0
  72. package/dist/components/inputs/date-field/date-field.styles.d.ts +2 -0
  73. package/dist/components/inputs/date-field/date-field.styles.d.ts.map +1 -0
  74. package/dist/components/inputs/date-field/date-field.styles.js +246 -0
  75. package/dist/components/inputs/date-field/date-field.styles.js.map +1 -0
  76. package/dist/components/inputs/date-field/date-field.template.d.ts +17 -0
  77. package/dist/components/inputs/date-field/date-field.template.d.ts.map +1 -0
  78. package/dist/components/inputs/date-field/date-field.template.js +141 -0
  79. package/dist/components/inputs/date-field/date-field.template.js.map +1 -0
  80. package/dist/components/inputs/date-picker/date-picker.d.ts +268 -0
  81. package/dist/components/inputs/date-picker/date-picker.d.ts.map +1 -0
  82. package/dist/components/inputs/date-picker/date-picker.i18n.d.ts +64 -0
  83. package/dist/components/inputs/date-picker/date-picker.i18n.d.ts.map +1 -0
  84. package/dist/components/inputs/date-picker/date-picker.i18n.js +81 -0
  85. package/dist/components/inputs/date-picker/date-picker.i18n.js.map +1 -0
  86. package/dist/components/inputs/date-picker/date-picker.js +748 -0
  87. package/dist/components/inputs/date-picker/date-picker.js.map +1 -0
  88. package/dist/components/inputs/date-picker/date-picker.styles.d.ts +2 -0
  89. package/dist/components/inputs/date-picker/date-picker.styles.d.ts.map +1 -0
  90. package/dist/components/inputs/date-picker/date-picker.styles.js +353 -0
  91. package/dist/components/inputs/date-picker/date-picker.styles.js.map +1 -0
  92. package/dist/components/inputs/date-picker/date-picker.template.d.ts +8 -0
  93. package/dist/components/inputs/date-picker/date-picker.template.d.ts.map +1 -0
  94. package/dist/components/inputs/date-picker/date-picker.template.js +223 -0
  95. package/dist/components/inputs/date-picker/date-picker.template.js.map +1 -0
  96. package/dist/components/inputs/dropdown/dropdown.styles.d.ts.map +1 -1
  97. package/dist/components/inputs/dropdown/dropdown.styles.js +1 -0
  98. package/dist/components/inputs/dropdown/dropdown.styles.js.map +1 -1
  99. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts +1 -0
  100. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts.map +1 -1
  101. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js +1 -0
  102. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js.map +1 -1
  103. package/dist/components/inputs/password-field/password-field.d.ts +1 -0
  104. package/dist/components/inputs/password-field/password-field.d.ts.map +1 -1
  105. package/dist/components/inputs/password-field/password-field.js +1 -0
  106. package/dist/components/inputs/password-field/password-field.js.map +1 -1
  107. package/dist/components/inputs/radio-button/radio-button.d.ts +3 -0
  108. package/dist/components/inputs/radio-button/radio-button.d.ts.map +1 -1
  109. package/dist/components/inputs/radio-button/radio-button.js +3 -0
  110. package/dist/components/inputs/radio-button/radio-button.js.map +1 -1
  111. package/dist/components/inputs/radio-button/radio-button.styles.d.ts.map +1 -1
  112. package/dist/components/inputs/radio-button/radio-button.styles.js +1 -0
  113. package/dist/components/inputs/radio-button/radio-button.styles.js.map +1 -1
  114. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts +2 -0
  115. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts.map +1 -1
  116. package/dist/components/inputs/radio-button-field/radio-button-field.js +2 -0
  117. package/dist/components/inputs/radio-button-field/radio-button-field.js.map +1 -1
  118. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts +1 -0
  119. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts.map +1 -1
  120. package/dist/components/inputs/radio-button-group/radio-button-group.js +1 -0
  121. package/dist/components/inputs/radio-button-group/radio-button-group.js.map +1 -1
  122. package/dist/components/inputs/segmented-control/segmented-control.d.ts +10 -1
  123. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  124. package/dist/components/inputs/segmented-control/segmented-control.js +11 -2
  125. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  126. package/dist/components/inputs/segmented-control/segmented-control.styles.d.ts.map +1 -1
  127. package/dist/components/inputs/segmented-control/segmented-control.styles.js +1 -0
  128. package/dist/components/inputs/segmented-control/segmented-control.styles.js.map +1 -1
  129. package/dist/components/inputs/stepper/stepper.d.ts +1 -0
  130. package/dist/components/inputs/stepper/stepper.d.ts.map +1 -1
  131. package/dist/components/inputs/stepper/stepper.js +1 -0
  132. package/dist/components/inputs/stepper/stepper.js.map +1 -1
  133. package/dist/components/inputs/stepper/stepper.styles.d.ts.map +1 -1
  134. package/dist/components/inputs/stepper/stepper.styles.js +1 -0
  135. package/dist/components/inputs/stepper/stepper.styles.js.map +1 -1
  136. package/dist/components/inputs/switch/switch.d.ts +2 -0
  137. package/dist/components/inputs/switch/switch.d.ts.map +1 -1
  138. package/dist/components/inputs/switch/switch.js +2 -0
  139. package/dist/components/inputs/switch/switch.js.map +1 -1
  140. package/dist/components/inputs/switch/switch.styles.d.ts.map +1 -1
  141. package/dist/components/inputs/switch/switch.styles.js +1 -0
  142. package/dist/components/inputs/switch/switch.styles.js.map +1 -1
  143. package/dist/components/inputs/text-field/text-field.d.ts +1 -0
  144. package/dist/components/inputs/text-field/text-field.d.ts.map +1 -1
  145. package/dist/components/inputs/text-field/text-field.js +1 -0
  146. package/dist/components/inputs/text-field/text-field.js.map +1 -1
  147. package/dist/components/inputs/toggle-button/toggle-button.styles.d.ts.map +1 -1
  148. package/dist/components/inputs/toggle-button/toggle-button.styles.js +1 -0
  149. package/dist/components/inputs/toggle-button/toggle-button.styles.js.map +1 -1
  150. package/dist/components/layout/container/container.d.ts +26 -3
  151. package/dist/components/layout/container/container.d.ts.map +1 -1
  152. package/dist/components/layout/container/container.js +26 -3
  153. package/dist/components/layout/container/container.js.map +1 -1
  154. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.d.ts +2 -2
  155. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js +2 -2
  156. package/dist/components/layout/popover/popover.d.ts +17 -0
  157. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  158. package/dist/components/layout/popover/popover.js +82 -5
  159. package/dist/components/layout/popover/popover.js.map +1 -1
  160. package/dist/components/layout/sheet/sheet.d.ts +12 -0
  161. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  162. package/dist/components/layout/sheet/sheet.js +25 -2
  163. package/dist/components/layout/sheet/sheet.js.map +1 -1
  164. package/dist/components/layout/sheet/sheet.styles.d.ts.map +1 -1
  165. package/dist/components/layout/sheet/sheet.styles.js +6 -1
  166. package/dist/components/layout/sheet/sheet.styles.js.map +1 -1
  167. package/dist/components/layout/sheet/sheet.template.d.ts.map +1 -1
  168. package/dist/components/layout/sheet/sheet.template.js +1 -0
  169. package/dist/components/layout/sheet/sheet.template.js.map +1 -1
  170. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.d.ts +1 -0
  171. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.d.ts.map +1 -1
  172. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js +5 -0
  173. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js.map +1 -1
  174. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.styles.d.ts.map +1 -1
  175. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.styles.js +27 -0
  176. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.styles.js.map +1 -1
  177. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.d.ts +2 -0
  178. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.d.ts.map +1 -1
  179. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js +3 -0
  180. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js.map +1 -1
  181. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.styles.d.ts.map +1 -1
  182. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.styles.js +24 -0
  183. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.styles.js.map +1 -1
  184. package/dist/components/layout/window/window.d.ts +9 -0
  185. package/dist/components/layout/window/window.d.ts.map +1 -1
  186. package/dist/components/layout/window/window.js +19 -0
  187. package/dist/components/layout/window/window.js.map +1 -1
  188. package/dist/components/layout/window/window.styles.d.ts.map +1 -1
  189. package/dist/components/layout/window/window.styles.js +5 -1
  190. package/dist/components/layout/window/window.styles.js.map +1 -1
  191. package/dist/components/layout/window/window.template.d.ts.map +1 -1
  192. package/dist/components/layout/window/window.template.js +1 -0
  193. package/dist/components/layout/window/window.template.js.map +1 -1
  194. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts +1 -0
  195. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts.map +1 -1
  196. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js +1 -0
  197. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js.map +1 -1
  198. package/dist/components/lists-and-tables/list/list.d.ts +14 -0
  199. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  200. package/dist/components/lists-and-tables/list/list.js +14 -0
  201. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  202. package/dist/components/lists-and-tables/list-item/list-item.d.ts +10 -0
  203. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  204. package/dist/components/lists-and-tables/list-item/list-item.js +10 -0
  205. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  206. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.d.ts.map +1 -1
  207. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js +1 -0
  208. package/dist/components/navigation/document-tab-bar/document-tab-bar.styles.js.map +1 -1
  209. package/dist/components/navigation/menu-bar/menu-bar.styles.d.ts.map +1 -1
  210. package/dist/components/navigation/menu-bar/menu-bar.styles.js +1 -0
  211. package/dist/components/navigation/menu-bar/menu-bar.styles.js.map +1 -1
  212. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts +1 -0
  213. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
  214. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +1 -0
  215. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  216. package/dist/components/navigation/menu-bar-item/menu-bar-item.styles.d.ts.map +1 -1
  217. package/dist/components/navigation/menu-bar-item/menu-bar-item.styles.js +1 -0
  218. package/dist/components/navigation/menu-bar-item/menu-bar-item.styles.js.map +1 -1
  219. package/dist/components/navigation/pagination/pagination.d.ts +1 -0
  220. package/dist/components/navigation/pagination/pagination.d.ts.map +1 -1
  221. package/dist/components/navigation/pagination/pagination.js +1 -0
  222. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  223. package/dist/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
  224. package/dist/components/navigation/pagination/pagination.styles.js +1 -0
  225. package/dist/components/navigation/pagination/pagination.styles.js.map +1 -1
  226. package/dist/components/navigation/tab-bar/tab-bar.d.ts +2 -0
  227. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  228. package/dist/components/navigation/tab-bar/tab-bar.js +2 -0
  229. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  230. package/dist/components/navigation/tab-bar/tab-bar.styles.d.ts.map +1 -1
  231. package/dist/components/navigation/tab-bar/tab-bar.styles.js +1 -0
  232. package/dist/components/navigation/tab-bar/tab-bar.styles.js.map +1 -1
  233. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +22 -0
  234. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  235. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +22 -0
  236. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  237. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts +10 -0
  238. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
  239. package/dist/components/navigation/top-title-bar/top-title-bar.js +27 -2
  240. package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
  241. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts.map +1 -1
  242. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +2 -0
  243. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
  244. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.d.ts.map +1 -1
  245. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.js +16 -0
  246. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.styles.js.map +1 -1
  247. package/dist/types/vue.d.ts +3277 -0
  248. package/dist/utilities/resolve-date-bound.d.ts +21 -0
  249. package/dist/utilities/resolve-date-bound.d.ts.map +1 -0
  250. package/dist/utilities/resolve-date-bound.js +75 -0
  251. package/dist/utilities/resolve-date-bound.js.map +1 -0
  252. package/package.json +31 -7
@@ -0,0 +1,748 @@
1
+ /**
2
+ * NLDD Design System Datumkiezer Component (Lit + TypeScript)
3
+ *
4
+ * Een kalender waarin een datum of een periode wordt gekozen. Het component is
5
+ * zelfstandig bruikbaar - inline op een pagina, in een filterpaneel - en zit ook
6
+ * in de popover van nldd-date-field.
7
+ *
8
+ * Waarden zijn altijd ISO (jjjj-mm-dd). Met `range` kiest de gebruiker in twee
9
+ * stappen een begin- en einddatum.
10
+ *
11
+ * @element nldd-date-picker
12
+ *
13
+ * @attr {string} value - De gekozen datum als ISO (jjjj-mm-dd). Alleen zonder `range`.
14
+ * @attr {string} start - Begin van de periode als ISO. Alleen met `range`.
15
+ * @attr {string} end - Einde van de periode als ISO. Alleen met `range`.
16
+ * @attr {boolean} range - Kies een periode in plaats van één datum.
17
+ * @attr {string} min - Vroegst toegestane datum: ISO, of `today` met een verschuiving (`today-18y`).
18
+ * @attr {string} max - Laatst toegestane datum: ISO, of `today` met een verschuiving (`today+1y`).
19
+ * @attr {number} first-day-of-week - Eerste dag van de week, 0 is zondag. Standaard 1 (maandag).
20
+ * @attr {boolean} week-numbers - Toont ISO-weeknummers in een kolom links.
21
+ * @attr {string} accessible-label - Toegankelijke naam van de kalender.
22
+ * @attr {object} translations - Vertalingen; niet opgegeven sleutels vallen terug op het Nederlands.
23
+ *
24
+ * @prop {(iso: string) => boolean} isDateUnavailable - Markeert losse datums als niet kiesbaar, bijvoorbeeld weekenden of feestdagen.
25
+ *
26
+ * @fires change - Wanneer een datum of een volledige periode is gekozen. detail: { value } of { start, end }.
27
+ * @fires input - Ook bij de tussenstap van een periode, wanneer alleen de begindatum staat.
28
+ */
29
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
30
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
32
+ 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;
33
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
34
+ };
35
+ import { LitElement } from 'lit';
36
+ import { customElement, property, state } from 'lit/decorators.js';
37
+ import { breakpoints } from '../../../assets/styles/breakpoints.js';
38
+ import { isPointerMode } from '../../../utilities/input-modality.js';
39
+ import { withTranslations } from '../../../utilities/with-translations.js';
40
+ import { resolveDateBound, toIso } from '../../../utilities/resolve-date-bound.js';
41
+ import { datePickerStyles } from './date-picker.styles.js';
42
+ import { datePickerTemplate } from './date-picker.template.js';
43
+ import { nlddDatePickerTranslations, MONTH_KEYS, WEEKDAY_KEYS } from './date-picker.i18n.js';
44
+ import './../../actions/icon-button/icon-button.js';
45
+ import './../../actions/button/button.js';
46
+ /**
47
+ * All arithmetic runs on UTC-midnight Dates and ISO strings. UTC keeps a DST
48
+ * transition from swallowing or repeating a day, and ISO strings compare
49
+ * lexicographically, so a bounds check is a plain string comparison.
50
+ */
51
+ function parseIso(iso) {
52
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
53
+ if (!match)
54
+ return null;
55
+ const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])));
56
+ return Number.isNaN(date.getTime()) ? null : date;
57
+ }
58
+ function isoOf(date) {
59
+ return toIso(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()) ?? '';
60
+ }
61
+ function addDays(iso, days) {
62
+ const date = parseIso(iso);
63
+ if (!date)
64
+ return iso;
65
+ date.setUTCDate(date.getUTCDate() + days);
66
+ return isoOf(date);
67
+ }
68
+ /** Clamped, like the bound resolver: 31 March plus a month is 30 April. */
69
+ function addMonths(iso, months) {
70
+ const date = parseIso(iso);
71
+ if (!date)
72
+ return iso;
73
+ const day = date.getUTCDate();
74
+ const total = date.getUTCFullYear() * 12 + date.getUTCMonth() + months;
75
+ const year = Math.floor(total / 12);
76
+ const month = ((total % 12) + 12) % 12 + 1;
77
+ const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
78
+ return toIso(year, month, Math.min(day, lastDay)) ?? iso;
79
+ }
80
+ function todayIso() {
81
+ const now = new Date();
82
+ return toIso(now.getFullYear(), now.getMonth() + 1, now.getDate()) ?? '';
83
+ }
84
+ function firstOfMonth(iso) {
85
+ return `${iso.slice(0, 7)}-01`;
86
+ }
87
+ function lastOfMonth(iso) {
88
+ const date = parseIso(iso);
89
+ if (!date)
90
+ return iso;
91
+ return toIso(date.getUTCFullYear(), date.getUTCMonth() + 1, new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)).getUTCDate()) ?? iso;
92
+ }
93
+ function weekdayOf(iso) {
94
+ return parseIso(iso)?.getUTCDay() ?? 0;
95
+ }
96
+ function startOfWeek(iso, firstDayOfWeek) {
97
+ const offset = (weekdayOf(iso) - firstDayOfWeek + 7) % 7;
98
+ return addDays(iso, -offset);
99
+ }
100
+ /** Same month and day in another year, clamped: 29 February is not every year. */
101
+ function withYear(iso, year) {
102
+ const month = Number(iso.slice(5, 7));
103
+ const day = Number(iso.slice(8, 10));
104
+ const lastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
105
+ return toIso(year, month, Math.min(day, lastDay)) ?? iso;
106
+ }
107
+ function clampIso(iso, min, max) {
108
+ if (min && iso < min)
109
+ return min;
110
+ if (max && iso > max)
111
+ return max;
112
+ return iso;
113
+ }
114
+ let NLDDDatePicker = class NLDDDatePicker extends withTranslations(LitElement, nlddDatePickerTranslations) {
115
+ constructor() {
116
+ super(...arguments);
117
+ this.value = '';
118
+ this.start = '';
119
+ this.end = '';
120
+ this.range = false;
121
+ this.min = '';
122
+ this.max = '';
123
+ this.firstDayOfWeek = 1;
124
+ this.weekNumbers = false;
125
+ this.accessibleLabel = '';
126
+ /** The date carrying the roving tabindex. */
127
+ this._focused = '';
128
+ /** First of the displayed month. */
129
+ this._view = '';
130
+ /** During a range selection: the date the user picked first. */
131
+ this._anchor = '';
132
+ /** Pointer preview of the range being drawn. Visual only - never announced. */
133
+ this._hover = '';
134
+ this._announcement = '';
135
+ this._yearMenuOpen = false;
136
+ /**
137
+ * Stacked layout: the paging controls move below the grid and grow to md. Not
138
+ * compact: everything gets roomier, tuned for fingers and narrow viewports.
139
+ * Driven from JS rather than a media query because the two layouts are not the
140
+ * same buttons in another place - side by side they are one bar, below they
141
+ * split into "Vandaag" on the left and the month arrows on the right, and CSS
142
+ * cannot regroup a component's children.
143
+ *
144
+ * Coarse pointers count too, not just narrow screens: a touch tablet has room
145
+ * for the wide layout but the same need for larger targets.
146
+ */
147
+ this._stacked = false;
148
+ this._handleStackedChange = () => {
149
+ this._stacked = Boolean(this._stackedQuery?.matches);
150
+ };
151
+ /** Set when the keyboard moved focus, so only then is focus pulled to a cell. */
152
+ this._restoreFocus = false;
153
+ /**
154
+ * A day focused by pointer should not show a ring. Browsers treat programmatic
155
+ * focus as focus-visible, and opening the calendar with the mouse focuses a day,
156
+ * so the ring would appear without anyone using the keyboard. Arrow keys switch
157
+ * the modality back, so navigating reveals it again.
158
+ *
159
+ * If this never runs the class is simply absent and the ring shows - the
160
+ * accessible outcome is the default.
161
+ */
162
+ /** Set by keyboard navigation; consumed by the focus it causes. */
163
+ this._focusFromKeyboard = false;
164
+ // — Dragging —————————————————————————————————————————————————————————————
165
+ /** Where the pointer went down; empty when no drag is in progress. */
166
+ this._dragOrigin = '';
167
+ /** Set once the pointer has actually moved to another day. */
168
+ this._dragged = false;
169
+ this._suppressClick = false;
170
+ this._onDocumentPointerUp = (e) => {
171
+ document.removeEventListener('pointerup', this._onDocumentPointerUp);
172
+ const origin = this._dragOrigin;
173
+ this._dragOrigin = '';
174
+ if (!this._dragged)
175
+ return;
176
+ this._dragged = false;
177
+ this._suppressClick = true;
178
+ const iso = this._dayUnderPointer(e);
179
+ // Released off the grid or on a blocked day: keep the start and wait for a
180
+ // second click rather than inventing an end date.
181
+ if (!iso || this._isUnavailable(iso))
182
+ return;
183
+ // Dragging backwards means the range runs the other way. That is not the
184
+ // ambiguous case the restart rule guards against - here the direction was
185
+ // spelled out by the gesture - so the ends are simply sorted.
186
+ this._commitRange(origin, iso);
187
+ };
188
+ }
189
+ async _handleYearMenuToggle(e) {
190
+ this._yearMenuOpen = e.newState === 'open';
191
+ if (!this._yearMenuOpen)
192
+ return;
193
+ // The menu sets its own focus after its update resolves, so waiting for that
194
+ // first is what keeps it from overwriting the line below.
195
+ const menu = this.shadowRoot?.querySelector('nldd-menu');
196
+ await menu?.updateComplete;
197
+ // The list runs to a hundred years or more, and the menu starts on its first
198
+ // item - so an arrow key walks a century back from the year you are actually
199
+ // looking at. Move to the year in view instead, and scroll it into sight.
200
+ const focusSelected = () => {
201
+ const selected = this.shadowRoot?.querySelector('nldd-menu-item[selected]');
202
+ if (!selected || this.shadowRoot?.activeElement === selected)
203
+ return;
204
+ // Both of these scroll every scrollable ancestor by default, and the page
205
+ // is one of them - opening the menu would shift what is behind it.
206
+ selected.scrollIntoView({ block: 'nearest' });
207
+ selected.focus({ preventScroll: true });
208
+ };
209
+ requestAnimationFrame(focusSelected);
210
+ // The menu finishes its own opening sequence after that frame and takes focus
211
+ // back, so that one hand-over is redirected rather than raced with a longer
212
+ // delay. Properly this belongs in nldd-menu: any menu with a current value
213
+ // should open on it.
214
+ menu?.addEventListener('focusin', (event) => {
215
+ if (event.target === menu)
216
+ focusSelected();
217
+ }, { once: true });
218
+ }
219
+ connectedCallback() {
220
+ super.connectedCallback();
221
+ if (!this._focused)
222
+ this._focused = this._initialFocus();
223
+ if (!this._view)
224
+ this._view = firstOfMonth(this._focused);
225
+ this._stackedQuery = window.matchMedia(`(max-width: ${breakpoints.smMax}), (pointer: coarse)`);
226
+ this._stacked = this._stackedQuery.matches;
227
+ this._stackedQuery.addEventListener('change', this._handleStackedChange);
228
+ }
229
+ disconnectedCallback() {
230
+ super.disconnectedCallback();
231
+ document.removeEventListener('pointerup', this._onDocumentPointerUp);
232
+ this._stackedQuery?.removeEventListener('change', this._handleStackedChange);
233
+ }
234
+ willUpdate(changed) {
235
+ super.willUpdate(changed);
236
+ // A consumer setting a value moves the calendar to it, but typing in a
237
+ // connected field should not yank the month away mid-selection, so the view
238
+ // only follows when the new value sits outside the month on screen.
239
+ if (changed.has('value') || changed.has('start') || changed.has('end')) {
240
+ const anchorDate = this.range ? (this.start || this.end) : this.value;
241
+ if (anchorDate && firstOfMonth(anchorDate) !== this._view) {
242
+ this._view = firstOfMonth(anchorDate);
243
+ this._focused = anchorDate;
244
+ }
245
+ }
246
+ }
247
+ updated() {
248
+ // Mirrored to an attribute so the host's own rules can key on it; consumers
249
+ // are not meant to set it.
250
+ this.toggleAttribute('stacked', this._stacked);
251
+ // Two associations the menu cannot make itself here. It resolves a string
252
+ // anchor with document.getElementById, which cannot see into a shadow root,
253
+ // so the element is handed over directly. And it leaves the native invoker
254
+ // link to the anchor component - nldd-button sets that up via `expandable` -
255
+ // which a plain button does not do, so without this the title never opens
256
+ // anything.
257
+ const menu = this.shadowRoot?.querySelector('nldd-menu');
258
+ const title = this.shadowRoot?.querySelector('.date-picker__title-button');
259
+ if (menu && title) {
260
+ if (menu.anchorElement !== title)
261
+ menu.anchorElement = title;
262
+ if (title.popoverTargetElement !== menu)
263
+ title.popoverTargetElement = menu;
264
+ }
265
+ if (!this._restoreFocus)
266
+ return;
267
+ this._restoreFocus = false;
268
+ this._focusedCell()?.focus();
269
+ }
270
+ _focusedCell() {
271
+ return this.shadowRoot?.querySelector('.date-picker__day[tabindex="0"]') ?? null;
272
+ }
273
+ /**
274
+ * Focus lands on the day carrying the roving tabindex - the chosen date, or
275
+ * today when there is none. Without this an overlay that focuses the calendar
276
+ * would land on its host, which forwards nowhere, leaving the arrow keys dead
277
+ * until the user has tabbed into the grid themselves.
278
+ */
279
+ focus(options) {
280
+ const cell = this._focusedCell();
281
+ if (cell)
282
+ cell.focus(options);
283
+ else
284
+ super.focus(options);
285
+ }
286
+ _initialFocus() {
287
+ const preferred = (this.range ? this.start : this.value) || todayIso();
288
+ return clampIso(preferred, this._min, this._max);
289
+ }
290
+ // — Bounds ———————————————————————————————————————————————————————————————
291
+ get _min() {
292
+ return resolveDateBound(this.min);
293
+ }
294
+ get _max() {
295
+ return resolveDateBound(this.max);
296
+ }
297
+ /** Out of bounds means unreachable; unavailable means visible but not selectable. */
298
+ _isOutOfBounds(iso) {
299
+ const min = this._min;
300
+ const max = this._max;
301
+ return Boolean((min && iso < min) || (max && iso > max));
302
+ }
303
+ _isUnavailable(iso) {
304
+ if (this._isOutOfBounds(iso))
305
+ return true;
306
+ return this.isDateUnavailable?.(iso) ?? false;
307
+ }
308
+ // — Grid —————————————————————————————————————————————————————————————————
309
+ /** Weekday numbers in display order, honouring first-day-of-week. */
310
+ get _weekdays() {
311
+ return Array.from({ length: 7 }, (_, i) => (this.firstDayOfWeek + i) % 7);
312
+ }
313
+ /**
314
+ * Six weeks of real dates, including the days either side of the month. Those
315
+ * neighbours are selectable and jump the calendar to their own month, which
316
+ * beats paging for a date a few days over the boundary. Every cell announces
317
+ * its full date, so a 1st from the next month can never be mistaken for this
318
+ * one.
319
+ *
320
+ * Always six rows: a month that needs five would otherwise resize the calendar
321
+ * as you page through it, which in a popover moves everything below it.
322
+ */
323
+ get _weeks() {
324
+ const lead = (weekdayOf(this._view) - this.firstDayOfWeek + 7) % 7;
325
+ const start = addDays(this._view, -lead);
326
+ return Array.from({ length: 6 }, (_, week) => Array.from({ length: 7 }, (_, day) => addDays(start, week * 7 + day)));
327
+ }
328
+ _isOutsideMonth(iso) {
329
+ return iso.slice(0, 7) !== this._view.slice(0, 7);
330
+ }
331
+ /**
332
+ * The ISO week of the row, taken from its Thursday. ISO weeks are anchored on
333
+ * Thursday, so reading it off any other day would give the wrong number for
334
+ * rows that do not start on Monday.
335
+ */
336
+ _weekNumber(week) {
337
+ const thursday = week.find((iso) => weekdayOf(iso) === 4) ?? week[0];
338
+ const date = parseIso(thursday);
339
+ if (!date)
340
+ return 0;
341
+ const firstThursday = new Date(Date.UTC(date.getUTCFullYear(), 0, 4));
342
+ firstThursday.setUTCDate(firstThursday.getUTCDate() - ((firstThursday.getUTCDay() + 6) % 7) + 3);
343
+ return 1 + Math.round((date.getTime() - firstThursday.getTime()) / (7 * 24 * 60 * 60 * 1000));
344
+ }
345
+ get _viewYear() {
346
+ return Number(this._view.slice(0, 4));
347
+ }
348
+ get _viewMonth() {
349
+ return Number(this._view.slice(5, 7));
350
+ }
351
+ /**
352
+ * Years offered in the title menu. Bounded by min and max where they are set,
353
+ * because those already say which years can be reached; without them a window
354
+ * wide enough for a birthdate on one side and for planning on the other.
355
+ */
356
+ get _years() {
357
+ const current = Number(todayIso().slice(0, 4));
358
+ let first = this._min ? Number(this._min.slice(0, 4)) : current - 120;
359
+ let last = this._max ? Number(this._max.slice(0, 4)) : current + 20;
360
+ // The year on screen must always be in the list, or the menu would show no
361
+ // selection at all after paging past the edge of the window.
362
+ first = Math.min(first, this._viewYear);
363
+ last = Math.max(last, this._viewYear);
364
+ return Array.from({ length: last - first + 1 }, (_, i) => first + i);
365
+ }
366
+ _handleYearSelect(year) {
367
+ this._view = firstOfMonth(clampIso(withYear(this._view, year), this._min, this._max));
368
+ this._focused = clampIso(withYear(this._focused, year), this._min, this._max);
369
+ this._restoreFocus = Boolean(this._focusedCell());
370
+ // Radio items keep their menu open, which is right when you are ticking
371
+ // several - but here one year is the whole answer.
372
+ const menu = this.shadowRoot?.querySelector('nldd-menu');
373
+ if (menu?.matches(':popover-open'))
374
+ menu.hidePopover?.();
375
+ }
376
+ /**
377
+ * Dutch writes month names in lower case, so the capital here is the ordinary
378
+ * sentence-initial one of a heading, not a proper noun. The translation itself
379
+ * stays lower case because it is reused mid-sentence in the day labels.
380
+ */
381
+ get _title() {
382
+ const month = this._t(`components.date-picker.${MONTH_KEYS[this._viewMonth - 1]}-capitalize`);
383
+ return `${month} ${this._viewYear}`;
384
+ }
385
+ // — Cell state ———————————————————————————————————————————————————————————
386
+ _isSelected(iso) {
387
+ if (!this.range)
388
+ return iso === this.value;
389
+ // Both ends of the preview, not just the committed ones: while drawing, the
390
+ // day under the pointer is the end date and has to look like it, or the band
391
+ // runs to a day that carries no mark at all.
392
+ const [from, to] = this._previewSpan();
393
+ if (from && to)
394
+ return iso === from || iso === to;
395
+ return iso === this.start || iso === this.end;
396
+ }
397
+ /**
398
+ * How the range band runs through this day. Derived from one span so the
399
+ * pointer preview and a committed period draw identically, and so the band
400
+ * stops at the middle of the first and last day instead of filling their whole
401
+ * cell - the fill marks the end, the band only connects the days between.
402
+ */
403
+ _bandFor(iso) {
404
+ if (!this.range)
405
+ return 'none';
406
+ const [from, to] = this._previewSpan();
407
+ if (!from || !to || from === to)
408
+ return 'none';
409
+ if (iso > from && iso < to)
410
+ return 'full';
411
+ if (iso === from)
412
+ return 'start';
413
+ if (iso === to)
414
+ return 'end';
415
+ return 'none';
416
+ }
417
+ /** Strictly between the ends, including the pointer preview while drawing. */
418
+ _isInRange(iso) {
419
+ return this._bandFor(iso) === 'full';
420
+ }
421
+ _previewSpan() {
422
+ if (this.start && this.end)
423
+ return [this.start, this.end];
424
+ if (this._anchor && this._hover) {
425
+ return this._anchor < this._hover ? [this._anchor, this._hover] : [this._hover, this._anchor];
426
+ }
427
+ return ['', ''];
428
+ }
429
+ _isToday(iso) {
430
+ return iso === todayIso();
431
+ }
432
+ /**
433
+ * Alleen de datum, zonder de aanduidingen die aan een cel hangen. De
434
+ * aankondigingen gebruiken deze: die van het hele cellabel maakte er
435
+ * "vrijdag 10 juli 2026, begin van de periode tot en met ..." van, waarin de
436
+ * celstatus midden in de zin belandt.
437
+ */
438
+ _dateText(iso) {
439
+ const date = parseIso(iso);
440
+ if (!date)
441
+ return '';
442
+ const weekday = this._t(`components.date-picker.${WEEKDAY_KEYS[date.getUTCDay()]}-lowercase`);
443
+ const month = this._t(`components.date-picker.${MONTH_KEYS[date.getUTCMonth()]}-lowercase`);
444
+ return this._t('components.date-picker.date-label', {
445
+ weekday,
446
+ day: date.getUTCDate(),
447
+ month,
448
+ year: date.getUTCFullYear(),
449
+ });
450
+ }
451
+ _dayLabel(iso) {
452
+ const date = parseIso(iso);
453
+ if (!date)
454
+ return '';
455
+ const parts = [this._dateText(iso)];
456
+ if (this._isToday(iso))
457
+ parts.push(this._t('components.date-picker.today-lowercase'));
458
+ const awaitingSecond = this.range && this._anchor !== '' && this.end === '';
459
+ if (awaitingSecond && iso === this._anchor) {
460
+ parts.push(this._t('components.date-picker.range-anchor-lowercase-label'));
461
+ }
462
+ else {
463
+ if (this.range && iso === this.start)
464
+ parts.push(this._t('components.date-picker.range-start-lowercase-label'));
465
+ if (this.range && iso === this.end)
466
+ parts.push(this._t('components.date-picker.range-end-lowercase-label'));
467
+ }
468
+ if (this._isInRange(iso))
469
+ parts.push(this._t('components.date-picker.in-range-lowercase-label'));
470
+ if (this._isUnavailable(iso))
471
+ parts.push(this._t('components.date-picker.unavailable-lowercase-label'));
472
+ return parts.join(', ');
473
+ }
474
+ // — Navigation ———————————————————————————————————————————————————————————
475
+ _shiftView(months) {
476
+ const next = addMonths(this._view, months);
477
+ this._view = next;
478
+ // Keep the roving tabindex on an equivalent day in the new month so the
479
+ // keyboard does not jump back to the 1st on every month change.
480
+ const day = Math.min(Number(this._focused.slice(8, 10)), Number(lastOfMonth(next).slice(8, 10)));
481
+ this._focused = clampIso(`${next.slice(0, 7)}-${String(day).padStart(2, '0')}`, this._min, this._max);
482
+ this._restoreFocus = Boolean(this._focusedCell());
483
+ }
484
+ _moveFocus(iso) {
485
+ const target = clampIso(iso, this._min, this._max);
486
+ this._focused = target;
487
+ if (firstOfMonth(target) !== this._view)
488
+ this._view = firstOfMonth(target);
489
+ // Only reached from the keydown handler, so the ring is certain here. Stated
490
+ // rather than asked of the modality module, which depends on that keydown
491
+ // having reached the document listener before focus moves - an ordering this
492
+ // component has no reason to rely on.
493
+ this._focusFromKeyboard = true;
494
+ this._restoreFocus = true;
495
+ }
496
+ _handleKeydown(e) {
497
+ const iso = this._focused;
498
+ let next = '';
499
+ switch (e.key) {
500
+ case 'ArrowLeft':
501
+ next = addDays(iso, -1);
502
+ break;
503
+ case 'ArrowRight':
504
+ next = addDays(iso, 1);
505
+ break;
506
+ case 'ArrowUp':
507
+ next = addDays(iso, -7);
508
+ break;
509
+ case 'ArrowDown':
510
+ next = addDays(iso, 7);
511
+ break;
512
+ case 'Home':
513
+ next = startOfWeek(iso, this.firstDayOfWeek);
514
+ break;
515
+ case 'End':
516
+ next = addDays(startOfWeek(iso, this.firstDayOfWeek), 6);
517
+ break;
518
+ case 'PageUp':
519
+ next = addMonths(iso, e.shiftKey ? -12 : -1);
520
+ break;
521
+ case 'PageDown':
522
+ next = addMonths(iso, e.shiftKey ? 12 : 1);
523
+ break;
524
+ case 'Enter':
525
+ case ' ':
526
+ e.preventDefault();
527
+ this._select(iso);
528
+ return;
529
+ default:
530
+ return;
531
+ }
532
+ e.preventDefault();
533
+ this._moveFocus(next);
534
+ }
535
+ // — Selection ————————————————————————————————————————————————————————————
536
+ _handleDayClick(iso) {
537
+ // A drag ends with a click on the day it was released over; that day was
538
+ // already handled on pointerup, so this one would start a second range.
539
+ if (this._suppressClick) {
540
+ this._suppressClick = false;
541
+ return;
542
+ }
543
+ this._select(iso);
544
+ }
545
+ _handleDayHover(iso) {
546
+ if (this.range && this._anchor)
547
+ this._hover = iso;
548
+ }
549
+ _handleDayFocusIn(e) {
550
+ const fromPointer = this._focusFromKeyboard ? false : isPointerMode();
551
+ this._focusFromKeyboard = false;
552
+ e.target?.classList?.toggle('is-pointer-focus', fromPointer);
553
+ }
554
+ _handleDayFocusOut(e) {
555
+ e.target?.classList?.remove('is-pointer-focus');
556
+ }
557
+ _handleGridLeave() {
558
+ if (this._dragOrigin)
559
+ return;
560
+ this._hover = '';
561
+ }
562
+ /**
563
+ * Dragging is for pointer devices only. On touch a horizontal drag across a
564
+ * calendar is indistinguishable from scrolling the page, and taking the
565
+ * gesture would leave a sheet you cannot scroll. Tapping twice still works
566
+ * everywhere, so nothing is lost.
567
+ */
568
+ _handleDayPointerDown(iso, e) {
569
+ // Cleared here rather than trusting the click to consume it. After a drag the
570
+ // click fires on the nearest common ancestor of the day it started on and the
571
+ // day it ended on - the grid, not a day - so the day handler never runs and a
572
+ // leftover flag would swallow the next real click instead.
573
+ this._suppressClick = false;
574
+ if (!this.range || e.pointerType === 'touch')
575
+ return;
576
+ if (this._isUnavailable(iso))
577
+ return;
578
+ this._dragOrigin = iso;
579
+ this._dragged = false;
580
+ document.addEventListener('pointerup', this._onDocumentPointerUp);
581
+ }
582
+ _handleGridPointerMove(e) {
583
+ if (!this._dragOrigin)
584
+ return;
585
+ const iso = this._dayUnderPointer(e);
586
+ if (!iso || iso === this._dragOrigin)
587
+ return;
588
+ // The range only starts once the pointer has left the day it went down on,
589
+ // so a plain click still runs through the click handler untouched.
590
+ if (!this._dragged) {
591
+ this._dragged = true;
592
+ this._beginRange(this._dragOrigin);
593
+ }
594
+ this._hover = iso;
595
+ }
596
+ _dayUnderPointer(e) {
597
+ const element = this.shadowRoot?.elementFromPoint(e.clientX, e.clientY);
598
+ return element?.closest('.date-picker__day')?.getAttribute('data-date') ?? '';
599
+ }
600
+ _select(iso) {
601
+ if (this._isUnavailable(iso))
602
+ return;
603
+ this._focused = iso;
604
+ // Choosing a neighbouring month's day brings that month into view, so the
605
+ // selection stays visible instead of sitting on a day that scrolls away.
606
+ if (this._isOutsideMonth(iso))
607
+ this._view = firstOfMonth(iso);
608
+ if (!this.range) {
609
+ this.value = iso;
610
+ this._announce(this._t('components.date-picker.date-selected-text', { date: this._dateText(iso) }));
611
+ this._emit('change', { value: iso });
612
+ return;
613
+ }
614
+ // No anchor, or a finished range: this click starts a new one.
615
+ if (!this._anchor || (this.start && this.end)) {
616
+ this._beginRange(iso);
617
+ return;
618
+ }
619
+ // Picking before the anchor completes the period backwards rather than
620
+ // starting over. The hover preview already draws the band that way, and
621
+ // dragging backwards already reverses, so restarting here would be the one
622
+ // behaviour contradicting what the calendar just showed. Beginning again is
623
+ // still one click away, since a finished period restarts on the next click.
624
+ this._commitRange(this._anchor, iso);
625
+ }
626
+ /** Any blocked day between two ends, inclusive. The endpoints are checked
627
+ * before we get here; this is the interior the endpoint checks miss. */
628
+ _rangeHasUnavailable(from, to) {
629
+ const [start, end] = from < to ? [from, to] : [to, from];
630
+ for (let day = start; day <= end; day = addDays(day, 1)) {
631
+ if (this._isUnavailable(day))
632
+ return true;
633
+ }
634
+ return false;
635
+ }
636
+ _commitRange(from, to) {
637
+ // A range may not span a blocked day. Both ends can be available while a
638
+ // booked day sits between them, and committing that would fire change with
639
+ // a period that visibly contains an unavailable date. Keep the anchor so
640
+ // the user can pick a different end.
641
+ if (this._rangeHasUnavailable(from, to)) {
642
+ this._announce(this._t('components.date-picker.range-blocked-text'));
643
+ return;
644
+ }
645
+ this.start = from < to ? from : to;
646
+ this.end = from < to ? to : from;
647
+ this._anchor = '';
648
+ this._hover = '';
649
+ this._announce(this._t('components.date-picker.range-selected-text', {
650
+ start: this._dateText(this.start),
651
+ end: this._dateText(this.end),
652
+ }));
653
+ this._emit('change', { start: this.start, end: this.end });
654
+ }
655
+ _beginRange(iso) {
656
+ this._anchor = iso;
657
+ this.start = iso;
658
+ this.end = '';
659
+ this._hover = '';
660
+ this._announce(this._t('components.date-picker.range-anchor-text', { date: this._dateText(iso) }));
661
+ this._emit('input', { start: iso, end: '' });
662
+ }
663
+ _announce(message) {
664
+ this._announcement = message;
665
+ }
666
+ _emit(type, detail) {
667
+ this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));
668
+ }
669
+ /**
670
+ * Whether today can be reached at all. Outside the bounds the button is a lie:
671
+ * it would clamp to the nearest allowed date, so on a birthdate calendar
672
+ * "Vandaag" would quietly jump eighteen years back.
673
+ */
674
+ get _todayReachable() {
675
+ return !this._isOutOfBounds(todayIso());
676
+ }
677
+ /**
678
+ * Jumps the calendar back to the current month without choosing anything.
679
+ * Navigation and selection are kept apart: someone who paged away to look
680
+ * around wants a way back, not a date they did not ask for.
681
+ */
682
+ _handleToday() {
683
+ const today = todayIso();
684
+ this._view = firstOfMonth(today);
685
+ this._focused = today;
686
+ this._restoreFocus = Boolean(this._focusedCell());
687
+ }
688
+ render() {
689
+ return datePickerTemplate(this);
690
+ }
691
+ };
692
+ NLDDDatePicker.styles = datePickerStyles;
693
+ __decorate([
694
+ property({ type: String })
695
+ ], NLDDDatePicker.prototype, "value", void 0);
696
+ __decorate([
697
+ property({ type: String })
698
+ ], NLDDDatePicker.prototype, "start", void 0);
699
+ __decorate([
700
+ property({ type: String })
701
+ ], NLDDDatePicker.prototype, "end", void 0);
702
+ __decorate([
703
+ property({ type: Boolean, reflect: true })
704
+ ], NLDDDatePicker.prototype, "range", void 0);
705
+ __decorate([
706
+ property({ type: String })
707
+ ], NLDDDatePicker.prototype, "min", void 0);
708
+ __decorate([
709
+ property({ type: String })
710
+ ], NLDDDatePicker.prototype, "max", void 0);
711
+ __decorate([
712
+ property({ type: Number, attribute: 'first-day-of-week' })
713
+ ], NLDDDatePicker.prototype, "firstDayOfWeek", void 0);
714
+ __decorate([
715
+ property({ type: Boolean, reflect: true, attribute: 'week-numbers' })
716
+ ], NLDDDatePicker.prototype, "weekNumbers", void 0);
717
+ __decorate([
718
+ property({ type: String, attribute: 'accessible-label' })
719
+ ], NLDDDatePicker.prototype, "accessibleLabel", void 0);
720
+ __decorate([
721
+ property({ attribute: false })
722
+ ], NLDDDatePicker.prototype, "isDateUnavailable", void 0);
723
+ __decorate([
724
+ state()
725
+ ], NLDDDatePicker.prototype, "_focused", void 0);
726
+ __decorate([
727
+ state()
728
+ ], NLDDDatePicker.prototype, "_view", void 0);
729
+ __decorate([
730
+ state()
731
+ ], NLDDDatePicker.prototype, "_anchor", void 0);
732
+ __decorate([
733
+ state()
734
+ ], NLDDDatePicker.prototype, "_hover", void 0);
735
+ __decorate([
736
+ state()
737
+ ], NLDDDatePicker.prototype, "_announcement", void 0);
738
+ __decorate([
739
+ state()
740
+ ], NLDDDatePicker.prototype, "_yearMenuOpen", void 0);
741
+ __decorate([
742
+ state()
743
+ ], NLDDDatePicker.prototype, "_stacked", void 0);
744
+ NLDDDatePicker = __decorate([
745
+ customElement('nldd-date-picker')
746
+ ], NLDDDatePicker);
747
+ export { NLDDDatePicker };
748
+ //# sourceMappingURL=date-picker.js.map