@nanahoshi/mona-ui 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/docs/api/auto-complete.md +67 -0
  2. package/docs/api/avatar.md +31 -0
  3. package/docs/api/breadcrumb.md +74 -0
  4. package/docs/api/button-group.md +71 -0
  5. package/docs/api/button.md +84 -0
  6. package/docs/api/calendar.md +123 -0
  7. package/docs/api/card.md +97 -0
  8. package/docs/api/chart.md +4380 -0
  9. package/docs/api/check-box.md +70 -0
  10. package/docs/api/chip.md +55 -0
  11. package/docs/api/circular-progress-bar.md +71 -0
  12. package/docs/api/collapsible.md +71 -0
  13. package/docs/api/color-gradient.md +54 -0
  14. package/docs/api/color-palette.md +52 -0
  15. package/docs/api/color-picker.md +89 -0
  16. package/docs/api/combo-box.md +69 -0
  17. package/docs/api/command.md +282 -0
  18. package/docs/api/common.md +599 -0
  19. package/docs/api/contextmenu.md +239 -0
  20. package/docs/api/date-input.md +119 -0
  21. package/docs/api/date-picker.md +67 -0
  22. package/docs/api/datetime-picker.md +72 -0
  23. package/docs/api/dialog.md +291 -0
  24. package/docs/api/dropdown-button.md +248 -0
  25. package/docs/api/dropdown-list.md +72 -0
  26. package/docs/api/dropdowns.md +172 -0
  27. package/docs/api/editor.md +117 -0
  28. package/docs/api/expansion-panel.md +85 -0
  29. package/docs/api/fieldset.md +33 -0
  30. package/docs/api/filter.md +116 -0
  31. package/docs/api/grid.md +1445 -0
  32. package/docs/api/i18n.md +1699 -0
  33. package/docs/api/label.md +58 -0
  34. package/docs/api/list-box.md +301 -0
  35. package/docs/api/list-view.md +294 -0
  36. package/docs/api/list.md +119 -0
  37. package/docs/api/locales.md +134 -0
  38. package/docs/api/menubar.md +275 -0
  39. package/docs/api/multi-select.md +92 -0
  40. package/docs/api/notification.md +164 -0
  41. package/docs/api/numeric-text-box.md +130 -0
  42. package/docs/api/otp-input.md +100 -0
  43. package/docs/api/pager.md +371 -0
  44. package/docs/api/placeholder.md +18 -0
  45. package/docs/api/popover.md +170 -0
  46. package/docs/api/popup-menu.md +328 -0
  47. package/docs/api/popup.md +299 -0
  48. package/docs/api/progress-bar.md +79 -0
  49. package/docs/api/query.md +367 -0
  50. package/docs/api/radio-button.md +113 -0
  51. package/docs/api/rating.md +187 -0
  52. package/docs/api/scroll-view.md +93 -0
  53. package/docs/api/segmented.md +114 -0
  54. package/docs/api/sheet.md +65 -0
  55. package/docs/api/sidebar.md +583 -0
  56. package/docs/api/skeleton.md +26 -0
  57. package/docs/api/slider.md +173 -0
  58. package/docs/api/spinner.md +132 -0
  59. package/docs/api/split-button.md +261 -0
  60. package/docs/api/splitter.md +57 -0
  61. package/docs/api/stepper.md +148 -0
  62. package/docs/api/switch.md +78 -0
  63. package/docs/api/tabs.md +139 -0
  64. package/docs/api/text-area.md +20 -0
  65. package/docs/api/text-box.md +106 -0
  66. package/docs/api/theme.md +627 -0
  67. package/docs/api/time-picker.md +69 -0
  68. package/docs/api/time-selector.md +54 -0
  69. package/docs/api/tooltip.md +112 -0
  70. package/docs/api/tree-view.md +631 -0
  71. package/docs/api/window.md +245 -0
  72. package/docs/auto-complete.md +28 -329
  73. package/docs/avatar.md +4 -24
  74. package/docs/breadcrumb.md +10 -65
  75. package/docs/button-group.md +7 -60
  76. package/docs/button.md +8 -67
  77. package/docs/calendar.md +16 -121
  78. package/docs/card.md +16 -79
  79. package/docs/chart-bar.md +16 -234
  80. package/docs/chart-financial.md +10 -121
  81. package/docs/chart-funnel.md +13 -176
  82. package/docs/chart-heatmap.md +15 -131
  83. package/docs/chart-line-area.md +12 -137
  84. package/docs/chart-pie.md +17 -221
  85. package/docs/chart-radar.md +13 -129
  86. package/docs/chart-radial.md +13 -211
  87. package/docs/chart-scatter.md +6 -74
  88. package/docs/chart-treemap.md +14 -196
  89. package/docs/chart.md +168 -1892
  90. package/docs/checkbox.md +5 -61
  91. package/docs/chip.md +7 -42
  92. package/docs/circular-progress-bar.md +9 -61
  93. package/docs/collapsible.md +5 -87
  94. package/docs/color-gradient.md +8 -81
  95. package/docs/color-palette.md +7 -69
  96. package/docs/color-picker.md +9 -105
  97. package/docs/combo-box.md +28 -331
  98. package/docs/command.md +25 -236
  99. package/docs/contextmenu.md +15 -140
  100. package/docs/date-picker.md +7 -110
  101. package/docs/datetime-picker.md +7 -129
  102. package/docs/decimal-textbox.md +6 -69
  103. package/docs/dialog.md +23 -263
  104. package/docs/dropdown-button.md +15 -146
  105. package/docs/dropdown-list.md +29 -332
  106. package/docs/editor.md +10 -164
  107. package/docs/expansion-panel.md +7 -69
  108. package/docs/fieldset.md +5 -24
  109. package/docs/grid-columns.md +12 -92
  110. package/docs/grid-editing.md +29 -291
  111. package/docs/grid-grouping.md +11 -50
  112. package/docs/grid-rows.md +10 -74
  113. package/docs/grid-selection.md +7 -36
  114. package/docs/grid-server.md +8 -293
  115. package/docs/grid-sorting-filtering.md +10 -333
  116. package/docs/grid-state-export.md +17 -228
  117. package/docs/grid.md +23 -216
  118. package/docs/input.md +7 -19
  119. package/docs/installation.md +147 -15
  120. package/docs/introduction.md +37 -15
  121. package/docs/label.md +8 -39
  122. package/docs/list-box.md +21 -253
  123. package/docs/list-view.md +25 -232
  124. package/docs/menubar.md +21 -167
  125. package/docs/multi-select.md +31 -350
  126. package/docs/notification.md +17 -116
  127. package/docs/numeric-textbox.md +9 -78
  128. package/docs/otp-input.md +9 -95
  129. package/docs/pager.md +19 -239
  130. package/docs/placeholder.md +5 -18
  131. package/docs/popover.md +13 -123
  132. package/docs/popup-menu.md +22 -243
  133. package/docs/popup.md +24 -248
  134. package/docs/progress-bar.md +10 -75
  135. package/docs/radio-button.md +8 -96
  136. package/docs/range-slider.md +9 -82
  137. package/docs/rating.md +15 -163
  138. package/docs/scroll-view.md +9 -86
  139. package/docs/segmented.md +8 -90
  140. package/docs/sheet.md +10 -74
  141. package/docs/sidebar-menus.md +20 -155
  142. package/docs/sidebar-state.md +16 -134
  143. package/docs/sidebar.md +18 -218
  144. package/docs/skeleton.md +5 -26
  145. package/docs/slider.md +9 -97
  146. package/docs/spinner.md +15 -95
  147. package/docs/split-button.md +21 -166
  148. package/docs/splitter.md +9 -56
  149. package/docs/stepper.md +13 -127
  150. package/docs/switch.md +8 -58
  151. package/docs/tabs.md +13 -111
  152. package/docs/textarea.md +4 -13
  153. package/docs/textbox.md +10 -77
  154. package/docs/theming-built-in-themes.md +67 -0
  155. package/docs/theming-custom-colors.md +274 -0
  156. package/docs/theming-custom-themes.md +168 -0
  157. package/docs/theming.md +164 -248
  158. package/docs/time-picker.md +7 -112
  159. package/docs/tooltip-directive.md +12 -96
  160. package/docs/tooltip.md +12 -96
  161. package/docs/tree-view.md +42 -495
  162. package/docs/window.md +19 -230
  163. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  164. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  165. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  166. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  167. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  168. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  169. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  170. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  171. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  172. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  173. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  174. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -389
  175. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  176. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  177. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  178. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  179. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  180. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -740
  181. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  182. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -254
  183. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  184. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  185. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  186. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  187. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  188. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -729
  189. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  190. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  191. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  192. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  193. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  194. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  195. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  196. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  197. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  198. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  199. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  200. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  201. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5068
  202. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  203. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  204. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  205. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  206. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  207. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  208. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  209. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  210. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  211. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  212. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  213. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  214. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  215. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  216. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  217. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  218. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  219. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  220. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  221. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  222. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  223. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  224. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  225. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  226. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  227. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  228. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  229. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  230. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  231. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  232. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  233. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  234. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  235. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  236. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  237. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  238. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  239. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  240. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  241. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  242. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  243. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  244. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  245. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  246. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  247. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  248. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  249. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  250. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  251. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  252. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  253. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  254. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  255. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  256. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  257. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  258. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  259. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  260. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  261. package/llms.txt +80 -2
  262. package/package.json +62 -23
  263. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  264. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  265. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  266. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  267. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  268. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  269. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  270. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  271. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  272. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  273. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  274. package/types/nanahoshi-mona-ui-collapsible.d.ts +105 -87
  275. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  276. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  277. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  278. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  279. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  280. package/types/nanahoshi-mona-ui-common.d.ts +360 -385
  281. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  282. package/types/nanahoshi-mona-ui-date-input.d.ts +97 -97
  283. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  284. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  285. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  286. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  287. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  288. package/types/nanahoshi-mona-ui-dropdowns.d.ts +255 -235
  289. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  290. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  291. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  292. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  293. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  294. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  295. package/types/nanahoshi-mona-ui-i18n.d.ts +999 -1052
  296. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  297. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  298. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  299. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  300. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  301. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  302. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  303. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  304. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  305. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  306. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  307. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  308. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  309. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  310. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  311. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  312. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  313. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  314. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  315. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  316. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  317. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  318. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  319. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  320. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  321. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  322. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  323. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  324. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  325. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  326. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  327. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  328. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  329. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  330. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  331. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  332. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  333. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  334. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  335. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  336. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  337. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  338. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  339. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  340. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  341. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  342. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  343. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  344. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  345. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  346. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  347. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  348. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  349. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  350. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  351. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  352. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  353. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  354. package/types/nanahoshi-mona-ui.d.ts +1 -2
  355. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  356. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  357. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  358. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  359. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,87 +1,143 @@
1
- import { NgTemplateOutlet } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { inject, TemplateRef, Directive, computed, input, output, DestroyRef, ElementRef, signal, contentChild, linkedSignal, booleanAttribute, model, afterNextRender, effect, untracked, Component } from '@angular/core';
4
- import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
- import { LucideChevronLeft, LucideChevronRight } from '@lucide/angular';
6
- import { Dictionary, lastOrDefault, range, index, select } from '@mirei/ts-collections';
7
- import { ButtonDirective } from '@nanahoshi/mona-ui/button';
8
- import { PreventableEvent, TakeFirstPipe } from '@nanahoshi/mona-ui/common';
9
- import { CalendarService } from '@nanahoshi/mona-ui/date-input';
10
- import { themeRaisedBackdropClasses, injectEffectiveDisabled, createElementControlId, rxTimeout } from '@nanahoshi/mona-ui/internal';
11
- import { DateTime } from 'luxon';
12
- import { skip, fromEvent } from 'rxjs';
13
- import { twMerge } from 'tailwind-merge';
14
- import { formatNumber, MonaI18nService, formatGregorianDateToLocaleString, injectComponentDirection, gregorianDateTime, getLocaleFirstDayOfWeek, gregorianDateTimeFromObject } from '@nanahoshi/mona-ui/i18n';
15
- import { cva } from 'class-variance-authority';
16
-
17
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
18
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import { NgTemplateOutlet } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, model, output, signal, untracked } from "@angular/core";
4
+ import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
5
+ import { LucideChevronLeft, LucideChevronRight } from "@lucide/angular";
6
+ import { Dictionary, index, lastOrDefault, range, select } from "@mirei/ts-collections";
7
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
8
+ import { PreventableEvent, TakeFirstPipe } from "@nanahoshi/mona-ui/common";
9
+ import { CalendarService } from "@nanahoshi/mona-ui/date-input";
10
+ import { createElementControlId, injectEffectiveDisabled, rxTimeout, themeRaisedBackdropClasses } from "@nanahoshi/mona-ui/internal";
11
+ import { DateTime } from "luxon";
12
+ import { fromEvent, skip } from "rxjs";
13
+ import { twMerge } from "tailwind-merge";
14
+ import { MonaI18nService, formatGregorianDateToLocaleString, formatNumber, getLocaleFirstDayOfWeek, gregorianDateTime, gregorianDateTimeFromObject, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
15
+ import { cva } from "class-variance-authority";
19
16
  function localizeNumber(value, options) {
20
- return formatNumber(value, "en-US", options);
17
+ return formatNumber(value, "en-US", options);
21
18
  }
22
19
  const CALENDAR_DEFAULT_MESSAGES = {
23
- calendarLabel: (formattedMonthAndYear) => `Calendar, ${formattedMonthAndYear}`,
24
- decadeRange: (start, end) => `${localizeNumber(start, { useGrouping: false })} to ${localizeNumber(end, { useGrouping: false })}`,
25
- decadeViewLabel: (start, end) => `Decade view, ${localizeNumber(start, { useGrouping: false })} - ${localizeNumber(end, { useGrouping: false })}`,
26
- goToToday: (formattedDate) => `Go to today, ${formattedDate}`,
27
- nextDecade: "Next decade",
28
- nextMonth: "Next month",
29
- nextYear: "Next year",
30
- previousDecade: "Previous decade",
31
- previousMonth: "Previous month",
32
- previousYear: "Previous year",
33
- switchToDecadeView: (currentYear) => `Switch to decade view, currently ${currentYear}`,
34
- switchToYearView: (currentMonthAndYear) => `Switch to year view, currently ${currentMonthAndYear}`,
35
- today: "Today",
36
- yearCellLabel: (year) => `Year ${localizeNumber(year, { useGrouping: false })}`,
37
- yearViewLabel: (year) => `Year view, ${year}`
20
+ calendarLabel: (formattedMonthAndYear) => `Calendar, ${formattedMonthAndYear}`,
21
+ decadeRange: (start, end) => `${localizeNumber(start, { useGrouping: false })} to ${localizeNumber(end, { useGrouping: false })}`,
22
+ decadeViewLabel: (start, end) => `Decade view, ${localizeNumber(start, { useGrouping: false })} - ${localizeNumber(end, { useGrouping: false })}`,
23
+ goToToday: (formattedDate) => `Go to today, ${formattedDate}`,
24
+ nextDecade: "Next decade",
25
+ nextMonth: "Next month",
26
+ nextYear: "Next year",
27
+ previousDecade: "Previous decade",
28
+ previousMonth: "Previous month",
29
+ previousYear: "Previous year",
30
+ switchToDecadeView: (currentYear) => `Switch to decade view, currently ${currentYear}`,
31
+ switchToYearView: (currentMonthAndYear) => `Switch to year view, currently ${currentMonthAndYear}`,
32
+ today: "Today",
33
+ yearCellLabel: (year) => `Year ${localizeNumber(year, { useGrouping: false })}`,
34
+ yearViewLabel: (year) => `Year view, ${year}`
38
35
  };
39
-
40
- /** Provides a custom template for each year cell in the decade view. */
41
- class CalendarDecadeCellTemplateDirective {
42
- constructor() {
43
- this.templateRef = inject(TemplateRef);
44
- }
45
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarDecadeCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
46
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CalendarDecadeCellTemplateDirective, isStandalone: true, selector: "ng-template[monaCalendarDecadeCellTemplate]", ngImport: i0 }); }
47
- }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarDecadeCellTemplateDirective, decorators: [{
49
- type: Directive,
50
- args: [{
51
- selector: "ng-template[monaCalendarDecadeCellTemplate]"
52
- }]
53
- }] });
54
-
55
- /** Provides a custom template for each day cell in the month view. */
56
- class CalendarMonthCellTemplateDirective {
57
- constructor() {
58
- this.templateRef = inject(TemplateRef);
59
- }
60
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarMonthCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
61
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CalendarMonthCellTemplateDirective, isStandalone: true, selector: "ng-template[monaCalendarMonthCellTemplate]", ngImport: i0 }); }
62
- }
63
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarMonthCellTemplateDirective, decorators: [{
64
- type: Directive,
65
- args: [{
66
- selector: "ng-template[monaCalendarMonthCellTemplate]"
67
- }]
68
- }] });
69
-
70
- /** Provides a custom template for each month cell in the year (month-selection) view. */
71
- class CalendarYearCellTemplateDirective {
72
- constructor() {
73
- this.templateRef = inject(TemplateRef);
74
- }
75
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarYearCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
76
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CalendarYearCellTemplateDirective, isStandalone: true, selector: "ng-template[monaCalendarYearCellTemplate]", ngImport: i0 }); }
77
- }
78
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarYearCellTemplateDirective, decorators: [{
79
- type: Directive,
80
- args: [{
81
- selector: "ng-template[monaCalendarYearCellTemplate]"
82
- }]
83
- }] });
84
-
36
+ var CalendarDecadeCellTemplateDirective = class CalendarDecadeCellTemplateDirective {
37
+ constructor() {
38
+ this.templateRef = inject(TemplateRef);
39
+ }
40
+ static {
41
+ this.ɵfac = i0.ɵɵngDeclareFactory({
42
+ minVersion: "12.0.0",
43
+ version: "22.2.6",
44
+ ngImport: i0,
45
+ type: CalendarDecadeCellTemplateDirective,
46
+ deps: [],
47
+ target: i0.ɵɵFactoryTarget.Directive
48
+ });
49
+ }
50
+ static {
51
+ this.ɵdir = i0.ɵɵngDeclareDirective({
52
+ minVersion: "14.0.0",
53
+ version: "22.2.6",
54
+ type: CalendarDecadeCellTemplateDirective,
55
+ isStandalone: true,
56
+ selector: "ng-template[monaCalendarDecadeCellTemplate]",
57
+ ngImport: i0
58
+ });
59
+ }
60
+ };
61
+ i0.ɵɵngDeclareClassMetadata({
62
+ minVersion: "12.0.0",
63
+ version: "22.2.6",
64
+ ngImport: i0,
65
+ type: CalendarDecadeCellTemplateDirective,
66
+ decorators: [{
67
+ type: Directive,
68
+ args: [{ selector: "ng-template[monaCalendarDecadeCellTemplate]" }]
69
+ }]
70
+ });
71
+ var CalendarMonthCellTemplateDirective = class CalendarMonthCellTemplateDirective {
72
+ constructor() {
73
+ this.templateRef = inject(TemplateRef);
74
+ }
75
+ static {
76
+ this.ɵfac = i0.ɵɵngDeclareFactory({
77
+ minVersion: "12.0.0",
78
+ version: "22.2.6",
79
+ ngImport: i0,
80
+ type: CalendarMonthCellTemplateDirective,
81
+ deps: [],
82
+ target: i0.ɵɵFactoryTarget.Directive
83
+ });
84
+ }
85
+ static {
86
+ this.ɵdir = i0.ɵɵngDeclareDirective({
87
+ minVersion: "14.0.0",
88
+ version: "22.2.6",
89
+ type: CalendarMonthCellTemplateDirective,
90
+ isStandalone: true,
91
+ selector: "ng-template[monaCalendarMonthCellTemplate]",
92
+ ngImport: i0
93
+ });
94
+ }
95
+ };
96
+ i0.ɵɵngDeclareClassMetadata({
97
+ minVersion: "12.0.0",
98
+ version: "22.2.6",
99
+ ngImport: i0,
100
+ type: CalendarMonthCellTemplateDirective,
101
+ decorators: [{
102
+ type: Directive,
103
+ args: [{ selector: "ng-template[monaCalendarMonthCellTemplate]" }]
104
+ }]
105
+ });
106
+ var CalendarYearCellTemplateDirective = class CalendarYearCellTemplateDirective {
107
+ constructor() {
108
+ this.templateRef = inject(TemplateRef);
109
+ }
110
+ static {
111
+ this.ɵfac = i0.ɵɵngDeclareFactory({
112
+ minVersion: "12.0.0",
113
+ version: "22.2.6",
114
+ ngImport: i0,
115
+ type: CalendarYearCellTemplateDirective,
116
+ deps: [],
117
+ target: i0.ɵɵFactoryTarget.Directive
118
+ });
119
+ }
120
+ static {
121
+ this.ɵdir = i0.ɵɵngDeclareDirective({
122
+ minVersion: "14.0.0",
123
+ version: "22.2.6",
124
+ type: CalendarYearCellTemplateDirective,
125
+ isStandalone: true,
126
+ selector: "ng-template[monaCalendarYearCellTemplate]",
127
+ ngImport: i0
128
+ });
129
+ }
130
+ };
131
+ i0.ɵɵngDeclareClassMetadata({
132
+ minVersion: "12.0.0",
133
+ version: "22.2.6",
134
+ ngImport: i0,
135
+ type: CalendarYearCellTemplateDirective,
136
+ decorators: [{
137
+ type: Directive,
138
+ args: [{ selector: "ng-template[monaCalendarYearCellTemplate]" }]
139
+ }]
140
+ });
85
141
  const calendarBaseThemeVariants = cva(`
86
142
  flex min-w-64 flex-col gap-2 p-2
87
143
  select-none
@@ -89,23 +145,17 @@ const calendarBaseThemeVariants = cva(`
89
145
  border border-border shadow-(--mona-calendar-shadow)
90
146
  data-[invalid='true']:border-error
91
147
  data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
92
- `, {
93
- variants: {
94
- disabled: {
95
- true: "pointer-events-none cursor-not-allowed opacity-50"
96
- },
97
- readonly: {
98
- true: "pointer-events-none"
99
- },
100
- rounded: {
101
- none: "rounded-none",
102
- small: "rounded-sm",
103
- medium: "rounded-md",
104
- large: "rounded-lg",
105
- full: "rounded-full"
106
- }
107
- }
108
- });
148
+ `, { variants: {
149
+ disabled: { true: "pointer-events-none cursor-not-allowed opacity-50" },
150
+ readonly: { true: "pointer-events-none" },
151
+ rounded: {
152
+ none: "rounded-none",
153
+ small: "rounded-sm",
154
+ medium: "rounded-md",
155
+ large: "rounded-lg",
156
+ full: "rounded-full"
157
+ }
158
+ } });
109
159
  const calendarHeaderThemeVariants = cva(`
110
160
  flex items-center justify-center
111
161
  [&>button+button]:not-focus:border-s-0
@@ -119,43 +169,27 @@ const calendarMonthViewDayThemeVariants = cva(`
119
169
  cursor-pointer
120
170
  hover:bg-hover active:bg-active
121
171
  `, {
122
- variants: {
123
- disabled: {
124
- true: "pointer-events-none cursor-not-allowed text-disabled-foreground"
125
- },
126
- focused: {
127
- true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35"
128
- },
129
- outside: {
130
- true: "text-muted-foreground"
131
- },
132
- rangePreview: {
133
- true: "bg-active hover:bg-active"
134
- },
135
- rounded: {
136
- none: "rounded-none",
137
- small: "rounded-sm",
138
- medium: "rounded-md",
139
- large: "rounded-lg",
140
- full: "rounded-full"
141
- },
142
- selected: {
143
- true: "bg-primary text-primary-foreground hover:bg-primary-hover forced-color-adjust-none forced-colors:bg-[Highlight]! forced-colors:text-[HighlightText]"
144
- },
145
- today: {
146
- true: "font-bold text-foreground"
147
- }
148
- },
149
- compoundVariants: [
150
- {
151
- selected: true,
152
- today: true,
153
- class: "text-primary-foreground"
154
- }
155
- ],
156
- defaultVariants: {
157
- rounded: "medium"
158
- }
172
+ variants: {
173
+ disabled: { true: "pointer-events-none cursor-not-allowed text-disabled-foreground" },
174
+ focused: { true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35" },
175
+ outside: { true: "text-muted-foreground" },
176
+ rangePreview: { true: "bg-active hover:bg-active" },
177
+ rounded: {
178
+ none: "rounded-none",
179
+ small: "rounded-sm",
180
+ medium: "rounded-md",
181
+ large: "rounded-lg",
182
+ full: "rounded-full"
183
+ },
184
+ selected: { true: "bg-primary text-primary-foreground hover:bg-primary-hover forced-color-adjust-none forced-colors:bg-[Highlight]! forced-colors:text-[HighlightText]" },
185
+ today: { true: "font-bold text-foreground" }
186
+ },
187
+ compoundVariants: [{
188
+ selected: true,
189
+ today: true,
190
+ class: "text-primary-foreground"
191
+ }],
192
+ defaultVariants: { rounded: "medium" }
159
193
  });
160
194
  const calendarMonthViewGridThemeVariants = cva(`
161
195
  grid justify-center gap-0.5
@@ -178,20 +212,16 @@ const calendarYearViewGridThemeVariants = cva(`
178
212
  const calendarYearViewCellThemeVariants = cva(`
179
213
  cursor-pointer py-2
180
214
  hover:bg-hover active:bg-active
181
- `, {
182
- variants: {
183
- focused: {
184
- true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35"
185
- },
186
- rounded: {
187
- none: "rounded-none",
188
- small: "rounded-sm",
189
- medium: "rounded-md",
190
- large: "rounded-lg",
191
- full: "rounded-full"
192
- }
193
- }
194
- });
215
+ `, { variants: {
216
+ focused: { true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35" },
217
+ rounded: {
218
+ none: "rounded-none",
219
+ small: "rounded-sm",
220
+ medium: "rounded-md",
221
+ large: "rounded-lg",
222
+ full: "rounded-full"
223
+ }
224
+ } });
195
225
  const calendarDecadeViewGridThemeVariants = cva(`
196
226
  grid grid-cols-4 justify-center gap-0.5
197
227
  [&>div]:flex [&>div]:h-12
@@ -200,1439 +230,1906 @@ const calendarDecadeViewGridThemeVariants = cva(`
200
230
  const calendarDecadeViewCellThemeVariants = cva(`
201
231
  cursor-pointer py-2
202
232
  hover:bg-hover active:bg-active
203
- `, {
204
- variants: {
205
- focused: {
206
- true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35"
207
- },
208
- rounded: {
209
- none: "rounded-none",
210
- small: "rounded-sm",
211
- medium: "rounded-md",
212
- large: "rounded-lg",
213
- full: "rounded-full"
214
- }
215
- }
233
+ `, { variants: {
234
+ focused: { true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35" },
235
+ rounded: {
236
+ none: "rounded-none",
237
+ small: "rounded-sm",
238
+ medium: "rounded-md",
239
+ large: "rounded-lg",
240
+ full: "rounded-full"
241
+ }
242
+ } });
243
+ var DecadeYearDirective = class DecadeYearDirective {
244
+ constructor() {
245
+ this.#i18n = inject(MonaI18nService);
246
+ this.ariaLabel = computed(() => this.messages().yearCellLabel(this.year()), ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
247
+ this.baseClass = computed(() => {
248
+ const focused = this.focused();
249
+ const rounded = this.rounded();
250
+ return calendarDecadeViewCellThemeVariants({
251
+ focused,
252
+ rounded
253
+ });
254
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
255
+ this.focused = computed(() => {
256
+ const navigatedYear = DateTime.fromJSDate(this.navigatedDate()).year;
257
+ return this.year() === navigatedYear;
258
+ }, ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
259
+ this.isCurrent = computed(() => {
260
+ return this.year() === DateTime.now().year;
261
+ }, ...ngDevMode ? [{ debugName: "isCurrent" }] : /* istanbul ignore next */ []);
262
+ this.messages = this.#i18n.componentMessages("calendar", CALENDAR_DEFAULT_MESSAGES);
263
+ this.selected = computed(() => {
264
+ const selectedDate = this.selectedDate();
265
+ if (!selectedDate) return false;
266
+ return this.year() === DateTime.fromJSDate(selectedDate).year;
267
+ }, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
268
+ this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
269
+ this.navigatedDate = input.required(...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
270
+ this.rounded = input.required(...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
271
+ this.selectedDate = input(null, ...ngDevMode ? [{ debugName: "selectedDate" }] : /* istanbul ignore next */ []);
272
+ this.year = input.required(...ngDevMode ? [{ debugName: "year" }] : /* istanbul ignore next */ []);
273
+ }
274
+ #i18n;
275
+ static {
276
+ this.ɵfac = i0.ɵɵngDeclareFactory({
277
+ minVersion: "12.0.0",
278
+ version: "22.2.6",
279
+ ngImport: i0,
280
+ type: DecadeYearDirective,
281
+ deps: [],
282
+ target: i0.ɵɵFactoryTarget.Directive
283
+ });
284
+ }
285
+ static {
286
+ this.ɵdir = i0.ɵɵngDeclareDirective({
287
+ minVersion: "17.1.0",
288
+ version: "22.2.6",
289
+ type: DecadeYearDirective,
290
+ isStandalone: true,
291
+ selector: "[monaDecadeYear]",
292
+ inputs: {
293
+ disabled: {
294
+ classPropertyName: "disabled",
295
+ publicName: "disabled",
296
+ isSignal: true,
297
+ isRequired: false,
298
+ transformFunction: null
299
+ },
300
+ navigatedDate: {
301
+ classPropertyName: "navigatedDate",
302
+ publicName: "navigatedDate",
303
+ isSignal: true,
304
+ isRequired: true,
305
+ transformFunction: null
306
+ },
307
+ rounded: {
308
+ classPropertyName: "rounded",
309
+ publicName: "rounded",
310
+ isSignal: true,
311
+ isRequired: true,
312
+ transformFunction: null
313
+ },
314
+ selectedDate: {
315
+ classPropertyName: "selectedDate",
316
+ publicName: "selectedDate",
317
+ isSignal: true,
318
+ isRequired: false,
319
+ transformFunction: null
320
+ },
321
+ year: {
322
+ classPropertyName: "year",
323
+ publicName: "year",
324
+ isSignal: true,
325
+ isRequired: true,
326
+ transformFunction: null
327
+ }
328
+ },
329
+ host: {
330
+ attributes: { "role": "gridcell" },
331
+ properties: {
332
+ "attr.tabindex": "focused() && !disabled() ? 0 : -1",
333
+ "attr.aria-current": "isCurrent() ? 'true' : null",
334
+ "attr.aria-disabled": "disabled() ? 'true' : null",
335
+ "attr.aria-label": "ariaLabel()",
336
+ "attr.aria-selected": "selected() ? 'true' : null",
337
+ "class": "baseClass()"
338
+ }
339
+ },
340
+ ngImport: i0
341
+ });
342
+ }
343
+ };
344
+ i0.ɵɵngDeclareClassMetadata({
345
+ minVersion: "12.0.0",
346
+ version: "22.2.6",
347
+ ngImport: i0,
348
+ type: DecadeYearDirective,
349
+ decorators: [{
350
+ type: Directive,
351
+ args: [{
352
+ selector: "[monaDecadeYear]",
353
+ host: {
354
+ "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
355
+ "[attr.aria-current]": "isCurrent() ? 'true' : null",
356
+ "[attr.aria-disabled]": "disabled() ? 'true' : null",
357
+ "[attr.aria-label]": "ariaLabel()",
358
+ "[attr.aria-selected]": "selected() ? 'true' : null",
359
+ "[class]": "baseClass()",
360
+ role: "gridcell"
361
+ }
362
+ }]
363
+ }],
364
+ propDecorators: {
365
+ disabled: [{
366
+ type: i0.Input,
367
+ args: [{
368
+ isSignal: true,
369
+ alias: "disabled",
370
+ required: false
371
+ }]
372
+ }],
373
+ navigatedDate: [{
374
+ type: i0.Input,
375
+ args: [{
376
+ isSignal: true,
377
+ alias: "navigatedDate",
378
+ required: true
379
+ }]
380
+ }],
381
+ rounded: [{
382
+ type: i0.Input,
383
+ args: [{
384
+ isSignal: true,
385
+ alias: "rounded",
386
+ required: true
387
+ }]
388
+ }],
389
+ selectedDate: [{
390
+ type: i0.Input,
391
+ args: [{
392
+ isSignal: true,
393
+ alias: "selectedDate",
394
+ required: false
395
+ }]
396
+ }],
397
+ year: [{
398
+ type: i0.Input,
399
+ args: [{
400
+ isSignal: true,
401
+ alias: "year",
402
+ required: true
403
+ }]
404
+ }]
405
+ }
216
406
  });
217
-
218
- /** One year of the decade view: a grid cell. */
219
- class DecadeYearDirective {
220
- constructor() {
221
- this.#i18n = inject(MonaI18nService);
222
- this.ariaLabel = computed(() => this.messages().yearCellLabel(this.year()), /* @ts-ignore */
223
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
224
- this.baseClass = computed(() => {
225
- const focused = this.focused();
226
- const rounded = this.rounded();
227
- return calendarDecadeViewCellThemeVariants({ focused, rounded });
228
- }, /* @ts-ignore */
229
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
230
- this.focused = computed(() => {
231
- const navigatedYear = DateTime.fromJSDate(this.navigatedDate()).year;
232
- return this.year() === navigatedYear;
233
- }, /* @ts-ignore */
234
- ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
235
- this.isCurrent = computed(() => {
236
- return this.year() === DateTime.now().year;
237
- }, /* @ts-ignore */
238
- ...(ngDevMode ? [{ debugName: "isCurrent" }] : /* istanbul ignore next */ []));
239
- this.messages = this.#i18n.componentMessages("calendar", CALENDAR_DEFAULT_MESSAGES);
240
- this.selected = computed(() => {
241
- const selectedDate = this.selectedDate();
242
- if (!selectedDate) {
243
- return false;
244
- }
245
- return this.year() === DateTime.fromJSDate(selectedDate).year;
246
- }, /* @ts-ignore */
247
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
248
- /** Whether the whole calendar is disabled. */
249
- this.disabled = input(false, /* @ts-ignore */
250
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
251
- this.navigatedDate = input.required(/* @ts-ignore */
252
- ...(ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []));
253
- this.rounded = input.required(/* @ts-ignore */
254
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
255
- this.selectedDate = input(null, /* @ts-ignore */
256
- ...(ngDevMode ? [{ debugName: "selectedDate" }] : /* istanbul ignore next */ []));
257
- this.year = input.required(/* @ts-ignore */
258
- ...(ngDevMode ? [{ debugName: "year" }] : /* istanbul ignore next */ []));
259
- }
260
- #i18n;
261
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecadeYearDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
262
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: DecadeYearDirective, isStandalone: true, selector: "[monaDecadeYear]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, navigatedDate: { classPropertyName: "navigatedDate", publicName: "navigatedDate", isSignal: true, isRequired: true, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: true, transformFunction: null }, selectedDate: { classPropertyName: "selectedDate", publicName: "selectedDate", isSignal: true, isRequired: false, transformFunction: null }, year: { classPropertyName: "year", publicName: "year", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "attr.tabindex": "focused() && !disabled() ? 0 : -1", "attr.aria-current": "isCurrent() ? 'true' : null", "attr.aria-disabled": "disabled() ? 'true' : null", "attr.aria-label": "ariaLabel()", "attr.aria-selected": "selected() ? 'true' : null", "class": "baseClass()" } }, ngImport: i0 }); }
263
- }
264
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DecadeYearDirective, decorators: [{
265
- type: Directive,
266
- args: [{
267
- selector: "[monaDecadeYear]",
268
- host: {
269
- "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
270
- "[attr.aria-current]": "isCurrent() ? 'true' : null",
271
- "[attr.aria-disabled]": "disabled() ? 'true' : null",
272
- "[attr.aria-label]": "ariaLabel()",
273
- "[attr.aria-selected]": "selected() ? 'true' : null",
274
- "[class]": "baseClass()",
275
- role: "gridcell"
276
- }
277
- }]
278
- }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], navigatedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigatedDate", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }], selectedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedDate", required: false }] }], year: [{ type: i0.Input, args: [{ isSignal: true, alias: "year", required: true }] }] } });
279
-
280
407
  const compareDates = (date1, date2, operator) => {
281
- if (!date1 || !date2) {
282
- return false;
283
- }
284
- const valueDateParts = [date1.getFullYear(), date1.getMonth(), date1.getDate()];
285
- const otherDateParts = [date2.getFullYear(), date2.getMonth(), date2.getDate()];
286
- for (let i = 0; i < 3; i++) {
287
- switch (operator) {
288
- case "==":
289
- if (valueDateParts[i] !== otherDateParts[i])
290
- return false;
291
- break;
292
- case "!=":
293
- if (valueDateParts[i] !== otherDateParts[i])
294
- return true;
295
- break;
296
- case "<":
297
- case "<=":
298
- if (valueDateParts[i] < otherDateParts[i])
299
- return true;
300
- if (valueDateParts[i] > otherDateParts[i])
301
- return false;
302
- if (operator === "<=" && i === 2 && valueDateParts[i] === otherDateParts[i])
303
- return true;
304
- break;
305
- case ">":
306
- case ">=":
307
- if (valueDateParts[i] > otherDateParts[i])
308
- return true;
309
- if (valueDateParts[i] < otherDateParts[i])
310
- return false;
311
- if (operator === ">=" && i === 2 && valueDateParts[i] === otherDateParts[i])
312
- return true;
313
- break;
314
- default:
315
- return false;
316
- }
317
- }
318
- return operator === "==";
408
+ if (!date1 || !date2) return false;
409
+ const valueDateParts = [
410
+ date1.getFullYear(),
411
+ date1.getMonth(),
412
+ date1.getDate()
413
+ ];
414
+ const otherDateParts = [
415
+ date2.getFullYear(),
416
+ date2.getMonth(),
417
+ date2.getDate()
418
+ ];
419
+ for (let i = 0; i < 3; i++) switch (operator) {
420
+ case "==":
421
+ if (valueDateParts[i] !== otherDateParts[i]) return false;
422
+ break;
423
+ case "!=":
424
+ if (valueDateParts[i] !== otherDateParts[i]) return true;
425
+ break;
426
+ case "<":
427
+ case "<=":
428
+ if (valueDateParts[i] < otherDateParts[i]) return true;
429
+ if (valueDateParts[i] > otherDateParts[i]) return false;
430
+ if (operator === "<=" && i === 2 && valueDateParts[i] === otherDateParts[i]) return true;
431
+ break;
432
+ case ">":
433
+ case ">=":
434
+ if (valueDateParts[i] > otherDateParts[i]) return true;
435
+ if (valueDateParts[i] < otherDateParts[i]) return false;
436
+ if (operator === ">=" && i === 2 && valueDateParts[i] === otherDateParts[i]) return true;
437
+ break;
438
+ default: return false;
439
+ }
440
+ return operator === "==";
319
441
  };
320
- /** A key that is equal for two dates on the same local calendar day, whatever their time. */
321
442
  const toDayKey = (date) => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
322
-
323
- /**
324
- * One day of the month view: a grid cell named by its full date ("Tuesday, November 4, 2026"). The calendar passes
325
- * the selection and the range preview as sets of day keys, so each cell answers in constant time.
326
- */
327
- class MonthDayDirective {
328
- constructor() {
329
- this.#i18n = inject(MonaI18nService);
330
- this.#key = computed(() => toDayKey(this.entry().key), /* @ts-ignore */
331
- ...(ngDevMode ? [{ debugName: "#key" }] : /* istanbul ignore next */ []));
332
- this.ariaLabel = computed(() => formatGregorianDateToLocaleString(this.entry().key, this.#i18n.localeId(), {
333
- weekday: "long",
334
- year: "numeric",
335
- month: "long",
336
- day: "numeric"
337
- }), /* @ts-ignore */
338
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
339
- this.baseClass = computed(() => {
340
- const disabled = this.dayDisabled();
341
- const focused = this.focused();
342
- const outside = this.outside();
343
- const rangePreview = this.rangePreviewed();
344
- const rounded = this.rounded();
345
- const selected = this.selected();
346
- const today = this.isToday();
347
- return calendarMonthViewDayThemeVariants({
348
- disabled,
349
- focused,
350
- outside,
351
- rangePreview,
352
- rounded,
353
- selected,
354
- today
355
- });
356
- }, /* @ts-ignore */
357
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
358
- this.dayDisabled = computed(() => this.disabled() || this.isDayUnavailable()(this.entry().key), /* @ts-ignore */
359
- ...(ngDevMode ? [{ debugName: "dayDisabled" }] : /* istanbul ignore next */ []));
360
- this.focused = computed(() => compareDates(this.entry().key, this.navigatedDate(), "=="), /* @ts-ignore */
361
- ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
362
- this.isToday = computed(() => compareDates(this.entry().key, this.today(), "=="), /* @ts-ignore */
363
- ...(ngDevMode ? [{ debugName: "isToday" }] : /* istanbul ignore next */ []));
364
- this.outside = computed(() => {
365
- const entry = this.entry();
366
- const monthStart = this.monthBounds()[0];
367
- const monthEnd = this.monthBounds()[1];
368
- return compareDates(entry.key, monthStart, "<") || compareDates(entry.key, monthEnd, ">");
369
- }, /* @ts-ignore */
370
- ...(ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []));
371
- this.rangePreviewed = computed(() => !this.selected() && this.rangePreviewKeys().has(this.#key()), /* @ts-ignore */
372
- ...(ngDevMode ? [{ debugName: "rangePreviewed" }] : /* istanbul ignore next */ []));
373
- this.selected = computed(() => this.selectedKeys().has(this.#key()), /* @ts-ignore */
374
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
375
- this.dayPointerEnter = output();
376
- this.daySelect = output();
377
- /** Whether the whole calendar is disabled. */
378
- this.disabled = input.required(/* @ts-ignore */
379
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
380
- this.entry = input.required(/* @ts-ignore */
381
- ...(ngDevMode ? [{ debugName: "entry" }] : /* istanbul ignore next */ []));
382
- /** Whether a day can't be picked: out of range or in `disabledDates`. */
383
- this.isDayUnavailable = input.required(/* @ts-ignore */
384
- ...(ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []));
385
- this.monthBounds = input.required(/* @ts-ignore */
386
- ...(ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []));
387
- this.navigatedDate = input.required(/* @ts-ignore */
388
- ...(ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []));
389
- this.rangePreviewKeys = input.required(/* @ts-ignore */
390
- ...(ngDevMode ? [{ debugName: "rangePreviewKeys" }] : /* istanbul ignore next */ []));
391
- this.rounded = input.required(/* @ts-ignore */
392
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
393
- this.selectedKeys = input.required(/* @ts-ignore */
394
- ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
395
- this.today = input.required(/* @ts-ignore */
396
- ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
397
- }
398
- #i18n;
399
- #key;
400
- onClick(event) {
401
- if (this.dayDisabled()) {
402
- return;
403
- }
404
- event.preventDefault();
405
- this.daySelect.emit({ date: this.entry().key, event });
406
- }
407
- onPointerEnter() {
408
- if (this.dayDisabled()) {
409
- return;
410
- }
411
- this.dayPointerEnter.emit(this.entry().key);
412
- }
413
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MonthDayDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
414
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: MonthDayDirective, isStandalone: true, selector: "[monaMonthDay]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: true, transformFunction: null }, entry: { classPropertyName: "entry", publicName: "entry", isSignal: true, isRequired: true, transformFunction: null }, isDayUnavailable: { classPropertyName: "isDayUnavailable", publicName: "isDayUnavailable", isSignal: true, isRequired: true, transformFunction: null }, monthBounds: { classPropertyName: "monthBounds", publicName: "monthBounds", isSignal: true, isRequired: true, transformFunction: null }, navigatedDate: { classPropertyName: "navigatedDate", publicName: "navigatedDate", isSignal: true, isRequired: true, transformFunction: null }, rangePreviewKeys: { classPropertyName: "rangePreviewKeys", publicName: "rangePreviewKeys", isSignal: true, isRequired: true, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: true, transformFunction: null }, selectedKeys: { classPropertyName: "selectedKeys", publicName: "selectedKeys", isSignal: true, isRequired: true, transformFunction: null }, today: { classPropertyName: "today", publicName: "today", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { dayPointerEnter: "dayPointerEnter", daySelect: "daySelect" }, host: { attributes: { "role": "gridcell" }, listeners: { "click": "onClick($event)", "pointerenter": "onPointerEnter()" }, properties: { "attr.tabindex": "focused() && !disabled() ? 0 : -1", "attr.aria-current": "isToday() ? 'date' : null", "attr.aria-disabled": "dayDisabled() ? 'true' : null", "attr.aria-label": "ariaLabel()", "attr.aria-selected": "selected() ? 'true' : null", "attr.data-range-preview": "rangePreviewed() ? 'true' : null", "class": "baseClass()" } }, ngImport: i0 }); }
415
- }
416
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MonthDayDirective, decorators: [{
417
- type: Directive,
418
- args: [{
419
- selector: "[monaMonthDay]",
420
- host: {
421
- "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
422
- "[attr.aria-current]": "isToday() ? 'date' : null",
423
- "[attr.aria-disabled]": "dayDisabled() ? 'true' : null",
424
- "[attr.aria-label]": "ariaLabel()",
425
- "[attr.aria-selected]": "selected() ? 'true' : null",
426
- "[attr.data-range-preview]": "rangePreviewed() ? 'true' : null",
427
- "[class]": "baseClass()",
428
- "(click)": "onClick($event)",
429
- "(pointerenter)": "onPointerEnter()",
430
- role: "gridcell"
431
- }
432
- }]
433
- }], propDecorators: { dayPointerEnter: [{ type: i0.Output, args: ["dayPointerEnter"] }], daySelect: [{ type: i0.Output, args: ["daySelect"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: true }] }], entry: [{ type: i0.Input, args: [{ isSignal: true, alias: "entry", required: true }] }], isDayUnavailable: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDayUnavailable", required: true }] }], monthBounds: [{ type: i0.Input, args: [{ isSignal: true, alias: "monthBounds", required: true }] }], navigatedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigatedDate", required: true }] }], rangePreviewKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "rangePreviewKeys", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }], selectedKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedKeys", required: true }] }], today: [{ type: i0.Input, args: [{ isSignal: true, alias: "today", required: true }] }] } });
434
-
435
- /** One month of the year view: a grid cell named by the long month and the year ("November 2026"). */
436
- class YearMonthDirective {
437
- constructor() {
438
- this.#i18n = inject(MonaI18nService);
439
- this.ariaLabel = computed(() => {
440
- const date = new Date(this.navigatedDate().getFullYear(), this.month() - 1, 1);
441
- return formatGregorianDateToLocaleString(date, this.#i18n.localeId(), { year: "numeric", month: "long" });
442
- }, /* @ts-ignore */
443
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
444
- this.baseClass = computed(() => {
445
- const focused = this.focused();
446
- const rounded = this.rounded();
447
- return calendarYearViewCellThemeVariants({ focused, rounded });
448
- }, /* @ts-ignore */
449
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
450
- this.focused = computed(() => {
451
- const navigatedMonth = DateTime.fromJSDate(this.navigatedDate()).month;
452
- return this.month() === navigatedMonth;
453
- }, /* @ts-ignore */
454
- ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
455
- this.isCurrent = computed(() => {
456
- const now = DateTime.now();
457
- const navDate = DateTime.fromJSDate(this.navigatedDate());
458
- return this.month() === now.month && navDate.year === now.year;
459
- }, /* @ts-ignore */
460
- ...(ngDevMode ? [{ debugName: "isCurrent" }] : /* istanbul ignore next */ []));
461
- this.selected = computed(() => {
462
- const selectedDate = this.selectedDate();
463
- if (!selectedDate) {
464
- return false;
465
- }
466
- const navDate = DateTime.fromJSDate(this.navigatedDate());
467
- const selDate = DateTime.fromJSDate(selectedDate);
468
- return this.month() === selDate.month && navDate.year === selDate.year;
469
- }, /* @ts-ignore */
470
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
471
- /** Whether the whole calendar is disabled. */
472
- this.disabled = input(false, /* @ts-ignore */
473
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
474
- this.month = input.required(/* @ts-ignore */
475
- ...(ngDevMode ? [{ debugName: "month" }] : /* istanbul ignore next */ []));
476
- this.navigatedDate = input.required(/* @ts-ignore */
477
- ...(ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []));
478
- this.rounded = input.required(/* @ts-ignore */
479
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
480
- this.selectedDate = input(/* @ts-ignore */
481
- ...(ngDevMode ? [undefined, { debugName: "selectedDate" }] : /* istanbul ignore next */ []));
482
- }
483
- #i18n;
484
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: YearMonthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
485
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: YearMonthDirective, isStandalone: true, selector: "[monaYearMonth]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, month: { classPropertyName: "month", publicName: "month", isSignal: true, isRequired: true, transformFunction: null }, navigatedDate: { classPropertyName: "navigatedDate", publicName: "navigatedDate", isSignal: true, isRequired: true, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: true, transformFunction: null }, selectedDate: { classPropertyName: "selectedDate", publicName: "selectedDate", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "attr.tabindex": "focused() && !disabled() ? 0 : -1", "attr.aria-current": "isCurrent() ? 'date' : null", "attr.aria-disabled": "disabled() ? 'true' : null", "attr.aria-label": "ariaLabel()", "attr.aria-selected": "selected() ? 'true' : null", "class": "baseClass()" } }, ngImport: i0 }); }
486
- }
487
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: YearMonthDirective, decorators: [{
488
- type: Directive,
489
- args: [{
490
- selector: "[monaYearMonth]",
491
- host: {
492
- "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
493
- "[attr.aria-current]": "isCurrent() ? 'date' : null",
494
- "[attr.aria-disabled]": "disabled() ? 'true' : null",
495
- "[attr.aria-label]": "ariaLabel()",
496
- "[attr.aria-selected]": "selected() ? 'true' : null",
497
- "[class]": "baseClass()",
498
- role: "gridcell"
499
- }
500
- }]
501
- }], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], month: [{ type: i0.Input, args: [{ isSignal: true, alias: "month", required: true }] }], navigatedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigatedDate", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }], selectedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedDate", required: false }] }] } });
502
-
503
- /** Midnight at the start of the local day `date` falls on. */
443
+ var MonthDayDirective = class MonthDayDirective {
444
+ constructor() {
445
+ this.#i18n = inject(MonaI18nService);
446
+ this.#key = computed(() => toDayKey(this.entry().key), ...ngDevMode ? [{ debugName: "#key" }] : /* istanbul ignore next */ []);
447
+ this.ariaLabel = computed(() => formatGregorianDateToLocaleString(this.entry().key, this.#i18n.localeId(), {
448
+ weekday: "long",
449
+ year: "numeric",
450
+ month: "long",
451
+ day: "numeric"
452
+ }), ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
453
+ this.baseClass = computed(() => {
454
+ const disabled = this.dayDisabled();
455
+ const focused = this.focused();
456
+ const outside = this.outside();
457
+ const rangePreview = this.rangePreviewed();
458
+ const rounded = this.rounded();
459
+ const selected = this.selected();
460
+ const today = this.isToday();
461
+ return calendarMonthViewDayThemeVariants({
462
+ disabled,
463
+ focused,
464
+ outside,
465
+ rangePreview,
466
+ rounded,
467
+ selected,
468
+ today
469
+ });
470
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
471
+ this.dayDisabled = computed(() => this.disabled() || this.isDayUnavailable()(this.entry().key), ...ngDevMode ? [{ debugName: "dayDisabled" }] : /* istanbul ignore next */ []);
472
+ this.focused = computed(() => compareDates(this.entry().key, this.navigatedDate(), "=="), ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
473
+ this.isToday = computed(() => compareDates(this.entry().key, this.today(), "=="), ...ngDevMode ? [{ debugName: "isToday" }] : /* istanbul ignore next */ []);
474
+ this.outside = computed(() => {
475
+ const entry = this.entry();
476
+ const monthStart = this.monthBounds()[0];
477
+ const monthEnd = this.monthBounds()[1];
478
+ return compareDates(entry.key, monthStart, "<") || compareDates(entry.key, monthEnd, ">");
479
+ }, ...ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []);
480
+ this.rangePreviewed = computed(() => !this.selected() && this.rangePreviewKeys().has(this.#key()), ...ngDevMode ? [{ debugName: "rangePreviewed" }] : /* istanbul ignore next */ []);
481
+ this.selected = computed(() => this.selectedKeys().has(this.#key()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
482
+ this.dayPointerEnter = output();
483
+ this.daySelect = output();
484
+ this.disabled = input.required(...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
485
+ this.entry = input.required(...ngDevMode ? [{ debugName: "entry" }] : /* istanbul ignore next */ []);
486
+ this.isDayUnavailable = input.required(...ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []);
487
+ this.monthBounds = input.required(...ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []);
488
+ this.navigatedDate = input.required(...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
489
+ this.rangePreviewKeys = input.required(...ngDevMode ? [{ debugName: "rangePreviewKeys" }] : /* istanbul ignore next */ []);
490
+ this.rounded = input.required(...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
491
+ this.selectedKeys = input.required(...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
492
+ this.today = input.required(...ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []);
493
+ }
494
+ #i18n;
495
+ #key;
496
+ onClick(event) {
497
+ if (this.dayDisabled()) return;
498
+ event.preventDefault();
499
+ this.daySelect.emit({
500
+ date: this.entry().key,
501
+ event
502
+ });
503
+ }
504
+ onPointerEnter() {
505
+ if (this.dayDisabled()) return;
506
+ this.dayPointerEnter.emit(this.entry().key);
507
+ }
508
+ static {
509
+ this.ɵfac = i0.ɵɵngDeclareFactory({
510
+ minVersion: "12.0.0",
511
+ version: "22.2.6",
512
+ ngImport: i0,
513
+ type: MonthDayDirective,
514
+ deps: [],
515
+ target: i0.ɵɵFactoryTarget.Directive
516
+ });
517
+ }
518
+ static {
519
+ this.ɵdir = i0.ɵɵngDeclareDirective({
520
+ minVersion: "17.1.0",
521
+ version: "22.2.6",
522
+ type: MonthDayDirective,
523
+ isStandalone: true,
524
+ selector: "[monaMonthDay]",
525
+ inputs: {
526
+ disabled: {
527
+ classPropertyName: "disabled",
528
+ publicName: "disabled",
529
+ isSignal: true,
530
+ isRequired: true,
531
+ transformFunction: null
532
+ },
533
+ entry: {
534
+ classPropertyName: "entry",
535
+ publicName: "entry",
536
+ isSignal: true,
537
+ isRequired: true,
538
+ transformFunction: null
539
+ },
540
+ isDayUnavailable: {
541
+ classPropertyName: "isDayUnavailable",
542
+ publicName: "isDayUnavailable",
543
+ isSignal: true,
544
+ isRequired: true,
545
+ transformFunction: null
546
+ },
547
+ monthBounds: {
548
+ classPropertyName: "monthBounds",
549
+ publicName: "monthBounds",
550
+ isSignal: true,
551
+ isRequired: true,
552
+ transformFunction: null
553
+ },
554
+ navigatedDate: {
555
+ classPropertyName: "navigatedDate",
556
+ publicName: "navigatedDate",
557
+ isSignal: true,
558
+ isRequired: true,
559
+ transformFunction: null
560
+ },
561
+ rangePreviewKeys: {
562
+ classPropertyName: "rangePreviewKeys",
563
+ publicName: "rangePreviewKeys",
564
+ isSignal: true,
565
+ isRequired: true,
566
+ transformFunction: null
567
+ },
568
+ rounded: {
569
+ classPropertyName: "rounded",
570
+ publicName: "rounded",
571
+ isSignal: true,
572
+ isRequired: true,
573
+ transformFunction: null
574
+ },
575
+ selectedKeys: {
576
+ classPropertyName: "selectedKeys",
577
+ publicName: "selectedKeys",
578
+ isSignal: true,
579
+ isRequired: true,
580
+ transformFunction: null
581
+ },
582
+ today: {
583
+ classPropertyName: "today",
584
+ publicName: "today",
585
+ isSignal: true,
586
+ isRequired: true,
587
+ transformFunction: null
588
+ }
589
+ },
590
+ outputs: {
591
+ dayPointerEnter: "dayPointerEnter",
592
+ daySelect: "daySelect"
593
+ },
594
+ host: {
595
+ attributes: { "role": "gridcell" },
596
+ listeners: {
597
+ "click": "onClick($event)",
598
+ "pointerenter": "onPointerEnter()"
599
+ },
600
+ properties: {
601
+ "attr.tabindex": "focused() && !disabled() ? 0 : -1",
602
+ "attr.aria-current": "isToday() ? 'date' : null",
603
+ "attr.aria-disabled": "dayDisabled() ? 'true' : null",
604
+ "attr.aria-label": "ariaLabel()",
605
+ "attr.aria-selected": "selected() ? 'true' : null",
606
+ "attr.data-range-preview": "rangePreviewed() ? 'true' : null",
607
+ "class": "baseClass()"
608
+ }
609
+ },
610
+ ngImport: i0
611
+ });
612
+ }
613
+ };
614
+ i0.ɵɵngDeclareClassMetadata({
615
+ minVersion: "12.0.0",
616
+ version: "22.2.6",
617
+ ngImport: i0,
618
+ type: MonthDayDirective,
619
+ decorators: [{
620
+ type: Directive,
621
+ args: [{
622
+ selector: "[monaMonthDay]",
623
+ host: {
624
+ "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
625
+ "[attr.aria-current]": "isToday() ? 'date' : null",
626
+ "[attr.aria-disabled]": "dayDisabled() ? 'true' : null",
627
+ "[attr.aria-label]": "ariaLabel()",
628
+ "[attr.aria-selected]": "selected() ? 'true' : null",
629
+ "[attr.data-range-preview]": "rangePreviewed() ? 'true' : null",
630
+ "[class]": "baseClass()",
631
+ "(click)": "onClick($event)",
632
+ "(pointerenter)": "onPointerEnter()",
633
+ role: "gridcell"
634
+ }
635
+ }]
636
+ }],
637
+ propDecorators: {
638
+ dayPointerEnter: [{
639
+ type: i0.Output,
640
+ args: ["dayPointerEnter"]
641
+ }],
642
+ daySelect: [{
643
+ type: i0.Output,
644
+ args: ["daySelect"]
645
+ }],
646
+ disabled: [{
647
+ type: i0.Input,
648
+ args: [{
649
+ isSignal: true,
650
+ alias: "disabled",
651
+ required: true
652
+ }]
653
+ }],
654
+ entry: [{
655
+ type: i0.Input,
656
+ args: [{
657
+ isSignal: true,
658
+ alias: "entry",
659
+ required: true
660
+ }]
661
+ }],
662
+ isDayUnavailable: [{
663
+ type: i0.Input,
664
+ args: [{
665
+ isSignal: true,
666
+ alias: "isDayUnavailable",
667
+ required: true
668
+ }]
669
+ }],
670
+ monthBounds: [{
671
+ type: i0.Input,
672
+ args: [{
673
+ isSignal: true,
674
+ alias: "monthBounds",
675
+ required: true
676
+ }]
677
+ }],
678
+ navigatedDate: [{
679
+ type: i0.Input,
680
+ args: [{
681
+ isSignal: true,
682
+ alias: "navigatedDate",
683
+ required: true
684
+ }]
685
+ }],
686
+ rangePreviewKeys: [{
687
+ type: i0.Input,
688
+ args: [{
689
+ isSignal: true,
690
+ alias: "rangePreviewKeys",
691
+ required: true
692
+ }]
693
+ }],
694
+ rounded: [{
695
+ type: i0.Input,
696
+ args: [{
697
+ isSignal: true,
698
+ alias: "rounded",
699
+ required: true
700
+ }]
701
+ }],
702
+ selectedKeys: [{
703
+ type: i0.Input,
704
+ args: [{
705
+ isSignal: true,
706
+ alias: "selectedKeys",
707
+ required: true
708
+ }]
709
+ }],
710
+ today: [{
711
+ type: i0.Input,
712
+ args: [{
713
+ isSignal: true,
714
+ alias: "today",
715
+ required: true
716
+ }]
717
+ }]
718
+ }
719
+ });
720
+ var YearMonthDirective = class YearMonthDirective {
721
+ constructor() {
722
+ this.#i18n = inject(MonaI18nService);
723
+ this.ariaLabel = computed(() => {
724
+ const date = new Date(this.navigatedDate().getFullYear(), this.month() - 1, 1);
725
+ return formatGregorianDateToLocaleString(date, this.#i18n.localeId(), {
726
+ year: "numeric",
727
+ month: "long"
728
+ });
729
+ }, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
730
+ this.baseClass = computed(() => {
731
+ const focused = this.focused();
732
+ const rounded = this.rounded();
733
+ return calendarYearViewCellThemeVariants({
734
+ focused,
735
+ rounded
736
+ });
737
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
738
+ this.focused = computed(() => {
739
+ const navigatedMonth = DateTime.fromJSDate(this.navigatedDate()).month;
740
+ return this.month() === navigatedMonth;
741
+ }, ...ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []);
742
+ this.isCurrent = computed(() => {
743
+ const now = DateTime.now();
744
+ const navDate = DateTime.fromJSDate(this.navigatedDate());
745
+ return this.month() === now.month && navDate.year === now.year;
746
+ }, ...ngDevMode ? [{ debugName: "isCurrent" }] : /* istanbul ignore next */ []);
747
+ this.selected = computed(() => {
748
+ const selectedDate = this.selectedDate();
749
+ if (!selectedDate) return false;
750
+ const navDate = DateTime.fromJSDate(this.navigatedDate());
751
+ const selDate = DateTime.fromJSDate(selectedDate);
752
+ return this.month() === selDate.month && navDate.year === selDate.year;
753
+ }, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
754
+ this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
755
+ this.month = input.required(...ngDevMode ? [{ debugName: "month" }] : /* istanbul ignore next */ []);
756
+ this.navigatedDate = input.required(...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
757
+ this.rounded = input.required(...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
758
+ this.selectedDate = input(...ngDevMode ? [void 0, { debugName: "selectedDate" }] : /* istanbul ignore next */ []);
759
+ }
760
+ #i18n;
761
+ static {
762
+ this.ɵfac = i0.ɵɵngDeclareFactory({
763
+ minVersion: "12.0.0",
764
+ version: "22.2.6",
765
+ ngImport: i0,
766
+ type: YearMonthDirective,
767
+ deps: [],
768
+ target: i0.ɵɵFactoryTarget.Directive
769
+ });
770
+ }
771
+ static {
772
+ this.ɵdir = i0.ɵɵngDeclareDirective({
773
+ minVersion: "17.1.0",
774
+ version: "22.2.6",
775
+ type: YearMonthDirective,
776
+ isStandalone: true,
777
+ selector: "[monaYearMonth]",
778
+ inputs: {
779
+ disabled: {
780
+ classPropertyName: "disabled",
781
+ publicName: "disabled",
782
+ isSignal: true,
783
+ isRequired: false,
784
+ transformFunction: null
785
+ },
786
+ month: {
787
+ classPropertyName: "month",
788
+ publicName: "month",
789
+ isSignal: true,
790
+ isRequired: true,
791
+ transformFunction: null
792
+ },
793
+ navigatedDate: {
794
+ classPropertyName: "navigatedDate",
795
+ publicName: "navigatedDate",
796
+ isSignal: true,
797
+ isRequired: true,
798
+ transformFunction: null
799
+ },
800
+ rounded: {
801
+ classPropertyName: "rounded",
802
+ publicName: "rounded",
803
+ isSignal: true,
804
+ isRequired: true,
805
+ transformFunction: null
806
+ },
807
+ selectedDate: {
808
+ classPropertyName: "selectedDate",
809
+ publicName: "selectedDate",
810
+ isSignal: true,
811
+ isRequired: false,
812
+ transformFunction: null
813
+ }
814
+ },
815
+ host: {
816
+ attributes: { "role": "gridcell" },
817
+ properties: {
818
+ "attr.tabindex": "focused() && !disabled() ? 0 : -1",
819
+ "attr.aria-current": "isCurrent() ? 'date' : null",
820
+ "attr.aria-disabled": "disabled() ? 'true' : null",
821
+ "attr.aria-label": "ariaLabel()",
822
+ "attr.aria-selected": "selected() ? 'true' : null",
823
+ "class": "baseClass()"
824
+ }
825
+ },
826
+ ngImport: i0
827
+ });
828
+ }
829
+ };
830
+ i0.ɵɵngDeclareClassMetadata({
831
+ minVersion: "12.0.0",
832
+ version: "22.2.6",
833
+ ngImport: i0,
834
+ type: YearMonthDirective,
835
+ decorators: [{
836
+ type: Directive,
837
+ args: [{
838
+ selector: "[monaYearMonth]",
839
+ host: {
840
+ "[attr.tabindex]": "focused() && !disabled() ? 0 : -1",
841
+ "[attr.aria-current]": "isCurrent() ? 'date' : null",
842
+ "[attr.aria-disabled]": "disabled() ? 'true' : null",
843
+ "[attr.aria-label]": "ariaLabel()",
844
+ "[attr.aria-selected]": "selected() ? 'true' : null",
845
+ "[class]": "baseClass()",
846
+ role: "gridcell"
847
+ }
848
+ }]
849
+ }],
850
+ propDecorators: {
851
+ disabled: [{
852
+ type: i0.Input,
853
+ args: [{
854
+ isSignal: true,
855
+ alias: "disabled",
856
+ required: false
857
+ }]
858
+ }],
859
+ month: [{
860
+ type: i0.Input,
861
+ args: [{
862
+ isSignal: true,
863
+ alias: "month",
864
+ required: true
865
+ }]
866
+ }],
867
+ navigatedDate: [{
868
+ type: i0.Input,
869
+ args: [{
870
+ isSignal: true,
871
+ alias: "navigatedDate",
872
+ required: true
873
+ }]
874
+ }],
875
+ rounded: [{
876
+ type: i0.Input,
877
+ args: [{
878
+ isSignal: true,
879
+ alias: "rounded",
880
+ required: true
881
+ }]
882
+ }],
883
+ selectedDate: [{
884
+ type: i0.Input,
885
+ args: [{
886
+ isSignal: true,
887
+ alias: "selectedDate",
888
+ required: false
889
+ }]
890
+ }]
891
+ }
892
+ });
504
893
  function startOfDay(date) {
505
- return DateTime.fromJSDate(date).startOf("day").toJSDate();
894
+ return DateTime.fromJSDate(date).startOf("day").toJSDate();
506
895
  }
507
- /** Whole calendar days from `start` to `end`, whatever their times and across DST changes. */
508
896
  function calendarDaysBetween(start, end) {
509
- return Math.round(end.startOf("day").diff(start.startOf("day"), "days").days);
897
+ return Math.round(end.startOf("day").diff(start.startOf("day"), "days").days);
510
898
  }
511
899
  const FIRST_DAY_OF_WEEK_TO_ISO = {
512
- monday: 1,
513
- tuesday: 2,
514
- wednesday: 3,
515
- thursday: 4,
516
- friday: 5,
517
- saturday: 6,
518
- sunday: 7
900
+ monday: 1,
901
+ tuesday: 2,
902
+ wednesday: 3,
903
+ thursday: 4,
904
+ friday: 5,
905
+ saturday: 6,
906
+ sunday: 7
519
907
  };
520
- class CalendarComponent {
521
- #calendarService;
522
- #destroyRef;
523
- #direction;
524
- #hostElementRef;
525
- #i18n;
526
- #monthDict;
527
- #outputValue;
528
- constructor() {
529
- this.#calendarService = inject(CalendarService, { optional: true });
530
- this.#destroyRef = inject(DestroyRef);
531
- this.#direction = injectComponentDirection();
532
- this.#hostElementRef = inject(ElementRef);
533
- this.#i18n = inject(MonaI18nService);
534
- this.#monthDict = computed(() => {
535
- const day = this.navigatedDate();
536
- const firstDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).startOf("month");
537
- const lastDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).endOf("month");
538
- const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
539
- const daysToSubtract = (firstDayOfMonth.weekday - firstDayIso + 7) % 7;
540
- const firstDayOfCalendar = firstDayOfMonth.minus({ days: daysToSubtract });
541
- const lastDayOfWeekIso = ((firstDayIso + 5) % 7) + 1;
542
- const daysToAdd = (lastDayOfWeekIso - lastDayOfMonth.weekday + 7) % 7;
543
- const lastDayOfCalendar = lastDayOfMonth.plus({ days: daysToAdd });
544
- const dictionary = new Dictionary();
545
- for (let i = firstDayOfCalendar; i <= lastDayOfCalendar; i = i.plus({ days: 1 })) {
546
- dictionary.add(i.toJSDate(), i.day);
547
- }
548
- return dictionary.toImmutableDictionary(e => e.key, e => e.value);
549
- }, /* @ts-ignore */
550
- ...(ngDevMode ? [{ debugName: "#monthDict" }] : /* istanbul ignore next */ []));
551
- this.#outputValue = computed(() => {
552
- const selection = this.selection();
553
- const selectedDates = this.selectedDates();
554
- if (selection === "single") {
555
- return lastOrDefault(selectedDates);
556
- }
557
- else if (selection === "multiple") {
558
- return selectedDates;
559
- }
560
- else if (selection === "range") {
561
- if (selectedDates.length === 1) {
562
- return [selectedDates[0], selectedDates[0]];
563
- }
564
- if (selectedDates.length > 1) {
565
- return [selectedDates[0], selectedDates[selectedDates.length - 1]];
566
- }
567
- return [];
568
- }
569
- return [];
570
- }, /* @ts-ignore */
571
- ...(ngDevMode ? [{ debugName: "#outputValue" }] : /* istanbul ignore next */ []));
572
- this.ariaLabel = computed(() => {
573
- const view = this.calendarView();
574
- const navigatedDate = this.navigatedDate();
575
- const locale = this.#i18n.localeId();
576
- const messages = this.messages();
577
- switch (view) {
578
- case "month":
579
- return messages.calendarLabel(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric", month: "long" }));
580
- case "year":
581
- return messages.yearViewLabel(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
582
- case "decade":
583
- return messages.decadeViewLabel(this.decadeStart(), this.decadeEnd());
584
- }
585
- }, /* @ts-ignore */
586
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
587
- this.baseClass = computed(() => {
588
- const disabled = this.effectiveDisabled();
589
- const readonly = this.readonly();
590
- const rounded = this.rounded() === "full" ? "large" : this.rounded();
591
- const variantClass = calendarBaseThemeVariants({ disabled, readonly, rounded });
592
- const userClass = this.userClass();
593
- return twMerge(variantClass, userClass);
594
- }, /* @ts-ignore */
595
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
596
- this.calendarView = signal("month", /* @ts-ignore */
597
- ...(ngDevMode ? [{ debugName: "calendarView" }] : /* istanbul ignore next */ []));
598
- this.decadeCellTemplate = contentChild(CalendarDecadeCellTemplateDirective, /* @ts-ignore */
599
- ...(ngDevMode ? [{ debugName: "decadeCellTemplate" }] : /* istanbul ignore next */ []));
600
- this.decadeEnd = computed(() => {
601
- return this.decadeStart() + 9;
602
- }, /* @ts-ignore */
603
- ...(ngDevMode ? [{ debugName: "decadeEnd" }] : /* istanbul ignore next */ []));
604
- this.decadeGridClass = computed(() => {
605
- return calendarDecadeViewGridThemeVariants();
606
- }, /* @ts-ignore */
607
- ...(ngDevMode ? [{ debugName: "decadeGridClass" }] : /* istanbul ignore next */ []));
608
- this.decadeStart = computed(() => {
609
- const navigatedDate = this.navigatedDate();
610
- const date = gregorianDateTime(navigatedDate, this.#i18n.localeId());
611
- const year = date.year;
612
- return year - (year % 10);
613
- }, /* @ts-ignore */
614
- ...(ngDevMode ? [{ debugName: "decadeStart" }] : /* istanbul ignore next */ []));
615
- this.decadeYears = computed(() => {
616
- const decadeStart = this.decadeStart();
617
- return range(decadeStart, 10)
618
- .chunk(4)
619
- .select(e => e.toArray())
620
- .toArray();
621
- }, /* @ts-ignore */
622
- ...(ngDevMode ? [{ debugName: "decadeYears" }] : /* istanbul ignore next */ []));
623
- this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
624
- this.effectiveFirstDay = computed(() => {
625
- return this.firstDay() ?? getLocaleFirstDayOfWeek(this.#i18n.localeId());
626
- }, /* @ts-ignore */
627
- ...(ngDevMode ? [{ debugName: "effectiveFirstDay" }] : /* istanbul ignore next */ []));
628
- this.gridId = createElementControlId();
629
- this.headerClass = computed(() => {
630
- return calendarHeaderThemeVariants({});
631
- }, /* @ts-ignore */
632
- ...(ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []));
633
- this.headerMonthYear = computed(() => {
634
- const locale = this.#i18n.localeId();
635
- return formatGregorianDateToLocaleString(this.navigatedDate(), locale, {
636
- year: "numeric",
637
- month: "long"
638
- });
639
- }, /* @ts-ignore */
640
- ...(ngDevMode ? [{ debugName: "headerMonthYear" }] : /* istanbul ignore next */ []));
641
- this.headerYear = computed(() => {
642
- const locale = this.#i18n.localeId();
643
- return formatGregorianDateToLocaleString(this.navigatedDate(), locale, {
644
- year: "numeric"
645
- });
646
- }, /* @ts-ignore */
647
- ...(ngDevMode ? [{ debugName: "headerYear" }] : /* istanbul ignore next */ []));
648
- this.invalidState = computed(() => this.touched() && (this.invalid() || (this.required() && this.isEmptyValue())), /* @ts-ignore */
649
- ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
650
- /**
651
- * Whether a day can't be picked: outside `minDate`/`maxDate` or in `disabledDates`. An iterable of disabled
652
- * dates is turned into a set of day keys once, so each of the 42 cells answers in constant time.
653
- */
654
- this.isDayUnavailable = computed(() => {
655
- const disabledDates = this.disabledDates();
656
- const min = this.minDate();
657
- const max = this.maxDate();
658
- const isOutOfRange = (date) => compareDates(date, max, ">") || compareDates(date, min, "<");
659
- if (typeof disabledDates === "function") {
660
- return date => isOutOfRange(date) || disabledDates(date);
661
- }
662
- const keys = new Set();
663
- for (const disabledDate of disabledDates ?? []) {
664
- keys.add(toDayKey(disabledDate));
665
- }
666
- return date => isOutOfRange(date) || keys.has(toDayKey(date));
667
- }, /* @ts-ignore */
668
- ...(ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []));
669
- this.messages = this.#i18n.componentMessages("calendar", CALENDAR_DEFAULT_MESSAGES);
670
- this.monthBounds = computed(() => {
671
- const navigatedDate = this.navigatedDate();
672
- const firstDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).startOf("month");
673
- const lastDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).endOf("month");
674
- return { start: firstDayOfMonth.toJSDate(), end: lastDayOfMonth.toJSDate() };
675
- }, /* @ts-ignore */
676
- ...(ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []));
677
- this.monthCellTemplate = contentChild(CalendarMonthCellTemplateDirective, /* @ts-ignore */
678
- ...(ngDevMode ? [{ debugName: "monthCellTemplate" }] : /* istanbul ignore next */ []));
679
- this.monthDictChunked = computed(() => {
680
- const dict = this.#monthDict();
681
- return dict
682
- .chunk(7)
683
- .select(e => e.toImmutableDictionary(e => e.key, e => e.value))
684
- .toImmutableSet();
685
- }, /* @ts-ignore */
686
- ...(ngDevMode ? [{ debugName: "monthDictChunked" }] : /* istanbul ignore next */ []));
687
- this.monthGridClass = computed(() => {
688
- return calendarMonthViewGridThemeVariants();
689
- }, /* @ts-ignore */
690
- ...(ngDevMode ? [{ debugName: "monthGridClass" }] : /* istanbul ignore next */ []));
691
- this.monthGridHeaderClass = computed(() => {
692
- return calendarMonthViewGridHeaderThemeVariants();
693
- }, /* @ts-ignore */
694
- ...(ngDevMode ? [{ debugName: "monthGridHeaderClass" }] : /* istanbul ignore next */ []));
695
- this.months = computed(() => {
696
- const locale = this.#i18n.localeId();
697
- const names = range(1, 12)
698
- .select(m => gregorianDateTimeFromObject({ year: 2024, month: m, day: 1 }, locale).toFormat("LLL"))
699
- .toArray();
700
- return index(names)
701
- .chunk(3)
702
- .select(e => e.select(m => [m[0] + 1, m[1]]).toImmutableSet())
703
- .toImmutableSet();
704
- }, /* @ts-ignore */
705
- ...(ngDevMode ? [{ debugName: "months" }] : /* istanbul ignore next */ []));
706
- // Midnight, so a date picked with the keyboard before any value exists carries no clock time.
707
- this.navigatedDate = signal(startOfDay(new Date()), /* @ts-ignore */
708
- ...(ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []));
709
- this.nextButtonLabel = computed(() => {
710
- const view = this.calendarView();
711
- const messages = this.messages();
712
- switch (view) {
713
- case "month":
714
- return messages.nextMonth;
715
- case "year":
716
- return messages.nextYear;
717
- case "decade":
718
- return messages.nextDecade;
719
- }
720
- }, /* @ts-ignore */
721
- ...(ngDevMode ? [{ debugName: "nextButtonLabel" }] : /* istanbul ignore next */ []));
722
- this.pendingRangeStart = signal(null, /* @ts-ignore */
723
- ...(ngDevMode ? [{ debugName: "pendingRangeStart" }] : /* istanbul ignore next */ []));
724
- this.prevButtonLabel = computed(() => {
725
- const view = this.calendarView();
726
- const messages = this.messages();
727
- switch (view) {
728
- case "month":
729
- return messages.previousMonth;
730
- case "year":
731
- return messages.previousYear;
732
- case "decade":
733
- return messages.previousDecade;
734
- }
735
- }, /* @ts-ignore */
736
- ...(ngDevMode ? [{ debugName: "prevButtonLabel" }] : /* istanbul ignore next */ []));
737
- this.rangePreviewDate = signal(null, /* @ts-ignore */
738
- ...(ngDevMode ? [{ debugName: "rangePreviewDate" }] : /* istanbul ignore next */ []));
739
- this.rangePreviewDates = computed(() => {
740
- if (this.selection() !== "range") {
741
- return [];
742
- }
743
- const pendingRangeStart = this.pendingRangeStart();
744
- if (!pendingRangeStart) {
745
- return [];
746
- }
747
- return this.getInclusiveDateRange(pendingRangeStart, this.rangePreviewDate() ?? this.navigatedDate());
748
- }, /* @ts-ignore */
749
- ...(ngDevMode ? [{ debugName: "rangePreviewDates" }] : /* istanbul ignore next */ []));
750
- this.rangePreviewKeys = computed(() => new Set(this.rangePreviewDates().map(toDayKey)), /* @ts-ignore */
751
- ...(ngDevMode ? [{ debugName: "rangePreviewKeys" }] : /* istanbul ignore next */ []));
752
- this.selectedDates = linkedSignal(() => {
753
- const v = this.value();
754
- const selection = this.selection();
755
- if (v == null) {
756
- return [];
757
- }
758
- if (selection === "range" && Array.isArray(v) && v.length >= 2) {
759
- const date1 = DateTime.fromJSDate(v[0]);
760
- const date2 = DateTime.fromJSDate(v[v.length - 1]);
761
- const startDate = date1 <= date2 ? date1 : date2;
762
- const endDate = date1 <= date2 ? date2 : date1;
763
- const totalDays = calendarDaysBetween(startDate, endDate) + 1;
764
- return range(0, totalDays)
765
- .select(i => startDate.plus({ days: i }).toJSDate())
766
- .toArray();
767
- }
768
- return Array.isArray(v) ? v : [v];
769
- }, /* @ts-ignore */
770
- ...(ngDevMode ? [{ debugName: "selectedDates" }] : /* istanbul ignore next */ []));
771
- this.selectedKeys = computed(() => new Set(this.selectedDates().map(toDayKey)), /* @ts-ignore */
772
- ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
773
- /** Today at midnight. Refreshed when focus enters the calendar, so a page left open overnight moves on. */
774
- this.today = signal(startOfDay(new Date()), /* @ts-ignore */
775
- ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
776
- this.todayButtonLabel = computed(() => {
777
- const locale = this.#i18n.localeId();
778
- const todayStr = formatGregorianDateToLocaleString(this.today(), locale, {
779
- year: "numeric",
780
- month: "long",
781
- day: "numeric"
782
- });
783
- return this.messages().goToToday(todayStr);
784
- }, /* @ts-ignore */
785
- ...(ngDevMode ? [{ debugName: "todayButtonLabel" }] : /* istanbul ignore next */ []));
786
- this.todayUnavailable = computed(() => this.isDayUnavailable()(this.today()), /* @ts-ignore */
787
- ...(ngDevMode ? [{ debugName: "todayUnavailable" }] : /* istanbul ignore next */ []));
788
- this.viewSwitchButtonLabel = computed(() => {
789
- const view = this.calendarView();
790
- const locale = this.#i18n.localeId();
791
- const navigatedDate = this.navigatedDate();
792
- const messages = this.messages();
793
- switch (view) {
794
- case "month":
795
- return messages.switchToYearView(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric", month: "long" }));
796
- case "year":
797
- return messages.switchToDecadeView(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
798
- case "decade":
799
- return messages.decadeRange(this.decadeStart(), this.decadeEnd());
800
- }
801
- }, /* @ts-ignore */
802
- ...(ngDevMode ? [{ debugName: "viewSwitchButtonLabel" }] : /* istanbul ignore next */ []));
803
- this.weekdays = computed(() => {
804
- const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
805
- const locale = this.#i18n.localeId();
806
- // 2024-01-01 was a Monday (ISO 1)
807
- const days = range(0, 7)
808
- .select(i => {
809
- const dt = gregorianDateTimeFromObject({ year: 2024, month: 1, day: 1 + i }, locale);
810
- const short = dt.toFormat("ccc");
811
- const full = dt.toFormat("cccc");
812
- const narrow = dt.toFormat("ccccc");
813
- const display = short.length > 4 || (short === full && short.length > 3) ? narrow : short;
814
- return {
815
- display,
816
- short,
817
- narrow,
818
- full
819
- };
820
- })
821
- .toArray();
822
- const startIndex = firstDayIso - 1;
823
- return [...days.slice(startIndex), ...days.slice(0, startIndex)];
824
- }, /* @ts-ignore */
825
- ...(ngDevMode ? [{ debugName: "weekdays" }] : /* istanbul ignore next */ []));
826
- this.yearCellTemplate = contentChild(CalendarYearCellTemplateDirective, /* @ts-ignore */
827
- ...(ngDevMode ? [{ debugName: "yearCellTemplate" }] : /* istanbul ignore next */ []));
828
- this.yearGridClass = computed(() => {
829
- return calendarYearViewGridThemeVariants();
830
- }, /* @ts-ignore */
831
- ...(ngDevMode ? [{ debugName: "yearGridClass" }] : /* istanbul ignore next */ []));
832
- /**
833
- * @description Sets the disabled state of the calendar.
834
- */
835
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
836
- /**
837
- * @description Sets the disabled dates of the calendar.
838
- * Accepts either an iterable of Date objects or a predicate function.
839
- */
840
- this.disabledDates = input(/* @ts-ignore */
841
- ...(ngDevMode ? [undefined, { debugName: "disabledDates" }] : /* istanbul ignore next */ []));
842
- /**
843
- * @description Sets the first day of the week. If not specified, derives from the active locale.
844
- * @default null
845
- */
846
- this.firstDay = input(null, /* @ts-ignore */
847
- ...(ngDevMode ? [{ debugName: "firstDay" }] : /* istanbul ignore next */ []));
848
- /**
849
- * @description Moves focus to the active day when the calendar first renders. An inline calendar on a page
850
- * should leave focus where it is; a calendar that opens in a popup sets this so focus moves into it.
851
- * @default false
852
- */
853
- this.focusOnMount = input(false, { ...(ngDevMode ? { debugName: "focusOnMount" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
854
- /**
855
- * @description Marks the calendar as invalid. When bound to a signal form field via `[formField]`,
856
- * this is written by the `FormField` directive.
857
- * @default false
858
- */
859
- this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
860
- /**
861
- * @description Sets the maximum date that can be selected.
862
- */
863
- this.maxDate = input(/* @ts-ignore */
864
- ...(ngDevMode ? [undefined, { debugName: "maxDate" }] : /* istanbul ignore next */ []));
865
- /**
866
- * @description Sets the minimum date that can be selected.
867
- */
868
- this.minDate = input(/* @ts-ignore */
869
- ...(ngDevMode ? [undefined, { debugName: "minDate" }] : /* istanbul ignore next */ []));
870
- /**
871
- * @description Sets the readonly state of the calendar.
872
- * @default false
873
- */
874
- this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
875
- /**
876
- * @description Sets whether the calendar is required. When bound to a signal form field via `[formField]`,
877
- * this is written by the `FormField` directive.
878
- * @default false
879
- */
880
- this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
881
- /**
882
- * @description Sets the border radius of the calendar.
883
- * @default "medium"
884
- */
885
- this.rounded = input("medium", /* @ts-ignore */
886
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
887
- /**
888
- * @description Sets the selection mode of the calendar.
889
- * @default "single"
890
- */
891
- this.selection = input("single", /* @ts-ignore */
892
- ...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
893
- /**
894
- * @description Emitted when focus leaves the calendar, as a native input is touched on blur. Moving between
895
- * its buttons and days doesn't count. The `FormField` directive listens to this to mark the field as touched.
896
- */
897
- this.touch = output();
898
- /**
899
- * @description Sets the touched state of the calendar. When bound to a signal form field via `[formField]`,
900
- * this is written by the `FormField` directive.
901
- * @default false
902
- */
903
- this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
904
- /**
905
- * @description Adds custom CSS classes to the calendar host element.
906
- */
907
- this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
908
- /**
909
- * @description The current value of the calendar: a `Date` in single selection, the selected dates in multiple
910
- * selection, and `[start, end]` in range selection. A range is written once both ends are picked.
911
- * @default null
912
- */
913
- this.value = model(null, /* @ts-ignore */
914
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
915
- /**
916
- * @description Enables the display of week numbers in the calendar.
917
- * @default false
918
- */
919
- this.weekNumber = input(false, { ...(ngDevMode ? { debugName: "weekNumber" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
920
- afterNextRender({
921
- read: () => {
922
- this.setupKeyboardNavigation();
923
- if (this.focusOnMount()) {
924
- this.focusActiveCell();
925
- }
926
- }
927
- });
928
- effect(() => {
929
- const min = this.minDate();
930
- const max = this.maxDate();
931
- untracked(() => {
932
- // Keep the active day within the range. A day disabled through disabledDates can stay active: it is
933
- // focusable and announced as unavailable, so the keyboard can move past it.
934
- const navigationDate = this.navigatedDate();
935
- if (compareDates(navigationDate, min, "<") && min) {
936
- this.navigatedDate.set(min);
937
- }
938
- else if (compareDates(navigationDate, max, ">") && max) {
939
- this.navigatedDate.set(max);
940
- }
941
- });
942
- });
943
- effect(() => {
944
- const v = this.value();
945
- untracked(() => {
946
- // Show the last selected date. Clearing the selection leaves the view where it is.
947
- const lastDate = Array.isArray(v) ? lastOrDefault(v) : v;
948
- if (lastDate) {
949
- this.navigatedDate.set(lastDate);
950
- }
951
- });
952
- });
953
- toObservable(this.calendarView)
954
- .pipe(skip(1))
955
- .subscribe(() => this.focusActiveCell());
956
- }
957
- formatInteger(value) {
958
- if (value == null) {
959
- return "";
960
- }
961
- return formatNumber(value, this.#i18n.localeId(), {
962
- maximumFractionDigits: 0,
963
- useGrouping: false
964
- });
965
- }
966
- getWeekNumber(date) {
967
- const dt = gregorianDateTime(date, this.#i18n.localeId());
968
- const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
969
- const daysToThursday = (4 - firstDayIso + 7) % 7;
970
- return dt.plus({ days: daysToThursday }).weekNumber;
971
- }
972
- onDayClick(date, event) {
973
- event.preventDefault();
974
- if (this.effectiveDisabled() || this.readonly()) {
975
- return;
976
- }
977
- const selection = this.selection();
978
- if (selection === "single") {
979
- this.handleSingleSelection(date);
980
- }
981
- else if (selection === "multiple") {
982
- if (event.ctrlKey || event.metaKey || event.shiftKey) {
983
- this.handleMultipleSelection(date, event.shiftKey);
984
- }
985
- else {
986
- this.handleSingleSelection(date);
987
- }
988
- }
989
- else if (selection === "range") {
990
- this.handleRangeSelection(date);
991
- this.navigatedDate.set(date);
992
- }
993
- this.focusActiveCell();
994
- this.commitUserSelection();
995
- }
996
- onDayPointerEnter(date) {
997
- if (this.effectiveDisabled() ||
998
- this.readonly() ||
999
- this.selection() !== "range" ||
1000
- this.pendingRangeStart() == null) {
1001
- return;
1002
- }
1003
- this.rangePreviewDate.set(date);
1004
- }
1005
- onFocusOut(event) {
1006
- // Removing a focused calendar from the page fires focusout after it is destroyed.
1007
- if (this.#destroyRef.destroyed) {
1008
- return;
1009
- }
1010
- const nextTarget = event.relatedTarget;
1011
- if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) {
1012
- return;
1013
- }
1014
- this.touch.emit();
1015
- }
1016
- onMonthClick(month) {
1017
- this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ month }).toJSDate());
1018
- this.calendarView.set("month");
1019
- }
1020
- onMonthGridPointerLeave() {
1021
- this.rangePreviewDate.set(null);
1022
- }
1023
- onNavigationClick(direction) {
1024
- this.rangePreviewDate.set(null);
1025
- const date = DateTime.fromJSDate(this.navigatedDate());
1026
- let unit;
1027
- switch (this.calendarView()) {
1028
- case "month":
1029
- unit = { months: 1 };
1030
- break;
1031
- case "year":
1032
- unit = { years: 1 };
1033
- break;
1034
- case "decade":
1035
- unit = { years: 10 };
1036
- break;
1037
- }
1038
- this.navigatedDate.set(direction === "prev" ? date.minus(unit).toJSDate() : date.plus(unit).toJSDate());
1039
- }
1040
- onTodayButtonClick() {
1041
- this.refreshToday();
1042
- if (this.effectiveDisabled() || this.readonly() || this.todayUnavailable()) {
1043
- return;
1044
- }
1045
- // Today is picked as a click on its day would pick it, so the same rules apply.
1046
- const today = this.today();
1047
- if (this.selection() === "range") {
1048
- this.handleRangeSelection(today);
1049
- this.navigatedDate.set(today);
1050
- }
1051
- else {
1052
- this.handleSingleSelection(today);
1053
- }
1054
- this.calendarView.set("month");
1055
- this.commitUserSelection();
1056
- }
1057
- onViewChangeClick(view) {
1058
- this.calendarView.set(view);
1059
- }
1060
- onYearClick(year) {
1061
- this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ year }).toJSDate());
1062
- this.calendarView.set("year");
1063
- }
1064
- refreshToday() {
1065
- const today = startOfDay(new Date());
1066
- if (!compareDates(today, this.today(), "==")) {
1067
- this.today.set(today);
1068
- }
1069
- }
1070
- clearPendingRange() {
1071
- this.pendingRangeStart.set(null);
1072
- this.rangePreviewDate.set(null);
1073
- }
1074
- commitUserSelection() {
1075
- // A range is written once both ends are picked; the first click only starts it.
1076
- if (this.selection() === "range" && this.pendingRangeStart() != null) {
1077
- return;
1078
- }
1079
- this.value.set(this.#outputValue());
1080
- }
1081
- extendSelection(offset) {
1082
- const currentDate = this.navigatedDate();
1083
- const newDate = DateTime.fromJSDate(currentDate).plus({ days: offset }).toJSDate();
1084
- if (this.isDateDisabled(newDate)) {
1085
- return;
1086
- }
1087
- const currentSelection = this.selectedDates();
1088
- const dateTime = DateTime.fromJSDate(newDate);
1089
- const isAlreadySelected = currentSelection.some(d => DateTime.fromJSDate(d).hasSame(dateTime, "day"));
1090
- if (!isAlreadySelected) {
1091
- this.setCurrentDate([...currentSelection, newDate]);
1092
- }
1093
- this.navigatedDate.set(newDate);
1094
- }
1095
- focusActiveCell() {
1096
- rxTimeout(this.#destroyRef, () => {
1097
- const calendarView = this.calendarView();
1098
- const selector = calendarView === "year"
1099
- ? "[monaYearMonth]"
1100
- : calendarView === "decade"
1101
- ? "[monaDecadeYear]"
1102
- : "[monaMonthDay]";
1103
- const activeCell = this.#hostElementRef.nativeElement.querySelector(`${selector}[tabindex="0"]`);
1104
- activeCell?.focus();
1105
- });
1106
- }
1107
- getDateArray(date) {
1108
- if (date == null) {
1109
- return [];
1110
- }
1111
- return Array.isArray(date) ? date : [date];
1112
- }
1113
- getDatesForMultipleSelection(date) {
1114
- const lastSelectedDate = lastOrDefault(this.selectedDates()) ?? this.navigatedDate();
1115
- const startDate = lastSelectedDate < date ? lastSelectedDate : date;
1116
- const endDate = this.navigatedDate() > date ? this.navigatedDate() : date;
1117
- const totalDays = calendarDaysBetween(DateTime.fromJSDate(startDate), DateTime.fromJSDate(endDate)) + 1;
1118
- return range(0, totalDays)
1119
- .select(i => DateTime.fromJSDate(startDate).plus({ days: i }).toJSDate())
1120
- .toArray();
1121
- }
1122
- getInclusiveDateRange(date1, date2) {
1123
- const dateTime1 = DateTime.fromJSDate(date1);
1124
- const dateTime2 = DateTime.fromJSDate(date2);
1125
- const startDate = dateTime1 <= dateTime2 ? dateTime1 : dateTime2;
1126
- const endDate = dateTime1 <= dateTime2 ? dateTime2 : dateTime1;
1127
- const totalDays = calendarDaysBetween(startDate, endDate) + 1;
1128
- return range(0, totalDays)
1129
- .select(i => startDate.plus({ days: i }).toJSDate())
1130
- .toArray();
1131
- }
1132
- handleKeydown(event) {
1133
- if (this.effectiveDisabled()) {
1134
- return;
1135
- }
1136
- const preventableEvent = new PreventableEvent("calendarKeydown", event);
1137
- this.#calendarService?.keydown$.next(preventableEvent);
1138
- if (preventableEvent.isDefaultPrevented()) {
1139
- return;
1140
- }
1141
- // Keys pressed on the header buttons belong to the buttons: the arrows don't move the active day.
1142
- if (event.target.closest("button")) {
1143
- return;
1144
- }
1145
- const view = this.calendarView();
1146
- const isCtrlOrCmd = event.ctrlKey || event.metaKey;
1147
- const isShift = event.shiftKey;
1148
- const selection = this.selection();
1149
- if (!this.readonly() && selection === "multiple" && (isCtrlOrCmd || isShift)) {
1150
- if (this.handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift)) {
1151
- this.commitUserSelection();
1152
- this.focusActiveCell();
1153
- return;
1154
- }
1155
- }
1156
- let shouldFocusCell = false;
1157
- switch (event.key) {
1158
- case "ArrowUp":
1159
- event.preventDefault();
1160
- if (isCtrlOrCmd) {
1161
- this.switchToUpperView();
1162
- }
1163
- else {
1164
- this.navigateByWeeksOrRows(-1, view);
1165
- }
1166
- shouldFocusCell = true;
1167
- break;
1168
- case "ArrowDown":
1169
- event.preventDefault();
1170
- if (isCtrlOrCmd) {
1171
- this.switchToLowerView();
1172
- }
1173
- else {
1174
- this.navigateByWeeksOrRows(1, view);
1175
- }
1176
- shouldFocusCell = true;
1177
- break;
1178
- case "ArrowLeft":
1179
- event.preventDefault();
1180
- if (isCtrlOrCmd) {
1181
- this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowLeft"));
1182
- }
1183
- else {
1184
- this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowLeft"), view);
1185
- }
1186
- shouldFocusCell = true;
1187
- break;
1188
- case "ArrowRight":
1189
- event.preventDefault();
1190
- if (isCtrlOrCmd) {
1191
- this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowRight"));
1192
- }
1193
- else {
1194
- this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowRight"), view);
1195
- }
1196
- shouldFocusCell = true;
1197
- break;
1198
- case "Enter":
1199
- case " ": {
1200
- event.preventDefault();
1201
- const previousView = this.calendarView();
1202
- if (this.readonly() && previousView === "month") {
1203
- shouldFocusCell = true;
1204
- break;
1205
- }
1206
- if (isCtrlOrCmd && selection === "multiple") {
1207
- this.toggleFocusedDateInSelection();
1208
- }
1209
- else if (isShift && selection === "multiple") {
1210
- this.selectRangeToFocused();
1211
- }
1212
- else {
1213
- this.selectFocusedItem();
1214
- }
1215
- if (previousView === "month" && this.calendarView() === "month") {
1216
- this.commitUserSelection();
1217
- }
1218
- shouldFocusCell = true;
1219
- break;
1220
- }
1221
- case "Home":
1222
- event.preventDefault();
1223
- this.navigateToStart(view);
1224
- shouldFocusCell = true;
1225
- break;
1226
- case "End":
1227
- event.preventDefault();
1228
- this.navigateToEnd(view);
1229
- shouldFocusCell = true;
1230
- break;
1231
- case "PageUp":
1232
- event.preventDefault();
1233
- // Shift+PageUp moves a year in the month view, as in the WAI-ARIA date picker pattern.
1234
- this.navigateByPeriod(isShift && view === "month" ? -12 : -1, view);
1235
- shouldFocusCell = true;
1236
- break;
1237
- case "PageDown":
1238
- event.preventDefault();
1239
- this.navigateByPeriod(isShift && view === "month" ? 12 : 1, view);
1240
- shouldFocusCell = true;
1241
- break;
1242
- case "t":
1243
- case "T":
1244
- if (!isCtrlOrCmd && !isShift) {
1245
- event.preventDefault();
1246
- this.navigateToToday();
1247
- shouldFocusCell = true;
1248
- }
1249
- break;
1250
- case "Escape":
1251
- event.preventDefault();
1252
- return;
1253
- }
1254
- if (shouldFocusCell) {
1255
- this.focusActiveCell();
1256
- }
1257
- }
1258
- handleMultipleSelection(date, rangedSelection) {
1259
- this.clearPendingRange();
1260
- const value = this.selectedDates();
1261
- if (value.length === 0) {
1262
- this.setCurrentDate([date]);
1263
- this.navigatedDate.set(date);
1264
- return;
1265
- }
1266
- if (!rangedSelection) {
1267
- const date1 = DateTime.fromJSDate(date);
1268
- const valueList = this.getDateArray(value);
1269
- const selectedDates = select(valueList, e => DateTime.fromJSDate(e));
1270
- // Compare by day: a selected value carries a time, the clicked day is midnight.
1271
- const alreadySelected = selectedDates.any(e => e.hasSame(date1, "day"));
1272
- if (alreadySelected) {
1273
- const newDates = selectedDates
1274
- .where(e => !e.hasSame(date1, "day"))
1275
- .select(e => e.toJSDate())
1276
- .toArray();
1277
- this.setCurrentDate(newDates);
1278
- }
1279
- else {
1280
- this.setCurrentDate([...valueList, date]);
1281
- }
1282
- this.navigatedDate.set(date);
1283
- }
1284
- else {
1285
- const selectedDates = this.getDatesForMultipleSelection(date);
1286
- this.setCurrentDate(selectedDates);
1287
- }
1288
- }
1289
- handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift) {
1290
- if (this.calendarView() !== "month") {
1291
- return false;
1292
- }
1293
- if (isShift && !isCtrlOrCmd) {
1294
- switch (event.key) {
1295
- case "ArrowLeft":
1296
- event.preventDefault();
1297
- this.extendSelection(this.horizontalCellDelta("ArrowLeft"));
1298
- return true;
1299
- case "ArrowRight":
1300
- event.preventDefault();
1301
- this.extendSelection(this.horizontalCellDelta("ArrowRight"));
1302
- return true;
1303
- case "ArrowUp":
1304
- event.preventDefault();
1305
- this.extendSelection(-7);
1306
- return true;
1307
- case "ArrowDown":
1308
- event.preventDefault();
1309
- this.extendSelection(7);
1310
- return true;
1311
- }
1312
- }
1313
- return false;
1314
- }
1315
- handleRangeSelection(date) {
1316
- const pendingRangeStart = this.pendingRangeStart();
1317
- if (pendingRangeStart == null) {
1318
- this.pendingRangeStart.set(date);
1319
- this.rangePreviewDate.set(null);
1320
- this.setCurrentDate([date]);
1321
- return;
1322
- }
1323
- this.setCurrentDate(this.getInclusiveDateRange(pendingRangeStart, date));
1324
- this.pendingRangeStart.set(null);
1325
- this.rangePreviewDate.set(null);
1326
- }
1327
- handleSingleSelection(date) {
1328
- this.clearPendingRange();
1329
- const value = this.selectedDates();
1330
- if (value.length > 0) {
1331
- const date1 = DateTime.fromJSDate(date);
1332
- const valueItem = lastOrDefault(value) ?? DateTime.now().toJSDate();
1333
- const newDate = DateTime.fromJSDate(valueItem)
1334
- .set({ day: date1.day, month: date1.month, year: date1.year })
1335
- .toJSDate();
1336
- this.navigatedDate.set(newDate);
1337
- this.setCurrentDate(newDate);
1338
- }
1339
- else {
1340
- this.navigatedDate.set(date);
1341
- this.setCurrentDate(date);
1342
- }
1343
- }
1344
- horizontalCellDelta(key) {
1345
- const isRtl = this.#direction() === "rtl";
1346
- if (key === "ArrowLeft") {
1347
- return isRtl ? 1 : -1;
1348
- }
1349
- return isRtl ? -1 : 1;
1350
- }
1351
- horizontalPeriodDirection(key) {
1352
- const isRtl = this.#direction() === "rtl";
1353
- if (key === "ArrowLeft") {
1354
- return isRtl ? "next" : "prev";
1355
- }
1356
- return isRtl ? "prev" : "next";
1357
- }
1358
- isDateDisabled(date) {
1359
- return this.isDayUnavailable()(date);
1360
- }
1361
- isEmptyValue() {
1362
- const value = this.value();
1363
- return value == null || (Array.isArray(value) && value.length === 0);
1364
- }
1365
- isOutOfRange(date) {
1366
- return compareDates(date, this.maxDate(), ">") || compareDates(date, this.minDate(), "<");
1367
- }
1368
- navigateByDaysOrCells(offset, view) {
1369
- const currentDate = this.navigatedDate();
1370
- const dateTime = DateTime.fromJSDate(currentDate);
1371
- let newDate;
1372
- switch (view) {
1373
- case "month":
1374
- newDate = dateTime.plus({ days: offset }).toJSDate();
1375
- break;
1376
- case "year":
1377
- newDate = dateTime.plus({ months: offset }).toJSDate();
1378
- break;
1379
- case "decade":
1380
- newDate = dateTime.plus({ years: offset }).toJSDate();
1381
- break;
1382
- }
1383
- // A disabled day can be focused (it is announced as unavailable); only the range bounds stop the arrows.
1384
- if (view === "month" && this.isOutOfRange(newDate)) {
1385
- return;
1386
- }
1387
- this.rangePreviewDate.set(null);
1388
- this.navigatedDate.set(newDate);
1389
- }
1390
- navigateByPeriod(offset, view) {
1391
- const currentDate = this.navigatedDate();
1392
- const dateTime = DateTime.fromJSDate(currentDate);
1393
- let newDate;
1394
- switch (view) {
1395
- case "month":
1396
- newDate = dateTime.plus({ months: offset }).toJSDate();
1397
- break;
1398
- case "year":
1399
- newDate = dateTime.plus({ years: offset }).toJSDate();
1400
- break;
1401
- case "decade":
1402
- newDate = dateTime.plus({ years: offset * 10 }).toJSDate();
1403
- break;
1404
- }
1405
- if (view === "month" && this.isDateDisabled(newDate)) {
1406
- const direction = offset > 0 ? 1 : -1;
1407
- const maxAttempts = 31;
1408
- for (let i = 1; i <= maxAttempts; i++) {
1409
- const adjustedDate = DateTime.fromJSDate(newDate)
1410
- .plus({ days: direction * i })
1411
- .toJSDate();
1412
- if (!this.isDateDisabled(adjustedDate)) {
1413
- newDate = adjustedDate;
1414
- break;
1415
- }
1416
- }
1417
- }
1418
- this.rangePreviewDate.set(null);
1419
- this.navigatedDate.set(newDate);
1420
- }
1421
- navigateByWeeksOrRows(offset, view) {
1422
- const currentDate = this.navigatedDate();
1423
- const dateTime = DateTime.fromJSDate(currentDate);
1424
- let newDate;
1425
- switch (view) {
1426
- case "month":
1427
- newDate = dateTime.plus({ weeks: offset }).toJSDate();
1428
- break;
1429
- case "year":
1430
- newDate = dateTime.plus({ months: offset * 3 }).toJSDate();
1431
- break;
1432
- case "decade":
1433
- newDate = dateTime.plus({ years: offset * 4 }).toJSDate();
1434
- break;
1435
- }
1436
- // A disabled day can be focused (it is announced as unavailable); only the range bounds stop the arrows.
1437
- if (view === "month" && this.isOutOfRange(newDate)) {
1438
- return;
1439
- }
1440
- this.rangePreviewDate.set(null);
1441
- this.navigatedDate.set(newDate);
1442
- }
1443
- navigatePeriodKeyboard(direction) {
1444
- this.rangePreviewDate.set(null);
1445
- this.onNavigationClick(direction);
1446
- }
1447
- navigateToEnd(view) {
1448
- const currentDate = this.navigatedDate();
1449
- const dateTime = DateTime.fromJSDate(currentDate);
1450
- let newDate;
1451
- switch (view) {
1452
- case "month": {
1453
- const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
1454
- const lastDayOfWeekIso = ((firstDayIso + 5) % 7) + 1;
1455
- const daysToAdd = (lastDayOfWeekIso - dateTime.weekday + 7) % 7;
1456
- newDate = dateTime.plus({ days: daysToAdd }).toJSDate();
1457
- if (this.isDateDisabled(newDate)) {
1458
- for (let i = 1; i <= 6; i++) {
1459
- const testDate = DateTime.fromJSDate(newDate).minus({ days: i }).toJSDate();
1460
- if (!this.isDateDisabled(testDate)) {
1461
- newDate = testDate;
1462
- break;
1463
- }
1464
- }
1465
- }
1466
- break;
1467
- }
1468
- case "year":
1469
- newDate = dateTime.set({ month: 12 }).toJSDate();
1470
- break;
1471
- case "decade": {
1472
- const yearEnd = this.decadeEnd();
1473
- newDate = dateTime.set({ year: yearEnd }).toJSDate();
1474
- break;
1475
- }
1476
- }
1477
- this.rangePreviewDate.set(null);
1478
- this.navigatedDate.set(newDate);
1479
- }
1480
- navigateToStart(view) {
1481
- const currentDate = this.navigatedDate();
1482
- const dateTime = DateTime.fromJSDate(currentDate);
1483
- let newDate;
1484
- switch (view) {
1485
- case "month": {
1486
- const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
1487
- const daysToSubtract = (dateTime.weekday - firstDayIso + 7) % 7;
1488
- newDate = dateTime.minus({ days: daysToSubtract }).toJSDate();
1489
- if (this.isDateDisabled(newDate)) {
1490
- for (let i = 1; i <= 6; i++) {
1491
- const testDate = DateTime.fromJSDate(newDate).plus({ days: i }).toJSDate();
1492
- if (!this.isDateDisabled(testDate)) {
1493
- newDate = testDate;
1494
- break;
1495
- }
1496
- }
1497
- }
1498
- break;
1499
- }
1500
- case "year":
1501
- newDate = dateTime.set({ month: 1 }).toJSDate();
1502
- break;
1503
- case "decade": {
1504
- const yearStart = this.decadeStart();
1505
- newDate = dateTime.set({ year: yearStart }).toJSDate();
1506
- break;
1507
- }
1508
- }
1509
- this.rangePreviewDate.set(null);
1510
- this.navigatedDate.set(newDate);
1511
- }
1512
- navigateToToday() {
1513
- this.refreshToday();
1514
- const today = this.today();
1515
- if (this.isDateDisabled(today)) {
1516
- return;
1517
- }
1518
- this.rangePreviewDate.set(null);
1519
- this.navigatedDate.set(today);
1520
- this.calendarView.set("month");
1521
- }
1522
- selectFocusedItem() {
1523
- const view = this.calendarView();
1524
- const currentDate = this.navigatedDate();
1525
- switch (view) {
1526
- case "month":
1527
- if (!this.isDateDisabled(currentDate)) {
1528
- const selection = this.selection();
1529
- if (selection === "single") {
1530
- this.handleSingleSelection(currentDate);
1531
- }
1532
- else if (selection === "multiple") {
1533
- this.handleSingleSelection(currentDate);
1534
- }
1535
- else if (selection === "range") {
1536
- this.handleRangeSelection(currentDate);
1537
- }
1538
- }
1539
- break;
1540
- case "year":
1541
- this.calendarView.set("month");
1542
- break;
1543
- case "decade":
1544
- this.calendarView.set("year");
1545
- break;
1546
- }
1547
- }
1548
- selectRangeToFocused() {
1549
- const focusedDate = this.navigatedDate();
1550
- if (this.isDateDisabled(focusedDate)) {
1551
- return;
1552
- }
1553
- const selectedDates = this.getDatesForMultipleSelection(focusedDate);
1554
- this.setCurrentDate(selectedDates);
1555
- }
1556
- setCurrentDate(date) {
1557
- this.selectedDates.set(this.getDateArray(date));
1558
- }
1559
- setupKeyboardNavigation() {
1560
- fromEvent(this.#hostElementRef.nativeElement, "keydown")
1561
- .pipe(takeUntilDestroyed(this.#destroyRef))
1562
- .subscribe(event => this.handleKeydown(event));
1563
- }
1564
- switchToLowerView() {
1565
- const view = this.calendarView();
1566
- switch (view) {
1567
- case "decade":
1568
- this.calendarView.set("year");
1569
- break;
1570
- case "year":
1571
- this.calendarView.set("month");
1572
- break;
1573
- }
1574
- }
1575
- switchToUpperView() {
1576
- const view = this.calendarView();
1577
- switch (view) {
1578
- case "month":
1579
- this.calendarView.set("year");
1580
- break;
1581
- case "year":
1582
- this.calendarView.set("decade");
1583
- break;
1584
- }
1585
- }
1586
- toggleFocusedDateInSelection() {
1587
- const focusedDate = this.navigatedDate();
1588
- if (this.isDateDisabled(focusedDate)) {
1589
- return;
1590
- }
1591
- const currentSelection = this.selectedDates();
1592
- const dateTime = DateTime.fromJSDate(focusedDate);
1593
- const isAlreadySelected = currentSelection.some(d => DateTime.fromJSDate(d).hasSame(dateTime, "day"));
1594
- if (isAlreadySelected) {
1595
- const newSelection = currentSelection.filter(d => !DateTime.fromJSDate(d).hasSame(dateTime, "day"));
1596
- this.setCurrentDate(newSelection);
1597
- }
1598
- else {
1599
- this.setCurrentDate([...currentSelection, focusedDate]);
1600
- }
1601
- }
1602
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1603
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: CalendarComponent, isStandalone: true, selector: "mona-calendar", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, disabledDates: { classPropertyName: "disabledDates", publicName: "disabledDates", isSignal: true, isRequired: false, transformFunction: null }, firstDay: { classPropertyName: "firstDay", publicName: "firstDay", isSignal: true, isRequired: false, transformFunction: null }, focusOnMount: { classPropertyName: "focusOnMount", publicName: "focusOnMount", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, maxDate: { classPropertyName: "maxDate", publicName: "maxDate", isSignal: true, isRequired: false, transformFunction: null }, minDate: { classPropertyName: "minDate", publicName: "minDate", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, weekNumber: { classPropertyName: "weekNumber", publicName: "weekNumber", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch", value: "valueChange" }, host: { listeners: { "focusin": "refreshToday()", "focusout": "onFocusOut($event)" }, properties: { "attr.aria-label": "null", "attr.data-disabled": "effectiveDisabled() || null", "attr.data-invalid": "invalidState() || null", "attr.data-required": "required() || null", "class": "baseClass()" } }, queries: [{ propertyName: "decadeCellTemplate", first: true, predicate: CalendarDecadeCellTemplateDirective, descendants: true, isSignal: true }, { propertyName: "monthCellTemplate", first: true, predicate: CalendarMonthCellTemplateDirective, descendants: true, isSignal: true }, { propertyName: "yearCellTemplate", first: true, predicate: CalendarYearCellTemplateDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class", "value"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: MonthDayDirective, selector: "[monaMonthDay]", inputs: ["disabled", "entry", "isDayUnavailable", "monthBounds", "navigatedDate", "rangePreviewKeys", "rounded", "selectedKeys", "today"], outputs: ["dayPointerEnter", "daySelect"] }, { kind: "directive", type: DecadeYearDirective, selector: "[monaDecadeYear]", inputs: ["disabled", "navigatedDate", "rounded", "selectedDate", "year"] }, { kind: "directive", type: YearMonthDirective, selector: "[monaYearMonth]", inputs: ["disabled", "month", "navigatedDate", "rounded", "selectedDate"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LucideChevronLeft, selector: "svg[lucideChevronLeft]" }, { kind: "component", type: LucideChevronRight, selector: "svg[lucideChevronRight]" }, { kind: "pipe", type: TakeFirstPipe, name: "monaTakeFirst" }] }); }
1604
- }
1605
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CalendarComponent, decorators: [{
1606
- type: Component,
1607
- args: [{ selector: "mona-calendar", imports: [
1608
- ButtonDirective,
1609
- MonthDayDirective,
1610
- DecadeYearDirective,
1611
- YearMonthDirective,
1612
- NgTemplateOutlet,
1613
- TakeFirstPipe,
1614
- LucideChevronLeft,
1615
- LucideChevronRight
1616
- ], host: {
1617
- // The host is a plain container: the grid inside it is the widget, and focus moves through its cells. A
1618
- // static aria-label written on <mona-calendar> would otherwise stay on the role-less host.
1619
- "[attr.aria-label]": "null",
1620
- "[attr.data-disabled]": "effectiveDisabled() || null",
1621
- "[attr.data-invalid]": "invalidState() || null",
1622
- "[attr.data-required]": "required() || null",
1623
- "[class]": "baseClass()",
1624
- "(focusin)": "refreshToday()",
1625
- "(focusout)": "onFocusOut($event)"
1626
- }, template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n" }]
1627
- }], ctorParameters: () => [], propDecorators: { decadeCellTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CalendarDecadeCellTemplateDirective), { isSignal: true }] }], monthCellTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CalendarMonthCellTemplateDirective), { isSignal: true }] }], yearCellTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CalendarYearCellTemplateDirective), { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], disabledDates: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledDates", required: false }] }], firstDay: [{ type: i0.Input, args: [{ isSignal: true, alias: "firstDay", required: false }] }], focusOnMount: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnMount", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], maxDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxDate", required: false }] }], minDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "minDate", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], weekNumber: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekNumber", required: false }] }] } });
1628
-
1629
- /*
1630
- * Public API Surface of @nanahoshi/mona-ui/calendar
1631
- */
1632
-
1633
- /**
1634
- * Generated bundle index. Do not edit.
1635
- */
1636
-
908
+ var CalendarComponent = class CalendarComponent {
909
+ #calendarService;
910
+ #destroyRef;
911
+ #direction;
912
+ #hostElementRef;
913
+ #i18n;
914
+ #monthDict;
915
+ #outputValue;
916
+ constructor() {
917
+ this.#calendarService = inject(CalendarService, { optional: true });
918
+ this.#destroyRef = inject(DestroyRef);
919
+ this.#direction = injectComponentDirection();
920
+ this.#hostElementRef = inject(ElementRef);
921
+ this.#i18n = inject(MonaI18nService);
922
+ this.#monthDict = computed(() => {
923
+ const day = this.navigatedDate();
924
+ const firstDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).startOf("month");
925
+ const lastDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).endOf("month");
926
+ const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
927
+ const daysToSubtract = (firstDayOfMonth.weekday - firstDayIso + 7) % 7;
928
+ const firstDayOfCalendar = firstDayOfMonth.minus({ days: daysToSubtract });
929
+ const daysToAdd = ((firstDayIso + 5) % 7 + 1 - lastDayOfMonth.weekday + 7) % 7;
930
+ const lastDayOfCalendar = lastDayOfMonth.plus({ days: daysToAdd });
931
+ const dictionary = new Dictionary();
932
+ for (let i = firstDayOfCalendar; i <= lastDayOfCalendar; i = i.plus({ days: 1 })) dictionary.add(i.toJSDate(), i.day);
933
+ return dictionary.toImmutableDictionary((e) => e.key, (e) => e.value);
934
+ }, ...ngDevMode ? [{ debugName: "#monthDict" }] : /* istanbul ignore next */ []);
935
+ this.#outputValue = computed(() => {
936
+ const selection = this.selection();
937
+ const selectedDates = this.selectedDates();
938
+ if (selection === "single") return lastOrDefault(selectedDates);
939
+ else if (selection === "multiple") return selectedDates;
940
+ else if (selection === "range") {
941
+ if (selectedDates.length === 1) return [selectedDates[0], selectedDates[0]];
942
+ if (selectedDates.length > 1) return [selectedDates[0], selectedDates[selectedDates.length - 1]];
943
+ return [];
944
+ }
945
+ return [];
946
+ }, ...ngDevMode ? [{ debugName: "#outputValue" }] : /* istanbul ignore next */ []);
947
+ this.ariaLabel = computed(() => {
948
+ const view = this.calendarView();
949
+ const navigatedDate = this.navigatedDate();
950
+ const locale = this.#i18n.localeId();
951
+ const messages = this.messages();
952
+ switch (view) {
953
+ case "month": return messages.calendarLabel(formatGregorianDateToLocaleString(navigatedDate, locale, {
954
+ year: "numeric",
955
+ month: "long"
956
+ }));
957
+ case "year": return messages.yearViewLabel(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
958
+ case "decade": return messages.decadeViewLabel(this.decadeStart(), this.decadeEnd());
959
+ }
960
+ }, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
961
+ this.baseClass = computed(() => {
962
+ const disabled = this.effectiveDisabled();
963
+ const readonly = this.readonly();
964
+ const rounded = this.rounded() === "full" ? "large" : this.rounded();
965
+ const variantClass = calendarBaseThemeVariants({
966
+ disabled,
967
+ readonly,
968
+ rounded
969
+ });
970
+ const userClass = this.userClass();
971
+ return twMerge(variantClass, userClass);
972
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
973
+ this.calendarView = signal("month", ...ngDevMode ? [{ debugName: "calendarView" }] : /* istanbul ignore next */ []);
974
+ this.decadeCellTemplate = contentChild(CalendarDecadeCellTemplateDirective, ...ngDevMode ? [{ debugName: "decadeCellTemplate" }] : /* istanbul ignore next */ []);
975
+ this.decadeEnd = computed(() => {
976
+ return this.decadeStart() + 9;
977
+ }, ...ngDevMode ? [{ debugName: "decadeEnd" }] : /* istanbul ignore next */ []);
978
+ this.decadeGridClass = computed(() => {
979
+ return calendarDecadeViewGridThemeVariants();
980
+ }, ...ngDevMode ? [{ debugName: "decadeGridClass" }] : /* istanbul ignore next */ []);
981
+ this.decadeStart = computed(() => {
982
+ const navigatedDate = this.navigatedDate();
983
+ const year = gregorianDateTime(navigatedDate, this.#i18n.localeId()).year;
984
+ return year - year % 10;
985
+ }, ...ngDevMode ? [{ debugName: "decadeStart" }] : /* istanbul ignore next */ []);
986
+ this.decadeYears = computed(() => {
987
+ const decadeStart = this.decadeStart();
988
+ return range(decadeStart, 10).chunk(4).select((e) => e.toArray()).toArray();
989
+ }, ...ngDevMode ? [{ debugName: "decadeYears" }] : /* istanbul ignore next */ []);
990
+ this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
991
+ this.effectiveFirstDay = computed(() => {
992
+ return this.firstDay() ?? getLocaleFirstDayOfWeek(this.#i18n.localeId());
993
+ }, ...ngDevMode ? [{ debugName: "effectiveFirstDay" }] : /* istanbul ignore next */ []);
994
+ this.gridId = createElementControlId();
995
+ this.headerClass = computed(() => {
996
+ return calendarHeaderThemeVariants({});
997
+ }, ...ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []);
998
+ this.headerMonthYear = computed(() => {
999
+ const locale = this.#i18n.localeId();
1000
+ return formatGregorianDateToLocaleString(this.navigatedDate(), locale, {
1001
+ year: "numeric",
1002
+ month: "long"
1003
+ });
1004
+ }, ...ngDevMode ? [{ debugName: "headerMonthYear" }] : /* istanbul ignore next */ []);
1005
+ this.headerYear = computed(() => {
1006
+ const locale = this.#i18n.localeId();
1007
+ return formatGregorianDateToLocaleString(this.navigatedDate(), locale, { year: "numeric" });
1008
+ }, ...ngDevMode ? [{ debugName: "headerYear" }] : /* istanbul ignore next */ []);
1009
+ this.invalidState = computed(() => this.touched() && (this.invalid() || this.required() && this.isEmptyValue()), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
1010
+ this.isDayUnavailable = computed(() => {
1011
+ const disabledDates = this.disabledDates();
1012
+ const min = this.minDate();
1013
+ const max = this.maxDate();
1014
+ const isOutOfRange = (date) => compareDates(date, max, ">") || compareDates(date, min, "<");
1015
+ if (typeof disabledDates === "function") return (date) => isOutOfRange(date) || disabledDates(date);
1016
+ const keys = /* @__PURE__ */ new Set();
1017
+ for (const disabledDate of disabledDates ?? []) keys.add(toDayKey(disabledDate));
1018
+ return (date) => isOutOfRange(date) || keys.has(toDayKey(date));
1019
+ }, ...ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []);
1020
+ this.messages = this.#i18n.componentMessages("calendar", CALENDAR_DEFAULT_MESSAGES);
1021
+ this.monthBounds = computed(() => {
1022
+ const navigatedDate = this.navigatedDate();
1023
+ const firstDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).startOf("month");
1024
+ const lastDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).endOf("month");
1025
+ return {
1026
+ start: firstDayOfMonth.toJSDate(),
1027
+ end: lastDayOfMonth.toJSDate()
1028
+ };
1029
+ }, ...ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []);
1030
+ this.monthCellTemplate = contentChild(CalendarMonthCellTemplateDirective, ...ngDevMode ? [{ debugName: "monthCellTemplate" }] : /* istanbul ignore next */ []);
1031
+ this.monthDictChunked = computed(() => {
1032
+ return this.#monthDict().chunk(7).select((e) => e.toImmutableDictionary((e) => e.key, (e) => e.value)).toImmutableSet();
1033
+ }, ...ngDevMode ? [{ debugName: "monthDictChunked" }] : /* istanbul ignore next */ []);
1034
+ this.monthGridClass = computed(() => {
1035
+ return calendarMonthViewGridThemeVariants();
1036
+ }, ...ngDevMode ? [{ debugName: "monthGridClass" }] : /* istanbul ignore next */ []);
1037
+ this.monthGridHeaderClass = computed(() => {
1038
+ return calendarMonthViewGridHeaderThemeVariants();
1039
+ }, ...ngDevMode ? [{ debugName: "monthGridHeaderClass" }] : /* istanbul ignore next */ []);
1040
+ this.months = computed(() => {
1041
+ const locale = this.#i18n.localeId();
1042
+ const names = range(1, 12).select((m) => gregorianDateTimeFromObject({
1043
+ year: 2024,
1044
+ month: m,
1045
+ day: 1
1046
+ }, locale).toFormat("LLL")).toArray();
1047
+ return index(names).chunk(3).select((e) => e.select((m) => [m[0] + 1, m[1]]).toImmutableSet()).toImmutableSet();
1048
+ }, ...ngDevMode ? [{ debugName: "months" }] : /* istanbul ignore next */ []);
1049
+ this.navigatedDate = signal(startOfDay(/* @__PURE__ */ new Date()), ...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
1050
+ this.nextButtonLabel = computed(() => {
1051
+ const view = this.calendarView();
1052
+ const messages = this.messages();
1053
+ switch (view) {
1054
+ case "month": return messages.nextMonth;
1055
+ case "year": return messages.nextYear;
1056
+ case "decade": return messages.nextDecade;
1057
+ }
1058
+ }, ...ngDevMode ? [{ debugName: "nextButtonLabel" }] : /* istanbul ignore next */ []);
1059
+ this.pendingRangeStart = signal(null, ...ngDevMode ? [{ debugName: "pendingRangeStart" }] : /* istanbul ignore next */ []);
1060
+ this.prevButtonLabel = computed(() => {
1061
+ const view = this.calendarView();
1062
+ const messages = this.messages();
1063
+ switch (view) {
1064
+ case "month": return messages.previousMonth;
1065
+ case "year": return messages.previousYear;
1066
+ case "decade": return messages.previousDecade;
1067
+ }
1068
+ }, ...ngDevMode ? [{ debugName: "prevButtonLabel" }] : /* istanbul ignore next */ []);
1069
+ this.rangePreviewDate = signal(null, ...ngDevMode ? [{ debugName: "rangePreviewDate" }] : /* istanbul ignore next */ []);
1070
+ this.rangePreviewDates = computed(() => {
1071
+ if (this.selection() !== "range") return [];
1072
+ const pendingRangeStart = this.pendingRangeStart();
1073
+ if (!pendingRangeStart) return [];
1074
+ return this.getInclusiveDateRange(pendingRangeStart, this.rangePreviewDate() ?? this.navigatedDate());
1075
+ }, ...ngDevMode ? [{ debugName: "rangePreviewDates" }] : /* istanbul ignore next */ []);
1076
+ this.rangePreviewKeys = computed(() => new Set(this.rangePreviewDates().map(toDayKey)), ...ngDevMode ? [{ debugName: "rangePreviewKeys" }] : /* istanbul ignore next */ []);
1077
+ this.selectedDates = linkedSignal(() => {
1078
+ const v = this.value();
1079
+ const selection = this.selection();
1080
+ if (v == null) return [];
1081
+ if (selection === "range" && Array.isArray(v) && v.length >= 2) {
1082
+ const date1 = DateTime.fromJSDate(v[0]);
1083
+ const date2 = DateTime.fromJSDate(v[v.length - 1]);
1084
+ const startDate = date1 <= date2 ? date1 : date2;
1085
+ const totalDays = calendarDaysBetween(startDate, date1 <= date2 ? date2 : date1) + 1;
1086
+ return range(0, totalDays).select((i) => startDate.plus({ days: i }).toJSDate()).toArray();
1087
+ }
1088
+ return Array.isArray(v) ? v : [v];
1089
+ }, ...ngDevMode ? [{ debugName: "selectedDates" }] : /* istanbul ignore next */ []);
1090
+ this.selectedKeys = computed(() => new Set(this.selectedDates().map(toDayKey)), ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
1091
+ this.today = signal(startOfDay(/* @__PURE__ */ new Date()), ...ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []);
1092
+ this.todayButtonLabel = computed(() => {
1093
+ const locale = this.#i18n.localeId();
1094
+ const todayStr = formatGregorianDateToLocaleString(this.today(), locale, {
1095
+ year: "numeric",
1096
+ month: "long",
1097
+ day: "numeric"
1098
+ });
1099
+ return this.messages().goToToday(todayStr);
1100
+ }, ...ngDevMode ? [{ debugName: "todayButtonLabel" }] : /* istanbul ignore next */ []);
1101
+ this.todayUnavailable = computed(() => this.isDayUnavailable()(this.today()), ...ngDevMode ? [{ debugName: "todayUnavailable" }] : /* istanbul ignore next */ []);
1102
+ this.viewSwitchButtonLabel = computed(() => {
1103
+ const view = this.calendarView();
1104
+ const locale = this.#i18n.localeId();
1105
+ const navigatedDate = this.navigatedDate();
1106
+ const messages = this.messages();
1107
+ switch (view) {
1108
+ case "month": return messages.switchToYearView(formatGregorianDateToLocaleString(navigatedDate, locale, {
1109
+ year: "numeric",
1110
+ month: "long"
1111
+ }));
1112
+ case "year": return messages.switchToDecadeView(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
1113
+ case "decade": return messages.decadeRange(this.decadeStart(), this.decadeEnd());
1114
+ }
1115
+ }, ...ngDevMode ? [{ debugName: "viewSwitchButtonLabel" }] : /* istanbul ignore next */ []);
1116
+ this.weekdays = computed(() => {
1117
+ const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
1118
+ const locale = this.#i18n.localeId();
1119
+ const days = range(0, 7).select((i) => {
1120
+ const dt = gregorianDateTimeFromObject({
1121
+ year: 2024,
1122
+ month: 1,
1123
+ day: 1 + i
1124
+ }, locale);
1125
+ const short = dt.toFormat("ccc");
1126
+ const full = dt.toFormat("cccc");
1127
+ const narrow = dt.toFormat("ccccc");
1128
+ return {
1129
+ display: short.length > 4 || short === full && short.length > 3 ? narrow : short,
1130
+ short,
1131
+ narrow,
1132
+ full
1133
+ };
1134
+ }).toArray();
1135
+ const startIndex = firstDayIso - 1;
1136
+ return [...days.slice(startIndex), ...days.slice(0, startIndex)];
1137
+ }, ...ngDevMode ? [{ debugName: "weekdays" }] : /* istanbul ignore next */ []);
1138
+ this.yearCellTemplate = contentChild(CalendarYearCellTemplateDirective, ...ngDevMode ? [{ debugName: "yearCellTemplate" }] : /* istanbul ignore next */ []);
1139
+ this.yearGridClass = computed(() => {
1140
+ return calendarYearViewGridThemeVariants();
1141
+ }, ...ngDevMode ? [{ debugName: "yearGridClass" }] : /* istanbul ignore next */ []);
1142
+ this.disabled = input(false, {
1143
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
1144
+ transform: booleanAttribute
1145
+ });
1146
+ this.disabledDates = input(...ngDevMode ? [void 0, { debugName: "disabledDates" }] : /* istanbul ignore next */ []);
1147
+ this.firstDay = input(null, ...ngDevMode ? [{ debugName: "firstDay" }] : /* istanbul ignore next */ []);
1148
+ this.focusOnMount = input(false, {
1149
+ ...ngDevMode ? { debugName: "focusOnMount" } : /* istanbul ignore next */ {},
1150
+ transform: booleanAttribute
1151
+ });
1152
+ this.invalid = input(false, {
1153
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
1154
+ transform: booleanAttribute
1155
+ });
1156
+ this.maxDate = input(...ngDevMode ? [void 0, { debugName: "maxDate" }] : /* istanbul ignore next */ []);
1157
+ this.minDate = input(...ngDevMode ? [void 0, { debugName: "minDate" }] : /* istanbul ignore next */ []);
1158
+ this.readonly = input(false, {
1159
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
1160
+ transform: booleanAttribute
1161
+ });
1162
+ this.required = input(false, {
1163
+ ...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
1164
+ transform: booleanAttribute
1165
+ });
1166
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
1167
+ this.selection = input("single", ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
1168
+ this.touch = output();
1169
+ this.touched = input(false, {
1170
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
1171
+ transform: booleanAttribute
1172
+ });
1173
+ this.userClass = input("", {
1174
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
1175
+ alias: "class"
1176
+ });
1177
+ this.value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1178
+ this.weekNumber = input(false, {
1179
+ ...ngDevMode ? { debugName: "weekNumber" } : /* istanbul ignore next */ {},
1180
+ transform: booleanAttribute
1181
+ });
1182
+ afterNextRender({ read: () => {
1183
+ this.setupKeyboardNavigation();
1184
+ if (this.focusOnMount()) this.focusActiveCell();
1185
+ } });
1186
+ effect(() => {
1187
+ const min = this.minDate();
1188
+ const max = this.maxDate();
1189
+ untracked(() => {
1190
+ const navigationDate = this.navigatedDate();
1191
+ if (compareDates(navigationDate, min, "<") && min) this.navigatedDate.set(min);
1192
+ else if (compareDates(navigationDate, max, ">") && max) this.navigatedDate.set(max);
1193
+ });
1194
+ });
1195
+ effect(() => {
1196
+ const v = this.value();
1197
+ untracked(() => {
1198
+ const lastDate = Array.isArray(v) ? lastOrDefault(v) : v;
1199
+ if (lastDate) this.navigatedDate.set(lastDate);
1200
+ });
1201
+ });
1202
+ toObservable(this.calendarView).pipe(skip(1)).subscribe(() => this.focusActiveCell());
1203
+ }
1204
+ formatInteger(value) {
1205
+ if (value == null) return "";
1206
+ return formatNumber(value, this.#i18n.localeId(), {
1207
+ maximumFractionDigits: 0,
1208
+ useGrouping: false
1209
+ });
1210
+ }
1211
+ getWeekNumber(date) {
1212
+ const dt = gregorianDateTime(date, this.#i18n.localeId());
1213
+ const daysToThursday = (4 - FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()] + 7) % 7;
1214
+ return dt.plus({ days: daysToThursday }).weekNumber;
1215
+ }
1216
+ onDayClick(date, event) {
1217
+ event.preventDefault();
1218
+ if (this.effectiveDisabled() || this.readonly()) return;
1219
+ const selection = this.selection();
1220
+ if (selection === "single") this.handleSingleSelection(date);
1221
+ else if (selection === "multiple") {
1222
+ if (event.ctrlKey || event.metaKey || event.shiftKey) this.handleMultipleSelection(date, event.shiftKey);
1223
+ else this.handleSingleSelection(date);
1224
+ } else if (selection === "range") {
1225
+ this.handleRangeSelection(date);
1226
+ this.navigatedDate.set(date);
1227
+ }
1228
+ this.focusActiveCell();
1229
+ this.commitUserSelection();
1230
+ }
1231
+ onDayPointerEnter(date) {
1232
+ if (this.effectiveDisabled() || this.readonly() || this.selection() !== "range" || this.pendingRangeStart() == null) return;
1233
+ this.rangePreviewDate.set(date);
1234
+ }
1235
+ onFocusOut(event) {
1236
+ if (this.#destroyRef.destroyed) return;
1237
+ const nextTarget = event.relatedTarget;
1238
+ if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) return;
1239
+ this.touch.emit();
1240
+ }
1241
+ onMonthClick(month) {
1242
+ this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ month }).toJSDate());
1243
+ this.calendarView.set("month");
1244
+ }
1245
+ onMonthGridPointerLeave() {
1246
+ this.rangePreviewDate.set(null);
1247
+ }
1248
+ onNavigationClick(direction) {
1249
+ this.rangePreviewDate.set(null);
1250
+ const date = DateTime.fromJSDate(this.navigatedDate());
1251
+ let unit;
1252
+ switch (this.calendarView()) {
1253
+ case "month":
1254
+ unit = { months: 1 };
1255
+ break;
1256
+ case "year":
1257
+ unit = { years: 1 };
1258
+ break;
1259
+ case "decade": unit = { years: 10 };
1260
+ }
1261
+ this.navigatedDate.set(direction === "prev" ? date.minus(unit).toJSDate() : date.plus(unit).toJSDate());
1262
+ }
1263
+ onTodayButtonClick() {
1264
+ this.refreshToday();
1265
+ if (this.effectiveDisabled() || this.readonly() || this.todayUnavailable()) return;
1266
+ const today = this.today();
1267
+ if (this.selection() === "range") {
1268
+ this.handleRangeSelection(today);
1269
+ this.navigatedDate.set(today);
1270
+ } else this.handleSingleSelection(today);
1271
+ this.calendarView.set("month");
1272
+ this.commitUserSelection();
1273
+ }
1274
+ onViewChangeClick(view) {
1275
+ this.calendarView.set(view);
1276
+ }
1277
+ onYearClick(year) {
1278
+ this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ year }).toJSDate());
1279
+ this.calendarView.set("year");
1280
+ }
1281
+ refreshToday() {
1282
+ const today = startOfDay(/* @__PURE__ */ new Date());
1283
+ if (!compareDates(today, this.today(), "==")) this.today.set(today);
1284
+ }
1285
+ clearPendingRange() {
1286
+ this.pendingRangeStart.set(null);
1287
+ this.rangePreviewDate.set(null);
1288
+ }
1289
+ commitUserSelection() {
1290
+ if (this.selection() === "range" && this.pendingRangeStart() != null) return;
1291
+ this.value.set(this.#outputValue());
1292
+ }
1293
+ extendSelection(offset) {
1294
+ const currentDate = this.navigatedDate();
1295
+ const newDate = DateTime.fromJSDate(currentDate).plus({ days: offset }).toJSDate();
1296
+ if (this.isDateDisabled(newDate)) return;
1297
+ const currentSelection = this.selectedDates();
1298
+ const dateTime = DateTime.fromJSDate(newDate);
1299
+ if (!currentSelection.some((d) => DateTime.fromJSDate(d).hasSame(dateTime, "day"))) this.setCurrentDate([...currentSelection, newDate]);
1300
+ this.navigatedDate.set(newDate);
1301
+ }
1302
+ focusActiveCell() {
1303
+ rxTimeout(this.#destroyRef, () => {
1304
+ const calendarView = this.calendarView();
1305
+ const selector = calendarView === "year" ? "[monaYearMonth]" : calendarView === "decade" ? "[monaDecadeYear]" : "[monaMonthDay]";
1306
+ this.#hostElementRef.nativeElement.querySelector(`${selector}[tabindex="0"]`)?.focus();
1307
+ });
1308
+ }
1309
+ getDateArray(date) {
1310
+ if (date == null) return [];
1311
+ return Array.isArray(date) ? date : [date];
1312
+ }
1313
+ getDatesForMultipleSelection(date) {
1314
+ const lastSelectedDate = lastOrDefault(this.selectedDates()) ?? this.navigatedDate();
1315
+ const startDate = lastSelectedDate < date ? lastSelectedDate : date;
1316
+ const endDate = this.navigatedDate() > date ? this.navigatedDate() : date;
1317
+ const totalDays = calendarDaysBetween(DateTime.fromJSDate(startDate), DateTime.fromJSDate(endDate)) + 1;
1318
+ return range(0, totalDays).select((i) => DateTime.fromJSDate(startDate).plus({ days: i }).toJSDate()).toArray();
1319
+ }
1320
+ getInclusiveDateRange(date1, date2) {
1321
+ const dateTime1 = DateTime.fromJSDate(date1);
1322
+ const dateTime2 = DateTime.fromJSDate(date2);
1323
+ const startDate = dateTime1 <= dateTime2 ? dateTime1 : dateTime2;
1324
+ const totalDays = calendarDaysBetween(startDate, dateTime1 <= dateTime2 ? dateTime2 : dateTime1) + 1;
1325
+ return range(0, totalDays).select((i) => startDate.plus({ days: i }).toJSDate()).toArray();
1326
+ }
1327
+ handleKeydown(event) {
1328
+ if (this.effectiveDisabled()) return;
1329
+ const preventableEvent = new PreventableEvent("calendarKeydown", event);
1330
+ this.#calendarService?.keydown$.next(preventableEvent);
1331
+ if (preventableEvent.isDefaultPrevented()) return;
1332
+ if (event.target.closest("button")) return;
1333
+ const view = this.calendarView();
1334
+ const isCtrlOrCmd = event.ctrlKey || event.metaKey;
1335
+ const isShift = event.shiftKey;
1336
+ const selection = this.selection();
1337
+ if (!this.readonly() && selection === "multiple" && (isCtrlOrCmd || isShift)) {
1338
+ if (this.handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift)) {
1339
+ this.commitUserSelection();
1340
+ this.focusActiveCell();
1341
+ return;
1342
+ }
1343
+ }
1344
+ let shouldFocusCell = false;
1345
+ switch (event.key) {
1346
+ case "ArrowUp":
1347
+ event.preventDefault();
1348
+ if (isCtrlOrCmd) this.switchToUpperView();
1349
+ else this.navigateByWeeksOrRows(-1, view);
1350
+ shouldFocusCell = true;
1351
+ break;
1352
+ case "ArrowDown":
1353
+ event.preventDefault();
1354
+ if (isCtrlOrCmd) this.switchToLowerView();
1355
+ else this.navigateByWeeksOrRows(1, view);
1356
+ shouldFocusCell = true;
1357
+ break;
1358
+ case "ArrowLeft":
1359
+ event.preventDefault();
1360
+ if (isCtrlOrCmd) this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowLeft"));
1361
+ else this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowLeft"), view);
1362
+ shouldFocusCell = true;
1363
+ break;
1364
+ case "ArrowRight":
1365
+ event.preventDefault();
1366
+ if (isCtrlOrCmd) this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowRight"));
1367
+ else this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowRight"), view);
1368
+ shouldFocusCell = true;
1369
+ break;
1370
+ case "Enter":
1371
+ case " ": {
1372
+ event.preventDefault();
1373
+ const previousView = this.calendarView();
1374
+ if (this.readonly() && previousView === "month") {
1375
+ shouldFocusCell = true;
1376
+ break;
1377
+ }
1378
+ if (isCtrlOrCmd && selection === "multiple") this.toggleFocusedDateInSelection();
1379
+ else if (isShift && selection === "multiple") this.selectRangeToFocused();
1380
+ else this.selectFocusedItem();
1381
+ if (previousView === "month" && this.calendarView() === "month") this.commitUserSelection();
1382
+ shouldFocusCell = true;
1383
+ break;
1384
+ }
1385
+ case "Home":
1386
+ event.preventDefault();
1387
+ this.navigateToStart(view);
1388
+ shouldFocusCell = true;
1389
+ break;
1390
+ case "End":
1391
+ event.preventDefault();
1392
+ this.navigateToEnd(view);
1393
+ shouldFocusCell = true;
1394
+ break;
1395
+ case "PageUp":
1396
+ event.preventDefault();
1397
+ this.navigateByPeriod(isShift && view === "month" ? -12 : -1, view);
1398
+ shouldFocusCell = true;
1399
+ break;
1400
+ case "PageDown":
1401
+ event.preventDefault();
1402
+ this.navigateByPeriod(isShift && view === "month" ? 12 : 1, view);
1403
+ shouldFocusCell = true;
1404
+ break;
1405
+ case "t":
1406
+ case "T":
1407
+ if (!isCtrlOrCmd && !isShift) {
1408
+ event.preventDefault();
1409
+ this.navigateToToday();
1410
+ shouldFocusCell = true;
1411
+ }
1412
+ break;
1413
+ case "Escape":
1414
+ event.preventDefault();
1415
+ return;
1416
+ }
1417
+ if (shouldFocusCell) this.focusActiveCell();
1418
+ }
1419
+ handleMultipleSelection(date, rangedSelection) {
1420
+ this.clearPendingRange();
1421
+ const value = this.selectedDates();
1422
+ if (value.length === 0) {
1423
+ this.setCurrentDate([date]);
1424
+ this.navigatedDate.set(date);
1425
+ return;
1426
+ }
1427
+ if (!rangedSelection) {
1428
+ const date1 = DateTime.fromJSDate(date);
1429
+ const valueList = this.getDateArray(value);
1430
+ const selectedDates = select(valueList, (e) => DateTime.fromJSDate(e));
1431
+ if (selectedDates.any((e) => e.hasSame(date1, "day"))) {
1432
+ const newDates = selectedDates.where((e) => !e.hasSame(date1, "day")).select((e) => e.toJSDate()).toArray();
1433
+ this.setCurrentDate(newDates);
1434
+ } else this.setCurrentDate([...valueList, date]);
1435
+ this.navigatedDate.set(date);
1436
+ } else {
1437
+ const selectedDates = this.getDatesForMultipleSelection(date);
1438
+ this.setCurrentDate(selectedDates);
1439
+ }
1440
+ }
1441
+ handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift) {
1442
+ if (this.calendarView() !== "month") return false;
1443
+ if (isShift && !isCtrlOrCmd) switch (event.key) {
1444
+ case "ArrowLeft":
1445
+ event.preventDefault();
1446
+ this.extendSelection(this.horizontalCellDelta("ArrowLeft"));
1447
+ return true;
1448
+ case "ArrowRight":
1449
+ event.preventDefault();
1450
+ this.extendSelection(this.horizontalCellDelta("ArrowRight"));
1451
+ return true;
1452
+ case "ArrowUp":
1453
+ event.preventDefault();
1454
+ this.extendSelection(-7);
1455
+ return true;
1456
+ case "ArrowDown":
1457
+ event.preventDefault();
1458
+ this.extendSelection(7);
1459
+ return true;
1460
+ }
1461
+ return false;
1462
+ }
1463
+ handleRangeSelection(date) {
1464
+ const pendingRangeStart = this.pendingRangeStart();
1465
+ if (pendingRangeStart == null) {
1466
+ this.pendingRangeStart.set(date);
1467
+ this.rangePreviewDate.set(null);
1468
+ this.setCurrentDate([date]);
1469
+ return;
1470
+ }
1471
+ this.setCurrentDate(this.getInclusiveDateRange(pendingRangeStart, date));
1472
+ this.pendingRangeStart.set(null);
1473
+ this.rangePreviewDate.set(null);
1474
+ }
1475
+ handleSingleSelection(date) {
1476
+ this.clearPendingRange();
1477
+ const value = this.selectedDates();
1478
+ if (value.length > 0) {
1479
+ const date1 = DateTime.fromJSDate(date);
1480
+ const valueItem = lastOrDefault(value) ?? DateTime.now().toJSDate();
1481
+ const newDate = DateTime.fromJSDate(valueItem).set({
1482
+ day: date1.day,
1483
+ month: date1.month,
1484
+ year: date1.year
1485
+ }).toJSDate();
1486
+ this.navigatedDate.set(newDate);
1487
+ this.setCurrentDate(newDate);
1488
+ } else {
1489
+ this.navigatedDate.set(date);
1490
+ this.setCurrentDate(date);
1491
+ }
1492
+ }
1493
+ horizontalCellDelta(key) {
1494
+ const isRtl = this.#direction() === "rtl";
1495
+ if (key === "ArrowLeft") return isRtl ? 1 : -1;
1496
+ return isRtl ? -1 : 1;
1497
+ }
1498
+ horizontalPeriodDirection(key) {
1499
+ const isRtl = this.#direction() === "rtl";
1500
+ if (key === "ArrowLeft") return isRtl ? "next" : "prev";
1501
+ return isRtl ? "prev" : "next";
1502
+ }
1503
+ isDateDisabled(date) {
1504
+ return this.isDayUnavailable()(date);
1505
+ }
1506
+ isEmptyValue() {
1507
+ const value = this.value();
1508
+ return value == null || Array.isArray(value) && value.length === 0;
1509
+ }
1510
+ isOutOfRange(date) {
1511
+ return compareDates(date, this.maxDate(), ">") || compareDates(date, this.minDate(), "<");
1512
+ }
1513
+ navigateByDaysOrCells(offset, view) {
1514
+ const currentDate = this.navigatedDate();
1515
+ const dateTime = DateTime.fromJSDate(currentDate);
1516
+ let newDate;
1517
+ switch (view) {
1518
+ case "month":
1519
+ newDate = dateTime.plus({ days: offset }).toJSDate();
1520
+ break;
1521
+ case "year":
1522
+ newDate = dateTime.plus({ months: offset }).toJSDate();
1523
+ break;
1524
+ case "decade": newDate = dateTime.plus({ years: offset }).toJSDate();
1525
+ }
1526
+ if (view === "month" && this.isOutOfRange(newDate)) return;
1527
+ this.rangePreviewDate.set(null);
1528
+ this.navigatedDate.set(newDate);
1529
+ }
1530
+ navigateByPeriod(offset, view) {
1531
+ const currentDate = this.navigatedDate();
1532
+ const dateTime = DateTime.fromJSDate(currentDate);
1533
+ let newDate;
1534
+ switch (view) {
1535
+ case "month":
1536
+ newDate = dateTime.plus({ months: offset }).toJSDate();
1537
+ break;
1538
+ case "year":
1539
+ newDate = dateTime.plus({ years: offset }).toJSDate();
1540
+ break;
1541
+ case "decade": newDate = dateTime.plus({ years: offset * 10 }).toJSDate();
1542
+ }
1543
+ if (view === "month" && this.isDateDisabled(newDate)) {
1544
+ const direction = offset > 0 ? 1 : -1;
1545
+ const maxAttempts = 31;
1546
+ for (let i = 1; i <= maxAttempts; i++) {
1547
+ const adjustedDate = DateTime.fromJSDate(newDate).plus({ days: direction * i }).toJSDate();
1548
+ if (!this.isDateDisabled(adjustedDate)) {
1549
+ newDate = adjustedDate;
1550
+ break;
1551
+ }
1552
+ }
1553
+ }
1554
+ this.rangePreviewDate.set(null);
1555
+ this.navigatedDate.set(newDate);
1556
+ }
1557
+ navigateByWeeksOrRows(offset, view) {
1558
+ const currentDate = this.navigatedDate();
1559
+ const dateTime = DateTime.fromJSDate(currentDate);
1560
+ let newDate;
1561
+ switch (view) {
1562
+ case "month":
1563
+ newDate = dateTime.plus({ weeks: offset }).toJSDate();
1564
+ break;
1565
+ case "year":
1566
+ newDate = dateTime.plus({ months: offset * 3 }).toJSDate();
1567
+ break;
1568
+ case "decade": newDate = dateTime.plus({ years: offset * 4 }).toJSDate();
1569
+ }
1570
+ if (view === "month" && this.isOutOfRange(newDate)) return;
1571
+ this.rangePreviewDate.set(null);
1572
+ this.navigatedDate.set(newDate);
1573
+ }
1574
+ navigatePeriodKeyboard(direction) {
1575
+ this.rangePreviewDate.set(null);
1576
+ this.onNavigationClick(direction);
1577
+ }
1578
+ navigateToEnd(view) {
1579
+ const currentDate = this.navigatedDate();
1580
+ const dateTime = DateTime.fromJSDate(currentDate);
1581
+ let newDate;
1582
+ switch (view) {
1583
+ case "month": {
1584
+ const daysToAdd = ((FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()] + 5) % 7 + 1 - dateTime.weekday + 7) % 7;
1585
+ newDate = dateTime.plus({ days: daysToAdd }).toJSDate();
1586
+ if (this.isDateDisabled(newDate)) for (let i = 1; i <= 6; i++) {
1587
+ const testDate = DateTime.fromJSDate(newDate).minus({ days: i }).toJSDate();
1588
+ if (!this.isDateDisabled(testDate)) {
1589
+ newDate = testDate;
1590
+ break;
1591
+ }
1592
+ }
1593
+ break;
1594
+ }
1595
+ case "year":
1596
+ newDate = dateTime.set({ month: 12 }).toJSDate();
1597
+ break;
1598
+ case "decade": {
1599
+ const yearEnd = this.decadeEnd();
1600
+ newDate = dateTime.set({ year: yearEnd }).toJSDate();
1601
+ break;
1602
+ }
1603
+ }
1604
+ this.rangePreviewDate.set(null);
1605
+ this.navigatedDate.set(newDate);
1606
+ }
1607
+ navigateToStart(view) {
1608
+ const currentDate = this.navigatedDate();
1609
+ const dateTime = DateTime.fromJSDate(currentDate);
1610
+ let newDate;
1611
+ switch (view) {
1612
+ case "month": {
1613
+ const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
1614
+ const daysToSubtract = (dateTime.weekday - firstDayIso + 7) % 7;
1615
+ newDate = dateTime.minus({ days: daysToSubtract }).toJSDate();
1616
+ if (this.isDateDisabled(newDate)) for (let i = 1; i <= 6; i++) {
1617
+ const testDate = DateTime.fromJSDate(newDate).plus({ days: i }).toJSDate();
1618
+ if (!this.isDateDisabled(testDate)) {
1619
+ newDate = testDate;
1620
+ break;
1621
+ }
1622
+ }
1623
+ break;
1624
+ }
1625
+ case "year":
1626
+ newDate = dateTime.set({ month: 1 }).toJSDate();
1627
+ break;
1628
+ case "decade": {
1629
+ const yearStart = this.decadeStart();
1630
+ newDate = dateTime.set({ year: yearStart }).toJSDate();
1631
+ break;
1632
+ }
1633
+ }
1634
+ this.rangePreviewDate.set(null);
1635
+ this.navigatedDate.set(newDate);
1636
+ }
1637
+ navigateToToday() {
1638
+ this.refreshToday();
1639
+ const today = this.today();
1640
+ if (this.isDateDisabled(today)) return;
1641
+ this.rangePreviewDate.set(null);
1642
+ this.navigatedDate.set(today);
1643
+ this.calendarView.set("month");
1644
+ }
1645
+ selectFocusedItem() {
1646
+ const view = this.calendarView();
1647
+ const currentDate = this.navigatedDate();
1648
+ switch (view) {
1649
+ case "month":
1650
+ if (!this.isDateDisabled(currentDate)) {
1651
+ const selection = this.selection();
1652
+ if (selection === "single") this.handleSingleSelection(currentDate);
1653
+ else if (selection === "multiple") this.handleSingleSelection(currentDate);
1654
+ else if (selection === "range") this.handleRangeSelection(currentDate);
1655
+ }
1656
+ break;
1657
+ case "year":
1658
+ this.calendarView.set("month");
1659
+ break;
1660
+ case "decade": this.calendarView.set("year");
1661
+ }
1662
+ }
1663
+ selectRangeToFocused() {
1664
+ const focusedDate = this.navigatedDate();
1665
+ if (this.isDateDisabled(focusedDate)) return;
1666
+ const selectedDates = this.getDatesForMultipleSelection(focusedDate);
1667
+ this.setCurrentDate(selectedDates);
1668
+ }
1669
+ setCurrentDate(date) {
1670
+ this.selectedDates.set(this.getDateArray(date));
1671
+ }
1672
+ setupKeyboardNavigation() {
1673
+ fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.handleKeydown(event));
1674
+ }
1675
+ switchToLowerView() {
1676
+ switch (this.calendarView()) {
1677
+ case "decade":
1678
+ this.calendarView.set("year");
1679
+ break;
1680
+ case "year": this.calendarView.set("month");
1681
+ }
1682
+ }
1683
+ switchToUpperView() {
1684
+ switch (this.calendarView()) {
1685
+ case "month":
1686
+ this.calendarView.set("year");
1687
+ break;
1688
+ case "year": this.calendarView.set("decade");
1689
+ }
1690
+ }
1691
+ toggleFocusedDateInSelection() {
1692
+ const focusedDate = this.navigatedDate();
1693
+ if (this.isDateDisabled(focusedDate)) return;
1694
+ const currentSelection = this.selectedDates();
1695
+ const dateTime = DateTime.fromJSDate(focusedDate);
1696
+ if (currentSelection.some((d) => DateTime.fromJSDate(d).hasSame(dateTime, "day"))) {
1697
+ const newSelection = currentSelection.filter((d) => !DateTime.fromJSDate(d).hasSame(dateTime, "day"));
1698
+ this.setCurrentDate(newSelection);
1699
+ } else this.setCurrentDate([...currentSelection, focusedDate]);
1700
+ }
1701
+ static {
1702
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1703
+ minVersion: "12.0.0",
1704
+ version: "22.2.6",
1705
+ ngImport: i0,
1706
+ type: CalendarComponent,
1707
+ deps: [],
1708
+ target: i0.ɵɵFactoryTarget.Component
1709
+ });
1710
+ }
1711
+ static {
1712
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1713
+ minVersion: "17.0.0",
1714
+ version: "22.2.6",
1715
+ type: CalendarComponent,
1716
+ isStandalone: true,
1717
+ selector: "mona-calendar",
1718
+ inputs: {
1719
+ disabled: {
1720
+ classPropertyName: "disabled",
1721
+ publicName: "disabled",
1722
+ isSignal: true,
1723
+ isRequired: false,
1724
+ transformFunction: null
1725
+ },
1726
+ disabledDates: {
1727
+ classPropertyName: "disabledDates",
1728
+ publicName: "disabledDates",
1729
+ isSignal: true,
1730
+ isRequired: false,
1731
+ transformFunction: null
1732
+ },
1733
+ firstDay: {
1734
+ classPropertyName: "firstDay",
1735
+ publicName: "firstDay",
1736
+ isSignal: true,
1737
+ isRequired: false,
1738
+ transformFunction: null
1739
+ },
1740
+ focusOnMount: {
1741
+ classPropertyName: "focusOnMount",
1742
+ publicName: "focusOnMount",
1743
+ isSignal: true,
1744
+ isRequired: false,
1745
+ transformFunction: null
1746
+ },
1747
+ invalid: {
1748
+ classPropertyName: "invalid",
1749
+ publicName: "invalid",
1750
+ isSignal: true,
1751
+ isRequired: false,
1752
+ transformFunction: null
1753
+ },
1754
+ maxDate: {
1755
+ classPropertyName: "maxDate",
1756
+ publicName: "maxDate",
1757
+ isSignal: true,
1758
+ isRequired: false,
1759
+ transformFunction: null
1760
+ },
1761
+ minDate: {
1762
+ classPropertyName: "minDate",
1763
+ publicName: "minDate",
1764
+ isSignal: true,
1765
+ isRequired: false,
1766
+ transformFunction: null
1767
+ },
1768
+ readonly: {
1769
+ classPropertyName: "readonly",
1770
+ publicName: "readonly",
1771
+ isSignal: true,
1772
+ isRequired: false,
1773
+ transformFunction: null
1774
+ },
1775
+ required: {
1776
+ classPropertyName: "required",
1777
+ publicName: "required",
1778
+ isSignal: true,
1779
+ isRequired: false,
1780
+ transformFunction: null
1781
+ },
1782
+ rounded: {
1783
+ classPropertyName: "rounded",
1784
+ publicName: "rounded",
1785
+ isSignal: true,
1786
+ isRequired: false,
1787
+ transformFunction: null
1788
+ },
1789
+ selection: {
1790
+ classPropertyName: "selection",
1791
+ publicName: "selection",
1792
+ isSignal: true,
1793
+ isRequired: false,
1794
+ transformFunction: null
1795
+ },
1796
+ touched: {
1797
+ classPropertyName: "touched",
1798
+ publicName: "touched",
1799
+ isSignal: true,
1800
+ isRequired: false,
1801
+ transformFunction: null
1802
+ },
1803
+ userClass: {
1804
+ classPropertyName: "userClass",
1805
+ publicName: "class",
1806
+ isSignal: true,
1807
+ isRequired: false,
1808
+ transformFunction: null
1809
+ },
1810
+ value: {
1811
+ classPropertyName: "value",
1812
+ publicName: "value",
1813
+ isSignal: true,
1814
+ isRequired: false,
1815
+ transformFunction: null
1816
+ },
1817
+ weekNumber: {
1818
+ classPropertyName: "weekNumber",
1819
+ publicName: "weekNumber",
1820
+ isSignal: true,
1821
+ isRequired: false,
1822
+ transformFunction: null
1823
+ }
1824
+ },
1825
+ outputs: {
1826
+ touch: "touch",
1827
+ value: "valueChange"
1828
+ },
1829
+ host: {
1830
+ listeners: {
1831
+ "focusin": "refreshToday()",
1832
+ "focusout": "onFocusOut($event)"
1833
+ },
1834
+ properties: {
1835
+ "attr.aria-label": "null",
1836
+ "attr.data-disabled": "effectiveDisabled() || null",
1837
+ "attr.data-invalid": "invalidState() || null",
1838
+ "attr.data-required": "required() || null",
1839
+ "class": "baseClass()"
1840
+ }
1841
+ },
1842
+ queries: [
1843
+ {
1844
+ propertyName: "decadeCellTemplate",
1845
+ first: true,
1846
+ predicate: CalendarDecadeCellTemplateDirective,
1847
+ descendants: true,
1848
+ isSignal: true
1849
+ },
1850
+ {
1851
+ propertyName: "monthCellTemplate",
1852
+ first: true,
1853
+ predicate: CalendarMonthCellTemplateDirective,
1854
+ descendants: true,
1855
+ isSignal: true
1856
+ },
1857
+ {
1858
+ propertyName: "yearCellTemplate",
1859
+ first: true,
1860
+ predicate: CalendarYearCellTemplateDirective,
1861
+ descendants: true,
1862
+ isSignal: true
1863
+ }
1864
+ ],
1865
+ ngImport: i0,
1866
+ template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n",
1867
+ dependencies: [
1868
+ {
1869
+ kind: "directive",
1870
+ type: ButtonDirective,
1871
+ selector: "button[monaButton]",
1872
+ inputs: [
1873
+ "aria-haspopup",
1874
+ "disabled",
1875
+ "iconOnly",
1876
+ "loading",
1877
+ "look",
1878
+ "rounded",
1879
+ "selected",
1880
+ "size",
1881
+ "tabindex",
1882
+ "toggleable",
1883
+ "type",
1884
+ "class",
1885
+ "value"
1886
+ ],
1887
+ outputs: ["lookChange", "selectedChange"]
1888
+ },
1889
+ {
1890
+ kind: "directive",
1891
+ type: MonthDayDirective,
1892
+ selector: "[monaMonthDay]",
1893
+ inputs: [
1894
+ "disabled",
1895
+ "entry",
1896
+ "isDayUnavailable",
1897
+ "monthBounds",
1898
+ "navigatedDate",
1899
+ "rangePreviewKeys",
1900
+ "rounded",
1901
+ "selectedKeys",
1902
+ "today"
1903
+ ],
1904
+ outputs: ["dayPointerEnter", "daySelect"]
1905
+ },
1906
+ {
1907
+ kind: "directive",
1908
+ type: DecadeYearDirective,
1909
+ selector: "[monaDecadeYear]",
1910
+ inputs: [
1911
+ "disabled",
1912
+ "navigatedDate",
1913
+ "rounded",
1914
+ "selectedDate",
1915
+ "year"
1916
+ ]
1917
+ },
1918
+ {
1919
+ kind: "directive",
1920
+ type: YearMonthDirective,
1921
+ selector: "[monaYearMonth]",
1922
+ inputs: [
1923
+ "disabled",
1924
+ "month",
1925
+ "navigatedDate",
1926
+ "rounded",
1927
+ "selectedDate"
1928
+ ]
1929
+ },
1930
+ {
1931
+ kind: "directive",
1932
+ type: NgTemplateOutlet,
1933
+ selector: "[ngTemplateOutlet]",
1934
+ inputs: [
1935
+ "ngTemplateOutletContext",
1936
+ "ngTemplateOutlet",
1937
+ "ngTemplateOutletInjector"
1938
+ ]
1939
+ },
1940
+ {
1941
+ kind: "component",
1942
+ type: LucideChevronLeft,
1943
+ selector: "svg[lucideChevronLeft]"
1944
+ },
1945
+ {
1946
+ kind: "component",
1947
+ type: LucideChevronRight,
1948
+ selector: "svg[lucideChevronRight]"
1949
+ },
1950
+ {
1951
+ kind: "pipe",
1952
+ type: TakeFirstPipe,
1953
+ name: "monaTakeFirst"
1954
+ }
1955
+ ]
1956
+ });
1957
+ }
1958
+ };
1959
+ i0.ɵɵngDeclareClassMetadata({
1960
+ minVersion: "12.0.0",
1961
+ version: "22.2.6",
1962
+ ngImport: i0,
1963
+ type: CalendarComponent,
1964
+ decorators: [{
1965
+ type: Component,
1966
+ args: [{
1967
+ selector: "mona-calendar",
1968
+ imports: [
1969
+ ButtonDirective,
1970
+ MonthDayDirective,
1971
+ DecadeYearDirective,
1972
+ YearMonthDirective,
1973
+ NgTemplateOutlet,
1974
+ TakeFirstPipe,
1975
+ LucideChevronLeft,
1976
+ LucideChevronRight
1977
+ ],
1978
+ host: {
1979
+ "[attr.aria-label]": "null",
1980
+ "[attr.data-disabled]": "effectiveDisabled() || null",
1981
+ "[attr.data-invalid]": "invalidState() || null",
1982
+ "[attr.data-required]": "required() || null",
1983
+ "[class]": "baseClass()",
1984
+ "(focusin)": "refreshToday()",
1985
+ "(focusout)": "onFocusOut($event)"
1986
+ },
1987
+ template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n"
1988
+ }]
1989
+ }],
1990
+ ctorParameters: () => [],
1991
+ propDecorators: {
1992
+ decadeCellTemplate: [{
1993
+ type: i0.ContentChild,
1994
+ args: [i0.forwardRef(() => CalendarDecadeCellTemplateDirective), { isSignal: true }]
1995
+ }],
1996
+ monthCellTemplate: [{
1997
+ type: i0.ContentChild,
1998
+ args: [i0.forwardRef(() => CalendarMonthCellTemplateDirective), { isSignal: true }]
1999
+ }],
2000
+ yearCellTemplate: [{
2001
+ type: i0.ContentChild,
2002
+ args: [i0.forwardRef(() => CalendarYearCellTemplateDirective), { isSignal: true }]
2003
+ }],
2004
+ disabled: [{
2005
+ type: i0.Input,
2006
+ args: [{
2007
+ isSignal: true,
2008
+ alias: "disabled",
2009
+ required: false
2010
+ }]
2011
+ }],
2012
+ disabledDates: [{
2013
+ type: i0.Input,
2014
+ args: [{
2015
+ isSignal: true,
2016
+ alias: "disabledDates",
2017
+ required: false
2018
+ }]
2019
+ }],
2020
+ firstDay: [{
2021
+ type: i0.Input,
2022
+ args: [{
2023
+ isSignal: true,
2024
+ alias: "firstDay",
2025
+ required: false
2026
+ }]
2027
+ }],
2028
+ focusOnMount: [{
2029
+ type: i0.Input,
2030
+ args: [{
2031
+ isSignal: true,
2032
+ alias: "focusOnMount",
2033
+ required: false
2034
+ }]
2035
+ }],
2036
+ invalid: [{
2037
+ type: i0.Input,
2038
+ args: [{
2039
+ isSignal: true,
2040
+ alias: "invalid",
2041
+ required: false
2042
+ }]
2043
+ }],
2044
+ maxDate: [{
2045
+ type: i0.Input,
2046
+ args: [{
2047
+ isSignal: true,
2048
+ alias: "maxDate",
2049
+ required: false
2050
+ }]
2051
+ }],
2052
+ minDate: [{
2053
+ type: i0.Input,
2054
+ args: [{
2055
+ isSignal: true,
2056
+ alias: "minDate",
2057
+ required: false
2058
+ }]
2059
+ }],
2060
+ readonly: [{
2061
+ type: i0.Input,
2062
+ args: [{
2063
+ isSignal: true,
2064
+ alias: "readonly",
2065
+ required: false
2066
+ }]
2067
+ }],
2068
+ required: [{
2069
+ type: i0.Input,
2070
+ args: [{
2071
+ isSignal: true,
2072
+ alias: "required",
2073
+ required: false
2074
+ }]
2075
+ }],
2076
+ rounded: [{
2077
+ type: i0.Input,
2078
+ args: [{
2079
+ isSignal: true,
2080
+ alias: "rounded",
2081
+ required: false
2082
+ }]
2083
+ }],
2084
+ selection: [{
2085
+ type: i0.Input,
2086
+ args: [{
2087
+ isSignal: true,
2088
+ alias: "selection",
2089
+ required: false
2090
+ }]
2091
+ }],
2092
+ touch: [{
2093
+ type: i0.Output,
2094
+ args: ["touch"]
2095
+ }],
2096
+ touched: [{
2097
+ type: i0.Input,
2098
+ args: [{
2099
+ isSignal: true,
2100
+ alias: "touched",
2101
+ required: false
2102
+ }]
2103
+ }],
2104
+ userClass: [{
2105
+ type: i0.Input,
2106
+ args: [{
2107
+ isSignal: true,
2108
+ alias: "class",
2109
+ required: false
2110
+ }]
2111
+ }],
2112
+ value: [{
2113
+ type: i0.Input,
2114
+ args: [{
2115
+ isSignal: true,
2116
+ alias: "value",
2117
+ required: false
2118
+ }]
2119
+ }, {
2120
+ type: i0.Output,
2121
+ args: ["valueChange"]
2122
+ }],
2123
+ weekNumber: [{
2124
+ type: i0.Input,
2125
+ args: [{
2126
+ isSignal: true,
2127
+ alias: "weekNumber",
2128
+ required: false
2129
+ }]
2130
+ }]
2131
+ }
2132
+ });
1637
2133
  export { CALENDAR_DEFAULT_MESSAGES, CalendarComponent, CalendarDecadeCellTemplateDirective, CalendarMonthCellTemplateDirective, CalendarYearCellTemplateDirective };
1638
- //# sourceMappingURL=nanahoshi-mona-ui-calendar.mjs.map
2134
+
2135
+ //# sourceMappingURL=nanahoshi-mona-ui-calendar.mjs.map