@six-group/ui-library 3.0.0-beta.1.7 → 3.0.0-beta.1.8

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 (367) hide show
  1. package/dist/cjs/{event-listeners-4a8d66d5.js → event-listeners-74715e62.js} +38 -38
  2. package/dist/cjs/{execution-control-3bc9c7c4.js → execution-control-46f388e0.js} +35 -35
  3. package/dist/cjs/{focus-visible-b08d956f.js → focus-visible-0b352c74.js} +40 -40
  4. package/dist/cjs/{form-control-9e4dffd1.js → form-control-866bbece.js} +25 -25
  5. package/dist/cjs/{modal-a9679ddf.js → modal-48d42228.js} +41 -41
  6. package/dist/cjs/{popover-e3781f5a.js → popover-1d2a037c.js} +95 -95
  7. package/dist/cjs/{scroll-5b8676ba.js → scroll-76e6f5d7.js} +57 -57
  8. package/dist/cjs/set-attributes_2.cjs.entry.js +57 -57
  9. package/dist/cjs/six-alert.cjs.entry.js +131 -131
  10. package/dist/cjs/six-avatar.cjs.entry.js +28 -28
  11. package/dist/cjs/six-badge.cjs.entry.js +26 -26
  12. package/dist/cjs/six-button.cjs.entry.js +97 -97
  13. package/dist/cjs/six-card.cjs.entry.js +8 -8
  14. package/dist/cjs/six-checkbox.cjs.entry.js +152 -152
  15. package/dist/cjs/six-datepicker.cjs.entry.js +1189 -1189
  16. package/dist/cjs/six-details.cjs.entry.js +139 -139
  17. package/dist/cjs/six-dialog.cjs.entry.js +152 -152
  18. package/dist/cjs/six-drawer.cjs.entry.js +174 -174
  19. package/dist/cjs/six-dropdown_3.cjs.entry.js +728 -728
  20. package/dist/cjs/six-error-page.cjs.entry.js +94 -94
  21. package/dist/cjs/six-file-list-item.cjs.entry.js +38 -38
  22. package/dist/cjs/six-file-list.cjs.entry.js +8 -8
  23. package/dist/cjs/six-file-upload.cjs.entry.js +96 -96
  24. package/dist/cjs/six-footer.cjs.entry.js +8 -8
  25. package/dist/cjs/six-form.cjs.entry.js +219 -219
  26. package/dist/cjs/six-group-label.cjs.entry.js +46 -46
  27. package/dist/cjs/six-header.cjs.entry.js +149 -149
  28. package/dist/cjs/six-icon-button.cjs.entry.js +33 -33
  29. package/dist/cjs/six-icon.cjs.entry.js +24 -24
  30. package/dist/cjs/six-input.cjs.entry.js +230 -230
  31. package/dist/cjs/six-item-picker.cjs.entry.js +361 -361
  32. package/dist/cjs/six-language-switcher.cjs.entry.js +52 -52
  33. package/dist/cjs/six-layout-grid.cjs.entry.js +19 -19
  34. package/dist/cjs/six-main-container.cjs.entry.js +11 -11
  35. package/dist/cjs/six-menu-divider.cjs.entry.js +8 -8
  36. package/dist/cjs/six-menu-label.cjs.entry.js +8 -8
  37. package/dist/cjs/six-picto.cjs.entry.js +15 -15
  38. package/dist/cjs/six-progress-bar.cjs.entry.js +17 -17
  39. package/dist/cjs/six-progress-ring.cjs.entry.js +31 -31
  40. package/dist/cjs/six-radio.cjs.entry.js +121 -121
  41. package/dist/cjs/six-range.cjs.entry.js +198 -198
  42. package/dist/cjs/six-root.cjs.entry.js +34 -34
  43. package/dist/cjs/six-search-field.cjs.entry.js +43 -43
  44. package/dist/cjs/six-select.cjs.entry.js +447 -447
  45. package/dist/cjs/six-sidebar-item-group.cjs.entry.js +42 -42
  46. package/dist/cjs/six-sidebar-item.cjs.entry.js +18 -18
  47. package/dist/cjs/six-sidebar.cjs.entry.js +171 -171
  48. package/dist/cjs/six-spinner.cjs.entry.js +16 -16
  49. package/dist/cjs/six-switch.cjs.entry.js +100 -100
  50. package/dist/cjs/six-tab-group.cjs.entry.js +226 -226
  51. package/dist/cjs/six-tab-panel.cjs.entry.js +17 -17
  52. package/dist/cjs/six-tab.cjs.entry.js +42 -42
  53. package/dist/cjs/six-table-cell_4.cjs.entry.js +70 -70
  54. package/dist/cjs/six-table.cjs.entry.js +145 -145
  55. package/dist/cjs/six-tag.cjs.entry.js +40 -40
  56. package/dist/cjs/six-textarea.cjs.entry.js +211 -211
  57. package/dist/cjs/six-tile.cjs.entry.js +89 -89
  58. package/dist/cjs/six-timepicker.cjs.entry.js +489 -489
  59. package/dist/cjs/{six-timepicker.types-c58cc88b.js → six-timepicker.types-c19ebff3.js} +43 -43
  60. package/dist/cjs/six-tooltip.cjs.entry.js +172 -172
  61. package/dist/cjs/{slot-8abe833c.js → slot-ad537f24.js} +42 -42
  62. package/dist/cjs/{types-65e5c95b.js → types-581e8ff0.js} +12 -12
  63. package/dist/cjs/{types-0c28e484.js → types-64878648.js} +12 -12
  64. package/dist/collection/components/six-alert/six-alert.js +366 -366
  65. package/dist/collection/components/six-avatar/six-avatar.js +131 -131
  66. package/dist/collection/components/six-badge/six-badge.js +101 -101
  67. package/dist/collection/components/six-button/six-button.js +466 -466
  68. package/dist/collection/components/six-card/six-card.js +21 -21
  69. package/dist/collection/components/six-checkbox/six-checkbox.js +550 -550
  70. package/dist/collection/components/six-datepicker/components/day-selection.js +13 -13
  71. package/dist/collection/components/six-datepicker/components/month-selection.js +12 -12
  72. package/dist/collection/components/six-datepicker/components/year-selection.js +10 -10
  73. package/dist/collection/components/six-datepicker/six-date-formats.js +23 -23
  74. package/dist/collection/components/six-datepicker/six-datepicker.js +1343 -1343
  75. package/dist/collection/components/six-datepicker/test/six-datepicker.test-helpers.js +16 -16
  76. package/dist/collection/components/six-details/six-details.js +432 -432
  77. package/dist/collection/components/six-dialog/six-dialog.js +401 -401
  78. package/dist/collection/components/six-drawer/six-drawer.js +458 -458
  79. package/dist/collection/components/six-dropdown/six-dropdown.js +939 -939
  80. package/dist/collection/components/six-error-page/six-error-page.js +199 -199
  81. package/dist/collection/components/six-file-list/six-file-list.js +20 -20
  82. package/dist/collection/components/six-file-list-item/six-file-list-item.js +203 -203
  83. package/dist/collection/components/six-file-upload/six-file-upload.js +272 -272
  84. package/dist/collection/components/six-footer/six-footer.js +21 -21
  85. package/dist/collection/components/six-form/six-form.js +408 -408
  86. package/dist/collection/components/six-group-label/six-group-label.js +166 -166
  87. package/dist/collection/components/six-header/six-header.js +420 -420
  88. package/dist/collection/components/six-icon/six-icon.js +77 -77
  89. package/dist/collection/components/six-icon-button/six-icon-button.js +142 -142
  90. package/dist/collection/components/six-input/six-input.js +1141 -1141
  91. package/dist/collection/components/six-item-picker/six-item-picker.js +688 -688
  92. package/dist/collection/components/six-item-picker/types.js +13 -13
  93. package/dist/collection/components/six-language-switcher/six-language-switcher.js +128 -128
  94. package/dist/collection/components/six-layout-grid/six-layout-grid.js +52 -52
  95. package/dist/collection/components/six-main-container/six-main-container.js +53 -53
  96. package/dist/collection/components/six-menu/six-menu.js +406 -406
  97. package/dist/collection/components/six-menu-divider/six-menu-divider.js +22 -22
  98. package/dist/collection/components/six-menu-item/six-menu-item.js +177 -177
  99. package/dist/collection/components/six-menu-label/six-menu-label.js +25 -25
  100. package/dist/collection/components/six-picto/six-picto.js +50 -50
  101. package/dist/collection/components/six-progress-bar/six-progress-bar.js +77 -77
  102. package/dist/collection/components/six-progress-ring/six-progress-ring.js +111 -111
  103. package/dist/collection/components/six-radio/six-radio.js +410 -410
  104. package/dist/collection/components/six-range/six-range.js +620 -620
  105. package/dist/collection/components/six-root/six-root.js +167 -167
  106. package/dist/collection/components/six-search-field/six-search-field.js +171 -171
  107. package/dist/collection/components/six-select/six-select.js +1105 -1105
  108. package/dist/collection/components/six-sidebar/six-sidebar.js +455 -455
  109. package/dist/collection/components/six-sidebar-item/six-sidebar-item.js +89 -89
  110. package/dist/collection/components/six-sidebar-item-group/six-sidebar-item-group.js +158 -158
  111. package/dist/collection/components/six-spinner/six-spinner.js +55 -55
  112. package/dist/collection/components/six-stage-indicator/six-stage-indicator.js +46 -46
  113. package/dist/collection/components/six-switch/six-switch.js +393 -393
  114. package/dist/collection/components/six-tab/six-tab.js +198 -198
  115. package/dist/collection/components/six-tab-group/six-tab-group.js +362 -362
  116. package/dist/collection/components/six-tab-panel/six-tab-panel.js +75 -75
  117. package/dist/collection/components/six-table/six-table.js +209 -209
  118. package/dist/collection/components/six-table/test/helpers.js +13 -13
  119. package/dist/collection/components/six-table/types.js +8 -8
  120. package/dist/collection/components/six-table/util/filter-by.js +34 -34
  121. package/dist/collection/components/six-table/util/from-data.js +33 -33
  122. package/dist/collection/components/six-table/util/is.js +3 -3
  123. package/dist/collection/components/six-table/util/quick-filter-by.js +13 -13
  124. package/dist/collection/components/six-table/util/sort-by.js +25 -25
  125. package/dist/collection/components/six-table-cell/six-table-cell.js +21 -21
  126. package/dist/collection/components/six-table-header/six-table-header.js +21 -21
  127. package/dist/collection/components/six-table-header-cell/get-next-state.js +7 -7
  128. package/dist/collection/components/six-table-header-cell/icons.js +12 -12
  129. package/dist/collection/components/six-table-header-cell/six-table-header-cell.js +174 -174
  130. package/dist/collection/components/six-table-header-cell/types.js +13 -13
  131. package/dist/collection/components/six-table-header-cell/util/create-model.js +6 -6
  132. package/dist/collection/components/six-table-header-cell/util/get-next-state.js +7 -7
  133. package/dist/collection/components/six-table-row/six-table-row.js +21 -21
  134. package/dist/collection/components/six-tag/six-tag.js +157 -157
  135. package/dist/collection/components/six-textarea/six-textarea.js +912 -912
  136. package/dist/collection/components/six-tile/six-tile.js +315 -315
  137. package/dist/collection/components/six-timepicker/six-time-format.js +14 -14
  138. package/dist/collection/components/six-timepicker/six-timepicker.js +980 -980
  139. package/dist/collection/components/six-timepicker/six-timepicker.types.js +40 -40
  140. package/dist/collection/components/six-tooltip/six-tooltip.js +435 -435
  141. package/dist/collection/functional-components/form-control/form-control.js +28 -28
  142. package/dist/collection/index.js +1 -1
  143. package/dist/collection/testUtil/delay.js +3 -3
  144. package/dist/collection/utils/as-array.js +1 -1
  145. package/dist/collection/utils/date-util.js +712 -712
  146. package/dist/collection/utils/event-listeners.js +39 -39
  147. package/dist/collection/utils/execution-control.js +38 -38
  148. package/dist/collection/utils/focus-visible.js +41 -41
  149. package/dist/collection/utils/matchers.js +2 -2
  150. package/dist/collection/utils/modal.js +28 -28
  151. package/dist/collection/utils/offset.js +13 -13
  152. package/dist/collection/utils/popover.js +113 -113
  153. package/dist/collection/utils/scroll.js +47 -47
  154. package/dist/collection/utils/slot.js +59 -59
  155. package/dist/collection/utils/support.js +15 -15
  156. package/dist/collection/utils/tabbable.js +22 -22
  157. package/dist/collection/utils/testing.js +38 -38
  158. package/dist/collection/utils/time.util.js +74 -74
  159. package/dist/collection/utils/type-check.js +5 -5
  160. package/dist/collection/utils/types.js +1 -1
  161. package/dist/collection/wrappers/set-attributes/set-attributes.js +68 -68
  162. package/dist/components.json +1 -1
  163. package/dist/custom-elements/index.js +7595 -7595
  164. package/dist/esm/{event-listeners-1bef934e.js → event-listeners-570a24ea.js} +38 -38
  165. package/dist/esm/{execution-control-235f5126.js → execution-control-1a60d709.js} +35 -35
  166. package/dist/esm/{focus-visible-4b7946aa.js → focus-visible-97933ea9.js} +40 -40
  167. package/dist/esm/{form-control-17478ad2.js → form-control-24f446af.js} +25 -25
  168. package/dist/esm/{modal-e5709f6b.js → modal-5ebdc320.js} +41 -41
  169. package/dist/esm/polyfills/core-js.js +0 -0
  170. package/dist/esm/polyfills/dom.js +0 -0
  171. package/dist/esm/polyfills/es5-html-element.js +0 -0
  172. package/dist/esm/polyfills/index.js +0 -0
  173. package/dist/esm/polyfills/system.js +0 -0
  174. package/dist/esm/{popover-5a51f84d.js → popover-1c7a1139.js} +95 -95
  175. package/dist/esm/{scroll-99b214c2.js → scroll-180b53fd.js} +57 -57
  176. package/dist/esm/set-attributes_2.entry.js +57 -57
  177. package/dist/esm/six-alert.entry.js +131 -131
  178. package/dist/esm/six-avatar.entry.js +28 -28
  179. package/dist/esm/six-badge.entry.js +26 -26
  180. package/dist/esm/six-button.entry.js +97 -97
  181. package/dist/esm/six-card.entry.js +8 -8
  182. package/dist/esm/six-checkbox.entry.js +152 -152
  183. package/dist/esm/six-datepicker.entry.js +1189 -1189
  184. package/dist/esm/six-details.entry.js +139 -139
  185. package/dist/esm/six-dialog.entry.js +152 -152
  186. package/dist/esm/six-drawer.entry.js +174 -174
  187. package/dist/esm/six-dropdown_3.entry.js +728 -728
  188. package/dist/esm/six-error-page.entry.js +94 -94
  189. package/dist/esm/six-file-list-item.entry.js +38 -38
  190. package/dist/esm/six-file-list.entry.js +8 -8
  191. package/dist/esm/six-file-upload.entry.js +96 -96
  192. package/dist/esm/six-footer.entry.js +8 -8
  193. package/dist/esm/six-form.entry.js +219 -219
  194. package/dist/esm/six-group-label.entry.js +46 -46
  195. package/dist/esm/six-header.entry.js +149 -149
  196. package/dist/esm/six-icon-button.entry.js +33 -33
  197. package/dist/esm/six-icon.entry.js +24 -24
  198. package/dist/esm/six-input.entry.js +230 -230
  199. package/dist/esm/six-item-picker.entry.js +361 -361
  200. package/dist/esm/six-language-switcher.entry.js +52 -52
  201. package/dist/esm/six-layout-grid.entry.js +19 -19
  202. package/dist/esm/six-main-container.entry.js +11 -11
  203. package/dist/esm/six-menu-divider.entry.js +8 -8
  204. package/dist/esm/six-menu-label.entry.js +8 -8
  205. package/dist/esm/six-picto.entry.js +15 -15
  206. package/dist/esm/six-progress-bar.entry.js +17 -17
  207. package/dist/esm/six-progress-ring.entry.js +31 -31
  208. package/dist/esm/six-radio.entry.js +121 -121
  209. package/dist/esm/six-range.entry.js +198 -198
  210. package/dist/esm/six-root.entry.js +34 -34
  211. package/dist/esm/six-search-field.entry.js +43 -43
  212. package/dist/esm/six-select.entry.js +447 -447
  213. package/dist/esm/six-sidebar-item-group.entry.js +42 -42
  214. package/dist/esm/six-sidebar-item.entry.js +18 -18
  215. package/dist/esm/six-sidebar.entry.js +171 -171
  216. package/dist/esm/six-spinner.entry.js +16 -16
  217. package/dist/esm/six-switch.entry.js +100 -100
  218. package/dist/esm/six-tab-group.entry.js +226 -226
  219. package/dist/esm/six-tab-panel.entry.js +17 -17
  220. package/dist/esm/six-tab.entry.js +42 -42
  221. package/dist/esm/six-table-cell_4.entry.js +70 -70
  222. package/dist/esm/six-table.entry.js +145 -145
  223. package/dist/esm/six-tag.entry.js +40 -40
  224. package/dist/esm/six-textarea.entry.js +211 -211
  225. package/dist/esm/six-tile.entry.js +89 -89
  226. package/dist/esm/six-timepicker.entry.js +489 -489
  227. package/dist/esm/{six-timepicker.types-cd6bac03.js → six-timepicker.types-e161a447.js} +43 -43
  228. package/dist/esm/six-tooltip.entry.js +172 -172
  229. package/dist/esm/{slot-5253e199.js → slot-6f3984c7.js} +42 -42
  230. package/dist/esm/{types-a37c1695.js → types-4b10b413.js} +12 -12
  231. package/dist/esm/{types-33d15673.js → types-ed860f7c.js} +12 -12
  232. package/dist/types/components/six-alert/six-alert.d.ts +60 -60
  233. package/dist/types/components/six-avatar/six-avatar.d.ts +27 -27
  234. package/dist/types/components/six-badge/six-badge.d.ts +20 -20
  235. package/dist/types/components/six-button/six-button.d.ts +69 -69
  236. package/dist/types/components/six-card/six-card.d.ts +9 -9
  237. package/dist/types/components/six-checkbox/six-checkbox.d.ts +86 -86
  238. package/dist/types/components/six-datepicker/components/day-selection.d.ts +5 -5
  239. package/dist/types/components/six-datepicker/components/month-selection.d.ts +5 -5
  240. package/dist/types/components/six-datepicker/components/year-selection.d.ts +5 -5
  241. package/dist/types/components/six-datepicker/six-date-formats.d.ts +22 -22
  242. package/dist/types/components/six-datepicker/six-datepicker.d.ts +214 -214
  243. package/dist/types/components/six-datepicker/test/six-datepicker.test-helpers.d.ts +1 -1
  244. package/dist/types/components/six-details/six-details.d.ts +61 -61
  245. package/dist/types/components/six-dialog/six-dialog.d.ts +75 -75
  246. package/dist/types/components/six-drawer/six-drawer.d.ts +82 -82
  247. package/dist/types/components/six-dropdown/six-dropdown.d.ts +140 -140
  248. package/dist/types/components/six-error-page/six-error-page.d.ts +27 -27
  249. package/dist/types/components/six-file-list/six-file-list.d.ts +8 -8
  250. package/dist/types/components/six-file-list-item/six-file-list-item.d.ts +35 -35
  251. package/dist/types/components/six-file-upload/six-file-upload.d.ts +42 -42
  252. package/dist/types/components/six-footer/six-footer.d.ts +9 -9
  253. package/dist/types/components/six-form/six-form.d.ts +69 -69
  254. package/dist/types/components/six-group-label/six-group-label.d.ts +37 -37
  255. package/dist/types/components/six-header/six-header.d.ts +90 -90
  256. package/dist/types/components/six-icon/six-icon.d.ts +13 -13
  257. package/dist/types/components/six-icon-button/six-icon-button.d.ts +28 -28
  258. package/dist/types/components/six-input/six-input.d.ts +165 -165
  259. package/dist/types/components/six-item-picker/six-item-picker.d.ts +106 -106
  260. package/dist/types/components/six-item-picker/types.d.ts +11 -11
  261. package/dist/types/components/six-language-switcher/six-language-switcher.d.ts +25 -25
  262. package/dist/types/components/six-layout-grid/six-layout-grid.d.ts +14 -14
  263. package/dist/types/components/six-main-container/six-main-container.d.ts +16 -16
  264. package/dist/types/components/six-menu/six-menu.d.ts +81 -81
  265. package/dist/types/components/six-menu-divider/six-menu-divider.d.ts +11 -11
  266. package/dist/types/components/six-menu-item/six-menu-item.d.ts +36 -36
  267. package/dist/types/components/six-menu-label/six-menu-label.d.ts +13 -13
  268. package/dist/types/components/six-picto/six-picto.d.ts +14 -14
  269. package/dist/types/components/six-progress-bar/six-progress-bar.d.ts +19 -19
  270. package/dist/types/components/six-progress-ring/six-progress-ring.d.ts +24 -24
  271. package/dist/types/components/six-radio/six-radio.d.ts +66 -66
  272. package/dist/types/components/six-range/six-range.d.ts +101 -101
  273. package/dist/types/components/six-root/six-root.d.ts +34 -34
  274. package/dist/types/components/six-search-field/six-search-field.d.ts +32 -32
  275. package/dist/types/components/six-select/six-select.d.ts +163 -163
  276. package/dist/types/components/six-sidebar/six-sidebar.d.ts +55 -55
  277. package/dist/types/components/six-sidebar-item/six-sidebar-item.d.ts +15 -15
  278. package/dist/types/components/six-sidebar-item-group/six-sidebar-item-group.d.ts +26 -26
  279. package/dist/types/components/six-spinner/six-spinner.d.ts +15 -15
  280. package/dist/types/components/six-stage-indicator/six-stage-indicator.d.ts +6 -6
  281. package/dist/types/components/six-switch/six-switch.d.ts +62 -62
  282. package/dist/types/components/six-tab/six-tab.d.ts +35 -35
  283. package/dist/types/components/six-tab-group/six-tab-group.d.ts +62 -62
  284. package/dist/types/components/six-tab-panel/six-tab-panel.d.ts +19 -19
  285. package/dist/types/components/six-table/six-table.d.ts +30 -30
  286. package/dist/types/components/six-table/test/helpers.d.ts +2 -2
  287. package/dist/types/components/six-table/types.d.ts +33 -33
  288. package/dist/types/components/six-table/util/filter-by.d.ts +2 -2
  289. package/dist/types/components/six-table/util/from-data.d.ts +8 -8
  290. package/dist/types/components/six-table/util/is.d.ts +3 -3
  291. package/dist/types/components/six-table/util/quick-filter-by.d.ts +2 -2
  292. package/dist/types/components/six-table/util/sort-by.d.ts +2 -2
  293. package/dist/types/components/six-table-cell/six-table-cell.d.ts +9 -9
  294. package/dist/types/components/six-table-header/six-table-header.d.ts +9 -9
  295. package/dist/types/components/six-table-header-cell/get-next-state.d.ts +2 -2
  296. package/dist/types/components/six-table-header-cell/icons.d.ts +3 -3
  297. package/dist/types/components/six-table-header-cell/six-table-header-cell.d.ts +32 -32
  298. package/dist/types/components/six-table-header-cell/types.d.ts +11 -11
  299. package/dist/types/components/six-table-header-cell/util/create-model.d.ts +4 -4
  300. package/dist/types/components/six-table-header-cell/util/get-next-state.d.ts +3 -3
  301. package/dist/types/components/six-table-row/six-table-row.d.ts +9 -9
  302. package/dist/types/components/six-tag/six-tag.d.ts +30 -30
  303. package/dist/types/components/six-textarea/six-textarea.d.ts +134 -134
  304. package/dist/types/components/six-tile/six-tile.d.ts +40 -40
  305. package/dist/types/components/six-timepicker/six-time-format.d.ts +13 -13
  306. package/dist/types/components/six-timepicker/six-timepicker.d.ts +184 -184
  307. package/dist/types/components/six-timepicker/six-timepicker.types.d.ts +36 -36
  308. package/dist/types/components/six-tooltip/six-tooltip.d.ts +72 -72
  309. package/dist/types/functional-components/form-control/form-control.d.ts +34 -34
  310. package/dist/types/index.d.ts +1 -1
  311. package/dist/types/testUtil/delay.d.ts +1 -1
  312. package/dist/types/utils/as-array.d.ts +1 -1
  313. package/dist/types/utils/date-util.d.ts +194 -194
  314. package/dist/types/utils/event-listeners.d.ts +15 -15
  315. package/dist/types/utils/execution-control.d.ts +26 -26
  316. package/dist/types/utils/focus-visible.d.ts +6 -6
  317. package/dist/types/utils/matchers.d.ts +2 -2
  318. package/dist/types/utils/modal.d.ts +13 -13
  319. package/dist/types/utils/offset.d.ts +4 -4
  320. package/dist/types/utils/popover.d.ts +27 -27
  321. package/dist/types/utils/scroll.d.ts +3 -3
  322. package/dist/types/utils/slot.d.ts +9 -9
  323. package/dist/types/utils/support.d.ts +1 -1
  324. package/dist/types/utils/tabbable.d.ts +2 -2
  325. package/dist/types/utils/testing.d.ts +2 -2
  326. package/dist/types/utils/time.util.d.ts +10 -10
  327. package/dist/types/utils/type-check.d.ts +4 -4
  328. package/dist/types/utils/types.d.ts +4 -4
  329. package/dist/types/wrappers/set-attributes/set-attributes.d.ts +9 -9
  330. package/dist/ui-library/{p-a8c225f2.entry.js → p-007bc8e8.entry.js} +1 -1
  331. package/dist/ui-library/{p-f9c0cfb7.entry.js → p-044b784e.entry.js} +1 -1
  332. package/dist/ui-library/{p-c733dead.js → p-0786fa7c.js} +0 -0
  333. package/dist/ui-library/{p-12cc24c3.js → p-07d1e830.js} +0 -0
  334. package/dist/ui-library/{p-48ea4419.entry.js → p-09cb13fa.entry.js} +1 -1
  335. package/dist/ui-library/{p-e96dcf96.entry.js → p-0c596054.entry.js} +1 -1
  336. package/dist/ui-library/{p-a77a6442.entry.js → p-1b8dc7b7.entry.js} +1 -1
  337. package/dist/ui-library/{p-68d31736.js → p-25a3bf57.js} +0 -0
  338. package/dist/ui-library/{p-ebaea182.entry.js → p-281e8c2d.entry.js} +1 -1
  339. package/dist/ui-library/{p-9f2dc381.entry.js → p-2924f82f.entry.js} +1 -1
  340. package/dist/ui-library/{p-ea1fcff2.entry.js → p-2d7ed407.entry.js} +1 -1
  341. package/dist/ui-library/{p-89f68e76.entry.js → p-4162dcdd.entry.js} +1 -1
  342. package/dist/ui-library/{p-6f67f986.entry.js → p-4d3a4e93.entry.js} +1 -1
  343. package/dist/ui-library/{p-8bd0873f.entry.js → p-4ed023b8.entry.js} +1 -1
  344. package/dist/ui-library/{p-af3d757c.js → p-4f8394d7.js} +0 -0
  345. package/dist/ui-library/{p-1b92cc7a.entry.js → p-530ea6ec.entry.js} +1 -1
  346. package/dist/ui-library/{p-19543c96.entry.js → p-531ab886.entry.js} +1 -1
  347. package/dist/ui-library/{p-fdb455d7.entry.js → p-54c48654.entry.js} +1 -1
  348. package/dist/ui-library/{p-c948d3db.entry.js → p-55c64cbc.entry.js} +1 -1
  349. package/dist/ui-library/{p-1c9f0dc6.js → p-5f1c6a5f.js} +0 -0
  350. package/dist/ui-library/{p-60491176.entry.js → p-675a8243.entry.js} +1 -1
  351. package/dist/ui-library/{p-b9fb8455.entry.js → p-6d622ed0.entry.js} +1 -1
  352. package/dist/ui-library/{p-572e3690.js → p-75297ad7.js} +0 -0
  353. package/dist/ui-library/{p-2ff97cdf.entry.js → p-90b26447.entry.js} +1 -1
  354. package/dist/ui-library/{p-fcd2356c.entry.js → p-93945629.entry.js} +1 -1
  355. package/dist/ui-library/{p-7735d99f.js → p-9a860acc.js} +0 -0
  356. package/dist/ui-library/{p-4cc01afc.entry.js → p-aa37e45a.entry.js} +1 -1
  357. package/dist/ui-library/{p-191f958b.js → p-b1e66136.js} +0 -0
  358. package/dist/ui-library/{p-c09dc3a9.js → p-b4dfb7cf.js} +0 -0
  359. package/dist/ui-library/{p-968c5169.entry.js → p-c24292b3.entry.js} +1 -1
  360. package/dist/ui-library/{p-ed21cc57.entry.js → p-cd79de73.entry.js} +1 -1
  361. package/dist/ui-library/{p-34e6d8e8.js → p-d12c6092.js} +0 -0
  362. package/dist/ui-library/{p-f0e91e17.entry.js → p-d28ac80a.entry.js} +1 -1
  363. package/dist/ui-library/{p-5ead7b2f.entry.js → p-d837e5a8.entry.js} +1 -1
  364. package/dist/ui-library/{p-ec1ecc2a.entry.js → p-dd3cae68.entry.js} +1 -1
  365. package/dist/ui-library/{p-044c6bf9.js → p-eb8f05a9.js} +0 -0
  366. package/dist/ui-library/ui-library.esm.js +1 -1
  367. package/package.json +1 -1
@@ -1,1206 +1,1206 @@
1
1
  import { h, r as registerInstance, c as createEvent, g as getElement } from './index-a2605a62.js';
2
- import { i as isNil, a as isNumber, b as isDate, c as isString, S as SixTimePropertyName } from './six-timepicker.types-cd6bac03.js';
3
- import { E as EventListeners } from './event-listeners-1bef934e.js';
4
- import { D as DEFAULT_DEBOUNCE_FAST, d as debounceEvent, a as debounce } from './execution-control-235f5126.js';
5
- import { h as hasSlot } from './slot-5253e199.js';
2
+ import { i as isNil, a as isNumber, b as isDate, c as isString, S as SixTimePropertyName } from './six-timepicker.types-e161a447.js';
3
+ import { E as EventListeners } from './event-listeners-570a24ea.js';
4
+ import { D as DEFAULT_DEBOUNCE_FAST, d as debounceEvent, a as debounce } from './execution-control-1a60d709.js';
5
+ import { h as hasSlot } from './slot-6f3984c7.js';
6
6
 
7
- const i18nDate = {
8
- en: {
9
- months: [
10
- 'January',
11
- 'February',
12
- 'March',
13
- 'April',
14
- 'May',
15
- 'June',
16
- 'July',
17
- 'August',
18
- 'September',
19
- 'October',
20
- 'November',
21
- 'December',
22
- ],
23
- monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
24
- monthsShortGrouped: [
25
- ['Jan', 'Feb', 'Mar', 'Apr'],
26
- ['May', 'Jun', 'Jul', 'Aug'],
27
- ['Sep', 'Oct', 'Nov', 'Dec'],
28
- ],
29
- weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
30
- weekdaysShort: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
31
- weekdaysMin: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
32
- },
33
- de: {
34
- months: [
35
- 'Januar',
36
- 'Februar',
37
- 'März',
38
- 'April',
39
- 'Mai',
40
- 'Juni',
41
- 'Juli',
42
- 'August',
43
- 'September',
44
- 'Oktober',
45
- 'November',
46
- 'Dezember',
47
- ],
48
- monthsShort: ['Jan.', 'Feb.', 'März', 'Apr.', 'Mai', 'Juni', 'Juli', 'Aug.', 'Sep.', 'Okt.', 'Nov.', 'Dez.'],
49
- monthsShortGrouped: [
50
- ['Jan.', 'Feb.', 'März', 'Apr.'],
51
- ['Mai', 'Juni', 'Juli', 'Aug.'],
52
- ['Sep.', 'Okt.', 'Nov.', 'Dez.'],
53
- ],
54
- weekdays: ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'],
55
- weekdaysShort: ['Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.', 'So.'],
56
- weekdaysMin: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
57
- },
58
- fr: {
59
- months: [
60
- 'janvier',
61
- 'février',
62
- 'mars',
63
- 'avril',
64
- 'mai',
65
- 'juin',
66
- 'juillet',
67
- 'août',
68
- 'septembre',
69
- 'octobre',
70
- 'novembre',
71
- 'décembre',
72
- ],
73
- monthsShort: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
74
- monthsShortGrouped: [
75
- ['janv.', 'févr.', 'mars', 'avr.'],
76
- ['mai', 'juin', 'juil.', 'août'],
77
- ['sept.', 'oct.', 'nov.', 'déc.'],
78
- ],
79
- weekdays: ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'],
80
- weekdaysShort: ['lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.', 'dim.'],
81
- weekdaysMin: ['lu', 'ma', 'me', 'je', 've', 'sa', 'di'],
82
- },
83
- it: {
84
- months: [
85
- 'gennaio',
86
- 'febbraio',
87
- 'marzo',
88
- 'aprile',
89
- 'maggio',
90
- 'giugno',
91
- 'luglio',
92
- 'agosto',
93
- 'settembre',
94
- 'ottobre',
95
- 'novembre',
96
- 'dicembre',
97
- ],
98
- monthsShort: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'],
99
- monthsShortGrouped: [
100
- ['gen', 'feb', 'mar', 'apr'],
101
- ['mag', 'giu', 'lug', 'ago'],
102
- ['set', 'ott', 'nov', 'dic'],
103
- ],
104
- weekdays: ['lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato', 'domenica'],
105
- weekdaysShort: ['lun', 'mar', 'mer', 'gio', 'ven', 'sab', 'dom'],
106
- weekdaysMin: ['lu', 'ma', 'me', 'gi', 've', 'sa', 'do'],
107
- },
108
- };
109
- /**
110
- * Returns a JS Date instance of the exact moment
111
- *
112
- * ```typescript
113
- * const date = now()
114
- * // Wed Mar 10 2021 20:30:32 GMT+0100 (Central European Standard Time)
115
- * ```
116
- */
117
- const now = () => new Date();
118
- /**
119
- * Returns `true` if the given date is valid
120
- */
121
- const isValidDate = (value) => {
122
- if (isNil(value)) {
123
- return false;
124
- }
125
- if (isNumber(value)) {
126
- return false;
127
- }
128
- if (isDate(value)) {
129
- return !isNaN(value.getTime());
130
- }
131
- return new Date(value).toString() !== 'Invalid Date';
132
- };
133
- /**
134
- * Returns the year number of the given date
135
- *
136
- * ```typescript
137
- * year(new Date(2020, 0, 1)) // 2020
138
- * ```
139
- */
140
- const year = (date) => {
141
- if (date && isValidDate(date)) {
142
- return date.getFullYear();
143
- }
144
- throw new Error('Not a valid date');
145
- };
146
- /**
147
- * Returns the month number of the given date
148
- *
149
- * ```typescript
150
- * month(new Date(2020, 0, 1)) // 0
151
- * ```
152
- */
153
- const month = (date) => {
154
- if (date && isValidDate(date)) {
155
- return date.getMonth();
156
- }
157
- throw new Error('Not a valid date');
158
- };
159
- /**
160
- * Returns the day number of the given date
161
- *
162
- * ```typescript
163
- * day(new Date(2020, 0, 1)) // 1
164
- * ```
165
- */
166
- const day = (date) => {
167
- if (date && isValidDate(date)) {
168
- return date.getDate();
169
- }
170
- throw new Error('Not a valid date');
171
- };
172
- /**
173
- * Returns the hours of the given date
174
- */
175
- const hours = (date) => {
176
- if (date && isValidDate(date)) {
177
- return date.getHours();
178
- }
179
- throw new Error('Not a valid date');
180
- };
181
- /**
182
- * Returns the minutes of the given date
183
- */
184
- const minutes = (date) => {
185
- if (date && isValidDate(date)) {
186
- return date.getMinutes();
187
- }
188
- throw new Error('Not a valid date');
189
- };
190
- /**
191
- * Returns the seconds of the given date
192
- */
193
- const seconds = (date) => {
194
- if (date && isValidDate(date)) {
195
- return date.getSeconds();
196
- }
197
- throw new Error('Not a valid date');
198
- };
199
- /**
200
- * Returns the first day of the week of the given date.
201
- */
202
- const getFirstDayOfTheWeek = (date) => {
203
- const weekdayDiff = [6, 0, 1, 2, 3, 4, 5];
204
- const day = new Date(date);
205
- day.setDate(day.getDate() - weekdayDiff[day.getDay()]);
206
- return day;
207
- };
208
- /**
209
- * Returns `true` when the year of the dates are the same
210
- */
211
- const isSameYear = (a, b) => (a === null || a === void 0 ? void 0 : a.getFullYear()) === (b === null || b === void 0 ? void 0 : b.getFullYear());
212
- /**
213
- * Returns `true` when the month of the dates are the same
214
- */
215
- const isSameMonth = (a, b) => isSameYear(a, b) && (a === null || a === void 0 ? void 0 : a.getMonth()) === (b === null || b === void 0 ? void 0 : b.getMonth());
216
- /**
217
- * Returns `true` when the day of the dates are the same
218
- */
219
- const isSameDay = (a, b) => isSameMonth(a, b) && (a === null || a === void 0 ? void 0 : a.getDate()) === (b === null || b === void 0 ? void 0 : b.getDate());
220
- /**
221
- * Returns `true` when the week of the dates are the same
222
- */
223
- const isSameWeek = (a, b) => isSameDay(getFirstDayOfTheWeek(a), getFirstDayOfTheWeek(b));
224
- /**
225
- * Returns `true` if the given datestring is valid
226
- */
227
- const isValidDateString = (datestring, format) => {
228
- if (!isString(datestring) || !isString(format)) {
229
- return false;
230
- }
231
- if (datestring.length < 6 || format.length < 6) {
232
- return false;
233
- }
234
- const { day, month } = getDateParts(datestring, format);
235
- if (day > 31 || month > 11 || day <= 0 || month < 0) {
236
- return false;
237
- }
238
- const date = toDate(datestring, format);
239
- if (isNil(date)) {
240
- return false;
241
- }
242
- return date.toString() !== 'Invalid Date';
243
- };
244
- /**
245
- * Returns `true` when the given date is not smaller than the minDate and not bigger than the maxDate.
246
- *
247
- * ```typescript
248
- * isInRange(new Date(2020, 1, 1), new Date(2020, 0, 1), new Date(2020, 2, 1)) // true
249
- * ```
250
- */
251
- const isInRange = (date, minDate, maxDate) => {
252
- if (!date) {
253
- return true;
254
- }
255
- if (minDate && date < minDate) {
256
- return false;
257
- }
258
- if (maxDate && maxDate < date) {
259
- return false;
260
- }
261
- return true;
262
- };
263
- const lookAhead = (iFormat, format, match, length = 2) => {
264
- const increment = length - 1;
265
- const followingCharacterMatches = format.charAt(iFormat + increment) === match;
266
- const hasProperLength = iFormat + increment < format.length;
267
- return hasProperLength && followingCharacterMatches;
268
- };
269
- const formatNumber = (value, len) => {
270
- let num = String(value);
271
- while (num.length < len) {
272
- num = '0' + num;
273
- }
274
- return num;
275
- };
276
- const formatDate = (date, format) => {
277
- if (!date) {
278
- return '';
279
- }
280
- let output = '';
281
- for (let iFormat = 0; iFormat < format.length; iFormat++) {
282
- switch (format.charAt(iFormat)) {
283
- case 'd':
284
- if (lookAhead(iFormat, format, 'd')) {
285
- output += formatNumber(date.getDate(), 2);
286
- iFormat++;
287
- }
288
- else {
289
- output += String(date.getDate());
290
- }
291
- break;
292
- case 'm':
293
- if (lookAhead(iFormat, format, 'm')) {
294
- output += formatNumber(date.getMonth() + 1, 2);
295
- iFormat++;
296
- }
297
- else {
298
- output += String(date.getMonth() + 1);
299
- }
300
- break;
301
- case 'y':
302
- if (lookAhead(iFormat, format, 'y', 4)) {
303
- iFormat += 3;
304
- output += date.getFullYear();
305
- }
306
- else {
307
- output += (date.getFullYear() % 100 < 10 ? '0' : '') + (date.getFullYear() % 100);
308
- iFormat++;
309
- }
310
- break;
311
- case 'h':
312
- if (lookAhead(iFormat, format, 'h')) {
313
- output += formatNumber(date.getHours(), 2);
314
- iFormat++;
315
- }
316
- else {
317
- output += String(date.getHours());
318
- }
319
- break;
320
- case 'M':
321
- if (lookAhead(iFormat, format, 'M')) {
322
- output += formatNumber(date.getMinutes(), 2);
323
- iFormat++;
324
- }
325
- else {
326
- output += String(date.getMinutes());
327
- }
328
- break;
329
- case 's':
330
- if (lookAhead(iFormat, format, 's')) {
331
- output += formatNumber(date.getSeconds(), 2);
332
- iFormat++;
333
- }
334
- else {
335
- output += String(date.getSeconds());
336
- }
337
- break;
338
- default:
339
- output += format.charAt(iFormat);
340
- }
341
- }
342
- return output;
343
- };
344
- const FORMATTING_TOKENS = /(\[[^\[]*\])|(mm|dd|yyyy|yy|hh|MM|ss|.)/g;
345
- const TWO_NUMERICS_REGEX = /\d\d/; // 00 - 99
346
- const FOUR_NUMERICS_REGEX = /\d{4}/; // 0000 - 9999
347
- const NON_NUMERIC_REGEX = /[^0-9]/g;
348
- const YEAR = 'year';
349
- const MONTH = 'month';
350
- const DAY = 'day';
351
- const HOUR = 'hour';
352
- const MINUTE = 'minute';
353
- const SECOND = 'second';
354
- const parseFlags = {};
355
- const addParseFlag = (token, regex, callback) => {
356
- const tokens = Array.isArray(token) ? token : [token];
357
- let func;
358
- if (typeof callback === 'string') {
359
- func = (input) => {
360
- const value = parseInt(input, 10);
361
- return { [callback]: value };
362
- };
363
- }
364
- else {
365
- func = callback;
366
- }
367
- tokens.forEach((key) => {
368
- parseFlags[key] = [regex, func];
369
- });
370
- };
371
- addParseFlag('yy', TWO_NUMERICS_REGEX, (input) => {
372
- const year = new Date().getFullYear();
373
- const cent = Math.floor(year / 100);
374
- let value = parseInt(input, 10);
375
- value = (value > 68 ? cent - 1 : cent) * 100 + value;
376
- return { [YEAR]: value };
377
- });
378
- addParseFlag('yyyy', FOUR_NUMERICS_REGEX, YEAR);
379
- addParseFlag('mm', TWO_NUMERICS_REGEX, (input) => ({ [MONTH]: parseInt(input, 10) - 1 }));
380
- addParseFlag('dd', TWO_NUMERICS_REGEX, DAY);
381
- addParseFlag('hh', TWO_NUMERICS_REGEX, HOUR);
382
- addParseFlag('MM', TWO_NUMERICS_REGEX, MINUTE);
383
- addParseFlag('ss', TWO_NUMERICS_REGEX, SECOND);
384
- const getFullInputArray = (input, backupDate = new Date()) => {
385
- const result = [0, 0, 1, 0, 0, 0];
386
- const backupArr = [
387
- backupDate.getFullYear(),
388
- backupDate.getMonth(),
389
- backupDate.getDate(),
390
- backupDate.getHours(),
391
- backupDate.getMinutes(),
392
- backupDate.getSeconds(),
393
- ];
394
- let useBackup = true;
395
- for (let i = 0; i < 7; i++) {
396
- if (input[i] === undefined) {
397
- result[i] = useBackup ? backupArr[i] : result[i];
398
- }
399
- else {
400
- result[i] = input[i];
401
- useBackup = false;
402
- }
403
- }
404
- return result;
405
- };
406
- const createDate = (year, month, day, hour, minute, second) => {
407
- if (!(year < 100 && year >= 0)) {
408
- return new Date(year, month, day, hour, minute, second);
409
- }
410
- const date = new Date(year + 400, month, day, hour, minute, second);
411
- if (isFinite(date.getFullYear())) {
412
- date.setFullYear(year);
413
- }
414
- return date;
415
- };
416
- const makeParser = (dateString, format) => {
417
- const tokens = format.match(FORMATTING_TOKENS);
418
- if (!tokens) {
419
- throw new Error();
420
- }
421
- const { length } = tokens;
422
- let mark = {};
423
- for (let i = 0; i < length; i += 1) {
424
- const token = tokens[i];
425
- const parseTo = parseFlags[token];
426
- if (!parseTo) {
427
- const word = token.replace(/^\[|\]$/g, '');
428
- if (dateString.indexOf(word) === 0) {
429
- dateString = dateString.substr(word.length);
430
- }
431
- else {
432
- throw new Error('not match');
433
- }
434
- }
435
- else {
436
- const regex = parseTo[0];
437
- const parser = parseTo[1];
438
- const value = (regex.exec(dateString) || [])[0];
439
- const obj = parser(value);
440
- mark = Object.assign(Object.assign({}, mark), obj);
441
- dateString = dateString.replace(value, '');
442
- }
443
- }
444
- return mark;
445
- };
446
- const getCleanDateString = (dirtyDateString, format) => {
447
- if (dirtyDateString.length === format.length) {
448
- return dirtyDateString;
449
- }
450
- const separator = dirtyDateString.match(NON_NUMERIC_REGEX)[0];
451
- // pad signle digits to follow supported dateformats
452
- return dirtyDateString
453
- .split(separator)
454
- .map((s) => (s.length === 1 ? '0' + s : s))
455
- .join(separator);
456
- };
457
- const getDateParts = (dirtyDateString, format) => {
458
- const dateString = getCleanDateString(dirtyDateString, format);
459
- return makeParser(dateString, format);
460
- };
461
- const toDate = (dirtyDateString, format) => {
462
- try {
463
- const { backupDate = new Date() } = {};
464
- const { year, month, day, hour, minute, second, date } = getDateParts(dirtyDateString, format);
465
- if (date) {
466
- return date;
467
- }
468
- const inputArray = [year, month, day, hour, minute, second];
469
- let parsedDate;
470
- const result = getFullInputArray(inputArray, backupDate);
471
- parsedDate = createDate(...result);
472
- return parsedDate;
473
- }
474
- catch (e) {
475
- return new Date(NaN);
476
- }
477
- };
478
- const createCalendarGrid = (calendarGridArguments) => {
479
- const { firstDateOfBox, allowedDates, dateFormat, selectedDate, minDate, maxDate, pointerDate } = calendarGridArguments;
480
- const weekDatePointer = new Date(firstDateOfBox);
481
- const dayDatePointer = new Date(firstDateOfBox);
482
- let calendar = [];
483
- do {
484
- let row = [];
485
- do {
486
- row = [
487
- ...row,
488
- {
489
- date: new Date(dayDatePointer),
490
- display: formatDate(dayDatePointer, dateFormat),
491
- dateString: formatDate(dayDatePointer, dateFormat),
492
- label: day(dayDatePointer).toString(),
493
- isToday: isSameDay(dayDatePointer, now()),
494
- isSelected: selectedDate && isSameDay(dayDatePointer, selectedDate),
495
- isDisabled: !allowedDates(dayDatePointer) || !isInRange(dayDatePointer, minDate, maxDate),
496
- isOutdated: pointerDate.month !== dayDatePointer.getMonth() || !isInRange(dayDatePointer, minDate, maxDate),
497
- },
498
- ];
499
- dayDatePointer.setDate(dayDatePointer.getDate() + 1);
500
- } while (isSameWeek(dayDatePointer, weekDatePointer));
501
- calendar = [...calendar, row];
502
- weekDatePointer.setDate(weekDatePointer.getDate() + 7);
503
- } while (isSameMonth(new Date(pointerDate.year, pointerDate.month, pointerDate.day), dayDatePointer));
504
- return calendar;
7
+ const i18nDate = {
8
+ en: {
9
+ months: [
10
+ 'January',
11
+ 'February',
12
+ 'March',
13
+ 'April',
14
+ 'May',
15
+ 'June',
16
+ 'July',
17
+ 'August',
18
+ 'September',
19
+ 'October',
20
+ 'November',
21
+ 'December',
22
+ ],
23
+ monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
24
+ monthsShortGrouped: [
25
+ ['Jan', 'Feb', 'Mar', 'Apr'],
26
+ ['May', 'Jun', 'Jul', 'Aug'],
27
+ ['Sep', 'Oct', 'Nov', 'Dec'],
28
+ ],
29
+ weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
30
+ weekdaysShort: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
31
+ weekdaysMin: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
32
+ },
33
+ de: {
34
+ months: [
35
+ 'Januar',
36
+ 'Februar',
37
+ 'März',
38
+ 'April',
39
+ 'Mai',
40
+ 'Juni',
41
+ 'Juli',
42
+ 'August',
43
+ 'September',
44
+ 'Oktober',
45
+ 'November',
46
+ 'Dezember',
47
+ ],
48
+ monthsShort: ['Jan.', 'Feb.', 'März', 'Apr.', 'Mai', 'Juni', 'Juli', 'Aug.', 'Sep.', 'Okt.', 'Nov.', 'Dez.'],
49
+ monthsShortGrouped: [
50
+ ['Jan.', 'Feb.', 'März', 'Apr.'],
51
+ ['Mai', 'Juni', 'Juli', 'Aug.'],
52
+ ['Sep.', 'Okt.', 'Nov.', 'Dez.'],
53
+ ],
54
+ weekdays: ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'],
55
+ weekdaysShort: ['Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.', 'So.'],
56
+ weekdaysMin: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
57
+ },
58
+ fr: {
59
+ months: [
60
+ 'janvier',
61
+ 'février',
62
+ 'mars',
63
+ 'avril',
64
+ 'mai',
65
+ 'juin',
66
+ 'juillet',
67
+ 'août',
68
+ 'septembre',
69
+ 'octobre',
70
+ 'novembre',
71
+ 'décembre',
72
+ ],
73
+ monthsShort: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
74
+ monthsShortGrouped: [
75
+ ['janv.', 'févr.', 'mars', 'avr.'],
76
+ ['mai', 'juin', 'juil.', 'août'],
77
+ ['sept.', 'oct.', 'nov.', 'déc.'],
78
+ ],
79
+ weekdays: ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'],
80
+ weekdaysShort: ['lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.', 'dim.'],
81
+ weekdaysMin: ['lu', 'ma', 'me', 'je', 've', 'sa', 'di'],
82
+ },
83
+ it: {
84
+ months: [
85
+ 'gennaio',
86
+ 'febbraio',
87
+ 'marzo',
88
+ 'aprile',
89
+ 'maggio',
90
+ 'giugno',
91
+ 'luglio',
92
+ 'agosto',
93
+ 'settembre',
94
+ 'ottobre',
95
+ 'novembre',
96
+ 'dicembre',
97
+ ],
98
+ monthsShort: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'],
99
+ monthsShortGrouped: [
100
+ ['gen', 'feb', 'mar', 'apr'],
101
+ ['mag', 'giu', 'lug', 'ago'],
102
+ ['set', 'ott', 'nov', 'dic'],
103
+ ],
104
+ weekdays: ['lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato', 'domenica'],
105
+ weekdaysShort: ['lun', 'mar', 'mer', 'gio', 'ven', 'sab', 'dom'],
106
+ weekdaysMin: ['lu', 'ma', 'me', 'gi', 've', 'sa', 'do'],
107
+ },
108
+ };
109
+ /**
110
+ * Returns a JS Date instance of the exact moment
111
+ *
112
+ * ```typescript
113
+ * const date = now()
114
+ * // Wed Mar 10 2021 20:30:32 GMT+0100 (Central European Standard Time)
115
+ * ```
116
+ */
117
+ const now = () => new Date();
118
+ /**
119
+ * Returns `true` if the given date is valid
120
+ */
121
+ const isValidDate = (value) => {
122
+ if (isNil(value)) {
123
+ return false;
124
+ }
125
+ if (isNumber(value)) {
126
+ return false;
127
+ }
128
+ if (isDate(value)) {
129
+ return !isNaN(value.getTime());
130
+ }
131
+ return new Date(value).toString() !== 'Invalid Date';
132
+ };
133
+ /**
134
+ * Returns the year number of the given date
135
+ *
136
+ * ```typescript
137
+ * year(new Date(2020, 0, 1)) // 2020
138
+ * ```
139
+ */
140
+ const year = (date) => {
141
+ if (date && isValidDate(date)) {
142
+ return date.getFullYear();
143
+ }
144
+ throw new Error('Not a valid date');
145
+ };
146
+ /**
147
+ * Returns the month number of the given date
148
+ *
149
+ * ```typescript
150
+ * month(new Date(2020, 0, 1)) // 0
151
+ * ```
152
+ */
153
+ const month = (date) => {
154
+ if (date && isValidDate(date)) {
155
+ return date.getMonth();
156
+ }
157
+ throw new Error('Not a valid date');
158
+ };
159
+ /**
160
+ * Returns the day number of the given date
161
+ *
162
+ * ```typescript
163
+ * day(new Date(2020, 0, 1)) // 1
164
+ * ```
165
+ */
166
+ const day = (date) => {
167
+ if (date && isValidDate(date)) {
168
+ return date.getDate();
169
+ }
170
+ throw new Error('Not a valid date');
171
+ };
172
+ /**
173
+ * Returns the hours of the given date
174
+ */
175
+ const hours = (date) => {
176
+ if (date && isValidDate(date)) {
177
+ return date.getHours();
178
+ }
179
+ throw new Error('Not a valid date');
180
+ };
181
+ /**
182
+ * Returns the minutes of the given date
183
+ */
184
+ const minutes = (date) => {
185
+ if (date && isValidDate(date)) {
186
+ return date.getMinutes();
187
+ }
188
+ throw new Error('Not a valid date');
189
+ };
190
+ /**
191
+ * Returns the seconds of the given date
192
+ */
193
+ const seconds = (date) => {
194
+ if (date && isValidDate(date)) {
195
+ return date.getSeconds();
196
+ }
197
+ throw new Error('Not a valid date');
198
+ };
199
+ /**
200
+ * Returns the first day of the week of the given date.
201
+ */
202
+ const getFirstDayOfTheWeek = (date) => {
203
+ const weekdayDiff = [6, 0, 1, 2, 3, 4, 5];
204
+ const day = new Date(date);
205
+ day.setDate(day.getDate() - weekdayDiff[day.getDay()]);
206
+ return day;
207
+ };
208
+ /**
209
+ * Returns `true` when the year of the dates are the same
210
+ */
211
+ const isSameYear = (a, b) => (a === null || a === void 0 ? void 0 : a.getFullYear()) === (b === null || b === void 0 ? void 0 : b.getFullYear());
212
+ /**
213
+ * Returns `true` when the month of the dates are the same
214
+ */
215
+ const isSameMonth = (a, b) => isSameYear(a, b) && (a === null || a === void 0 ? void 0 : a.getMonth()) === (b === null || b === void 0 ? void 0 : b.getMonth());
216
+ /**
217
+ * Returns `true` when the day of the dates are the same
218
+ */
219
+ const isSameDay = (a, b) => isSameMonth(a, b) && (a === null || a === void 0 ? void 0 : a.getDate()) === (b === null || b === void 0 ? void 0 : b.getDate());
220
+ /**
221
+ * Returns `true` when the week of the dates are the same
222
+ */
223
+ const isSameWeek = (a, b) => isSameDay(getFirstDayOfTheWeek(a), getFirstDayOfTheWeek(b));
224
+ /**
225
+ * Returns `true` if the given datestring is valid
226
+ */
227
+ const isValidDateString = (datestring, format) => {
228
+ if (!isString(datestring) || !isString(format)) {
229
+ return false;
230
+ }
231
+ if (datestring.length < 6 || format.length < 6) {
232
+ return false;
233
+ }
234
+ const { day, month } = getDateParts(datestring, format);
235
+ if (day > 31 || month > 11 || day <= 0 || month < 0) {
236
+ return false;
237
+ }
238
+ const date = toDate(datestring, format);
239
+ if (isNil(date)) {
240
+ return false;
241
+ }
242
+ return date.toString() !== 'Invalid Date';
243
+ };
244
+ /**
245
+ * Returns `true` when the given date is not smaller than the minDate and not bigger than the maxDate.
246
+ *
247
+ * ```typescript
248
+ * isInRange(new Date(2020, 1, 1), new Date(2020, 0, 1), new Date(2020, 2, 1)) // true
249
+ * ```
250
+ */
251
+ const isInRange = (date, minDate, maxDate) => {
252
+ if (!date) {
253
+ return true;
254
+ }
255
+ if (minDate && date < minDate) {
256
+ return false;
257
+ }
258
+ if (maxDate && maxDate < date) {
259
+ return false;
260
+ }
261
+ return true;
262
+ };
263
+ const lookAhead = (iFormat, format, match, length = 2) => {
264
+ const increment = length - 1;
265
+ const followingCharacterMatches = format.charAt(iFormat + increment) === match;
266
+ const hasProperLength = iFormat + increment < format.length;
267
+ return hasProperLength && followingCharacterMatches;
268
+ };
269
+ const formatNumber = (value, len) => {
270
+ let num = String(value);
271
+ while (num.length < len) {
272
+ num = '0' + num;
273
+ }
274
+ return num;
275
+ };
276
+ const formatDate = (date, format) => {
277
+ if (!date) {
278
+ return '';
279
+ }
280
+ let output = '';
281
+ for (let iFormat = 0; iFormat < format.length; iFormat++) {
282
+ switch (format.charAt(iFormat)) {
283
+ case 'd':
284
+ if (lookAhead(iFormat, format, 'd')) {
285
+ output += formatNumber(date.getDate(), 2);
286
+ iFormat++;
287
+ }
288
+ else {
289
+ output += String(date.getDate());
290
+ }
291
+ break;
292
+ case 'm':
293
+ if (lookAhead(iFormat, format, 'm')) {
294
+ output += formatNumber(date.getMonth() + 1, 2);
295
+ iFormat++;
296
+ }
297
+ else {
298
+ output += String(date.getMonth() + 1);
299
+ }
300
+ break;
301
+ case 'y':
302
+ if (lookAhead(iFormat, format, 'y', 4)) {
303
+ iFormat += 3;
304
+ output += date.getFullYear();
305
+ }
306
+ else {
307
+ output += (date.getFullYear() % 100 < 10 ? '0' : '') + (date.getFullYear() % 100);
308
+ iFormat++;
309
+ }
310
+ break;
311
+ case 'h':
312
+ if (lookAhead(iFormat, format, 'h')) {
313
+ output += formatNumber(date.getHours(), 2);
314
+ iFormat++;
315
+ }
316
+ else {
317
+ output += String(date.getHours());
318
+ }
319
+ break;
320
+ case 'M':
321
+ if (lookAhead(iFormat, format, 'M')) {
322
+ output += formatNumber(date.getMinutes(), 2);
323
+ iFormat++;
324
+ }
325
+ else {
326
+ output += String(date.getMinutes());
327
+ }
328
+ break;
329
+ case 's':
330
+ if (lookAhead(iFormat, format, 's')) {
331
+ output += formatNumber(date.getSeconds(), 2);
332
+ iFormat++;
333
+ }
334
+ else {
335
+ output += String(date.getSeconds());
336
+ }
337
+ break;
338
+ default:
339
+ output += format.charAt(iFormat);
340
+ }
341
+ }
342
+ return output;
343
+ };
344
+ const FORMATTING_TOKENS = /(\[[^\[]*\])|(mm|dd|yyyy|yy|hh|MM|ss|.)/g;
345
+ const TWO_NUMERICS_REGEX = /\d\d/; // 00 - 99
346
+ const FOUR_NUMERICS_REGEX = /\d{4}/; // 0000 - 9999
347
+ const NON_NUMERIC_REGEX = /[^0-9]/g;
348
+ const YEAR = 'year';
349
+ const MONTH = 'month';
350
+ const DAY = 'day';
351
+ const HOUR = 'hour';
352
+ const MINUTE = 'minute';
353
+ const SECOND = 'second';
354
+ const parseFlags = {};
355
+ const addParseFlag = (token, regex, callback) => {
356
+ const tokens = Array.isArray(token) ? token : [token];
357
+ let func;
358
+ if (typeof callback === 'string') {
359
+ func = (input) => {
360
+ const value = parseInt(input, 10);
361
+ return { [callback]: value };
362
+ };
363
+ }
364
+ else {
365
+ func = callback;
366
+ }
367
+ tokens.forEach((key) => {
368
+ parseFlags[key] = [regex, func];
369
+ });
370
+ };
371
+ addParseFlag('yy', TWO_NUMERICS_REGEX, (input) => {
372
+ const year = new Date().getFullYear();
373
+ const cent = Math.floor(year / 100);
374
+ let value = parseInt(input, 10);
375
+ value = (value > 68 ? cent - 1 : cent) * 100 + value;
376
+ return { [YEAR]: value };
377
+ });
378
+ addParseFlag('yyyy', FOUR_NUMERICS_REGEX, YEAR);
379
+ addParseFlag('mm', TWO_NUMERICS_REGEX, (input) => ({ [MONTH]: parseInt(input, 10) - 1 }));
380
+ addParseFlag('dd', TWO_NUMERICS_REGEX, DAY);
381
+ addParseFlag('hh', TWO_NUMERICS_REGEX, HOUR);
382
+ addParseFlag('MM', TWO_NUMERICS_REGEX, MINUTE);
383
+ addParseFlag('ss', TWO_NUMERICS_REGEX, SECOND);
384
+ const getFullInputArray = (input, backupDate = new Date()) => {
385
+ const result = [0, 0, 1, 0, 0, 0];
386
+ const backupArr = [
387
+ backupDate.getFullYear(),
388
+ backupDate.getMonth(),
389
+ backupDate.getDate(),
390
+ backupDate.getHours(),
391
+ backupDate.getMinutes(),
392
+ backupDate.getSeconds(),
393
+ ];
394
+ let useBackup = true;
395
+ for (let i = 0; i < 7; i++) {
396
+ if (input[i] === undefined) {
397
+ result[i] = useBackup ? backupArr[i] : result[i];
398
+ }
399
+ else {
400
+ result[i] = input[i];
401
+ useBackup = false;
402
+ }
403
+ }
404
+ return result;
405
+ };
406
+ const createDate = (year, month, day, hour, minute, second) => {
407
+ if (!(year < 100 && year >= 0)) {
408
+ return new Date(year, month, day, hour, minute, second);
409
+ }
410
+ const date = new Date(year + 400, month, day, hour, minute, second);
411
+ if (isFinite(date.getFullYear())) {
412
+ date.setFullYear(year);
413
+ }
414
+ return date;
415
+ };
416
+ const makeParser = (dateString, format) => {
417
+ const tokens = format.match(FORMATTING_TOKENS);
418
+ if (!tokens) {
419
+ throw new Error();
420
+ }
421
+ const { length } = tokens;
422
+ let mark = {};
423
+ for (let i = 0; i < length; i += 1) {
424
+ const token = tokens[i];
425
+ const parseTo = parseFlags[token];
426
+ if (!parseTo) {
427
+ const word = token.replace(/^\[|\]$/g, '');
428
+ if (dateString.indexOf(word) === 0) {
429
+ dateString = dateString.substr(word.length);
430
+ }
431
+ else {
432
+ throw new Error('not match');
433
+ }
434
+ }
435
+ else {
436
+ const regex = parseTo[0];
437
+ const parser = parseTo[1];
438
+ const value = (regex.exec(dateString) || [])[0];
439
+ const obj = parser(value);
440
+ mark = Object.assign(Object.assign({}, mark), obj);
441
+ dateString = dateString.replace(value, '');
442
+ }
443
+ }
444
+ return mark;
445
+ };
446
+ const getCleanDateString = (dirtyDateString, format) => {
447
+ if (dirtyDateString.length === format.length) {
448
+ return dirtyDateString;
449
+ }
450
+ const separator = dirtyDateString.match(NON_NUMERIC_REGEX)[0];
451
+ // pad signle digits to follow supported dateformats
452
+ return dirtyDateString
453
+ .split(separator)
454
+ .map((s) => (s.length === 1 ? '0' + s : s))
455
+ .join(separator);
456
+ };
457
+ const getDateParts = (dirtyDateString, format) => {
458
+ const dateString = getCleanDateString(dirtyDateString, format);
459
+ return makeParser(dateString, format);
460
+ };
461
+ const toDate = (dirtyDateString, format) => {
462
+ try {
463
+ const { backupDate = new Date() } = {};
464
+ const { year, month, day, hour, minute, second, date } = getDateParts(dirtyDateString, format);
465
+ if (date) {
466
+ return date;
467
+ }
468
+ const inputArray = [year, month, day, hour, minute, second];
469
+ let parsedDate;
470
+ const result = getFullInputArray(inputArray, backupDate);
471
+ parsedDate = createDate(...result);
472
+ return parsedDate;
473
+ }
474
+ catch (e) {
475
+ return new Date(NaN);
476
+ }
477
+ };
478
+ const createCalendarGrid = (calendarGridArguments) => {
479
+ const { firstDateOfBox, allowedDates, dateFormat, selectedDate, minDate, maxDate, pointerDate } = calendarGridArguments;
480
+ const weekDatePointer = new Date(firstDateOfBox);
481
+ const dayDatePointer = new Date(firstDateOfBox);
482
+ let calendar = [];
483
+ do {
484
+ let row = [];
485
+ do {
486
+ row = [
487
+ ...row,
488
+ {
489
+ date: new Date(dayDatePointer),
490
+ display: formatDate(dayDatePointer, dateFormat),
491
+ dateString: formatDate(dayDatePointer, dateFormat),
492
+ label: day(dayDatePointer).toString(),
493
+ isToday: isSameDay(dayDatePointer, now()),
494
+ isSelected: selectedDate && isSameDay(dayDatePointer, selectedDate),
495
+ isDisabled: !allowedDates(dayDatePointer) || !isInRange(dayDatePointer, minDate, maxDate),
496
+ isOutdated: pointerDate.month !== dayDatePointer.getMonth() || !isInRange(dayDatePointer, minDate, maxDate),
497
+ },
498
+ ];
499
+ dayDatePointer.setDate(dayDatePointer.getDate() + 1);
500
+ } while (isSameWeek(dayDatePointer, weekDatePointer));
501
+ calendar = [...calendar, row];
502
+ weekDatePointer.setDate(weekDatePointer.getDate() + 7);
503
+ } while (isSameMonth(new Date(pointerDate.year, pointerDate.month, pointerDate.day), dayDatePointer));
504
+ return calendar;
505
505
  };
506
506
 
507
- var SixDateFormats;
508
- (function (SixDateFormats) {
509
- SixDateFormats["DDMMYYY_DOT"] = "dd.mm.yyyy";
510
- SixDateFormats["YYYYMMDD_DASH"] = "yyyy-mm-dd";
511
- SixDateFormats["DDMMYYYY_DASH"] = "dd-mm-yyyy";
512
- SixDateFormats["DDMMYYYY_SLASH"] = "dd/mm/yyyy";
513
- SixDateFormats["YYYYMMDD_SLASH"] = "yyyy/mm/dd";
514
- SixDateFormats["DDMMYY_DOT"] = "dd.mm.yy";
515
- SixDateFormats["YYMMDD_DASH"] = "yy-mm-dd";
516
- SixDateFormats["DDMMYY_DASH"] = "dd-mm-yy";
517
- SixDateFormats["DDMMYY_SLASH"] = "dd/mm/yy";
518
- SixDateFormats["YYMMDD_SLASH"] = "yy/mm/dd";
519
- SixDateFormats["DDMMYYY_DOT_TIME"] = "dd.mm.yyyy hh:MM:ss";
520
- SixDateFormats["YYYYMMDD_DASH_TIME"] = "yyyy-mm-dd hh:MM:ss";
521
- SixDateFormats["DDMMYYYY_DASH_TIME"] = "dd-mm-yyyy hh:MM:ss";
522
- SixDateFormats["DDMMYYYY_SLASH_TIME"] = "dd/mm/yyyy hh:MM:ss";
523
- SixDateFormats["YYYYMMDD_SLASH_TIME"] = "yyyy/mm/dd hh:MM:ss";
524
- SixDateFormats["DDMMYY_DOT_TIME"] = "dd.mm.yy hh:MM:ss";
525
- SixDateFormats["YYMMDD_DASH_TIME"] = "yy-mm-dd hh:MM:ss";
526
- SixDateFormats["DDMMYY_DASH_TIME"] = "dd-mm-yy hh:MM:ss";
527
- SixDateFormats["DDMMYY_SLASH_TIME"] = "dd/mm/yy hh:MM:ss";
528
- SixDateFormats["YYMMDD_SLASH_TIME"] = "yy/mm/dd hh:MM:ss";
507
+ var SixDateFormats;
508
+ (function (SixDateFormats) {
509
+ SixDateFormats["DDMMYYY_DOT"] = "dd.mm.yyyy";
510
+ SixDateFormats["YYYYMMDD_DASH"] = "yyyy-mm-dd";
511
+ SixDateFormats["DDMMYYYY_DASH"] = "dd-mm-yyyy";
512
+ SixDateFormats["DDMMYYYY_SLASH"] = "dd/mm/yyyy";
513
+ SixDateFormats["YYYYMMDD_SLASH"] = "yyyy/mm/dd";
514
+ SixDateFormats["DDMMYY_DOT"] = "dd.mm.yy";
515
+ SixDateFormats["YYMMDD_DASH"] = "yy-mm-dd";
516
+ SixDateFormats["DDMMYY_DASH"] = "dd-mm-yy";
517
+ SixDateFormats["DDMMYY_SLASH"] = "dd/mm/yy";
518
+ SixDateFormats["YYMMDD_SLASH"] = "yy/mm/dd";
519
+ SixDateFormats["DDMMYYY_DOT_TIME"] = "dd.mm.yyyy hh:MM:ss";
520
+ SixDateFormats["YYYYMMDD_DASH_TIME"] = "yyyy-mm-dd hh:MM:ss";
521
+ SixDateFormats["DDMMYYYY_DASH_TIME"] = "dd-mm-yyyy hh:MM:ss";
522
+ SixDateFormats["DDMMYYYY_SLASH_TIME"] = "dd/mm/yyyy hh:MM:ss";
523
+ SixDateFormats["YYYYMMDD_SLASH_TIME"] = "yyyy/mm/dd hh:MM:ss";
524
+ SixDateFormats["DDMMYY_DOT_TIME"] = "dd.mm.yy hh:MM:ss";
525
+ SixDateFormats["YYMMDD_DASH_TIME"] = "yy-mm-dd hh:MM:ss";
526
+ SixDateFormats["DDMMYY_DASH_TIME"] = "dd-mm-yy hh:MM:ss";
527
+ SixDateFormats["DDMMYY_SLASH_TIME"] = "dd/mm/yy hh:MM:ss";
528
+ SixDateFormats["YYMMDD_SLASH_TIME"] = "yy/mm/dd hh:MM:ss";
529
529
  })(SixDateFormats || (SixDateFormats = {}));
530
530
 
531
- const MonthSelection = ({ locale, selectedDate, onClickMonthCell }) => {
532
- const isToday = (value) => locale.monthsShort[now().getMonth()] === value;
533
- const isSelectedMonth = (value) => (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getMonth()) === locale.monthsShort.findIndex((m) => m === value);
534
- return (h("table", { class: "datepicker-table", part: "month-selection" },
535
- h("tbody", null, locale.monthsShortGrouped.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((month) => (h("td", { onClick: () => onClickMonthCell(month), class: {
536
- 'datepicker-table__cell': true,
537
- 'datepicker-table__cell--is-today': isToday(month),
538
- 'datepicker-table__cell--is-selected': isSelectedMonth(month),
539
- } }, month)))))))));
531
+ const MonthSelection = ({ locale, selectedDate, onClickMonthCell }) => {
532
+ const isToday = (value) => locale.monthsShort[now().getMonth()] === value;
533
+ const isSelectedMonth = (value) => (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getMonth()) === locale.monthsShort.findIndex((m) => m === value);
534
+ return (h("table", { class: "datepicker-table", part: "month-selection" },
535
+ h("tbody", null, locale.monthsShortGrouped.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((month) => (h("td", { onClick: () => onClickMonthCell(month), class: {
536
+ 'datepicker-table__cell': true,
537
+ 'datepicker-table__cell--is-today': isToday(month),
538
+ 'datepicker-table__cell--is-selected': isSelectedMonth(month),
539
+ } }, month)))))))));
540
540
  };
541
541
 
542
- const DaySelection = ({ locale, calendarGrid, onClickDateCell }) => {
543
- return (h("table", { class: "datepicker-table", part: "day-selection" },
544
- h("thead", { part: "weekday-header" }, locale.weekdaysMin.map((weekday) => (h("th", { class: "datepicker__cell" }, weekday)))),
545
- h("tbody", null, calendarGrid.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((cell) => (h("td", { "data-date": cell.dateString, onClick: () => onClickDateCell(cell), class: {
546
- 'datepicker-table__cell': true,
547
- 'datepicker-table__cell--is-today': cell.isToday,
548
- 'datepicker-table__cell--is-selected': cell.isSelected,
549
- 'datepicker-table__cell--is-outdated': cell.isOutdated,
550
- 'datepicker-table__cell--is-disabled': cell.isDisabled,
551
- 'datepicker-table__cell--is-selectable': !cell.isDisabled,
552
- } }, cell.label)))))))));
542
+ const DaySelection = ({ locale, calendarGrid, onClickDateCell }) => {
543
+ return (h("table", { class: "datepicker-table", part: "day-selection" },
544
+ h("thead", { part: "weekday-header" }, locale.weekdaysMin.map((weekday) => (h("th", { class: "datepicker__cell" }, weekday)))),
545
+ h("tbody", null, calendarGrid.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((cell) => (h("td", { "data-date": cell.dateString, onClick: () => onClickDateCell(cell), class: {
546
+ 'datepicker-table__cell': true,
547
+ 'datepicker-table__cell--is-today': cell.isToday,
548
+ 'datepicker-table__cell--is-selected': cell.isSelected,
549
+ 'datepicker-table__cell--is-outdated': cell.isOutdated,
550
+ 'datepicker-table__cell--is-disabled': cell.isDisabled,
551
+ 'datepicker-table__cell--is-selectable': !cell.isDisabled,
552
+ } }, cell.label)))))))));
553
553
  };
554
554
 
555
- const YearSelection = ({ selectedDate, yearSelection, onClickYearCell }) => {
556
- return (h("table", { class: "datepicker-table", part: "year-selection" },
557
- h("tbody", null, yearSelection.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((year) => (h("td", { onClick: () => onClickYearCell(year), class: {
558
- 'datepicker-table__cell': true,
559
- 'datepicker-table__cell--is-today': now().getFullYear() === year,
560
- 'datepicker-table__cell--is-selected': (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getFullYear()) === year,
561
- } }, year)))))))));
555
+ const YearSelection = ({ selectedDate, yearSelection, onClickYearCell }) => {
556
+ return (h("table", { class: "datepicker-table", part: "year-selection" },
557
+ h("tbody", null, yearSelection.map((row) => (h("tr", { class: "datepicker-table__row" }, row.map((year) => (h("td", { onClick: () => onClickYearCell(year), class: {
558
+ 'datepicker-table__cell': true,
559
+ 'datepicker-table__cell--is-today': now().getFullYear() === year,
560
+ 'datepicker-table__cell--is-selected': (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getFullYear()) === year,
561
+ } }, year)))))))));
562
562
  };
563
563
 
564
564
  const sixDatepickerCss = ":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}:host{display:block;font-family:var(--six-font-family)}.datepicker__container{position:relative}.datepicker__popup{min-width:400px;background-color:white;padding:0.5em 0.5em 1.5em;box-shadow:0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12);user-select:none;position:absolute;z-index:var(--six-z-index-dropdown);right:0;left:0}.datepicker__popup--is-up{bottom:100%;min-height:382px}.datepicker__popup--is-inline{position:initial;box-shadow:none;border:1px solid var(--six-color-web-rock-400)}.datepicker-header{display:flex;justify-content:space-between;border-bottom:1px solid var(--six-color-web-rock-400);padding:0.5em;margin-bottom:1em}.datepicker-header svg{fill:var(--six-color-web-rock-900);stroke:none}.datepicker-header__btn{cursor:pointer;width:2.5em;height:2.5em;display:flex;vertical-align:middle;align-items:center;justify-content:center}.datepicker-header__btn:hover{background-color:var(--six-color-web-rock-100);border-radius:100%}.datepicker-header__label{display:flex}.datepicker-header__label>div{cursor:pointer;padding:0.5em;display:flex;vertical-align:middle;align-items:center;justify-content:center}.datepicker-header__label>div:hover{background-color:var(--six-color-web-rock-100)}.datepicker-table{width:100%}.datepicker-table__cell{text-align:center;width:2.5rem;height:2.5rem;cursor:pointer}.datepicker-table__cell:hover{background-color:var(--six-table-row-background-color-hover)}.datepicker-table__cell--is-today{border:1px solid var(--six-color-web-rock-400)}.datepicker-table__cell--is-selected{background-color:var(--six-color-red);color:var(--six-color-white)}.datepicker-table__cell--is-disabled{background-color:var(--six-color-web-rock-200);cursor:initial}.datepicker-table__cell--is-disabled:hover{background-color:var(--six-color-web-rock-200)}.datepicker-table__cell--is-outdated{color:var(--six-color-web-rock-400)}.datepicker-clear{display:inline-flex;align-items:center;font-size:inherit;color:var(--six-input-icon-color);border:none;background:none;padding:0;transition:var(--six-transition-fast) color;cursor:pointer}.datepicker-clear:hover{color:var(--six-input-icon-color-hover)}.datepicker-clear:focus{outline:none}.datepicker-clear--right{right:0;position:absolute}.datepicker-clear--left{right:35px;position:absolute}.input--empty .datepicker-clear{visibility:hidden}.prefix{cursor:pointer}.prefix--right{right:0;display:inline-flex;position:absolute;font-size:inherit;color:var(--six-input-icon-color);border:none;background:none;margin-right:var(--six-input-spacing-medium);transition:var(--six-transition-fast) color}six-timepicker::part(popup){border:none;padding:0.5em 0.5em 0;min-height:0}";
565
565
 
566
- const NUMBER_OF_YEARS_SHOWN = 25;
567
- const MIN_POPUP_HEIGHT = 400;
568
- var SelectionMode;
569
- (function (SelectionMode) {
570
- SelectionMode["DAY"] = "day";
571
- SelectionMode["MONTH"] = "month";
572
- SelectionMode["YEAR"] = "year";
573
- })(SelectionMode || (SelectionMode = {}));
574
- const getYearSelectionAroundYear = (year) => {
575
- const numberOfElementsPerRow = 5;
576
- return Array.from(new Array(NUMBER_OF_YEARS_SHOWN).keys())
577
- .map((n) => n + year - Math.floor(NUMBER_OF_YEARS_SHOWN / 2))
578
- .reduce((curr, item, index) => {
579
- if (index % numberOfElementsPerRow === 0) {
580
- curr.push([]);
581
- }
582
- curr[curr.length - 1].push(item);
583
- return curr;
584
- }, []);
585
- };
586
- let SixDatepicker = class {
587
- constructor(hostRef) {
588
- registerInstance(this, hostRef);
589
- this.sixSelect = createEvent(this, "six-datepicker-select", 7);
590
- this.sixClear = createEvent(this, "six-datepicker-clear", 7);
591
- this.sixBlur = createEvent(this, "six-datepicker-blur", 7);
592
- this.eventListeners = new EventListeners();
593
- this.selectedDate = null;
594
- this.pointerDate = SixDatepicker.getCurrentDateAsPointer();
595
- this.selectionMode = SelectionMode.DAY;
596
- this.isDropDownContentUp = false;
597
- /**
598
- * Set the type.
599
- */
600
- this.type = 'date';
601
- /**
602
- * The language used to render the weekdays and months.
603
- */
604
- this.locale = 'en';
605
- /** Indicates whether or not the calendar dropdown is open on startup. You can use this in lieu of the show/hide methods. */
606
- this.open = false;
607
- /** Indicates whether or not the calendar should be shown as an inline (always open) component */
608
- this.inline = false;
609
- /**
610
- * If `true` the user can only select a date via the component in the popup, but not directly edit the input field.
611
- */
612
- this.readonly = false;
613
- /**
614
- * If `true` the component is disabled.
615
- */
616
- this.disabled = false;
617
- /**
618
- * Callback to determine which date in the datepicker should be selectable.
619
- * the callback function will get a datestring as an argument, e.g. '2021-07-04'
620
- *
621
- * Usage e.g.:
622
- * const datepicker = document.getElementById('allowed-date-picker');
623
- * datepicker.allowedDates = datestring => parseInt(datestring.split('-')[2], 10) % 2 === 0;
624
- */
625
- this.allowedDates = () => true;
626
- /**
627
- * The minimum datetime allowed. Value must be a date object
628
- */
629
- this.min = null;
630
- /**
631
- * The maximum datetime allowed. Value must be a date object
632
- */
633
- this.max = null;
634
- /**
635
- * Closes the datepicker dropdown after selection
636
- */
637
- this.closeOnSelect = this.type === 'date';
638
- /** Datepicker size. */
639
- this.size = 'medium';
640
- /**
641
- * The value of the form field, which accepts a date object.
642
- */
643
- this.value = null;
644
- /** Define the dateFormat. Valid formats are:
645
- * 'dd.mm.yyyy'
646
- * 'yyyy-mm-dd'
647
- * 'dd-mm-yyyy'
648
- * 'dd/mm/yyyy'
649
- * 'yyyy/mm/dd'
650
- * 'dd.mm.yy'
651
- * 'yy-mm-dd'
652
- * 'dd-mm-yy'
653
- * 'dd/mm/yy'
654
- * 'yy/mm/dd'
655
- * */
656
- this.dateFormat = SixDateFormats.DDMMYYY_DOT;
657
- /**
658
- * Set the amount of time, in milliseconds, to wait to trigger the `dateChange` event after each keystroke.
659
- */
660
- this.debounce = DEFAULT_DEBOUNCE_FAST;
661
- /** Set to display the error text on blur and not when typing */
662
- this.errorOnBlur = false;
663
- /** The input's error text. Alternatively, you can use the error-text slot. */
664
- this.errorText = '';
665
- /** The input's label. Alternatively, you can use the label slot. */
666
- this.label = '';
667
- /** The input's name attribute. */
668
- this.name = '';
669
- /** Set to true to add a clear button when the input is populated. */
670
- this.clearable = false;
671
- /** Set the position of the icon */
672
- this.iconPosition = 'left';
673
- /**
674
- * Enable this option to prevent the panel from being clipped when the component is placed inside a container with
675
- * `overflow: auto|scroll`.
676
- */
677
- this.hoist = false;
678
- this.defaultValue = null;
679
- this.handleDocumentKeyDown = (event) => {
680
- // Close when escape is pressed
681
- if (this.open && event.key === 'Escape') {
682
- event.stopPropagation();
683
- this.closePopup();
684
- void this.inputElement.setFocus();
685
- }
686
- // Handle tabbing
687
- if (event.key === 'Tab') {
688
- this.closePopup();
689
- }
690
- };
691
- this.handleDocumentMouseDown = (event) => {
692
- // Close when clicking outside of the containing element
693
- const path = event.composedPath();
694
- if (!path.includes(this.container)) {
695
- this.closePopup();
696
- return;
697
- }
698
- };
699
- this.onTimepickerChange = (sixTimepickerChange) => {
700
- const time = sixTimepickerChange.detail.value;
701
- const newDate = new Date();
702
- if (this.selectedDate) {
703
- newDate.setFullYear(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate());
704
- }
705
- newDate.setHours(time[SixTimePropertyName.HOURS], time[SixTimePropertyName.MINUTES], time[SixTimePropertyName.SECONDS]);
706
- this.updateValue(newDate);
707
- this.updatePointerDates();
708
- };
709
- this.onClickDateCell = (cell) => {
710
- if (!cell.isDisabled) {
711
- void this.select(cell.dateString);
712
- }
713
- };
714
- this.onClickMonthCell = (selectedMonth) => {
715
- const month = i18nDate[this.locale].monthsShort.findIndex((monthShort) => monthShort === selectedMonth);
716
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { month });
717
- this.selectionMode = SelectionMode.DAY;
718
- };
719
- this.onClickYearCell = (year) => {
720
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year });
721
- this.selectionMode = SelectionMode.DAY;
722
- };
723
- this.handleInputChange = (event) => {
724
- const inputValue = this.inputElement.value;
725
- if (!isValidDateString(inputValue, this.dateFormat)) {
726
- return;
727
- }
728
- const inputValueDate = toDate(inputValue, this.dateFormat);
729
- if (inputValueDate === undefined) {
730
- return;
731
- }
732
- if (this.min && this.min.getTime() > inputValueDate.getTime()) {
733
- return;
734
- }
735
- if (this.max && this.max.getTime() < inputValueDate.getTime()) {
736
- return;
737
- }
738
- this.updateIfChanged(inputValueDate);
739
- event.stopPropagation();
740
- const datesOnly = inputValue.replace(/[^\d]/g, '');
741
- let isDateValid = !inputValue;
742
- if (inputValue && datesOnly.length >= 6) {
743
- const date = toDate(inputValue, this.dateFormat);
744
- const datestring = formatDate(date, this.dateFormat);
745
- if (isValidDateString(datestring, this.dateFormat)) {
746
- this.selectedDate = toDate(datestring, this.dateFormat);
747
- this.updatePointerDates();
748
- this.updateValue(this.selectedDate);
749
- isDateValid = true;
750
- }
751
- }
752
- this.displayCustomMessage(isDateValid);
753
- };
754
- this.handleOnBlur = (event) => {
755
- // clear the value if the user deleted the date
756
- if (this.inputElement.value === '' && isValidDate(this.value)) {
757
- this.value = undefined;
758
- }
759
- event.stopPropagation();
760
- const inputValue = this.inputElement.value;
761
- const inputValueDate = toDate(inputValue, this.dateFormat);
762
- const formattedDate = formatDate(this.value, this.dateFormat);
763
- if (inputValueDate && inputValue !== formattedDate) {
764
- // properly format date if necessary
765
- this.inputElement.value = formattedDate;
766
- }
767
- this.sixBlur.emit(this.value);
768
- };
769
- }
770
- debounceChanged() {
771
- this.sixSelect = debounceEvent(this.sixSelect, this.debounce);
772
- }
773
- /**
774
- * Update the native input element when the value changes
775
- */
776
- valueChanged() {
777
- // map unreadable values to undefined to make the datepicker fault-tolerant
778
- if (this.isValidValue()) {
779
- console.warn('Encountered unreadable date, will map to undefined. Received value', this.value);
780
- this.value = undefined;
781
- return;
782
- }
783
- this.selectedDate = this.value;
784
- this.updatePointerDates();
785
- this.sixSelect.emit(this.value);
786
- }
787
- async resizeHandler() {
788
- this.calcIsDropDownContentUp();
789
- this.moveOpenHoistedPopup();
790
- this.adjustPopupPosition();
791
- }
792
- async scrollHandler() {
793
- this.calcIsDropDownContentUp();
794
- this.moveOpenHoistedPopup();
795
- }
796
- get container() {
797
- return this.containingElement || this.host;
798
- }
799
- get firstDateOfBox() {
800
- const date = new Date(this.pointerDate.year, this.pointerDate.month, 1);
801
- return getFirstDayOfTheWeek(date);
802
- }
803
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
804
- async reportValidity() {
805
- return this.inputElement.reportValidity();
806
- }
807
- /** Checks for validity. */
808
- async checkValidity() {
809
- return this.inputElement.checkValidity();
810
- }
811
- /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
812
- async setCustomValidity(message) {
813
- await this.inputElement.setCustomValidity(message);
814
- }
815
- /** Resets the formcontrol */
816
- async reset() {
817
- this.value = this.defaultValue;
818
- this.inputElement.value = formatDate(this.defaultValue, this.dateFormat);
819
- await this.inputElement.reset();
820
- }
821
- isValidValue() {
822
- if (this.value === undefined || this.value === null) {
823
- return false;
824
- }
825
- if (!(this.value instanceof Date)) {
826
- return true;
827
- }
828
- return this.value instanceof Date && isNaN(this.value);
829
- }
830
- get calendarGrid() {
831
- return createCalendarGrid({
832
- firstDateOfBox: this.firstDateOfBox,
833
- allowedDates: this.allowedDates,
834
- dateFormat: this.dateFormat,
835
- locale: this.locale,
836
- selectedDate: this.selectedDate,
837
- minDate: this.min,
838
- maxDate: this.max,
839
- pointerDate: this.pointerDate,
840
- });
841
- }
842
- calcIsDropDownContentUp() {
843
- if (!this.inputElement || !this.wrapper) {
844
- return;
845
- }
846
- const inputBoundingRect = this.inputElement.getBoundingClientRect();
847
- const wrapperBoundingRect = this.wrapper.getBoundingClientRect();
848
- const minPopupHeight = Math.max(wrapperBoundingRect.height, MIN_POPUP_HEIGHT);
849
- const moreSpaceInTop = inputBoundingRect.y > window.innerHeight / 2;
850
- this.isDropDownContentUp = moreSpaceInTop && window.innerHeight < inputBoundingRect.bottom + minPopupHeight;
851
- }
852
- getMonthStringForIndex(index) {
853
- return i18nDate[this.locale].months[index];
854
- }
855
- previousUnit() {
856
- if (this.selectionMode === SelectionMode.DAY) {
857
- this.previousMonth();
858
- }
859
- else if (this.selectionMode === SelectionMode.MONTH) {
860
- this.previousYear();
861
- }
862
- else if (this.selectionMode === SelectionMode.YEAR) {
863
- this.previousYearGroup();
864
- }
865
- }
866
- previousYear() {
867
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year - 1 });
868
- }
869
- previousYearGroup() {
870
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year - NUMBER_OF_YEARS_SHOWN });
871
- }
872
- previousMonth() {
873
- if (this.pointerDate.month === 0) {
874
- this.pointerDate = { year: this.pointerDate.year - 1, month: 11, day: 1, hours: 0, minutes: 0, seconds: 0 };
875
- }
876
- else {
877
- this.pointerDate = {
878
- year: this.pointerDate.year,
879
- month: this.pointerDate.month - 1,
880
- day: 1,
881
- hours: 0,
882
- minutes: 0,
883
- seconds: 0,
884
- };
885
- }
886
- }
887
- nextUnit() {
888
- if (this.selectionMode === SelectionMode.DAY) {
889
- this.nextMonth();
890
- }
891
- else if (this.selectionMode === SelectionMode.MONTH) {
892
- this.nextYear();
893
- }
894
- else if (this.selectionMode === SelectionMode.YEAR) {
895
- this.nextYearGroup();
896
- }
897
- }
898
- nextMonth() {
899
- if (this.pointerDate.month === 11) {
900
- this.pointerDate = { year: this.pointerDate.year + 1, month: 0, day: 1, hours: 0, minutes: 0, seconds: 0 };
901
- }
902
- else {
903
- this.pointerDate = {
904
- year: this.pointerDate.year,
905
- month: this.pointerDate.month + 1,
906
- day: 1,
907
- hours: 0,
908
- minutes: 0,
909
- seconds: 0,
910
- };
911
- }
912
- }
913
- nextYear() {
914
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year + 1 });
915
- }
916
- nextYearGroup() {
917
- this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year + NUMBER_OF_YEARS_SHOWN });
918
- }
919
- openCalendar() {
920
- if (!this.open && !this.disabled) {
921
- this.open = true;
922
- this.setupEventListenersForOpenPopup();
923
- }
924
- }
925
- setupEventListenersForOpenPopup() {
926
- this.eventListeners.add(document, 'keydown', this.handleDocumentKeyDown);
927
- this.eventListeners.add(document, 'mousedown', this.handleDocumentMouseDown);
928
- }
929
- handleClearClick(event) {
930
- event.stopPropagation();
931
- void this.select(undefined);
932
- this.sixClear.emit();
933
- }
934
- closePopup() {
935
- if (this.inline) {
936
- return;
937
- }
938
- this.open = false;
939
- this.eventListeners.remove(document, 'keydown', this.handleDocumentKeyDown);
940
- this.eventListeners.remove(document, 'mousedown', this.handleDocumentMouseDown);
941
- this.selectionMode = SelectionMode.DAY;
942
- }
943
- updatePointerDates() {
944
- const date = this.getPointerDate();
945
- if (this.differsFromPointerDate(date)) {
946
- this.pointerDate = {
947
- year: year(date),
948
- month: month(date),
949
- day: day(date),
950
- hours: hours(date),
951
- minutes: minutes(date),
952
- seconds: seconds(date),
953
- };
954
- }
955
- }
956
- differsFromPointerDate(date) {
957
- return (this.pointerDate.day !== day(date) ||
958
- this.pointerDate.month !== month(date) ||
959
- this.pointerDate.year !== year(date) ||
960
- this.pointerDate.hours !== hours(date) ||
961
- this.pointerDate.minutes !== minutes(date) ||
962
- this.pointerDate.seconds !== seconds(date));
963
- }
964
- getPointerDate() {
965
- if (this.selectedDate !== undefined && this.selectedDate !== null) {
966
- return this.selectedDate;
967
- }
968
- if (isNil(this.defaultDate)) {
969
- return now();
970
- }
971
- else {
972
- return this.defaultDate && toDate(this.defaultDate, this.dateFormat);
973
- }
974
- }
975
- updateValue(newDate) {
976
- this.displayCustomMessage(true);
977
- this.updateIfChanged(newDate);
978
- }
979
- updateIfChanged(newDate) {
980
- var _a;
981
- if (((_a = this.value) === null || _a === void 0 ? void 0 : _a.getTime()) === (newDate === null || newDate === void 0 ? void 0 : newDate.getTime())) {
982
- return;
983
- }
984
- this.value = newDate;
985
- }
986
- /**
987
- * Selects an option
988
- */
989
- async select(datestring) {
990
- if (!datestring) {
991
- this.updateValue(undefined);
992
- }
993
- else {
994
- const newDate = toDate(datestring, this.dateFormat);
995
- newDate.setHours(this.pointerDate.hours, this.pointerDate.minutes, this.pointerDate.seconds);
996
- this.updateValue(newDate);
997
- }
998
- this.updatePointerDates();
999
- if (this.closeOnSelect) {
1000
- this.closePopup();
1001
- }
1002
- }
1003
- componentWillLoad() {
1004
- this.validateProps();
1005
- this.defaultValue = this.value;
1006
- this.selectedDate = this.value;
1007
- this.updatePointerDates();
1008
- this.updateValue(this.value);
1009
- if (this.inline) {
1010
- this.open = true;
1011
- }
1012
- if (this.open) {
1013
- this.setupEventListenersForOpenPopup();
1014
- }
1015
- }
1016
- validateProps() {
1017
- if (this.value !== null && this.value !== undefined && !(this.value instanceof Date)) {
1018
- throw new Error('Datepicker no longer supports strings as value. Use a date object instead!');
1019
- }
1020
- if (this.min !== null && this.min !== undefined && !(this.min instanceof Date)) {
1021
- throw new Error('Datepicker no longer supports strings as min. Use a date object instead!');
1022
- }
1023
- if (this.max !== null && this.max !== undefined && !(this.max instanceof Date)) {
1024
- throw new Error('Datepicker no longer supports strings as min. Use a date object instead!');
1025
- }
1026
- }
1027
- componentDidLoad() {
1028
- this.eventListeners.add(this.inputElement, 'six-input-input', debounce(this.handleInputChange, this.debounce));
1029
- this.eventListeners.add(this.inputElement, 'six-input-blur', this.handleOnBlur);
1030
- }
1031
- renderHeader() {
1032
- return (h("header", { class: "datepicker-header", part: "header" }, h("div", { class: "datepicker-header__btn prev", onClick: () => this.previousUnit() }, h("svg", { viewBox: "0 5 13 13", width: "14", height: "23" }, h("path", { d: "M11.67 3.87L9.9 2.1 0 12l9.9 9.9 1.77-1.77L3.54 12z" }))), h("div", { class: "datepicker-header__label" }, this.selectionMode === SelectionMode.DAY && (h("div", { onClick: () => (this.selectionMode = SelectionMode.MONTH) }, h("span", { class: "datepicker-header__label-month" }, this.getMonthStringForIndex(this.pointerDate.month)), h("span", null, h("svg", { viewBox: "-3 -4 24 24", width: "20", height: "20" }, h("polyline", { points: "6 9 12 15 18 9" }))))), this.selectionMode !== SelectionMode.YEAR && (h("div", { onClick: () => (this.selectionMode = SelectionMode.YEAR) }, h("span", { class: "datepicker-header__label-year" }, this.pointerDate.year), h("span", null, h("svg", { viewBox: "-3 -4 24 24", width: "20", height: "20" }, h("polyline", { points: "6 9 12 15 18 9" }))))), this.selectionMode === SelectionMode.YEAR && (h("div", null, this.pointerDate.year - Math.floor(NUMBER_OF_YEARS_SHOWN / 2), " \u2013", ' ', this.pointerDate.year + Math.floor(NUMBER_OF_YEARS_SHOWN / 2)))), h("div", { class: "datepicker-header__btn next", onClick: () => this.nextUnit() }, h("svg", { viewBox: "5 5 13 13", width: "14", height: "23" }, h("path", { d: "M5.88 4.12L13.76 12l-7.88 7.88L8 22l10-10L8 2z" })))));
1033
- }
1034
- renderBody() {
1035
- switch (this.selectionMode) {
1036
- case SelectionMode.DAY:
1037
- return (h(DaySelection, { locale: i18nDate[this.locale], calendarGrid: this.calendarGrid, onClickDateCell: this.onClickDateCell }));
1038
- case SelectionMode.MONTH:
1039
- return (h(MonthSelection, { locale: i18nDate[this.locale], selectedDate: this.selectedDate, onClickMonthCell: this.onClickMonthCell }));
1040
- case SelectionMode.YEAR:
1041
- return (h(YearSelection, { selectedDate: this.selectedDate, yearSelection: getYearSelectionAroundYear(this.pointerDate.year), onClickYearCell: this.onClickYearCell }));
1042
- }
1043
- }
1044
- renderCustomIcon() {
1045
- const icon = hasSlot(this.host, 'custom-icon') ? (h("slot", { name: "custom-icon" })) : (h("six-icon", { size: this.size === 'large' ? 'medium' : this.size }, "today"));
1046
- return (h("span", { slot: "prefix", part: "icon", class: {
1047
- prefix: true,
1048
- 'prefix--right': this.iconPosition === 'right',
1049
- } }, icon));
1050
- }
1051
- renderClearable() {
1052
- return (this.clearable && (h("button", { slot: "suffix", class: {
1053
- 'datepicker-clear': true,
1054
- 'datepicker-clear--right': this.iconPosition === 'left',
1055
- 'datepicker-clear--left': this.iconPosition === 'right',
1056
- }, type: "button", onClick: this.handleClearClick, tabindex: "-1" }, h("six-icon", { size: "small" }, "clear"))));
1057
- }
1058
- render() {
1059
- var _a, _b, _c;
1060
- this.adjustPopupPosition();
1061
- return (h("div", { ref: (el) => (this.wrapper = el), class: "datepicker__container" }, h("six-input", { part: "base", value: formatDate(this.value, this.dateFormat), ref: (el) => (this.inputElement = el), placeholder: this.placeholder, readonly: this.readonly, disabled: this.disabled, name: this.name, label: this.label, required: this.required, "error-text": this.errorText, "error-on-blur": this.errorOnBlur, onClick: () => this.openCalendar(), size: this.size, class: { 'input--empty': !this.value } }, this.renderCustomIcon(), this.renderClearable(), hasSlot(this.host, 'error-text') ? (h("span", { slot: "error-text" }, h("slot", { name: "error-text" }))) : null, hasSlot(this.host, 'label') ? (h("span", { slot: "label" }, h("slot", { name: "label" }))) : null), this.open && (h("div", { part: "popup", ref: (el) => (this.popup = el), class: {
1062
- datepicker__popup: true,
1063
- 'datepicker__popup--is-up': this.placement ? this.placement === 'top' : this.isDropDownContentUp,
1064
- 'datepicker__popup--is-inline': this.inline,
1065
- } }, this.renderHeader(), this.renderBody(), this.type === 'date-time' && (h("six-timepicker", { inline: true, "onSix-timepicker-change-debounced": (event) => this.onTimepickerChange(event), value: ((_a = this.selectedDate) === null || _a === void 0 ? void 0 : _a.getHours()) +
1066
- ':' +
1067
- ((_b = this.selectedDate) === null || _b === void 0 ? void 0 : _b.getMinutes()) +
1068
- ':' +
1069
- ((_c = this.selectedDate) === null || _c === void 0 ? void 0 : _c.getSeconds()) })), h("div", { class: "datepicker__footer" }, h("slot", null))))));
1070
- }
1071
- adjustPopupPosition() {
1072
- this.adjustPopupForHoisting();
1073
- this.adjustPopupForSmallScreens();
1074
- }
1075
- /*
1076
- * The position of the hoisted datepicker needs to be correctly calculated since the position changes to fixed.
1077
- * Thus if the user scrolls or adjusts the screen size we need to recalculate the datepicker position.
1078
- */
1079
- moveOpenHoistedPopup() {
1080
- if (!this.hoist || !this.open) {
1081
- return;
1082
- }
1083
- const popupBoundingClientRect = this.popup.getBoundingClientRect();
1084
- const popupHeight = popupBoundingClientRect.height;
1085
- const inputBoundingClientRect = this.inputElement.getBoundingClientRect();
1086
- const inputTop = inputBoundingClientRect.top;
1087
- const inputHeight = inputBoundingClientRect.height;
1088
- this.calcIsDropDownContentUp();
1089
- if (this.isDropDownContentUp) {
1090
- this.popup.style.top = `${inputTop - popupHeight}px`;
1091
- }
1092
- else {
1093
- this.popup.style.top = `${inputTop + inputHeight}px`;
1094
- }
1095
- }
1096
- /*
1097
- * For small screens the datepicker popup could be cut-off even though there might still be space within the viewport.
1098
- * This is because the popup is always aligned with the trigger input field. However in the scenario of small screens
1099
- * we should reposition the popup to use the space available.
1100
- */
1101
- adjustPopupForSmallScreens() {
1102
- // execute after dropdown has been rendered to make sure the popup reference is correctly set
1103
- setTimeout(() => {
1104
- if (!this.popup) {
1105
- return;
1106
- }
1107
- const popupBoundingClientRect = this.popup.getBoundingClientRect();
1108
- const setPopupAsFixPosition = () => {
1109
- // apply screen position to fixed popup
1110
- this.popup.style.position = 'fixed';
1111
- ['top', 'left', 'width', 'height'].forEach((property) => {
1112
- this.popup.style[property] = `${popupBoundingClientRect[property]}px`;
1113
- });
1114
- };
1115
- if (popupBoundingClientRect.y < 0 &&
1116
- window.innerHeight - popupBoundingClientRect.height > 0 &&
1117
- Math.abs(popupBoundingClientRect.y) <= popupBoundingClientRect.height) {
1118
- // handle case where popup is cut-off on top but there is still space available
1119
- setPopupAsFixPosition();
1120
- this.popup.style.top = '0px';
1121
- }
1122
- else if (window.innerHeight < popupBoundingClientRect.y + popupBoundingClientRect.height &&
1123
- window.innerHeight > popupBoundingClientRect.height &&
1124
- Math.abs(popupBoundingClientRect.y - window.innerHeight) <= popupBoundingClientRect.height) {
1125
- // handle case where popup is cut-off at the bottom but there is still space available above
1126
- // apply screen position to fixed popup
1127
- setPopupAsFixPosition();
1128
- this.popup.style.top = `${window.innerHeight - popupBoundingClientRect.height}px`;
1129
- }
1130
- if (window.innerWidth < popupBoundingClientRect.x + popupBoundingClientRect.width &&
1131
- window.innerWidth > popupBoundingClientRect.width &&
1132
- Math.abs(popupBoundingClientRect.x - window.innerWidth) <= popupBoundingClientRect.width) {
1133
- // handle case where popup is cut-off to the right
1134
- setPopupAsFixPosition();
1135
- this.popup.style.left = `${window.innerWidth - popupBoundingClientRect.width}px`;
1136
- }
1137
- }, 0);
1138
- }
1139
- /*
1140
- * If the popup is hoisted we popup is hoisted its position will change to fix to not be clipped of by a containing container.
1141
- * To render the popup correctly we render it normally, and then assign this screenposition to the fixed popup
1142
- */
1143
- adjustPopupForHoisting() {
1144
- if (!this.hoist) {
1145
- return;
1146
- }
1147
- // execute after dropdown has been rendered to make sure the popup reference is correctly set
1148
- setTimeout(() => {
1149
- if (!this.popup) {
1150
- return;
1151
- }
1152
- // take a snapshot of normally rendered popup
1153
- const popupBoundingClientRect = this.popup.getBoundingClientRect();
1154
- // apply screen position to fixed popup
1155
- this.popup.style.position = 'fixed';
1156
- ['top', 'left', 'width', 'height'].forEach((property) => {
1157
- this.popup.style[property] = `${popupBoundingClientRect[property]}px`;
1158
- });
1159
- const inputBoundingClientRect = this.inputElement.getBoundingClientRect();
1160
- const inputTop = inputBoundingClientRect.top;
1161
- const popupTop = popupBoundingClientRect.top;
1162
- this.calcIsDropDownContentUp();
1163
- // check screen position to check whether the popup should be moved above or below the trigger element
1164
- if (this.isDropDownContentUp && inputTop < popupTop) {
1165
- // move popup above input field if datepicker is at bottom of screen
1166
- this.popup.style.top = `${popupTop - popupBoundingClientRect.height - inputBoundingClientRect.height}px`;
1167
- }
1168
- }, 0);
1169
- }
1170
- connectedCallback() {
1171
- this.handleClearClick = this.handleClearClick.bind(this);
1172
- }
1173
- disconnectedCallback() {
1174
- this.eventListeners.removeAll();
1175
- }
1176
- displayCustomMessage(valid) {
1177
- if (!this.inputElement) {
1178
- return;
1179
- }
1180
- if (valid) {
1181
- void this.setCustomValidity('');
1182
- }
1183
- else {
1184
- const message = this.errorText ? this.errorText : 'Invalid date format';
1185
- void this.setCustomValidity(message);
1186
- }
1187
- }
1188
- static getCurrentDateAsPointer() {
1189
- return {
1190
- year: year(now()),
1191
- month: month(now()),
1192
- day: day(now()),
1193
- hours: hours(now()),
1194
- minutes: minutes(now()),
1195
- seconds: seconds(now()),
1196
- };
1197
- }
1198
- get host() { return getElement(this); }
1199
- static get watchers() { return {
1200
- "debounce": ["debounceChanged"],
1201
- "value": ["valueChanged"]
1202
- }; }
1203
- };
566
+ const NUMBER_OF_YEARS_SHOWN = 25;
567
+ const MIN_POPUP_HEIGHT = 400;
568
+ var SelectionMode;
569
+ (function (SelectionMode) {
570
+ SelectionMode["DAY"] = "day";
571
+ SelectionMode["MONTH"] = "month";
572
+ SelectionMode["YEAR"] = "year";
573
+ })(SelectionMode || (SelectionMode = {}));
574
+ const getYearSelectionAroundYear = (year) => {
575
+ const numberOfElementsPerRow = 5;
576
+ return Array.from(new Array(NUMBER_OF_YEARS_SHOWN).keys())
577
+ .map((n) => n + year - Math.floor(NUMBER_OF_YEARS_SHOWN / 2))
578
+ .reduce((curr, item, index) => {
579
+ if (index % numberOfElementsPerRow === 0) {
580
+ curr.push([]);
581
+ }
582
+ curr[curr.length - 1].push(item);
583
+ return curr;
584
+ }, []);
585
+ };
586
+ let SixDatepicker = class {
587
+ constructor(hostRef) {
588
+ registerInstance(this, hostRef);
589
+ this.sixSelect = createEvent(this, "six-datepicker-select", 7);
590
+ this.sixClear = createEvent(this, "six-datepicker-clear", 7);
591
+ this.sixBlur = createEvent(this, "six-datepicker-blur", 7);
592
+ this.eventListeners = new EventListeners();
593
+ this.selectedDate = null;
594
+ this.pointerDate = SixDatepicker.getCurrentDateAsPointer();
595
+ this.selectionMode = SelectionMode.DAY;
596
+ this.isDropDownContentUp = false;
597
+ /**
598
+ * Set the type.
599
+ */
600
+ this.type = 'date';
601
+ /**
602
+ * The language used to render the weekdays and months.
603
+ */
604
+ this.locale = 'en';
605
+ /** Indicates whether or not the calendar dropdown is open on startup. You can use this in lieu of the show/hide methods. */
606
+ this.open = false;
607
+ /** Indicates whether or not the calendar should be shown as an inline (always open) component */
608
+ this.inline = false;
609
+ /**
610
+ * If `true` the user can only select a date via the component in the popup, but not directly edit the input field.
611
+ */
612
+ this.readonly = false;
613
+ /**
614
+ * If `true` the component is disabled.
615
+ */
616
+ this.disabled = false;
617
+ /**
618
+ * Callback to determine which date in the datepicker should be selectable.
619
+ * the callback function will get a datestring as an argument, e.g. '2021-07-04'
620
+ *
621
+ * Usage e.g.:
622
+ * const datepicker = document.getElementById('allowed-date-picker');
623
+ * datepicker.allowedDates = datestring => parseInt(datestring.split('-')[2], 10) % 2 === 0;
624
+ */
625
+ this.allowedDates = () => true;
626
+ /**
627
+ * The minimum datetime allowed. Value must be a date object
628
+ */
629
+ this.min = null;
630
+ /**
631
+ * The maximum datetime allowed. Value must be a date object
632
+ */
633
+ this.max = null;
634
+ /**
635
+ * Closes the datepicker dropdown after selection
636
+ */
637
+ this.closeOnSelect = this.type === 'date';
638
+ /** Datepicker size. */
639
+ this.size = 'medium';
640
+ /**
641
+ * The value of the form field, which accepts a date object.
642
+ */
643
+ this.value = null;
644
+ /** Define the dateFormat. Valid formats are:
645
+ * 'dd.mm.yyyy'
646
+ * 'yyyy-mm-dd'
647
+ * 'dd-mm-yyyy'
648
+ * 'dd/mm/yyyy'
649
+ * 'yyyy/mm/dd'
650
+ * 'dd.mm.yy'
651
+ * 'yy-mm-dd'
652
+ * 'dd-mm-yy'
653
+ * 'dd/mm/yy'
654
+ * 'yy/mm/dd'
655
+ * */
656
+ this.dateFormat = SixDateFormats.DDMMYYY_DOT;
657
+ /**
658
+ * Set the amount of time, in milliseconds, to wait to trigger the `dateChange` event after each keystroke.
659
+ */
660
+ this.debounce = DEFAULT_DEBOUNCE_FAST;
661
+ /** Set to display the error text on blur and not when typing */
662
+ this.errorOnBlur = false;
663
+ /** The input's error text. Alternatively, you can use the error-text slot. */
664
+ this.errorText = '';
665
+ /** The input's label. Alternatively, you can use the label slot. */
666
+ this.label = '';
667
+ /** The input's name attribute. */
668
+ this.name = '';
669
+ /** Set to true to add a clear button when the input is populated. */
670
+ this.clearable = false;
671
+ /** Set the position of the icon */
672
+ this.iconPosition = 'left';
673
+ /**
674
+ * Enable this option to prevent the panel from being clipped when the component is placed inside a container with
675
+ * `overflow: auto|scroll`.
676
+ */
677
+ this.hoist = false;
678
+ this.defaultValue = null;
679
+ this.handleDocumentKeyDown = (event) => {
680
+ // Close when escape is pressed
681
+ if (this.open && event.key === 'Escape') {
682
+ event.stopPropagation();
683
+ this.closePopup();
684
+ void this.inputElement.setFocus();
685
+ }
686
+ // Handle tabbing
687
+ if (event.key === 'Tab') {
688
+ this.closePopup();
689
+ }
690
+ };
691
+ this.handleDocumentMouseDown = (event) => {
692
+ // Close when clicking outside of the containing element
693
+ const path = event.composedPath();
694
+ if (!path.includes(this.container)) {
695
+ this.closePopup();
696
+ return;
697
+ }
698
+ };
699
+ this.onTimepickerChange = (sixTimepickerChange) => {
700
+ const time = sixTimepickerChange.detail.value;
701
+ const newDate = new Date();
702
+ if (this.selectedDate) {
703
+ newDate.setFullYear(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate());
704
+ }
705
+ newDate.setHours(time[SixTimePropertyName.HOURS], time[SixTimePropertyName.MINUTES], time[SixTimePropertyName.SECONDS]);
706
+ this.updateValue(newDate);
707
+ this.updatePointerDates();
708
+ };
709
+ this.onClickDateCell = (cell) => {
710
+ if (!cell.isDisabled) {
711
+ void this.select(cell.dateString);
712
+ }
713
+ };
714
+ this.onClickMonthCell = (selectedMonth) => {
715
+ const month = i18nDate[this.locale].monthsShort.findIndex((monthShort) => monthShort === selectedMonth);
716
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { month });
717
+ this.selectionMode = SelectionMode.DAY;
718
+ };
719
+ this.onClickYearCell = (year) => {
720
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year });
721
+ this.selectionMode = SelectionMode.DAY;
722
+ };
723
+ this.handleInputChange = (event) => {
724
+ const inputValue = this.inputElement.value;
725
+ if (!isValidDateString(inputValue, this.dateFormat)) {
726
+ return;
727
+ }
728
+ const inputValueDate = toDate(inputValue, this.dateFormat);
729
+ if (inputValueDate === undefined) {
730
+ return;
731
+ }
732
+ if (this.min && this.min.getTime() > inputValueDate.getTime()) {
733
+ return;
734
+ }
735
+ if (this.max && this.max.getTime() < inputValueDate.getTime()) {
736
+ return;
737
+ }
738
+ this.updateIfChanged(inputValueDate);
739
+ event.stopPropagation();
740
+ const datesOnly = inputValue.replace(/[^\d]/g, '');
741
+ let isDateValid = !inputValue;
742
+ if (inputValue && datesOnly.length >= 6) {
743
+ const date = toDate(inputValue, this.dateFormat);
744
+ const datestring = formatDate(date, this.dateFormat);
745
+ if (isValidDateString(datestring, this.dateFormat)) {
746
+ this.selectedDate = toDate(datestring, this.dateFormat);
747
+ this.updatePointerDates();
748
+ this.updateValue(this.selectedDate);
749
+ isDateValid = true;
750
+ }
751
+ }
752
+ this.displayCustomMessage(isDateValid);
753
+ };
754
+ this.handleOnBlur = (event) => {
755
+ // clear the value if the user deleted the date
756
+ if (this.inputElement.value === '' && isValidDate(this.value)) {
757
+ this.value = undefined;
758
+ }
759
+ event.stopPropagation();
760
+ const inputValue = this.inputElement.value;
761
+ const inputValueDate = toDate(inputValue, this.dateFormat);
762
+ const formattedDate = formatDate(this.value, this.dateFormat);
763
+ if (inputValueDate && inputValue !== formattedDate) {
764
+ // properly format date if necessary
765
+ this.inputElement.value = formattedDate;
766
+ }
767
+ this.sixBlur.emit(this.value);
768
+ };
769
+ }
770
+ debounceChanged() {
771
+ this.sixSelect = debounceEvent(this.sixSelect, this.debounce);
772
+ }
773
+ /**
774
+ * Update the native input element when the value changes
775
+ */
776
+ valueChanged() {
777
+ // map unreadable values to undefined to make the datepicker fault-tolerant
778
+ if (this.isValidValue()) {
779
+ console.warn('Encountered unreadable date, will map to undefined. Received value', this.value);
780
+ this.value = undefined;
781
+ return;
782
+ }
783
+ this.selectedDate = this.value;
784
+ this.updatePointerDates();
785
+ this.sixSelect.emit(this.value);
786
+ }
787
+ async resizeHandler() {
788
+ this.calcIsDropDownContentUp();
789
+ this.moveOpenHoistedPopup();
790
+ this.adjustPopupPosition();
791
+ }
792
+ async scrollHandler() {
793
+ this.calcIsDropDownContentUp();
794
+ this.moveOpenHoistedPopup();
795
+ }
796
+ get container() {
797
+ return this.containingElement || this.host;
798
+ }
799
+ get firstDateOfBox() {
800
+ const date = new Date(this.pointerDate.year, this.pointerDate.month, 1);
801
+ return getFirstDayOfTheWeek(date);
802
+ }
803
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
804
+ async reportValidity() {
805
+ return this.inputElement.reportValidity();
806
+ }
807
+ /** Checks for validity. */
808
+ async checkValidity() {
809
+ return this.inputElement.checkValidity();
810
+ }
811
+ /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
812
+ async setCustomValidity(message) {
813
+ await this.inputElement.setCustomValidity(message);
814
+ }
815
+ /** Resets the formcontrol */
816
+ async reset() {
817
+ this.value = this.defaultValue;
818
+ this.inputElement.value = formatDate(this.defaultValue, this.dateFormat);
819
+ await this.inputElement.reset();
820
+ }
821
+ isValidValue() {
822
+ if (this.value === undefined || this.value === null) {
823
+ return false;
824
+ }
825
+ if (!(this.value instanceof Date)) {
826
+ return true;
827
+ }
828
+ return this.value instanceof Date && isNaN(this.value);
829
+ }
830
+ get calendarGrid() {
831
+ return createCalendarGrid({
832
+ firstDateOfBox: this.firstDateOfBox,
833
+ allowedDates: this.allowedDates,
834
+ dateFormat: this.dateFormat,
835
+ locale: this.locale,
836
+ selectedDate: this.selectedDate,
837
+ minDate: this.min,
838
+ maxDate: this.max,
839
+ pointerDate: this.pointerDate,
840
+ });
841
+ }
842
+ calcIsDropDownContentUp() {
843
+ if (!this.inputElement || !this.wrapper) {
844
+ return;
845
+ }
846
+ const inputBoundingRect = this.inputElement.getBoundingClientRect();
847
+ const wrapperBoundingRect = this.wrapper.getBoundingClientRect();
848
+ const minPopupHeight = Math.max(wrapperBoundingRect.height, MIN_POPUP_HEIGHT);
849
+ const moreSpaceInTop = inputBoundingRect.y > window.innerHeight / 2;
850
+ this.isDropDownContentUp = moreSpaceInTop && window.innerHeight < inputBoundingRect.bottom + minPopupHeight;
851
+ }
852
+ getMonthStringForIndex(index) {
853
+ return i18nDate[this.locale].months[index];
854
+ }
855
+ previousUnit() {
856
+ if (this.selectionMode === SelectionMode.DAY) {
857
+ this.previousMonth();
858
+ }
859
+ else if (this.selectionMode === SelectionMode.MONTH) {
860
+ this.previousYear();
861
+ }
862
+ else if (this.selectionMode === SelectionMode.YEAR) {
863
+ this.previousYearGroup();
864
+ }
865
+ }
866
+ previousYear() {
867
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year - 1 });
868
+ }
869
+ previousYearGroup() {
870
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year - NUMBER_OF_YEARS_SHOWN });
871
+ }
872
+ previousMonth() {
873
+ if (this.pointerDate.month === 0) {
874
+ this.pointerDate = { year: this.pointerDate.year - 1, month: 11, day: 1, hours: 0, minutes: 0, seconds: 0 };
875
+ }
876
+ else {
877
+ this.pointerDate = {
878
+ year: this.pointerDate.year,
879
+ month: this.pointerDate.month - 1,
880
+ day: 1,
881
+ hours: 0,
882
+ minutes: 0,
883
+ seconds: 0,
884
+ };
885
+ }
886
+ }
887
+ nextUnit() {
888
+ if (this.selectionMode === SelectionMode.DAY) {
889
+ this.nextMonth();
890
+ }
891
+ else if (this.selectionMode === SelectionMode.MONTH) {
892
+ this.nextYear();
893
+ }
894
+ else if (this.selectionMode === SelectionMode.YEAR) {
895
+ this.nextYearGroup();
896
+ }
897
+ }
898
+ nextMonth() {
899
+ if (this.pointerDate.month === 11) {
900
+ this.pointerDate = { year: this.pointerDate.year + 1, month: 0, day: 1, hours: 0, minutes: 0, seconds: 0 };
901
+ }
902
+ else {
903
+ this.pointerDate = {
904
+ year: this.pointerDate.year,
905
+ month: this.pointerDate.month + 1,
906
+ day: 1,
907
+ hours: 0,
908
+ minutes: 0,
909
+ seconds: 0,
910
+ };
911
+ }
912
+ }
913
+ nextYear() {
914
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year + 1 });
915
+ }
916
+ nextYearGroup() {
917
+ this.pointerDate = Object.assign(Object.assign({}, this.pointerDate), { year: this.pointerDate.year + NUMBER_OF_YEARS_SHOWN });
918
+ }
919
+ openCalendar() {
920
+ if (!this.open && !this.disabled) {
921
+ this.open = true;
922
+ this.setupEventListenersForOpenPopup();
923
+ }
924
+ }
925
+ setupEventListenersForOpenPopup() {
926
+ this.eventListeners.add(document, 'keydown', this.handleDocumentKeyDown);
927
+ this.eventListeners.add(document, 'mousedown', this.handleDocumentMouseDown);
928
+ }
929
+ handleClearClick(event) {
930
+ event.stopPropagation();
931
+ void this.select(undefined);
932
+ this.sixClear.emit();
933
+ }
934
+ closePopup() {
935
+ if (this.inline) {
936
+ return;
937
+ }
938
+ this.open = false;
939
+ this.eventListeners.remove(document, 'keydown', this.handleDocumentKeyDown);
940
+ this.eventListeners.remove(document, 'mousedown', this.handleDocumentMouseDown);
941
+ this.selectionMode = SelectionMode.DAY;
942
+ }
943
+ updatePointerDates() {
944
+ const date = this.getPointerDate();
945
+ if (this.differsFromPointerDate(date)) {
946
+ this.pointerDate = {
947
+ year: year(date),
948
+ month: month(date),
949
+ day: day(date),
950
+ hours: hours(date),
951
+ minutes: minutes(date),
952
+ seconds: seconds(date),
953
+ };
954
+ }
955
+ }
956
+ differsFromPointerDate(date) {
957
+ return (this.pointerDate.day !== day(date) ||
958
+ this.pointerDate.month !== month(date) ||
959
+ this.pointerDate.year !== year(date) ||
960
+ this.pointerDate.hours !== hours(date) ||
961
+ this.pointerDate.minutes !== minutes(date) ||
962
+ this.pointerDate.seconds !== seconds(date));
963
+ }
964
+ getPointerDate() {
965
+ if (this.selectedDate !== undefined && this.selectedDate !== null) {
966
+ return this.selectedDate;
967
+ }
968
+ if (isNil(this.defaultDate)) {
969
+ return now();
970
+ }
971
+ else {
972
+ return this.defaultDate && toDate(this.defaultDate, this.dateFormat);
973
+ }
974
+ }
975
+ updateValue(newDate) {
976
+ this.displayCustomMessage(true);
977
+ this.updateIfChanged(newDate);
978
+ }
979
+ updateIfChanged(newDate) {
980
+ var _a;
981
+ if (((_a = this.value) === null || _a === void 0 ? void 0 : _a.getTime()) === (newDate === null || newDate === void 0 ? void 0 : newDate.getTime())) {
982
+ return;
983
+ }
984
+ this.value = newDate;
985
+ }
986
+ /**
987
+ * Selects an option
988
+ */
989
+ async select(datestring) {
990
+ if (!datestring) {
991
+ this.updateValue(undefined);
992
+ }
993
+ else {
994
+ const newDate = toDate(datestring, this.dateFormat);
995
+ newDate.setHours(this.pointerDate.hours, this.pointerDate.minutes, this.pointerDate.seconds);
996
+ this.updateValue(newDate);
997
+ }
998
+ this.updatePointerDates();
999
+ if (this.closeOnSelect) {
1000
+ this.closePopup();
1001
+ }
1002
+ }
1003
+ componentWillLoad() {
1004
+ this.validateProps();
1005
+ this.defaultValue = this.value;
1006
+ this.selectedDate = this.value;
1007
+ this.updatePointerDates();
1008
+ this.updateValue(this.value);
1009
+ if (this.inline) {
1010
+ this.open = true;
1011
+ }
1012
+ if (this.open) {
1013
+ this.setupEventListenersForOpenPopup();
1014
+ }
1015
+ }
1016
+ validateProps() {
1017
+ if (this.value !== null && this.value !== undefined && !(this.value instanceof Date)) {
1018
+ throw new Error('Datepicker no longer supports strings as value. Use a date object instead!');
1019
+ }
1020
+ if (this.min !== null && this.min !== undefined && !(this.min instanceof Date)) {
1021
+ throw new Error('Datepicker no longer supports strings as min. Use a date object instead!');
1022
+ }
1023
+ if (this.max !== null && this.max !== undefined && !(this.max instanceof Date)) {
1024
+ throw new Error('Datepicker no longer supports strings as min. Use a date object instead!');
1025
+ }
1026
+ }
1027
+ componentDidLoad() {
1028
+ this.eventListeners.add(this.inputElement, 'six-input-input', debounce(this.handleInputChange, this.debounce));
1029
+ this.eventListeners.add(this.inputElement, 'six-input-blur', this.handleOnBlur);
1030
+ }
1031
+ renderHeader() {
1032
+ return (h("header", { class: "datepicker-header", part: "header" }, h("div", { class: "datepicker-header__btn prev", onClick: () => this.previousUnit() }, h("svg", { viewBox: "0 5 13 13", width: "14", height: "23" }, h("path", { d: "M11.67 3.87L9.9 2.1 0 12l9.9 9.9 1.77-1.77L3.54 12z" }))), h("div", { class: "datepicker-header__label" }, this.selectionMode === SelectionMode.DAY && (h("div", { onClick: () => (this.selectionMode = SelectionMode.MONTH) }, h("span", { class: "datepicker-header__label-month" }, this.getMonthStringForIndex(this.pointerDate.month)), h("span", null, h("svg", { viewBox: "-3 -4 24 24", width: "20", height: "20" }, h("polyline", { points: "6 9 12 15 18 9" }))))), this.selectionMode !== SelectionMode.YEAR && (h("div", { onClick: () => (this.selectionMode = SelectionMode.YEAR) }, h("span", { class: "datepicker-header__label-year" }, this.pointerDate.year), h("span", null, h("svg", { viewBox: "-3 -4 24 24", width: "20", height: "20" }, h("polyline", { points: "6 9 12 15 18 9" }))))), this.selectionMode === SelectionMode.YEAR && (h("div", null, this.pointerDate.year - Math.floor(NUMBER_OF_YEARS_SHOWN / 2), " \u2013", ' ', this.pointerDate.year + Math.floor(NUMBER_OF_YEARS_SHOWN / 2)))), h("div", { class: "datepicker-header__btn next", onClick: () => this.nextUnit() }, h("svg", { viewBox: "5 5 13 13", width: "14", height: "23" }, h("path", { d: "M5.88 4.12L13.76 12l-7.88 7.88L8 22l10-10L8 2z" })))));
1033
+ }
1034
+ renderBody() {
1035
+ switch (this.selectionMode) {
1036
+ case SelectionMode.DAY:
1037
+ return (h(DaySelection, { locale: i18nDate[this.locale], calendarGrid: this.calendarGrid, onClickDateCell: this.onClickDateCell }));
1038
+ case SelectionMode.MONTH:
1039
+ return (h(MonthSelection, { locale: i18nDate[this.locale], selectedDate: this.selectedDate, onClickMonthCell: this.onClickMonthCell }));
1040
+ case SelectionMode.YEAR:
1041
+ return (h(YearSelection, { selectedDate: this.selectedDate, yearSelection: getYearSelectionAroundYear(this.pointerDate.year), onClickYearCell: this.onClickYearCell }));
1042
+ }
1043
+ }
1044
+ renderCustomIcon() {
1045
+ const icon = hasSlot(this.host, 'custom-icon') ? (h("slot", { name: "custom-icon" })) : (h("six-icon", { size: this.size === 'large' ? 'medium' : this.size }, "today"));
1046
+ return (h("span", { slot: "prefix", part: "icon", class: {
1047
+ prefix: true,
1048
+ 'prefix--right': this.iconPosition === 'right',
1049
+ } }, icon));
1050
+ }
1051
+ renderClearable() {
1052
+ return (this.clearable && (h("button", { slot: "suffix", class: {
1053
+ 'datepicker-clear': true,
1054
+ 'datepicker-clear--right': this.iconPosition === 'left',
1055
+ 'datepicker-clear--left': this.iconPosition === 'right',
1056
+ }, type: "button", onClick: this.handleClearClick, tabindex: "-1" }, h("six-icon", { size: "small" }, "clear"))));
1057
+ }
1058
+ render() {
1059
+ var _a, _b, _c;
1060
+ this.adjustPopupPosition();
1061
+ return (h("div", { ref: (el) => (this.wrapper = el), class: "datepicker__container" }, h("six-input", { part: "base", value: formatDate(this.value, this.dateFormat), ref: (el) => (this.inputElement = el), placeholder: this.placeholder, readonly: this.readonly, disabled: this.disabled, name: this.name, label: this.label, required: this.required, "error-text": this.errorText, "error-on-blur": this.errorOnBlur, onClick: () => this.openCalendar(), size: this.size, class: { 'input--empty': !this.value } }, this.renderCustomIcon(), this.renderClearable(), hasSlot(this.host, 'error-text') ? (h("span", { slot: "error-text" }, h("slot", { name: "error-text" }))) : null, hasSlot(this.host, 'label') ? (h("span", { slot: "label" }, h("slot", { name: "label" }))) : null), this.open && (h("div", { part: "popup", ref: (el) => (this.popup = el), class: {
1062
+ datepicker__popup: true,
1063
+ 'datepicker__popup--is-up': this.placement ? this.placement === 'top' : this.isDropDownContentUp,
1064
+ 'datepicker__popup--is-inline': this.inline,
1065
+ } }, this.renderHeader(), this.renderBody(), this.type === 'date-time' && (h("six-timepicker", { inline: true, "onSix-timepicker-change-debounced": (event) => this.onTimepickerChange(event), value: ((_a = this.selectedDate) === null || _a === void 0 ? void 0 : _a.getHours()) +
1066
+ ':' +
1067
+ ((_b = this.selectedDate) === null || _b === void 0 ? void 0 : _b.getMinutes()) +
1068
+ ':' +
1069
+ ((_c = this.selectedDate) === null || _c === void 0 ? void 0 : _c.getSeconds()) })), h("div", { class: "datepicker__footer" }, h("slot", null))))));
1070
+ }
1071
+ adjustPopupPosition() {
1072
+ this.adjustPopupForHoisting();
1073
+ this.adjustPopupForSmallScreens();
1074
+ }
1075
+ /*
1076
+ * The position of the hoisted datepicker needs to be correctly calculated since the position changes to fixed.
1077
+ * Thus if the user scrolls or adjusts the screen size we need to recalculate the datepicker position.
1078
+ */
1079
+ moveOpenHoistedPopup() {
1080
+ if (!this.hoist || !this.open) {
1081
+ return;
1082
+ }
1083
+ const popupBoundingClientRect = this.popup.getBoundingClientRect();
1084
+ const popupHeight = popupBoundingClientRect.height;
1085
+ const inputBoundingClientRect = this.inputElement.getBoundingClientRect();
1086
+ const inputTop = inputBoundingClientRect.top;
1087
+ const inputHeight = inputBoundingClientRect.height;
1088
+ this.calcIsDropDownContentUp();
1089
+ if (this.isDropDownContentUp) {
1090
+ this.popup.style.top = `${inputTop - popupHeight}px`;
1091
+ }
1092
+ else {
1093
+ this.popup.style.top = `${inputTop + inputHeight}px`;
1094
+ }
1095
+ }
1096
+ /*
1097
+ * For small screens the datepicker popup could be cut-off even though there might still be space within the viewport.
1098
+ * This is because the popup is always aligned with the trigger input field. However in the scenario of small screens
1099
+ * we should reposition the popup to use the space available.
1100
+ */
1101
+ adjustPopupForSmallScreens() {
1102
+ // execute after dropdown has been rendered to make sure the popup reference is correctly set
1103
+ setTimeout(() => {
1104
+ if (!this.popup) {
1105
+ return;
1106
+ }
1107
+ const popupBoundingClientRect = this.popup.getBoundingClientRect();
1108
+ const setPopupAsFixPosition = () => {
1109
+ // apply screen position to fixed popup
1110
+ this.popup.style.position = 'fixed';
1111
+ ['top', 'left', 'width', 'height'].forEach((property) => {
1112
+ this.popup.style[property] = `${popupBoundingClientRect[property]}px`;
1113
+ });
1114
+ };
1115
+ if (popupBoundingClientRect.y < 0 &&
1116
+ window.innerHeight - popupBoundingClientRect.height > 0 &&
1117
+ Math.abs(popupBoundingClientRect.y) <= popupBoundingClientRect.height) {
1118
+ // handle case where popup is cut-off on top but there is still space available
1119
+ setPopupAsFixPosition();
1120
+ this.popup.style.top = '0px';
1121
+ }
1122
+ else if (window.innerHeight < popupBoundingClientRect.y + popupBoundingClientRect.height &&
1123
+ window.innerHeight > popupBoundingClientRect.height &&
1124
+ Math.abs(popupBoundingClientRect.y - window.innerHeight) <= popupBoundingClientRect.height) {
1125
+ // handle case where popup is cut-off at the bottom but there is still space available above
1126
+ // apply screen position to fixed popup
1127
+ setPopupAsFixPosition();
1128
+ this.popup.style.top = `${window.innerHeight - popupBoundingClientRect.height}px`;
1129
+ }
1130
+ if (window.innerWidth < popupBoundingClientRect.x + popupBoundingClientRect.width &&
1131
+ window.innerWidth > popupBoundingClientRect.width &&
1132
+ Math.abs(popupBoundingClientRect.x - window.innerWidth) <= popupBoundingClientRect.width) {
1133
+ // handle case where popup is cut-off to the right
1134
+ setPopupAsFixPosition();
1135
+ this.popup.style.left = `${window.innerWidth - popupBoundingClientRect.width}px`;
1136
+ }
1137
+ }, 0);
1138
+ }
1139
+ /*
1140
+ * If the popup is hoisted we popup is hoisted its position will change to fix to not be clipped of by a containing container.
1141
+ * To render the popup correctly we render it normally, and then assign this screenposition to the fixed popup
1142
+ */
1143
+ adjustPopupForHoisting() {
1144
+ if (!this.hoist) {
1145
+ return;
1146
+ }
1147
+ // execute after dropdown has been rendered to make sure the popup reference is correctly set
1148
+ setTimeout(() => {
1149
+ if (!this.popup) {
1150
+ return;
1151
+ }
1152
+ // take a snapshot of normally rendered popup
1153
+ const popupBoundingClientRect = this.popup.getBoundingClientRect();
1154
+ // apply screen position to fixed popup
1155
+ this.popup.style.position = 'fixed';
1156
+ ['top', 'left', 'width', 'height'].forEach((property) => {
1157
+ this.popup.style[property] = `${popupBoundingClientRect[property]}px`;
1158
+ });
1159
+ const inputBoundingClientRect = this.inputElement.getBoundingClientRect();
1160
+ const inputTop = inputBoundingClientRect.top;
1161
+ const popupTop = popupBoundingClientRect.top;
1162
+ this.calcIsDropDownContentUp();
1163
+ // check screen position to check whether the popup should be moved above or below the trigger element
1164
+ if (this.isDropDownContentUp && inputTop < popupTop) {
1165
+ // move popup above input field if datepicker is at bottom of screen
1166
+ this.popup.style.top = `${popupTop - popupBoundingClientRect.height - inputBoundingClientRect.height}px`;
1167
+ }
1168
+ }, 0);
1169
+ }
1170
+ connectedCallback() {
1171
+ this.handleClearClick = this.handleClearClick.bind(this);
1172
+ }
1173
+ disconnectedCallback() {
1174
+ this.eventListeners.removeAll();
1175
+ }
1176
+ displayCustomMessage(valid) {
1177
+ if (!this.inputElement) {
1178
+ return;
1179
+ }
1180
+ if (valid) {
1181
+ void this.setCustomValidity('');
1182
+ }
1183
+ else {
1184
+ const message = this.errorText ? this.errorText : 'Invalid date format';
1185
+ void this.setCustomValidity(message);
1186
+ }
1187
+ }
1188
+ static getCurrentDateAsPointer() {
1189
+ return {
1190
+ year: year(now()),
1191
+ month: month(now()),
1192
+ day: day(now()),
1193
+ hours: hours(now()),
1194
+ minutes: minutes(now()),
1195
+ seconds: seconds(now()),
1196
+ };
1197
+ }
1198
+ get host() { return getElement(this); }
1199
+ static get watchers() { return {
1200
+ "debounce": ["debounceChanged"],
1201
+ "value": ["valueChanged"]
1202
+ }; }
1203
+ };
1204
1204
  SixDatepicker.style = sixDatepickerCss;
1205
1205
 
1206
1206
  export { SixDatepicker as six_datepicker };