@nanahoshi/mona-ui 0.27.2 → 0.29.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 (213) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/locales.md +8 -0
  3. package/docs/api/popup.md +1 -1
  4. package/docs/api/theme.md +2 -2
  5. package/docs/chart.md +14 -0
  6. package/docs/editor.md +2 -0
  7. package/docs/installation.md +147 -15
  8. package/docs/introduction.md +37 -15
  9. package/docs/theming-built-in-themes.md +67 -0
  10. package/docs/theming-custom-colors.md +274 -0
  11. package/docs/theming-custom-themes.md +168 -0
  12. package/docs/theming.md +164 -248
  13. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  14. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  15. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  16. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  17. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  18. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
  19. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  20. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  21. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  22. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  23. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  24. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  25. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  26. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  27. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  28. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  29. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  30. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  31. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  32. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  33. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  34. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  35. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  37. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  38. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  39. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  40. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  41. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  42. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  49. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  50. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  51. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  52. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  53. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  54. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  55. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  58. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  59. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  60. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  61. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  62. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  63. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  65. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  66. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  67. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  68. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  70. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
  71. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  72. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  73. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  74. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  75. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  76. package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
  77. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  78. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  79. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  80. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  81. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  82. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  83. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  84. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  85. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  86. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  87. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  88. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  89. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  90. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  91. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  92. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  93. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  94. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  95. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  96. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  97. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  98. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  99. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  100. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  101. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  102. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  103. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  104. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  105. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  106. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  107. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  108. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  109. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  110. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  111. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  112. package/llms.txt +7 -3
  113. package/locales/pl-pl/package.json +4 -0
  114. package/locales/pl-pl/pl-pl.messages.json +536 -0
  115. package/package.json +66 -23
  116. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  117. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  118. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  119. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  120. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  121. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  122. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  123. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  124. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  125. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  126. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  127. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  128. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  129. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  130. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  131. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  132. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  133. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  134. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  135. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  136. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  137. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  138. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  139. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  140. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  141. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  142. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  143. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  144. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  145. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  146. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  147. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  148. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  149. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  150. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  151. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  152. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  153. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  154. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  155. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  156. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  157. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  158. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  159. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
  168. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  169. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  170. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  171. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  172. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  173. package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
  174. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  175. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  176. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  177. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  178. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  179. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  180. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  181. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  182. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  183. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  184. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  185. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  186. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  187. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  188. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  189. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  190. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  191. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  192. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  193. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  194. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  195. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  196. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  197. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  198. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  199. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  200. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  201. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  202. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  203. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  204. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  205. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  206. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  207. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  208. package/types/nanahoshi-mona-ui.d.ts +1 -2
  209. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  210. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  211. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  212. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  213. 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,1907 @@ 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 names = range(0, 7).select((i) => {
1120
+ const dt = gregorianDateTimeFromObject({
1121
+ year: 2024,
1122
+ month: 1,
1123
+ day: 1 + i
1124
+ }, locale);
1125
+ return {
1126
+ full: dt.toFormat("cccc"),
1127
+ narrow: dt.toFormat("ccccc"),
1128
+ short: dt.toFormat("ccc")
1129
+ };
1130
+ }).toArray();
1131
+ const useNarrow = names.some(({ full, short }) => short.length > 4 || short === full && short.length > 3);
1132
+ const days = names.map((name) => ({
1133
+ ...name,
1134
+ display: useNarrow ? name.narrow : name.short
1135
+ }));
1136
+ const startIndex = firstDayIso - 1;
1137
+ return [...days.slice(startIndex), ...days.slice(0, startIndex)];
1138
+ }, ...ngDevMode ? [{ debugName: "weekdays" }] : /* istanbul ignore next */ []);
1139
+ this.yearCellTemplate = contentChild(CalendarYearCellTemplateDirective, ...ngDevMode ? [{ debugName: "yearCellTemplate" }] : /* istanbul ignore next */ []);
1140
+ this.yearGridClass = computed(() => {
1141
+ return calendarYearViewGridThemeVariants();
1142
+ }, ...ngDevMode ? [{ debugName: "yearGridClass" }] : /* istanbul ignore next */ []);
1143
+ this.disabled = input(false, {
1144
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
1145
+ transform: booleanAttribute
1146
+ });
1147
+ this.disabledDates = input(...ngDevMode ? [void 0, { debugName: "disabledDates" }] : /* istanbul ignore next */ []);
1148
+ this.firstDay = input(null, ...ngDevMode ? [{ debugName: "firstDay" }] : /* istanbul ignore next */ []);
1149
+ this.focusOnMount = input(false, {
1150
+ ...ngDevMode ? { debugName: "focusOnMount" } : /* istanbul ignore next */ {},
1151
+ transform: booleanAttribute
1152
+ });
1153
+ this.invalid = input(false, {
1154
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
1155
+ transform: booleanAttribute
1156
+ });
1157
+ this.maxDate = input(...ngDevMode ? [void 0, { debugName: "maxDate" }] : /* istanbul ignore next */ []);
1158
+ this.minDate = input(...ngDevMode ? [void 0, { debugName: "minDate" }] : /* istanbul ignore next */ []);
1159
+ this.readonly = input(false, {
1160
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
1161
+ transform: booleanAttribute
1162
+ });
1163
+ this.required = input(false, {
1164
+ ...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
1165
+ transform: booleanAttribute
1166
+ });
1167
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
1168
+ this.selection = input("single", ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
1169
+ this.touch = output();
1170
+ this.touched = input(false, {
1171
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
1172
+ transform: booleanAttribute
1173
+ });
1174
+ this.userClass = input("", {
1175
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
1176
+ alias: "class"
1177
+ });
1178
+ this.value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1179
+ this.weekNumber = input(false, {
1180
+ ...ngDevMode ? { debugName: "weekNumber" } : /* istanbul ignore next */ {},
1181
+ transform: booleanAttribute
1182
+ });
1183
+ afterNextRender({ read: () => {
1184
+ this.setupKeyboardNavigation();
1185
+ if (this.focusOnMount()) this.focusActiveCell();
1186
+ } });
1187
+ effect(() => {
1188
+ const min = this.minDate();
1189
+ const max = this.maxDate();
1190
+ untracked(() => {
1191
+ const navigationDate = this.navigatedDate();
1192
+ if (compareDates(navigationDate, min, "<") && min) this.navigatedDate.set(min);
1193
+ else if (compareDates(navigationDate, max, ">") && max) this.navigatedDate.set(max);
1194
+ });
1195
+ });
1196
+ effect(() => {
1197
+ const v = this.value();
1198
+ untracked(() => {
1199
+ const lastDate = Array.isArray(v) ? lastOrDefault(v) : v;
1200
+ if (lastDate) this.navigatedDate.set(lastDate);
1201
+ });
1202
+ });
1203
+ toObservable(this.calendarView).pipe(skip(1)).subscribe(() => this.focusActiveCell());
1204
+ }
1205
+ formatInteger(value) {
1206
+ if (value == null) return "";
1207
+ return formatNumber(value, this.#i18n.localeId(), {
1208
+ maximumFractionDigits: 0,
1209
+ useGrouping: false
1210
+ });
1211
+ }
1212
+ getWeekNumber(date) {
1213
+ const dt = gregorianDateTime(date, this.#i18n.localeId());
1214
+ const daysToThursday = (4 - FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()] + 7) % 7;
1215
+ return dt.plus({ days: daysToThursday }).weekNumber;
1216
+ }
1217
+ onDayClick(date, event) {
1218
+ event.preventDefault();
1219
+ if (this.effectiveDisabled() || this.readonly()) return;
1220
+ const selection = this.selection();
1221
+ if (selection === "single") this.handleSingleSelection(date);
1222
+ else if (selection === "multiple") {
1223
+ if (event.ctrlKey || event.metaKey || event.shiftKey) this.handleMultipleSelection(date, event.shiftKey);
1224
+ else this.handleSingleSelection(date);
1225
+ } else if (selection === "range") {
1226
+ this.handleRangeSelection(date);
1227
+ this.navigatedDate.set(date);
1228
+ }
1229
+ this.focusActiveCell();
1230
+ this.commitUserSelection();
1231
+ }
1232
+ onDayPointerEnter(date) {
1233
+ if (this.effectiveDisabled() || this.readonly() || this.selection() !== "range" || this.pendingRangeStart() == null) return;
1234
+ this.rangePreviewDate.set(date);
1235
+ }
1236
+ onFocusOut(event) {
1237
+ if (this.#destroyRef.destroyed) return;
1238
+ const nextTarget = event.relatedTarget;
1239
+ if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) return;
1240
+ this.touch.emit();
1241
+ }
1242
+ onMonthClick(month) {
1243
+ this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ month }).toJSDate());
1244
+ this.calendarView.set("month");
1245
+ }
1246
+ onMonthGridPointerLeave() {
1247
+ this.rangePreviewDate.set(null);
1248
+ }
1249
+ onNavigationClick(direction) {
1250
+ this.rangePreviewDate.set(null);
1251
+ const date = DateTime.fromJSDate(this.navigatedDate());
1252
+ let unit;
1253
+ switch (this.calendarView()) {
1254
+ case "month":
1255
+ unit = { months: 1 };
1256
+ break;
1257
+ case "year":
1258
+ unit = { years: 1 };
1259
+ break;
1260
+ case "decade": unit = { years: 10 };
1261
+ }
1262
+ this.navigatedDate.set(direction === "prev" ? date.minus(unit).toJSDate() : date.plus(unit).toJSDate());
1263
+ }
1264
+ onTodayButtonClick() {
1265
+ this.refreshToday();
1266
+ if (this.effectiveDisabled() || this.readonly() || this.todayUnavailable()) return;
1267
+ const today = this.today();
1268
+ if (this.selection() === "range") {
1269
+ this.handleRangeSelection(today);
1270
+ this.navigatedDate.set(today);
1271
+ } else this.handleSingleSelection(today);
1272
+ this.calendarView.set("month");
1273
+ this.commitUserSelection();
1274
+ }
1275
+ onViewChangeClick(view) {
1276
+ this.calendarView.set(view);
1277
+ }
1278
+ onYearClick(year) {
1279
+ this.navigatedDate.set(DateTime.fromJSDate(this.navigatedDate()).set({ year }).toJSDate());
1280
+ this.calendarView.set("year");
1281
+ }
1282
+ refreshToday() {
1283
+ const today = startOfDay(/* @__PURE__ */ new Date());
1284
+ if (!compareDates(today, this.today(), "==")) this.today.set(today);
1285
+ }
1286
+ clearPendingRange() {
1287
+ this.pendingRangeStart.set(null);
1288
+ this.rangePreviewDate.set(null);
1289
+ }
1290
+ commitUserSelection() {
1291
+ if (this.selection() === "range" && this.pendingRangeStart() != null) return;
1292
+ this.value.set(this.#outputValue());
1293
+ }
1294
+ extendSelection(offset) {
1295
+ const currentDate = this.navigatedDate();
1296
+ const newDate = DateTime.fromJSDate(currentDate).plus({ days: offset }).toJSDate();
1297
+ if (this.isDateDisabled(newDate)) return;
1298
+ const currentSelection = this.selectedDates();
1299
+ const dateTime = DateTime.fromJSDate(newDate);
1300
+ if (!currentSelection.some((d) => DateTime.fromJSDate(d).hasSame(dateTime, "day"))) this.setCurrentDate([...currentSelection, newDate]);
1301
+ this.navigatedDate.set(newDate);
1302
+ }
1303
+ focusActiveCell() {
1304
+ rxTimeout(this.#destroyRef, () => {
1305
+ const calendarView = this.calendarView();
1306
+ const selector = calendarView === "year" ? "[monaYearMonth]" : calendarView === "decade" ? "[monaDecadeYear]" : "[monaMonthDay]";
1307
+ this.#hostElementRef.nativeElement.querySelector(`${selector}[tabindex="0"]`)?.focus();
1308
+ });
1309
+ }
1310
+ getDateArray(date) {
1311
+ if (date == null) return [];
1312
+ return Array.isArray(date) ? date : [date];
1313
+ }
1314
+ getDatesForMultipleSelection(date) {
1315
+ const lastSelectedDate = lastOrDefault(this.selectedDates()) ?? this.navigatedDate();
1316
+ const startDate = lastSelectedDate < date ? lastSelectedDate : date;
1317
+ const endDate = this.navigatedDate() > date ? this.navigatedDate() : date;
1318
+ const totalDays = calendarDaysBetween(DateTime.fromJSDate(startDate), DateTime.fromJSDate(endDate)) + 1;
1319
+ return range(0, totalDays).select((i) => DateTime.fromJSDate(startDate).plus({ days: i }).toJSDate()).toArray();
1320
+ }
1321
+ getInclusiveDateRange(date1, date2) {
1322
+ const dateTime1 = DateTime.fromJSDate(date1);
1323
+ const dateTime2 = DateTime.fromJSDate(date2);
1324
+ const startDate = dateTime1 <= dateTime2 ? dateTime1 : dateTime2;
1325
+ const totalDays = calendarDaysBetween(startDate, dateTime1 <= dateTime2 ? dateTime2 : dateTime1) + 1;
1326
+ return range(0, totalDays).select((i) => startDate.plus({ days: i }).toJSDate()).toArray();
1327
+ }
1328
+ handleKeydown(event) {
1329
+ if (this.effectiveDisabled()) return;
1330
+ const preventableEvent = new PreventableEvent("calendarKeydown", event);
1331
+ this.#calendarService?.keydown$.next(preventableEvent);
1332
+ if (preventableEvent.isDefaultPrevented()) return;
1333
+ if (event.target.closest("button")) return;
1334
+ const view = this.calendarView();
1335
+ const isCtrlOrCmd = event.ctrlKey || event.metaKey;
1336
+ const isShift = event.shiftKey;
1337
+ const selection = this.selection();
1338
+ if (!this.readonly() && selection === "multiple" && (isCtrlOrCmd || isShift)) {
1339
+ if (this.handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift)) {
1340
+ this.commitUserSelection();
1341
+ this.focusActiveCell();
1342
+ return;
1343
+ }
1344
+ }
1345
+ let shouldFocusCell = false;
1346
+ switch (event.key) {
1347
+ case "ArrowUp":
1348
+ event.preventDefault();
1349
+ if (isCtrlOrCmd) this.switchToUpperView();
1350
+ else this.navigateByWeeksOrRows(-1, view);
1351
+ shouldFocusCell = true;
1352
+ break;
1353
+ case "ArrowDown":
1354
+ event.preventDefault();
1355
+ if (isCtrlOrCmd) this.switchToLowerView();
1356
+ else this.navigateByWeeksOrRows(1, view);
1357
+ shouldFocusCell = true;
1358
+ break;
1359
+ case "ArrowLeft":
1360
+ event.preventDefault();
1361
+ if (isCtrlOrCmd) this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowLeft"));
1362
+ else this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowLeft"), view);
1363
+ shouldFocusCell = true;
1364
+ break;
1365
+ case "ArrowRight":
1366
+ event.preventDefault();
1367
+ if (isCtrlOrCmd) this.navigatePeriodKeyboard(this.horizontalPeriodDirection("ArrowRight"));
1368
+ else this.navigateByDaysOrCells(this.horizontalCellDelta("ArrowRight"), view);
1369
+ shouldFocusCell = true;
1370
+ break;
1371
+ case "Enter":
1372
+ case " ": {
1373
+ event.preventDefault();
1374
+ const previousView = this.calendarView();
1375
+ if (this.readonly() && previousView === "month") {
1376
+ shouldFocusCell = true;
1377
+ break;
1378
+ }
1379
+ if (isCtrlOrCmd && selection === "multiple") this.toggleFocusedDateInSelection();
1380
+ else if (isShift && selection === "multiple") this.selectRangeToFocused();
1381
+ else this.selectFocusedItem();
1382
+ if (previousView === "month" && this.calendarView() === "month") this.commitUserSelection();
1383
+ shouldFocusCell = true;
1384
+ break;
1385
+ }
1386
+ case "Home":
1387
+ event.preventDefault();
1388
+ this.navigateToStart(view);
1389
+ shouldFocusCell = true;
1390
+ break;
1391
+ case "End":
1392
+ event.preventDefault();
1393
+ this.navigateToEnd(view);
1394
+ shouldFocusCell = true;
1395
+ break;
1396
+ case "PageUp":
1397
+ event.preventDefault();
1398
+ this.navigateByPeriod(isShift && view === "month" ? -12 : -1, view);
1399
+ shouldFocusCell = true;
1400
+ break;
1401
+ case "PageDown":
1402
+ event.preventDefault();
1403
+ this.navigateByPeriod(isShift && view === "month" ? 12 : 1, view);
1404
+ shouldFocusCell = true;
1405
+ break;
1406
+ case "t":
1407
+ case "T":
1408
+ if (!isCtrlOrCmd && !isShift) {
1409
+ event.preventDefault();
1410
+ this.navigateToToday();
1411
+ shouldFocusCell = true;
1412
+ }
1413
+ break;
1414
+ case "Escape":
1415
+ event.preventDefault();
1416
+ return;
1417
+ }
1418
+ if (shouldFocusCell) this.focusActiveCell();
1419
+ }
1420
+ handleMultipleSelection(date, rangedSelection) {
1421
+ this.clearPendingRange();
1422
+ const value = this.selectedDates();
1423
+ if (value.length === 0) {
1424
+ this.setCurrentDate([date]);
1425
+ this.navigatedDate.set(date);
1426
+ return;
1427
+ }
1428
+ if (!rangedSelection) {
1429
+ const date1 = DateTime.fromJSDate(date);
1430
+ const valueList = this.getDateArray(value);
1431
+ const selectedDates = select(valueList, (e) => DateTime.fromJSDate(e));
1432
+ if (selectedDates.any((e) => e.hasSame(date1, "day"))) {
1433
+ const newDates = selectedDates.where((e) => !e.hasSame(date1, "day")).select((e) => e.toJSDate()).toArray();
1434
+ this.setCurrentDate(newDates);
1435
+ } else this.setCurrentDate([...valueList, date]);
1436
+ this.navigatedDate.set(date);
1437
+ } else {
1438
+ const selectedDates = this.getDatesForMultipleSelection(date);
1439
+ this.setCurrentDate(selectedDates);
1440
+ }
1441
+ }
1442
+ handleMultipleSelectionKeyboard(event, isCtrlOrCmd, isShift) {
1443
+ if (this.calendarView() !== "month") return false;
1444
+ if (isShift && !isCtrlOrCmd) switch (event.key) {
1445
+ case "ArrowLeft":
1446
+ event.preventDefault();
1447
+ this.extendSelection(this.horizontalCellDelta("ArrowLeft"));
1448
+ return true;
1449
+ case "ArrowRight":
1450
+ event.preventDefault();
1451
+ this.extendSelection(this.horizontalCellDelta("ArrowRight"));
1452
+ return true;
1453
+ case "ArrowUp":
1454
+ event.preventDefault();
1455
+ this.extendSelection(-7);
1456
+ return true;
1457
+ case "ArrowDown":
1458
+ event.preventDefault();
1459
+ this.extendSelection(7);
1460
+ return true;
1461
+ }
1462
+ return false;
1463
+ }
1464
+ handleRangeSelection(date) {
1465
+ const pendingRangeStart = this.pendingRangeStart();
1466
+ if (pendingRangeStart == null) {
1467
+ this.pendingRangeStart.set(date);
1468
+ this.rangePreviewDate.set(null);
1469
+ this.setCurrentDate([date]);
1470
+ return;
1471
+ }
1472
+ this.setCurrentDate(this.getInclusiveDateRange(pendingRangeStart, date));
1473
+ this.pendingRangeStart.set(null);
1474
+ this.rangePreviewDate.set(null);
1475
+ }
1476
+ handleSingleSelection(date) {
1477
+ this.clearPendingRange();
1478
+ const value = this.selectedDates();
1479
+ if (value.length > 0) {
1480
+ const date1 = DateTime.fromJSDate(date);
1481
+ const valueItem = lastOrDefault(value) ?? DateTime.now().toJSDate();
1482
+ const newDate = DateTime.fromJSDate(valueItem).set({
1483
+ day: date1.day,
1484
+ month: date1.month,
1485
+ year: date1.year
1486
+ }).toJSDate();
1487
+ this.navigatedDate.set(newDate);
1488
+ this.setCurrentDate(newDate);
1489
+ } else {
1490
+ this.navigatedDate.set(date);
1491
+ this.setCurrentDate(date);
1492
+ }
1493
+ }
1494
+ horizontalCellDelta(key) {
1495
+ const isRtl = this.#direction() === "rtl";
1496
+ if (key === "ArrowLeft") return isRtl ? 1 : -1;
1497
+ return isRtl ? -1 : 1;
1498
+ }
1499
+ horizontalPeriodDirection(key) {
1500
+ const isRtl = this.#direction() === "rtl";
1501
+ if (key === "ArrowLeft") return isRtl ? "next" : "prev";
1502
+ return isRtl ? "prev" : "next";
1503
+ }
1504
+ isDateDisabled(date) {
1505
+ return this.isDayUnavailable()(date);
1506
+ }
1507
+ isEmptyValue() {
1508
+ const value = this.value();
1509
+ return value == null || Array.isArray(value) && value.length === 0;
1510
+ }
1511
+ isOutOfRange(date) {
1512
+ return compareDates(date, this.maxDate(), ">") || compareDates(date, this.minDate(), "<");
1513
+ }
1514
+ navigateByDaysOrCells(offset, view) {
1515
+ const currentDate = this.navigatedDate();
1516
+ const dateTime = DateTime.fromJSDate(currentDate);
1517
+ let newDate;
1518
+ switch (view) {
1519
+ case "month":
1520
+ newDate = dateTime.plus({ days: offset }).toJSDate();
1521
+ break;
1522
+ case "year":
1523
+ newDate = dateTime.plus({ months: offset }).toJSDate();
1524
+ break;
1525
+ case "decade": newDate = dateTime.plus({ years: offset }).toJSDate();
1526
+ }
1527
+ if (view === "month" && this.isOutOfRange(newDate)) return;
1528
+ this.rangePreviewDate.set(null);
1529
+ this.navigatedDate.set(newDate);
1530
+ }
1531
+ navigateByPeriod(offset, view) {
1532
+ const currentDate = this.navigatedDate();
1533
+ const dateTime = DateTime.fromJSDate(currentDate);
1534
+ let newDate;
1535
+ switch (view) {
1536
+ case "month":
1537
+ newDate = dateTime.plus({ months: offset }).toJSDate();
1538
+ break;
1539
+ case "year":
1540
+ newDate = dateTime.plus({ years: offset }).toJSDate();
1541
+ break;
1542
+ case "decade": newDate = dateTime.plus({ years: offset * 10 }).toJSDate();
1543
+ }
1544
+ if (view === "month" && this.isDateDisabled(newDate)) {
1545
+ const direction = offset > 0 ? 1 : -1;
1546
+ const maxAttempts = 31;
1547
+ for (let i = 1; i <= maxAttempts; i++) {
1548
+ const adjustedDate = DateTime.fromJSDate(newDate).plus({ days: direction * i }).toJSDate();
1549
+ if (!this.isDateDisabled(adjustedDate)) {
1550
+ newDate = adjustedDate;
1551
+ break;
1552
+ }
1553
+ }
1554
+ }
1555
+ this.rangePreviewDate.set(null);
1556
+ this.navigatedDate.set(newDate);
1557
+ }
1558
+ navigateByWeeksOrRows(offset, view) {
1559
+ const currentDate = this.navigatedDate();
1560
+ const dateTime = DateTime.fromJSDate(currentDate);
1561
+ let newDate;
1562
+ switch (view) {
1563
+ case "month":
1564
+ newDate = dateTime.plus({ weeks: offset }).toJSDate();
1565
+ break;
1566
+ case "year":
1567
+ newDate = dateTime.plus({ months: offset * 3 }).toJSDate();
1568
+ break;
1569
+ case "decade": newDate = dateTime.plus({ years: offset * 4 }).toJSDate();
1570
+ }
1571
+ if (view === "month" && this.isOutOfRange(newDate)) return;
1572
+ this.rangePreviewDate.set(null);
1573
+ this.navigatedDate.set(newDate);
1574
+ }
1575
+ navigatePeriodKeyboard(direction) {
1576
+ this.rangePreviewDate.set(null);
1577
+ this.onNavigationClick(direction);
1578
+ }
1579
+ navigateToEnd(view) {
1580
+ const currentDate = this.navigatedDate();
1581
+ const dateTime = DateTime.fromJSDate(currentDate);
1582
+ let newDate;
1583
+ switch (view) {
1584
+ case "month": {
1585
+ const daysToAdd = ((FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()] + 5) % 7 + 1 - dateTime.weekday + 7) % 7;
1586
+ newDate = dateTime.plus({ days: daysToAdd }).toJSDate();
1587
+ if (this.isDateDisabled(newDate)) for (let i = 1; i <= 6; i++) {
1588
+ const testDate = DateTime.fromJSDate(newDate).minus({ days: i }).toJSDate();
1589
+ if (!this.isDateDisabled(testDate)) {
1590
+ newDate = testDate;
1591
+ break;
1592
+ }
1593
+ }
1594
+ break;
1595
+ }
1596
+ case "year":
1597
+ newDate = dateTime.set({ month: 12 }).toJSDate();
1598
+ break;
1599
+ case "decade": {
1600
+ const yearEnd = this.decadeEnd();
1601
+ newDate = dateTime.set({ year: yearEnd }).toJSDate();
1602
+ break;
1603
+ }
1604
+ }
1605
+ this.rangePreviewDate.set(null);
1606
+ this.navigatedDate.set(newDate);
1607
+ }
1608
+ navigateToStart(view) {
1609
+ const currentDate = this.navigatedDate();
1610
+ const dateTime = DateTime.fromJSDate(currentDate);
1611
+ let newDate;
1612
+ switch (view) {
1613
+ case "month": {
1614
+ const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
1615
+ const daysToSubtract = (dateTime.weekday - firstDayIso + 7) % 7;
1616
+ newDate = dateTime.minus({ days: daysToSubtract }).toJSDate();
1617
+ if (this.isDateDisabled(newDate)) for (let i = 1; i <= 6; i++) {
1618
+ const testDate = DateTime.fromJSDate(newDate).plus({ days: i }).toJSDate();
1619
+ if (!this.isDateDisabled(testDate)) {
1620
+ newDate = testDate;
1621
+ break;
1622
+ }
1623
+ }
1624
+ break;
1625
+ }
1626
+ case "year":
1627
+ newDate = dateTime.set({ month: 1 }).toJSDate();
1628
+ break;
1629
+ case "decade": {
1630
+ const yearStart = this.decadeStart();
1631
+ newDate = dateTime.set({ year: yearStart }).toJSDate();
1632
+ break;
1633
+ }
1634
+ }
1635
+ this.rangePreviewDate.set(null);
1636
+ this.navigatedDate.set(newDate);
1637
+ }
1638
+ navigateToToday() {
1639
+ this.refreshToday();
1640
+ const today = this.today();
1641
+ if (this.isDateDisabled(today)) return;
1642
+ this.rangePreviewDate.set(null);
1643
+ this.navigatedDate.set(today);
1644
+ this.calendarView.set("month");
1645
+ }
1646
+ selectFocusedItem() {
1647
+ const view = this.calendarView();
1648
+ const currentDate = this.navigatedDate();
1649
+ switch (view) {
1650
+ case "month":
1651
+ if (!this.isDateDisabled(currentDate)) {
1652
+ const selection = this.selection();
1653
+ if (selection === "single") this.handleSingleSelection(currentDate);
1654
+ else if (selection === "multiple") this.handleSingleSelection(currentDate);
1655
+ else if (selection === "range") this.handleRangeSelection(currentDate);
1656
+ }
1657
+ break;
1658
+ case "year":
1659
+ this.calendarView.set("month");
1660
+ break;
1661
+ case "decade": this.calendarView.set("year");
1662
+ }
1663
+ }
1664
+ selectRangeToFocused() {
1665
+ const focusedDate = this.navigatedDate();
1666
+ if (this.isDateDisabled(focusedDate)) return;
1667
+ const selectedDates = this.getDatesForMultipleSelection(focusedDate);
1668
+ this.setCurrentDate(selectedDates);
1669
+ }
1670
+ setCurrentDate(date) {
1671
+ this.selectedDates.set(this.getDateArray(date));
1672
+ }
1673
+ setupKeyboardNavigation() {
1674
+ fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.handleKeydown(event));
1675
+ }
1676
+ switchToLowerView() {
1677
+ switch (this.calendarView()) {
1678
+ case "decade":
1679
+ this.calendarView.set("year");
1680
+ break;
1681
+ case "year": this.calendarView.set("month");
1682
+ }
1683
+ }
1684
+ switchToUpperView() {
1685
+ switch (this.calendarView()) {
1686
+ case "month":
1687
+ this.calendarView.set("year");
1688
+ break;
1689
+ case "year": this.calendarView.set("decade");
1690
+ }
1691
+ }
1692
+ toggleFocusedDateInSelection() {
1693
+ const focusedDate = this.navigatedDate();
1694
+ if (this.isDateDisabled(focusedDate)) return;
1695
+ const currentSelection = this.selectedDates();
1696
+ const dateTime = DateTime.fromJSDate(focusedDate);
1697
+ if (currentSelection.some((d) => DateTime.fromJSDate(d).hasSame(dateTime, "day"))) {
1698
+ const newSelection = currentSelection.filter((d) => !DateTime.fromJSDate(d).hasSame(dateTime, "day"));
1699
+ this.setCurrentDate(newSelection);
1700
+ } else this.setCurrentDate([...currentSelection, focusedDate]);
1701
+ }
1702
+ static {
1703
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1704
+ minVersion: "12.0.0",
1705
+ version: "22.2.6",
1706
+ ngImport: i0,
1707
+ type: CalendarComponent,
1708
+ deps: [],
1709
+ target: i0.ɵɵFactoryTarget.Component
1710
+ });
1711
+ }
1712
+ static {
1713
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1714
+ minVersion: "17.0.0",
1715
+ version: "22.2.6",
1716
+ type: CalendarComponent,
1717
+ isStandalone: true,
1718
+ selector: "mona-calendar",
1719
+ inputs: {
1720
+ disabled: {
1721
+ classPropertyName: "disabled",
1722
+ publicName: "disabled",
1723
+ isSignal: true,
1724
+ isRequired: false,
1725
+ transformFunction: null
1726
+ },
1727
+ disabledDates: {
1728
+ classPropertyName: "disabledDates",
1729
+ publicName: "disabledDates",
1730
+ isSignal: true,
1731
+ isRequired: false,
1732
+ transformFunction: null
1733
+ },
1734
+ firstDay: {
1735
+ classPropertyName: "firstDay",
1736
+ publicName: "firstDay",
1737
+ isSignal: true,
1738
+ isRequired: false,
1739
+ transformFunction: null
1740
+ },
1741
+ focusOnMount: {
1742
+ classPropertyName: "focusOnMount",
1743
+ publicName: "focusOnMount",
1744
+ isSignal: true,
1745
+ isRequired: false,
1746
+ transformFunction: null
1747
+ },
1748
+ invalid: {
1749
+ classPropertyName: "invalid",
1750
+ publicName: "invalid",
1751
+ isSignal: true,
1752
+ isRequired: false,
1753
+ transformFunction: null
1754
+ },
1755
+ maxDate: {
1756
+ classPropertyName: "maxDate",
1757
+ publicName: "maxDate",
1758
+ isSignal: true,
1759
+ isRequired: false,
1760
+ transformFunction: null
1761
+ },
1762
+ minDate: {
1763
+ classPropertyName: "minDate",
1764
+ publicName: "minDate",
1765
+ isSignal: true,
1766
+ isRequired: false,
1767
+ transformFunction: null
1768
+ },
1769
+ readonly: {
1770
+ classPropertyName: "readonly",
1771
+ publicName: "readonly",
1772
+ isSignal: true,
1773
+ isRequired: false,
1774
+ transformFunction: null
1775
+ },
1776
+ required: {
1777
+ classPropertyName: "required",
1778
+ publicName: "required",
1779
+ isSignal: true,
1780
+ isRequired: false,
1781
+ transformFunction: null
1782
+ },
1783
+ rounded: {
1784
+ classPropertyName: "rounded",
1785
+ publicName: "rounded",
1786
+ isSignal: true,
1787
+ isRequired: false,
1788
+ transformFunction: null
1789
+ },
1790
+ selection: {
1791
+ classPropertyName: "selection",
1792
+ publicName: "selection",
1793
+ isSignal: true,
1794
+ isRequired: false,
1795
+ transformFunction: null
1796
+ },
1797
+ touched: {
1798
+ classPropertyName: "touched",
1799
+ publicName: "touched",
1800
+ isSignal: true,
1801
+ isRequired: false,
1802
+ transformFunction: null
1803
+ },
1804
+ userClass: {
1805
+ classPropertyName: "userClass",
1806
+ publicName: "class",
1807
+ isSignal: true,
1808
+ isRequired: false,
1809
+ transformFunction: null
1810
+ },
1811
+ value: {
1812
+ classPropertyName: "value",
1813
+ publicName: "value",
1814
+ isSignal: true,
1815
+ isRequired: false,
1816
+ transformFunction: null
1817
+ },
1818
+ weekNumber: {
1819
+ classPropertyName: "weekNumber",
1820
+ publicName: "weekNumber",
1821
+ isSignal: true,
1822
+ isRequired: false,
1823
+ transformFunction: null
1824
+ }
1825
+ },
1826
+ outputs: {
1827
+ touch: "touch",
1828
+ value: "valueChange"
1829
+ },
1830
+ host: {
1831
+ listeners: {
1832
+ "focusin": "refreshToday()",
1833
+ "focusout": "onFocusOut($event)"
1834
+ },
1835
+ properties: {
1836
+ "attr.aria-label": "null",
1837
+ "attr.data-disabled": "effectiveDisabled() || null",
1838
+ "attr.data-invalid": "invalidState() || null",
1839
+ "attr.data-required": "required() || null",
1840
+ "class": "baseClass()"
1841
+ }
1842
+ },
1843
+ queries: [
1844
+ {
1845
+ propertyName: "decadeCellTemplate",
1846
+ first: true,
1847
+ predicate: CalendarDecadeCellTemplateDirective,
1848
+ descendants: true,
1849
+ isSignal: true
1850
+ },
1851
+ {
1852
+ propertyName: "monthCellTemplate",
1853
+ first: true,
1854
+ predicate: CalendarMonthCellTemplateDirective,
1855
+ descendants: true,
1856
+ isSignal: true
1857
+ },
1858
+ {
1859
+ propertyName: "yearCellTemplate",
1860
+ first: true,
1861
+ predicate: CalendarYearCellTemplateDirective,
1862
+ descendants: true,
1863
+ isSignal: true
1864
+ }
1865
+ ],
1866
+ ngImport: i0,
1867
+ 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",
1868
+ dependencies: [
1869
+ {
1870
+ kind: "directive",
1871
+ type: ButtonDirective,
1872
+ selector: "button[monaButton]",
1873
+ inputs: [
1874
+ "aria-haspopup",
1875
+ "disabled",
1876
+ "iconOnly",
1877
+ "loading",
1878
+ "look",
1879
+ "rounded",
1880
+ "selected",
1881
+ "size",
1882
+ "tabindex",
1883
+ "toggleable",
1884
+ "type",
1885
+ "class",
1886
+ "value"
1887
+ ],
1888
+ outputs: ["lookChange", "selectedChange"]
1889
+ },
1890
+ {
1891
+ kind: "directive",
1892
+ type: MonthDayDirective,
1893
+ selector: "[monaMonthDay]",
1894
+ inputs: [
1895
+ "disabled",
1896
+ "entry",
1897
+ "isDayUnavailable",
1898
+ "monthBounds",
1899
+ "navigatedDate",
1900
+ "rangePreviewKeys",
1901
+ "rounded",
1902
+ "selectedKeys",
1903
+ "today"
1904
+ ],
1905
+ outputs: ["dayPointerEnter", "daySelect"]
1906
+ },
1907
+ {
1908
+ kind: "directive",
1909
+ type: DecadeYearDirective,
1910
+ selector: "[monaDecadeYear]",
1911
+ inputs: [
1912
+ "disabled",
1913
+ "navigatedDate",
1914
+ "rounded",
1915
+ "selectedDate",
1916
+ "year"
1917
+ ]
1918
+ },
1919
+ {
1920
+ kind: "directive",
1921
+ type: YearMonthDirective,
1922
+ selector: "[monaYearMonth]",
1923
+ inputs: [
1924
+ "disabled",
1925
+ "month",
1926
+ "navigatedDate",
1927
+ "rounded",
1928
+ "selectedDate"
1929
+ ]
1930
+ },
1931
+ {
1932
+ kind: "directive",
1933
+ type: NgTemplateOutlet,
1934
+ selector: "[ngTemplateOutlet]",
1935
+ inputs: [
1936
+ "ngTemplateOutletContext",
1937
+ "ngTemplateOutlet",
1938
+ "ngTemplateOutletInjector"
1939
+ ]
1940
+ },
1941
+ {
1942
+ kind: "component",
1943
+ type: LucideChevronLeft,
1944
+ selector: "svg[lucideChevronLeft]"
1945
+ },
1946
+ {
1947
+ kind: "component",
1948
+ type: LucideChevronRight,
1949
+ selector: "svg[lucideChevronRight]"
1950
+ },
1951
+ {
1952
+ kind: "pipe",
1953
+ type: TakeFirstPipe,
1954
+ name: "monaTakeFirst"
1955
+ }
1956
+ ]
1957
+ });
1958
+ }
1959
+ };
1960
+ i0.ɵɵngDeclareClassMetadata({
1961
+ minVersion: "12.0.0",
1962
+ version: "22.2.6",
1963
+ ngImport: i0,
1964
+ type: CalendarComponent,
1965
+ decorators: [{
1966
+ type: Component,
1967
+ args: [{
1968
+ selector: "mona-calendar",
1969
+ imports: [
1970
+ ButtonDirective,
1971
+ MonthDayDirective,
1972
+ DecadeYearDirective,
1973
+ YearMonthDirective,
1974
+ NgTemplateOutlet,
1975
+ TakeFirstPipe,
1976
+ LucideChevronLeft,
1977
+ LucideChevronRight
1978
+ ],
1979
+ host: {
1980
+ "[attr.aria-label]": "null",
1981
+ "[attr.data-disabled]": "effectiveDisabled() || null",
1982
+ "[attr.data-invalid]": "invalidState() || null",
1983
+ "[attr.data-required]": "required() || null",
1984
+ "[class]": "baseClass()",
1985
+ "(focusin)": "refreshToday()",
1986
+ "(focusout)": "onFocusOut($event)"
1987
+ },
1988
+ 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"
1989
+ }]
1990
+ }],
1991
+ ctorParameters: () => [],
1992
+ propDecorators: {
1993
+ decadeCellTemplate: [{
1994
+ type: i0.ContentChild,
1995
+ args: [i0.forwardRef(() => CalendarDecadeCellTemplateDirective), { isSignal: true }]
1996
+ }],
1997
+ monthCellTemplate: [{
1998
+ type: i0.ContentChild,
1999
+ args: [i0.forwardRef(() => CalendarMonthCellTemplateDirective), { isSignal: true }]
2000
+ }],
2001
+ yearCellTemplate: [{
2002
+ type: i0.ContentChild,
2003
+ args: [i0.forwardRef(() => CalendarYearCellTemplateDirective), { isSignal: true }]
2004
+ }],
2005
+ disabled: [{
2006
+ type: i0.Input,
2007
+ args: [{
2008
+ isSignal: true,
2009
+ alias: "disabled",
2010
+ required: false
2011
+ }]
2012
+ }],
2013
+ disabledDates: [{
2014
+ type: i0.Input,
2015
+ args: [{
2016
+ isSignal: true,
2017
+ alias: "disabledDates",
2018
+ required: false
2019
+ }]
2020
+ }],
2021
+ firstDay: [{
2022
+ type: i0.Input,
2023
+ args: [{
2024
+ isSignal: true,
2025
+ alias: "firstDay",
2026
+ required: false
2027
+ }]
2028
+ }],
2029
+ focusOnMount: [{
2030
+ type: i0.Input,
2031
+ args: [{
2032
+ isSignal: true,
2033
+ alias: "focusOnMount",
2034
+ required: false
2035
+ }]
2036
+ }],
2037
+ invalid: [{
2038
+ type: i0.Input,
2039
+ args: [{
2040
+ isSignal: true,
2041
+ alias: "invalid",
2042
+ required: false
2043
+ }]
2044
+ }],
2045
+ maxDate: [{
2046
+ type: i0.Input,
2047
+ args: [{
2048
+ isSignal: true,
2049
+ alias: "maxDate",
2050
+ required: false
2051
+ }]
2052
+ }],
2053
+ minDate: [{
2054
+ type: i0.Input,
2055
+ args: [{
2056
+ isSignal: true,
2057
+ alias: "minDate",
2058
+ required: false
2059
+ }]
2060
+ }],
2061
+ readonly: [{
2062
+ type: i0.Input,
2063
+ args: [{
2064
+ isSignal: true,
2065
+ alias: "readonly",
2066
+ required: false
2067
+ }]
2068
+ }],
2069
+ required: [{
2070
+ type: i0.Input,
2071
+ args: [{
2072
+ isSignal: true,
2073
+ alias: "required",
2074
+ required: false
2075
+ }]
2076
+ }],
2077
+ rounded: [{
2078
+ type: i0.Input,
2079
+ args: [{
2080
+ isSignal: true,
2081
+ alias: "rounded",
2082
+ required: false
2083
+ }]
2084
+ }],
2085
+ selection: [{
2086
+ type: i0.Input,
2087
+ args: [{
2088
+ isSignal: true,
2089
+ alias: "selection",
2090
+ required: false
2091
+ }]
2092
+ }],
2093
+ touch: [{
2094
+ type: i0.Output,
2095
+ args: ["touch"]
2096
+ }],
2097
+ touched: [{
2098
+ type: i0.Input,
2099
+ args: [{
2100
+ isSignal: true,
2101
+ alias: "touched",
2102
+ required: false
2103
+ }]
2104
+ }],
2105
+ userClass: [{
2106
+ type: i0.Input,
2107
+ args: [{
2108
+ isSignal: true,
2109
+ alias: "class",
2110
+ required: false
2111
+ }]
2112
+ }],
2113
+ value: [{
2114
+ type: i0.Input,
2115
+ args: [{
2116
+ isSignal: true,
2117
+ alias: "value",
2118
+ required: false
2119
+ }]
2120
+ }, {
2121
+ type: i0.Output,
2122
+ args: ["valueChange"]
2123
+ }],
2124
+ weekNumber: [{
2125
+ type: i0.Input,
2126
+ args: [{
2127
+ isSignal: true,
2128
+ alias: "weekNumber",
2129
+ required: false
2130
+ }]
2131
+ }]
2132
+ }
2133
+ });
1637
2134
  export { CALENDAR_DEFAULT_MESSAGES, CalendarComponent, CalendarDecadeCellTemplateDirective, CalendarMonthCellTemplateDirective, CalendarYearCellTemplateDirective };
1638
- //# sourceMappingURL=nanahoshi-mona-ui-calendar.mjs.map
2135
+
2136
+ //# sourceMappingURL=nanahoshi-mona-ui-calendar.mjs.map