@mortenbrudvik/waveui 0.9.0 → 0.11.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 (264) hide show
  1. package/README.md +758 -152
  2. package/dist/components/button/Toolbar.cjs +1 -1
  3. package/dist/components/button/Toolbar.cjs.map +1 -1
  4. package/dist/components/button/Toolbar.mjs +25 -30
  5. package/dist/components/button/Toolbar.mjs.map +1 -1
  6. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  7. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  8. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  9. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  10. package/dist/components/data-display/Avatar.cjs +1 -1
  11. package/dist/components/data-display/Avatar.cjs.map +1 -1
  12. package/dist/components/data-display/Avatar.context.cjs +2 -0
  13. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  14. package/dist/components/data-display/Avatar.context.mjs +9 -0
  15. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  16. package/dist/components/data-display/Avatar.mjs +66 -61
  17. package/dist/components/data-display/Avatar.mjs.map +1 -1
  18. package/dist/components/data-display/InteractionTag.cjs +2 -0
  19. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  20. package/dist/components/data-display/InteractionTag.mjs +234 -0
  21. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  22. package/dist/components/data-display/Tag.cjs +1 -1
  23. package/dist/components/data-display/Tag.cjs.map +1 -1
  24. package/dist/components/data-display/Tag.mjs +222 -90
  25. package/dist/components/data-display/Tag.mjs.map +1 -1
  26. package/dist/components/data-display/TagGroup.cjs +2 -0
  27. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  28. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  29. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  30. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  31. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  32. package/dist/components/data-display/TagGroup.mjs +149 -0
  33. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  34. package/dist/components/data-display/tagStyles.cjs +2 -0
  35. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  36. package/dist/components/data-display/tagStyles.mjs +108 -0
  37. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  38. package/dist/components/feedback/Toaster.cjs +1 -1
  39. package/dist/components/feedback/Toaster.cjs.map +1 -1
  40. package/dist/components/feedback/Toaster.mjs +213 -181
  41. package/dist/components/feedback/Toaster.mjs.map +1 -1
  42. package/dist/components/input/Calendar.cjs +2 -0
  43. package/dist/components/input/Calendar.cjs.map +1 -0
  44. package/dist/components/input/Calendar.mjs +352 -0
  45. package/dist/components/input/Calendar.mjs.map +1 -0
  46. package/dist/components/input/Calendar.views.cjs +2 -0
  47. package/dist/components/input/Calendar.views.cjs.map +1 -0
  48. package/dist/components/input/Calendar.views.mjs +194 -0
  49. package/dist/components/input/Calendar.views.mjs.map +1 -0
  50. package/dist/components/input/ColorArea.cjs +1 -1
  51. package/dist/components/input/ColorArea.cjs.map +1 -1
  52. package/dist/components/input/ColorArea.mjs +18 -18
  53. package/dist/components/input/ColorArea.mjs.map +1 -1
  54. package/dist/components/input/Combobox.cjs +1 -1
  55. package/dist/components/input/Combobox.cjs.map +1 -1
  56. package/dist/components/input/Combobox.expand.cjs +1 -1
  57. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  58. package/dist/components/input/Combobox.expand.mjs +7 -7
  59. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  60. package/dist/components/input/Combobox.mjs +232 -156
  61. package/dist/components/input/Combobox.mjs.map +1 -1
  62. package/dist/components/input/Combobox.text.cjs +2 -0
  63. package/dist/components/input/Combobox.text.cjs.map +1 -0
  64. package/dist/components/input/Combobox.text.mjs +24 -0
  65. package/dist/components/input/Combobox.text.mjs.map +1 -0
  66. package/dist/components/input/DatePicker.cjs +1 -1
  67. package/dist/components/input/DatePicker.cjs.map +1 -1
  68. package/dist/components/input/DatePicker.mjs +203 -288
  69. package/dist/components/input/DatePicker.mjs.map +1 -1
  70. package/dist/components/input/Dropdown.cjs +1 -1
  71. package/dist/components/input/Dropdown.cjs.map +1 -1
  72. package/dist/components/input/Dropdown.mjs +135 -109
  73. package/dist/components/input/Dropdown.mjs.map +1 -1
  74. package/dist/components/input/Listbox.cjs +2 -0
  75. package/dist/components/input/Listbox.cjs.map +1 -0
  76. package/dist/components/input/Listbox.mjs +134 -0
  77. package/dist/components/input/Listbox.mjs.map +1 -0
  78. package/dist/components/input/Option.cjs +1 -1
  79. package/dist/components/input/Option.cjs.map +1 -1
  80. package/dist/components/input/Option.mjs +163 -97
  81. package/dist/components/input/Option.mjs.map +1 -1
  82. package/dist/components/input/SwatchPicker.cjs +1 -1
  83. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  84. package/dist/components/input/SwatchPicker.context.cjs +2 -0
  85. package/dist/components/input/SwatchPicker.context.cjs.map +1 -0
  86. package/dist/components/input/SwatchPicker.context.mjs +35 -0
  87. package/dist/components/input/SwatchPicker.context.mjs.map +1 -0
  88. package/dist/components/input/SwatchPicker.mjs +131 -103
  89. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  90. package/dist/components/input/SwatchPicker.swatches.cjs +2 -0
  91. package/dist/components/input/SwatchPicker.swatches.cjs.map +1 -0
  92. package/dist/components/input/SwatchPicker.swatches.mjs +207 -0
  93. package/dist/components/input/SwatchPicker.swatches.mjs.map +1 -0
  94. package/dist/components/input/TagPicker.cjs +1 -1
  95. package/dist/components/input/TagPicker.cjs.map +1 -1
  96. package/dist/components/input/TagPicker.context.cjs +2 -0
  97. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  98. package/dist/components/input/TagPicker.context.mjs +20 -0
  99. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  100. package/dist/components/input/TagPicker.create.cjs +2 -0
  101. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  102. package/dist/components/input/TagPicker.create.mjs +24 -0
  103. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  104. package/dist/components/input/TagPicker.mjs +13 -274
  105. package/dist/components/input/TagPicker.mjs.map +1 -1
  106. package/dist/components/input/TagPicker.option.cjs +2 -0
  107. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  108. package/dist/components/input/TagPicker.option.mjs +45 -0
  109. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  110. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  111. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  112. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  113. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  114. package/dist/components/input/TagPicker.parts.cjs +2 -0
  115. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  116. package/dist/components/input/TagPicker.parts.mjs +425 -0
  117. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  118. package/dist/components/input/TagPicker.root.cjs +2 -0
  119. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  120. package/dist/components/input/TagPicker.root.mjs +416 -0
  121. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  122. package/dist/components/input/TimePicker.cjs +1 -1
  123. package/dist/components/input/TimePicker.cjs.map +1 -1
  124. package/dist/components/input/TimePicker.mjs +77 -77
  125. package/dist/components/input/TimePicker.mjs.map +1 -1
  126. package/dist/components/input/dateUtils.cjs +1 -1
  127. package/dist/components/input/dateUtils.cjs.map +1 -1
  128. package/dist/components/input/dateUtils.mjs +114 -96
  129. package/dist/components/input/dateUtils.mjs.map +1 -1
  130. package/dist/components/input/pickerLabels.cjs +2 -0
  131. package/dist/components/input/pickerLabels.cjs.map +1 -0
  132. package/dist/components/input/pickerLabels.mjs +16 -0
  133. package/dist/components/input/pickerLabels.mjs.map +1 -0
  134. package/dist/components/input/pickerValues.cjs +2 -0
  135. package/dist/components/input/pickerValues.cjs.map +1 -0
  136. package/dist/components/input/pickerValues.mjs +24 -0
  137. package/dist/components/input/pickerValues.mjs.map +1 -0
  138. package/dist/components/layout/Accordion.cjs.map +1 -1
  139. package/dist/components/layout/Accordion.mjs.map +1 -1
  140. package/dist/components/navigation/Hamburger.cjs +2 -0
  141. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  142. package/dist/components/navigation/Hamburger.mjs +54 -0
  143. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  144. package/dist/components/navigation/Nav.cjs +1 -1
  145. package/dist/components/navigation/Nav.cjs.map +1 -1
  146. package/dist/components/navigation/Nav.context.cjs +2 -0
  147. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  148. package/dist/components/navigation/Nav.context.mjs +137 -0
  149. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  150. package/dist/components/navigation/Nav.mjs +151 -258
  151. package/dist/components/navigation/Nav.mjs.map +1 -1
  152. package/dist/components/navigation/Nav.parts.cjs +2 -0
  153. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  154. package/dist/components/navigation/Nav.parts.mjs +77 -0
  155. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  156. package/dist/components/navigation/Nav.root.cjs +2 -0
  157. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  158. package/dist/components/navigation/Nav.root.mjs +78 -0
  159. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  160. package/dist/components/navigation/NavDrawer.cjs +2 -0
  161. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  162. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  163. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  164. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  165. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  166. package/dist/components/navigation/NavDrawer.mjs +179 -0
  167. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  168. package/dist/components/overlays/Dialog.cjs +1 -1
  169. package/dist/components/overlays/Dialog.cjs.map +1 -1
  170. package/dist/components/overlays/Dialog.mjs +190 -125
  171. package/dist/components/overlays/Dialog.mjs.map +1 -1
  172. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  173. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  174. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  175. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  176. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  177. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  178. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  179. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  180. package/dist/components/overlays/Drawer.cjs +1 -1
  181. package/dist/components/overlays/Drawer.cjs.map +1 -1
  182. package/dist/components/overlays/Drawer.context.cjs +2 -0
  183. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  184. package/dist/components/overlays/Drawer.context.mjs +29 -0
  185. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  186. package/dist/components/overlays/Drawer.mjs +12 -187
  187. package/dist/components/overlays/Drawer.mjs.map +1 -1
  188. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  189. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  190. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  191. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  192. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  193. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  194. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  195. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  196. package/dist/components/overlays/Drawer.root.cjs +2 -0
  197. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  198. package/dist/components/overlays/Drawer.root.mjs +207 -0
  199. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  200. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  201. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  202. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  203. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  204. package/dist/components/table/useGridNavigation.cjs +1 -1
  205. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  206. package/dist/components/table/useGridNavigation.mjs +67 -70
  207. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  208. package/dist/hooks/useActiveDescendant.cjs +2 -0
  209. package/dist/hooks/useActiveDescendant.cjs.map +1 -0
  210. package/dist/hooks/useActiveDescendant.mjs +56 -0
  211. package/dist/hooks/useActiveDescendant.mjs.map +1 -0
  212. package/dist/hooks/useDismiss.cjs.map +1 -1
  213. package/dist/hooks/useDismiss.mjs.map +1 -1
  214. package/dist/hooks/useFocusTrap.cjs +1 -1
  215. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  216. package/dist/hooks/useFocusTrap.mjs +115 -98
  217. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  218. package/dist/hooks/useListbox.cjs +1 -1
  219. package/dist/hooks/useListbox.cjs.map +1 -1
  220. package/dist/hooks/useListbox.mjs +250 -210
  221. package/dist/hooks/useListbox.mjs.map +1 -1
  222. package/dist/hooks/useModalLayer.cjs +1 -1
  223. package/dist/hooks/useModalLayer.cjs.map +1 -1
  224. package/dist/hooks/useModalLayer.mjs +35 -22
  225. package/dist/hooks/useModalLayer.mjs.map +1 -1
  226. package/dist/hooks/useRestoreFocus.cjs +1 -1
  227. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  228. package/dist/hooks/useRestoreFocus.mjs +91 -78
  229. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  230. package/dist/hooks/useRovingGrid.cjs +2 -0
  231. package/dist/hooks/useRovingGrid.cjs.map +1 -0
  232. package/dist/hooks/useRovingGrid.mjs +69 -0
  233. package/dist/hooks/useRovingGrid.mjs.map +1 -0
  234. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  235. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  236. package/dist/hooks/useRovingTabIndex.mjs +102 -78
  237. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  238. package/dist/index.cjs +1 -1
  239. package/dist/index.d.cts +4391 -394
  240. package/dist/index.d.ts +4391 -394
  241. package/dist/index.mjs +115 -101
  242. package/dist/lib/classNames.cjs +1 -1
  243. package/dist/lib/classNames.cjs.map +1 -1
  244. package/dist/lib/classNames.mjs +170 -74
  245. package/dist/lib/classNames.mjs.map +1 -1
  246. package/dist/lib/date.cjs +2 -0
  247. package/dist/lib/date.cjs.map +1 -0
  248. package/dist/lib/date.mjs +44 -0
  249. package/dist/lib/date.mjs.map +1 -0
  250. package/dist/lib/focus.cjs +1 -1
  251. package/dist/lib/focus.cjs.map +1 -1
  252. package/dist/lib/focus.mjs +5 -2
  253. package/dist/lib/focus.mjs.map +1 -1
  254. package/dist/lib/icons.cjs +1 -1
  255. package/dist/lib/icons.cjs.map +1 -1
  256. package/dist/lib/icons.mjs +13 -6
  257. package/dist/lib/icons.mjs.map +1 -1
  258. package/dist/lib/layers.cjs +1 -1
  259. package/dist/lib/layers.cjs.map +1 -1
  260. package/dist/lib/layers.mjs +53 -47
  261. package/dist/lib/layers.mjs.map +1 -1
  262. package/dist/styles.css +1 -1
  263. package/package.json +1 -1
  264. package/src/styles/tokens.css +25 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Calendar.cjs","names":["startOfDay","React","startOfMonth","clampDate","getDecadeStart","useId","formatISODate","isSameMonth","isDayUnavailable","getSelectionRange","getCalendarDays","addMonths","isSameDay","makeDate","isOwnEvent","addDays","formatMonthYear","isYearOutOfRange","formatYear","formatDecade","isDateInRange","CalendarDayGrid","getYearMonths","CalendarPickerGrid","formatMonthShort","isMonthOutOfRange","getDecadeYears","_Fragment","cn","focusableDisabledProps","preventIfDisabled","focusRing","disabledStyles","ChevronLeftIcon","ChevronRightIcon","calendarClassNames","useControllable","useIsClient","isValidLocaleTag","useFieldContext","useFieldControl","useMergedRefs","joinIds","HiddenInput","require_runtime","require_cn","require_dev","require_classNames","require_date","require_useControllable","require_useId","require_useMergedRefs","require_useIsClient","require_aria","require_useFieldControl","require_styles","require_icons","require_useFormReset","require_HiddenInput","require_events","require_dateUtils","require_Calendar_views","react","react_jsx_runtime","NAV_BUTTON_CLASSES","HEADING_BUTTON_CLASSES","FOOTER_BUTTON_CLASSES","DEFAULT_WORK_WEEK_DAYS","toWeeks","weeks","i","days","inDecadeGrid","year","decade","clampYear","min","max","CalendarView","todayProp","Heading","today","viewState","setView","view","showMonthPicker","viewMonth","setViewMonth","value","initialVisibleDate","minDate","maxDate","focusedDay","setFocusedDay","monthViewYear","setMonthViewYear","focusedMonth","setFocusedMonth","setDecade","focusedYear","setFocusedYear","gridRef","focusGridRef","focusRequest","setFocusRequest","gridId","hintId","valueIso","seenValueIso","setSeenValueIso","isUnavailable","date","disabledDates","selectedDays","selectionRange","firstDayOfWeek","workWeekDays","inView","inGrid","clampedToday","firstInRange","focusTarget","focusIso","moveFocus","target","next","navigateMonth","nextView","delta","moved","handleDayFocus","day","minMonth","maxMonth","clampMonth","month","inMonthView","firstMonthInRange","monthTarget","moveMonthFocus","navigateYear","nextYear","firstYearInRange","yearTarget","moveYearFocus","preferredDecade","navigateDecade","nextDecade","changeView","goToToday","request","showMonths","showYears","pickMonth","monthsAway","pickYear","yearDate","handleEscape","event","periodKey","cellKey","headerRef","viewHadFocusRef","onFocusIn","previousViewRef","viewChanged","requested","grid","active","lost","button","previousLabel","nextLabel","previousDisabled","nextDisabled","navigate","headingText","labels","locale","todayOutOfRange","headingButtonTarget","hint","months","direction","partClassNames","years","headingId","showGoToToday","onClose","closeLabel","CALENDAR_PART_CLASS_NAMES","Calendar","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","setValue","defaultValue","onValueChange","commit","normalized","isClient","hasDate","field","fieldAriaRequired","fieldDescribedBy","fieldProps","required","isRequired","requiredHintId","showRequiredHint","rootRef","mergedRef","ref","form","focusTabStop","className"],"sources":["../../../src/components/input/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { DayOfWeek, FirstWeekOfYear } from '../../lib/types';\nimport { cn } from '../../lib/cn';\nimport { focusableDisabledProps, joinIds, preventIfDisabled } from '../../lib/aria';\nimport { calendarClassNames } from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport { isOwnEvent } from '../../lib/events';\nimport { ChevronLeftIcon, ChevronRightIcon } from '../../lib/icons';\nimport { disabledStyles, focusRing } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { makeDate } from '../../lib/date';\nimport {\n CalendarDayGrid,\n CalendarPickerGrid,\n type CalendarDayGridPartClassNames,\n} from './Calendar.views';\nimport {\n addDays,\n addMonths,\n clampDate,\n formatDecade,\n formatISODate,\n formatMonthShort,\n formatMonthYear,\n formatYear,\n getCalendarDays,\n getDecadeStart,\n getDecadeYears,\n getSelectionRange,\n getYearMonths,\n isDateInRange,\n isDayUnavailable,\n isMonthOutOfRange,\n isSameDay,\n isSameMonth,\n isValidLocaleTag,\n isYearOutOfRange,\n startOfDay,\n startOfMonth,\n type CalendarSelectionRange,\n} from './dateUtils';\n\n/**\n * The built-in texts of the calendar, for localization: the names of the navigation buttons in\n * the day, month and year views, the hints of the heading button, the \"Go to today\" button, the\n * week-number column and the marked days, and (Calendar only) the required hint. Each member is\n * optional and falls back to its English default. Month and weekday names and the day labels follow\n * `locale`. DatePicker's labels extend this type.\n */\nexport interface CalendarLabels {\n /** Name of the previous-month button.\n * @default 'Previous month'\n */\n previousMonth?: string;\n /** Name of the next-month button.\n * @default 'Next month'\n */\n nextMonth?: string;\n /** Name of the previous-year button of the month view.\n * @default 'Previous year'\n */\n previousYear?: string;\n /** Name of the next-year button of the month view.\n * @default 'Next year'\n */\n nextYear?: string;\n /** Name of the previous-decade button of the year view.\n * @default 'Previous decade'\n */\n previousDecade?: string;\n /** Name of the next-decade button of the year view.\n * @default 'Next decade'\n */\n nextDecade?: string;\n /** Description of the heading button that shows the month view.\n * @default 'Choose a month'\n */\n chooseMonth?: string;\n /** Description of the heading button that shows the year view.\n * @default 'Choose a year'\n */\n chooseYear?: string;\n /** Name of the \"Go to today\" button.\n * @default 'Go to today'\n */\n goToToday?: string;\n /** Hidden text of the week-number column header.\n * @default 'Week'\n */\n week?: string;\n /** Name of a week-number row header.\n * @default (week) => `Week ${week}`\n */\n weekNumber?: (week: number) => string;\n /** Name of a marked day, built from its default name.\n * @default (dayLabel) => `${dayLabel}, marked`\n */\n markedDay?: (dayLabel: string) => string;\n /**\n * Said in the calendar's description while it is required (`required`, a required Field, or a\n * consumer `aria-required` alone), since its role cannot carry `aria-required`.\n * @default 'Required'\n */\n required?: string;\n}\n\n/** Second argument of `Calendar`'s `onValueChange`. */\nexport interface CalendarValueChangeDetails {\n /**\n * The selected days in order (local midnight): the picked day, or with `selectionRange` its\n * week, work week or month (the days that are not available left out); `[]` for `null`.\n */\n range: Date[];\n}\n\n/** Properties for the Calendar component. */\nexport interface CalendarProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /** Controlled selected day (`null` for none). */\n value?: Date | null;\n /**\n * Initial selected day for uncontrolled usage.\n * @default null\n */\n defaultValue?: Date | null;\n /**\n * Called with the new day (local midnight) when the selected day changes: a pick of another day\n * or a form reset (Fluent's `onSelectDate` fires on every pick). Picking the selected day again\n * does nothing. WaveUI always passes `details`.\n */\n onValueChange?: (date: Date | null, details?: CalendarValueChangeDetails) => void;\n /** Earliest available day (the whole day is included). */\n minDate?: Date;\n /** Latest available day (the whole day is included). */\n maxDate?: Date;\n /** Returns `true` for days that cannot be picked (called with local-midnight dates). */\n disabledDates?: (date: Date) => boolean;\n /**\n * First day of the week (0 = Sunday, 1 = Monday, etc.).\n * @default 0\n */\n firstDayOfWeek?: DayOfWeek;\n /**\n * BCP 47 locale of the month text, the weekday names and the day labels. Pass it when rendering\n * on the server, so the server and the browser render the same text. The grid is Gregorian, as\n * in DatePicker. A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the runtime\n * default locale (development warning).\n * @default the runtime default locale\n */\n locale?: string;\n /**\n * The day marked as today (`aria-current=\"date\"`), and the tab stop when no day is selected in\n * the shown month. Without it, the server HTML and the hydration render mark no day and the\n * browser applies the current date once hydrated: pass it when rendering on the server, so the\n * mark is in the HTML.\n * @default the current date (applied after hydration when not passed)\n */\n today?: Date;\n /**\n * The month shown first when there is no value (Fluent's `initialPickerDate`), clamped into\n * `minDate`/`maxDate` like the value's month and today's.\n * @default today's month\n */\n initialVisibleDate?: Date;\n /**\n * Turns the month text into a button that shows the month view (the 12 months of the year),\n * whose heading, the year, is a button to the year view (a decade with the year before and\n * after it). A picked year shows its months and a picked month its days; Escape goes back a\n * level to the period shown before. Fluent's `isMonthPickerVisible`, here as a drill-down in one\n * pane.\n * @default true\n */\n showMonthPicker?: boolean;\n /**\n * Adds a leading column of week numbers: a row header per week (`Week 23`, from\n * `labels.weekNumber`) under a header cell named `labels.week`. The numbers follow\n * `firstDayOfWeek` and `firstWeekOfYear`; the column is not focusable and the keys skip it.\n * @default false\n */\n showWeekNumbers?: boolean;\n /**\n * Which week is week 1 of a year. ISO 8601 is `'first-four-day-week'` with `firstDayOfWeek={1}`.\n * @default 'first-day'\n */\n firstWeekOfYear?: FirstWeekOfYear;\n /**\n * Adds a footer button that shows today's month in the day view and focuses today without\n * selecting it. It is disabled while today is outside `minDate`/`maxDate`.\n * @default false\n */\n showGoToToday?: boolean;\n /**\n * Days that draw a dot under the number (in the text colour of the day) and say \"marked\" in\n * their name (`labels.markedDay`); also `data-marked` on the day's button (Fluent's\n * `getMarkedDays`). Called with local-midnight dates.\n */\n markedDates?: (date: Date) => boolean;\n /**\n * Replaces the content inside a day's button, which keeps its role, state and keys;\n * `defaultContent` is the day number. The content must be non-interactive (no buttons or links),\n * and the button's name does not follow it: set the name with `dayLabel`. The marked-day dot is\n * drawn next to the content.\n */\n renderDay?: (date: Date, defaultContent: React.ReactNode) => React.ReactNode;\n /**\n * The accessible name of a day, from its default name (the date in words, `Monday, June 2,\n * 2025`, with `labels.markedDay` applied for a marked day). Use it to say what `renderDay` shows.\n */\n dayLabel?: (date: Date, defaultLabel: string) => string;\n /**\n * What a pick selects: the day, or its week, work week (`workWeekDays`) or month. The value is\n * the picked day, `details.range` the selected days, and every day of the range is\n * `aria-selected`, `aria-pressed` and `data-selected`. Days that are not available are left\n * out. Fluent's `dateRangeType`.\n * @default 'day'\n */\n selectionRange?: CalendarSelectionRange;\n /**\n * The days of `selectionRange=\"work-week\"` (0 = Sunday), within the week that starts on\n * `firstDayOfWeek`.\n * @default [1, 2, 3, 4, 5]\n */\n workWeekDays?: readonly DayOfWeek[];\n /**\n * Names of the navigation buttons, the heading button's hints, the \"Go to today\" button, the\n * week-number column, the marked days and the required hint, for localization.\n */\n labels?: CalendarLabels;\n /** Form field name: the day is submitted as ISO `yyyy-mm-dd` (hidden input). */\n name?: string;\n /** Id of the `<form>` the value belongs to, when the calendar is outside it. */\n form?: string;\n /**\n * Blocks form submission while no day is selected; the form's report focuses the calendar's\n * tab stop. Said in the description (`labels.required`), as the group cannot carry\n * `aria-required`. A consumer `aria-required` alone also shows that hint (assistive technology\n * only: it does not block submission).\n */\n required?: boolean;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Internal: the stable classes of a calendar view's parts, passed in by the component that\n * renders the view (DatePicker passes its own).\n */\nexport interface CalendarViewPartClassNames extends CalendarDayGridPartClassNames {\n /** On the row of the navigation buttons and the heading. */\n header?: string;\n /** On the previous button (previous month, year or decade). */\n previousMonthButton?: string;\n /** On the heading (the month, the year or the decade). */\n heading?: string;\n /** On the heading's button, which shows the month or the year view. */\n headingButton?: string;\n /** On the next button (next month, year or decade). */\n nextMonthButton?: string;\n /** On each month button of the month view. */\n month?: string;\n /** On each year button of the year view. */\n year?: string;\n /** On the row of the footer buttons. */\n footer?: string;\n /** On the \"Go to today\" button. */\n todayButton?: string;\n /** On the \"Close\" button. */\n closeButton?: string;\n}\n\n/** Internal props of {@link CalendarView}. */\nexport interface CalendarViewProps {\n /** The selected day, or `null` for none. */\n value: Date | null;\n /** Called with an available day the user picks (click, Enter or Space on a day button). */\n onPick: (date: Date) => void;\n /** Earliest available day (the whole day is included). */\n minDate?: Date;\n /** Latest available day (the whole day is included). */\n maxDate?: Date;\n /** Returns `true` for days that cannot be picked (called with local-midnight dates). */\n disabledDates?: (date: Date) => boolean;\n /** First day of the week (0 = Sunday). */\n firstDayOfWeek: DayOfWeek;\n /** BCP 47 locale of the heading, the weekday names and the day labels. */\n locale?: string;\n /**\n * The day marked as today; `null` while it is unknown (the server HTML and the hydration render\n * of a Calendar without `today`): no day is marked, and the tab stop skips today.\n * @default the current date\n */\n today?: Date | null;\n /** The month shown first when there is no value (else today's, else the clock's). */\n initialVisibleDate?: Date;\n /**\n * The heading is a button that shows the month view, whose heading shows the year view.\n * @default true\n */\n showMonthPicker?: boolean;\n /** Adds a leading column of week numbers to the day view. @default false */\n showWeekNumbers?: boolean;\n /** Which week is week 1 of a year. @default 'first-day' */\n firstWeekOfYear?: FirstWeekOfYear;\n /** Returns `true` for days that draw a dot and are named \"marked\". */\n markedDates?: (date: Date) => boolean;\n /** Replaces the content of a day button. */\n renderDay?: (date: Date, defaultContent: React.ReactNode) => React.ReactNode;\n /** The accessible name of a day, from its default name. */\n dayLabel?: (date: Date, defaultLabel: string) => string;\n /**\n * What a pick selects (the day, or its week, work week or month): the days drawn selected. The\n * parent receives only the picked day.\n * @default 'day'\n */\n selectionRange?: CalendarSelectionRange;\n /** The days of the `'work-week'` range. @default [1, 2, 3, 4, 5] */\n workWeekDays?: readonly DayOfWeek[];\n /** Adds a footer button that shows today's month and focuses today. @default false */\n showGoToToday?: boolean;\n /** Adds a footer \"Close\" button that calls this (DatePicker closes its dialog). */\n onClose?: () => void;\n /** Name of the \"Close\" button. @default 'Close' */\n closeLabel?: string;\n /** Names of the navigation buttons, the heading button's hints and the footer buttons. */\n labels?: CalendarLabels;\n /** Element of the heading: `h2` in DatePicker's dialog (its title), else `div`. */\n headingAs: 'h2' | 'div';\n /** Id of the heading (it labels the grid; DatePicker also labels its dialog with it). */\n headingId: string;\n /** Stable classes of the view's parts. */\n partClassNames?: CalendarViewPartClassNames;\n}\n\n// Every button sets its own padding and background (C-NATIVE): an app-wide `button` rule would\n// otherwise pad and fill them.\nconst NAV_BUTTON_CLASSES =\n 'flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover';\n\n// The heading's button keeps the heading's text style, set on itself (C-NATIVE).\nconst HEADING_BUTTON_CLASSES =\n 'flex h-8 items-center justify-center rounded bg-transparent p-0 px-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover';\n\n// The footer's text buttons (C-NATIVE: their own padding and background).\nconst FOOTER_BUTTON_CLASSES =\n 'flex h-8 items-center justify-center rounded bg-transparent p-0 px-3 text-body-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover';\n\n/** The days of `'work-week'` unless `workWeekDays` says otherwise (Monday to Friday). */\nconst DEFAULT_WORK_WEEK_DAYS: readonly DayOfWeek[] = [1, 2, 3, 4, 5];\n\n/** The 42 grid days as 6 weeks. */\nfunction toWeeks(days: Date[]): Date[][] {\n const weeks: Date[][] = [];\n for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));\n return weeks;\n}\n\n/** The years of the year view of the decade starting at `decade` (the year before and after it). */\nfunction inDecadeGrid(year: number, decade: number): boolean {\n return year >= decade - 1 && year <= decade + 10;\n}\n\n/** `year` clamped into the years of `[min, max]` (as `clampDate` clamps a day). */\nfunction clampYear(year: number, min?: Date, max?: Date): number {\n if (min && year < min.getFullYear()) return min.getFullYear();\n if (max && year > max.getFullYear()) return max.getFullYear();\n return year;\n}\n\n/** Which grid a calendar view shows. */\ntype CalendarViewKind = 'day' | 'month' | 'year';\n\n/**\n * Internal: the header (the previous button, the heading, the next button), the grid and the\n * optional footer (Go to today, Close) of a calendar, in one of three views: the days of a month, the months of a year (the month view) and\n * the years of a decade (the year view). It renders no element of its own (a fragment). It opens\n * on the day view of the month of `value`, else `initialVisibleDate`'s, else today's, clamped into\n * `minDate`/`maxDate`, and keeps that month until navigated or until `value` changes to a day of\n * another month, whose month it then shows (DatePicker mounts it with each opening of its dialog).\n *\n * With `showMonthPicker`, the day view's heading is a button to the month view, and the month\n * view's heading a button to the year view; a picked year shows its months and a picked month its\n * days. Escape in the year and month views goes back one level to the period shown before (and is\n * consumed, also on the footer's buttons). Each view change moves focus into the new grid in the\n * same commit. The day view can add a week-number column, a dot and a name suffix for marked\n * days, custom day content, and a range around the picked day (`selectionRange`); the footer has\n * \"Go to today\" (`showGoToToday`) and a Close button (`onClose`).\n */\nexport const CalendarView = ({\n value,\n onPick,\n minDate,\n maxDate,\n disabledDates,\n firstDayOfWeek,\n locale,\n today: todayProp,\n initialVisibleDate,\n showMonthPicker = true,\n showWeekNumbers,\n firstWeekOfYear,\n markedDates,\n renderDay,\n dayLabel,\n selectionRange = 'day',\n workWeekDays = DEFAULT_WORK_WEEK_DAYS,\n showGoToToday = false,\n onClose,\n closeLabel,\n labels,\n headingAs: Heading,\n headingId,\n partClassNames,\n}: CalendarViewProps) => {\n const today =\n todayProp === undefined ? startOfDay(new Date()) : todayProp && startOfDay(todayProp);\n const [viewState, setView] = React.useState<CalendarViewKind>('day');\n // Without the month picker the headings are no buttons: only the day view exists.\n const view = showMonthPicker ? viewState : 'day';\n if (viewState !== view) setView(view);\n // Day view: the shown month and the day moved to.\n const [viewMonth, setViewMonth] = React.useState<Date>(() =>\n // Without a value, an `initialVisibleDate` or a known today the month comes from the clock:\n // on the server, the server's (the Calendar warns after such a hydration render).\n startOfMonth(clampDate(value ?? initialVisibleDate ?? today ?? new Date(), minDate, maxDate)),\n );\n const [focusedDay, setFocusedDay] = React.useState<Date | null>(null);\n // Month view: the shown year and the month moved to. Year view: the first year of the shown\n // decade and the year moved to. Each view keeps its state while a higher view is shown, so\n // Escape shows the period it showed before.\n const [monthViewYear, setMonthViewYear] = React.useState(() => viewMonth.getFullYear());\n const [focusedMonth, setFocusedMonth] = React.useState<Date | null>(null);\n const [decade, setDecade] = React.useState(() => getDecadeStart(viewMonth.getFullYear()));\n const [focusedYear, setFocusedYear] = React.useState<number | null>(null);\n const gridRef = React.useRef<HTMLTableElement | null>(null);\n /** Set by a view change: the next layout effect moves focus into the new grid. */\n const focusGridRef = React.useRef(false);\n /** Bumped by \"Go to today\": the next layout effect moves focus to the focused day. */\n const [focusRequest, setFocusRequest] = React.useState(0);\n const gridId = useId('calendar-grid');\n const hintId = useId('calendar-heading-hint');\n\n // A value that changes to a day of another month shows that month (adjusted during render,\n // C-HOOKS): a controlled value set by the parent, a form reset, or a picked day of the next\n // month.\n const valueIso = value ? formatISODate(value) : '';\n const [seenValueIso, setSeenValueIso] = React.useState(valueIso);\n if (seenValueIso !== valueIso) {\n setSeenValueIso(valueIso);\n if (value) {\n if (!isSameMonth(value, viewMonth)) {\n setViewMonth(startOfMonth(clampDate(value, minDate, maxDate)));\n setFocusedDay(null);\n }\n // The month and year views follow the value too, to its year and its decade.\n const year = clampYear(value.getFullYear(), minDate, maxDate);\n setMonthViewYear(year);\n setFocusedMonth(null);\n setDecade(getDecadeStart(year));\n setFocusedYear(null);\n }\n }\n\n const isUnavailable = (date: Date) => isDayUnavailable(date, minDate, maxDate, disabledDates);\n\n // The days drawn selected: the range around the value (its available days).\n const selectedDays = new Set(\n value\n ? getSelectionRange(value, selectionRange, firstDayOfWeek, workWeekDays, isUnavailable).map(\n formatISODate,\n )\n : [],\n );\n\n const weeks = React.useMemo(\n () => toWeeks(getCalendarDays(viewMonth, firstDayOfWeek)),\n [viewMonth, firstDayOfWeek],\n );\n\n /* ---- day view ----------------------------------------------------- */\n\n // The focused day is derived: the day moved to while it is shown (a pointer-focused day of the\n // previous/next month counts too), else the selected day of the month, else today (clamped into\n // the range; skipped while today is unknown), else the first day of the month in range (it may\n // be unavailable: unavailable days are focusable).\n const inView = (date: Date | null | undefined): date is Date =>\n !!date && isSameMonth(date, viewMonth);\n const inGrid = (date: Date | null | undefined): date is Date =>\n !!date && date >= weeks[0][0] && date <= weeks[weeks.length - 1][6];\n const clampedToday = today && clampDate(today, minDate, maxDate);\n const firstInRange = clampDate(viewMonth, minDate, maxDate);\n const focusTarget = inGrid(focusedDay)\n ? focusedDay\n : inView(value)\n ? startOfDay(value)\n : inView(clampedToday)\n ? clampedToday\n : inView(firstInRange)\n ? firstInRange\n : viewMonth;\n const focusIso = formatISODate(focusTarget);\n\n const moveFocus = (next: Date) => {\n const target = clampDate(next, minDate, maxDate);\n setFocusedDay(target);\n if (!isSameMonth(target, viewMonth)) setViewMonth(startOfMonth(target));\n };\n\n const navigateMonth = (delta: number) => {\n const nextView = addMonths(viewMonth, delta);\n const moved = clampDate(addMonths(focusTarget, delta), minDate, maxDate);\n setViewMonth(nextView);\n // From a day of the previous/next month the moved day may fall outside the new month: the\n // focused day is then derived again (selected, today or the first day of the month).\n setFocusedDay(isSameMonth(moved, nextView) ? moved : null);\n };\n\n /** Pointer (or assistive technology) focus on a day makes it the roving day; the month stays. */\n const handleDayFocus = (day: Date) => {\n if (!isSameDay(day, focusTarget)) setFocusedDay(day);\n };\n\n /* ---- month view --------------------------------------------------- */\n\n const minMonth = minDate && startOfMonth(minDate);\n const maxMonth = maxDate && startOfMonth(maxDate);\n const clampMonth = (month: Date) => clampDate(startOfMonth(month), minMonth, maxMonth);\n const inMonthView = (date: Date | null | undefined): date is Date =>\n !!date && date.getFullYear() === monthViewYear;\n const firstMonthInRange = clampMonth(makeDate(monthViewYear, 0, 1));\n const monthTarget = inMonthView(focusedMonth)\n ? focusedMonth\n : inMonthView(value)\n ? startOfMonth(value)\n : inMonthView(clampedToday)\n ? startOfMonth(clampedToday)\n : inMonthView(firstMonthInRange)\n ? firstMonthInRange\n : makeDate(monthViewYear, 0, 1);\n\n /** A key moves the focused month; the shown year follows it. */\n const moveMonthFocus = (next: Date) => {\n const target = clampMonth(next);\n setFocusedMonth(target);\n setMonthViewYear(target.getFullYear());\n };\n\n const navigateYear = (delta: number) => {\n const nextYear = monthViewYear + delta;\n const moved = clampMonth(addMonths(monthTarget, delta * 12));\n setMonthViewYear(nextYear);\n setFocusedMonth(moved.getFullYear() === nextYear ? moved : null);\n };\n\n /* ---- year view ---------------------------------------------------- */\n\n const firstYearInRange = clampYear(decade, minDate, maxDate);\n const yearTarget =\n focusedYear !== null && inDecadeGrid(focusedYear, decade)\n ? focusedYear\n : value && inDecadeGrid(value.getFullYear(), decade)\n ? value.getFullYear()\n : clampedToday && inDecadeGrid(clampedToday.getFullYear(), decade)\n ? clampedToday.getFullYear()\n : inDecadeGrid(firstYearInRange, decade)\n ? firstYearInRange\n : decade;\n\n /**\n * A key moves the focused year. The arrows keep the decade while the year is in its grid (the\n * year before and after it included), PageUp/PageDown show the previous and next decade; a\n * year the bounds clamp outside that grid shows its own decade.\n */\n const moveYearFocus = (next: number, preferredDecade: number) => {\n const target = clampYear(next, minDate, maxDate);\n setFocusedYear(target);\n setDecade(inDecadeGrid(target, preferredDecade) ? preferredDecade : getDecadeStart(target));\n };\n\n const navigateDecade = (delta: number) => {\n const nextDecade = decade + delta * 10;\n const moved = clampYear(yearTarget + delta * 10, minDate, maxDate);\n setDecade(nextDecade);\n setFocusedYear(inDecadeGrid(moved, nextDecade) ? moved : null);\n };\n\n /* ---- view changes ------------------------------------------------- */\n\n const changeView = (next: CalendarViewKind) => {\n focusGridRef.current = true;\n setView(next);\n };\n\n /** \"Go to today\": today's month in the day view, today focused; nothing is selected. */\n const goToToday = () => {\n const target = clampDate(today ?? startOfDay(new Date()), minDate, maxDate);\n setViewMonth(startOfMonth(target));\n setFocusedDay(target);\n setFocusRequest((request) => request + 1);\n changeView('day');\n };\n\n /** The day view's heading button: the months of the focused day's year, its month focused. */\n const showMonths = () => {\n setFocusedDay(focusTarget);\n setMonthViewYear(focusTarget.getFullYear());\n setFocusedMonth(startOfMonth(focusTarget));\n changeView('month');\n };\n\n /** The month view's heading button: the decade of the focused month, its year focused. */\n const showYears = () => {\n setFocusedMonth(monthTarget);\n setDecade(getDecadeStart(monthTarget.getFullYear()));\n setFocusedYear(monthTarget.getFullYear());\n changeView('year');\n };\n\n /** A picked month shows its days; the focused day keeps its day of the month, clamped. */\n const pickMonth = (month: Date) => {\n const monthsAway =\n (month.getFullYear() - focusTarget.getFullYear()) * 12 +\n (month.getMonth() - focusTarget.getMonth());\n const day = clampDate(addMonths(focusTarget, monthsAway), minDate, maxDate);\n setViewMonth(month);\n setFocusedDay(isSameMonth(day, month) ? day : null);\n changeView('day');\n };\n\n /** A picked year shows its months; the focused month keeps its month, clamped. */\n const pickYear = (yearDate: Date) => {\n const year = yearDate.getFullYear();\n const month = clampMonth(makeDate(year, monthTarget.getMonth(), 1));\n setMonthViewYear(year);\n setFocusedMonth(month.getFullYear() === year ? month : null);\n changeView('month');\n };\n\n // Escape goes back one level (C-POPUPS: an inner widget that consumes Escape prevents its\n // default, so a DatePicker stays open); the day view leaves it to the surroundings.\n const handleEscape = (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key !== 'Escape' || view === 'day' || !isOwnEvent(event)) return;\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n event.preventDefault();\n changeView(view === 'year' ? 'month' : 'day');\n };\n\n /* ---- focus -------------------------------------------------------- */\n\n const periodKey =\n view === 'day' ? formatISODate(viewMonth) : view === 'month' ? monthViewYear : decade;\n const cellKey =\n view === 'day' ? focusIso : view === 'month' ? formatISODate(monthTarget) : yearTarget;\n\n // Roving focus: while the grid holds focus, focus follows the focused cell, also when the\n // period changes under it (the buttons are keyed by position, so the focused one shows another\n // cell). A view change moves focus into the new grid in the same commit, since the element that\n // had it (the heading button that becomes text, a picked cell) may be gone.\n const headerRef = React.useRef<HTMLDivElement | null>(null);\n /** Whether focus last rested in the header or the grid (a removed element fires no event). */\n const viewHadFocusRef = React.useRef(false);\n React.useEffect(() => {\n const onFocusIn = (event: FocusEvent) => {\n const target = event.target as Node | null;\n viewHadFocusRef.current =\n !!target && (!!gridRef.current?.contains(target) || !!headerRef.current?.contains(target));\n };\n document.addEventListener('focusin', onFocusIn);\n return () => document.removeEventListener('focusin', onFocusIn);\n }, []);\n const previousViewRef = React.useRef(view);\n React.useLayoutEffect(() => {\n const viewChanged = previousViewRef.current !== view;\n previousViewRef.current = view;\n const requested = focusGridRef.current;\n focusGridRef.current = false;\n const grid = gridRef.current;\n if (!grid) return;\n const active = grid.ownerDocument.activeElement;\n // A view change the props made (the month picker turned off) removed the element that had\n // focus: focus then moves into the new grid, if the view had focus and it now rests on\n // nothing. A calendar that did not have focus keeps it where it is.\n const lost =\n viewChanged && viewHadFocusRef.current && (!active || active === grid.ownerDocument.body);\n if (!requested && !lost && (!active || !grid.contains(active))) return;\n const button = grid.querySelector<HTMLElement>('button[tabindex=\"0\"]');\n if (button && button !== active) button.focus();\n }, [view, periodKey, cellKey, focusRequest]);\n\n /* ---- render ------------------------------------------------------- */\n\n let previousLabel: string;\n let nextLabel: string;\n let previousDisabled: boolean;\n let nextDisabled: boolean;\n let navigate: (delta: number) => void;\n let headingText: string;\n if (view === 'day') {\n previousLabel = labels?.previousMonth ?? 'Previous month';\n nextLabel = labels?.nextMonth ?? 'Next month';\n previousDisabled = !!minDate && addDays(viewMonth, -1) < startOfDay(minDate);\n nextDisabled = !!maxDate && addMonths(viewMonth, 1) > startOfDay(maxDate);\n navigate = navigateMonth;\n headingText = formatMonthYear(viewMonth, locale);\n } else if (view === 'month') {\n previousLabel = labels?.previousYear ?? 'Previous year';\n nextLabel = labels?.nextYear ?? 'Next year';\n previousDisabled = isYearOutOfRange(monthViewYear - 1, minDate, maxDate);\n nextDisabled = isYearOutOfRange(monthViewYear + 1, minDate, maxDate);\n navigate = navigateYear;\n headingText = formatYear(makeDate(monthViewYear, 0, 1), locale);\n } else {\n previousLabel = labels?.previousDecade ?? 'Previous decade';\n nextLabel = labels?.nextDecade ?? 'Next decade';\n // A decade is wholly outside when its last year is before minDate or its first after maxDate.\n previousDisabled =\n isYearOutOfRange(decade - 1, minDate, undefined) ||\n isYearOutOfRange(decade - 10, undefined, maxDate);\n nextDisabled =\n isYearOutOfRange(decade + 10, undefined, maxDate) ||\n isYearOutOfRange(decade + 19, minDate, undefined);\n navigate = navigateDecade;\n headingText = formatDecade(decade, locale);\n }\n\n // Unknown today (before hydration) leaves the button enabled; the clock decides once it is known.\n const todayOutOfRange = !!today && !isDateInRange(today, minDate, maxDate);\n\n const headingButtonTarget = showMonthPicker && view !== 'year' ? view : null;\n const hint =\n view === 'day'\n ? (labels?.chooseMonth ?? 'Choose a month')\n : (labels?.chooseYear ?? 'Choose a year');\n\n let grid: React.ReactNode;\n if (view === 'day') {\n grid = (\n <CalendarDayGrid\n ref={gridRef}\n id={gridId}\n headingId={headingId}\n viewMonth={viewMonth}\n weeks={weeks}\n focusTarget={focusTarget}\n selectedDays={selectedDays}\n today={today}\n firstDayOfWeek={firstDayOfWeek}\n locale={locale}\n showWeekNumbers={showWeekNumbers}\n firstWeekOfYear={firstWeekOfYear}\n markedDates={markedDates}\n renderDay={renderDay}\n dayLabel={dayLabel}\n labels={labels}\n isUnavailable={isUnavailable}\n onMoveFocus={moveFocus}\n onDayFocus={handleDayFocus}\n onPick={onPick}\n partClassNames={partClassNames}\n />\n );\n } else if (view === 'month') {\n const months = getYearMonths(monthViewYear);\n grid = (\n <CalendarPickerGrid\n ref={gridRef}\n id={gridId}\n headingId={headingId}\n cells={months.map((month) => ({\n date: month,\n text: formatMonthShort(month, locale),\n label: formatMonthYear(month, locale),\n selected: !!value && isSameMonth(month, value),\n current: !!today && isSameMonth(month, today),\n outside: false,\n unavailable: isMonthOutOfRange(month, minDate, maxDate),\n }))}\n focusIndex={monthTarget.getMonth()}\n onMoveFocus={(delta) => moveMonthFocus(addMonths(monthTarget, delta))}\n onPage={(direction) => moveMonthFocus(addMonths(monthTarget, direction * 12))}\n onCellFocus={(month) => {\n if (!isSameMonth(month, monthTarget)) setFocusedMonth(month);\n }}\n onPick={pickMonth}\n onKeyDown={handleEscape}\n partClassNames={{ grid: partClassNames?.grid, cell: partClassNames?.month }}\n />\n );\n } else {\n const years = getDecadeYears(decade);\n grid = (\n <CalendarPickerGrid\n ref={gridRef}\n id={gridId}\n headingId={headingId}\n cells={years.map((yearDate) => {\n const year = yearDate.getFullYear();\n return {\n date: yearDate,\n text: formatYear(yearDate, locale),\n selected: value?.getFullYear() === year,\n current: today?.getFullYear() === year,\n outside: year < decade || year > decade + 9,\n unavailable: isYearOutOfRange(year, minDate, maxDate),\n };\n })}\n focusIndex={yearTarget - (decade - 1)}\n onMoveFocus={(delta) => moveYearFocus(yearTarget + delta, decade)}\n onPage={(direction) => moveYearFocus(yearTarget + direction * 10, decade + direction * 10)}\n onCellFocus={(yearDate) => {\n if (yearDate.getFullYear() !== yearTarget) setFocusedYear(yearDate.getFullYear());\n }}\n onPick={pickYear}\n onKeyDown={handleEscape}\n partClassNames={{ grid: partClassNames?.grid, cell: partClassNames?.year }}\n />\n );\n }\n\n return (\n <>\n <div\n ref={headerRef}\n className={cn(partClassNames?.header, 'mb-2 flex items-center justify-between gap-2')}\n onKeyDown={handleEscape}\n >\n <button\n type=\"button\"\n aria-label={previousLabel}\n aria-controls={gridId}\n {...focusableDisabledProps(previousDisabled)}\n onClick={preventIfDisabled(previousDisabled, () => navigate(-1))}\n className={cn(\n partClassNames?.previousMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronLeftIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n <Heading\n id={headingId}\n aria-live=\"polite\"\n className={cn(partClassNames?.heading, 'text-body-1 font-semibold')}\n >\n {headingButtonTarget ? (\n // Named by its text, so the grid and a DatePicker's dialog keep their names; the hint\n // is outside the heading, which names them.\n <button\n type=\"button\"\n aria-describedby={hintId}\n onClick={headingButtonTarget === 'day' ? showMonths : showYears}\n className={cn(partClassNames?.headingButton, HEADING_BUTTON_CLASSES, focusRing)}\n >\n {headingText}\n </button>\n ) : (\n headingText\n )}\n </Heading>\n {headingButtonTarget && (\n <span id={hintId} hidden>\n {hint}\n </span>\n )}\n <button\n type=\"button\"\n aria-label={nextLabel}\n aria-controls={gridId}\n {...focusableDisabledProps(nextDisabled)}\n onClick={preventIfDisabled(nextDisabled, () => navigate(1))}\n className={cn(\n partClassNames?.nextMonthButton,\n NAV_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n <ChevronRightIcon className=\"wave-rtl:-scale-x-100\" />\n </button>\n </div>\n {grid}\n {(showGoToToday || onClose) && (\n <div\n className={cn(partClassNames?.footer, 'mt-2 flex items-center justify-end gap-2')}\n onKeyDown={handleEscape}\n >\n {showGoToToday && (\n <button\n type=\"button\"\n // Natively disabled, since it never disables itself by its own activation.\n disabled={todayOutOfRange}\n onClick={goToToday}\n className={cn(\n partClassNames?.todayButton,\n FOOTER_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n {labels?.goToToday ?? 'Go to today'}\n </button>\n )}\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n className={cn(\n partClassNames?.closeButton,\n FOOTER_BUTTON_CLASSES,\n focusRing,\n disabledStyles,\n )}\n >\n {closeLabel ?? 'Close'}\n </button>\n )}\n </div>\n )}\n </>\n );\n};\n\nCalendarView.displayName = 'CalendarView';\n\n// The Calendar's parts carry its own stable classes (the view's keys name the day view's buttons;\n// the navigation buttons of every view share them).\nconst CALENDAR_PART_CLASS_NAMES: CalendarViewPartClassNames = {\n header: calendarClassNames.header,\n previousMonthButton: calendarClassNames.previousButton,\n heading: calendarClassNames.heading,\n headingButton: calendarClassNames.headingButton,\n nextMonthButton: calendarClassNames.nextButton,\n grid: calendarClassNames.grid,\n weekday: calendarClassNames.weekday,\n day: calendarClassNames.day,\n month: calendarClassNames.month,\n year: calendarClassNames.year,\n weekNumberHeader: calendarClassNames.weekNumberHeader,\n weekNumber: calendarClassNames.weekNumber,\n markedDot: calendarClassNames.markedDot,\n footer: calendarClassNames.footer,\n todayButton: calendarClassNames.todayButton,\n};\n\n/**\n * A month calendar for picking one day, without a text input: the grid of DatePicker's dialog,\n * placed in the page (APG date picker grid).\n *\n * - **Structure**: a `role=\"group\"` root, named with `aria-label`/`aria-labelledby` or by a\n * surrounding `Field`, around the previous-month button, the month text (a polite live region\n * that labels the grid), the next-month button and a `role=\"grid\"` table of six weeks, with an\n * optional leading column of week numbers (`showWeekNumbers`, `firstWeekOfYear`) and an\n * optional footer button, \"Go to today\" (`showGoToToday`), which shows today's month and focuses\n * today without selecting it. The month text is no heading, since a component cannot know the\n * page's heading levels.\n * - **Month and year views** (`showMonthPicker`, on by default): the month text is a button\n * (named by that text, its hint `labels.chooseMonth`) that shows the 12 months of the year; their\n * heading, the year, is a button to the year view, a decade with the year before and after it\n * (muted). The header buttons move by a year, then by a decade. A picked year shows its months\n * and a picked month its days (the focused day keeps its day of the month, clamped); Escape\n * goes back a level to the period shown before. Each view change moves focus into the new\n * grid. Months and years wholly outside `minDate`/`maxDate` stay focusable, `aria-disabled`.\n * - **Keyboard**: one tab stop in the grid, the focused day (the selected day of the shown month,\n * else today, else the first day of the month in range, which may be unavailable). Arrow keys\n * move by day and week (mirrored in RTL), PageUp/PageDown by month, Shift+PageUp/PageDown by\n * year (the day is clamped to the month), Home/End to the start and end of the week; Enter,\n * Space and a click pick the day. Unavailable days (`minDate`, `maxDate`, `disabledDates`) stay\n * focusable and are `aria-disabled`. In the month and year views the arrows move by a cell and a\n * row of four, Home/End to the row's ends, PageUp/PageDown by a year (months) or ten (years).\n * - **Value**: `onValueChange` fires only when the day changes, with local midnight and `details`;\n * picking the selected day again does nothing. A value that moves to another month shows that\n * month. The selected day is `aria-selected` on its gridcell and `aria-pressed` on its button;\n * today is `aria-current=\"date\"`. With `selectionRange` a pick selects the day's week, work\n * week (`workWeekDays`) or month: every available day of it is drawn and marked selected, the\n * value is the picked day, and `details.range` lists the selected days in order.\n * - **Marked days and custom content**: `markedDates` draws a dot in the text colour under the\n * number, sets `data-marked` and says \"marked\" in the day's name; `renderDay` replaces the\n * content of the day button (non-interactive content only) and `dayLabel` sets its name.\n * - **Forms and Field**: `name`/`required` add a hidden input (ISO `yyyy-mm-dd`) that resets with\n * its form (to `defaultValue`); a required calendar that the form reports missing focuses its\n * tab stop. Inside a `Field` the group takes the label, the description and `aria-invalid`; it\n * says \"required\" in its description (`labels.required`), since a group cannot carry\n * `aria-required`.\n * - **Server rendering**: pass `locale`, and `today`, `initialVisibleDate` or a value, so the\n * server and the browser render the same month. Only `today` marks a day in the server HTML:\n * without it the server HTML marks none and the browser marks today once hydrated. Without any\n * of the three the month shown first comes from the server's clock (development warning).\n *\n * @example\n * <Calendar aria-label=\"Due date\" defaultValue={new Date(2025, 5, 12)} onValueChange={setDue} />\n */\nexport const Calendar = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n minDate,\n maxDate,\n disabledDates,\n firstDayOfWeek = 0,\n locale,\n today: todayProp,\n initialVisibleDate,\n showMonthPicker = true,\n showWeekNumbers,\n firstWeekOfYear,\n showGoToToday,\n markedDates,\n renderDay,\n dayLabel,\n selectionRange = 'day',\n workWeekDays,\n labels,\n name,\n form,\n required,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n className,\n ref,\n ...rest\n}: CalendarProps) => {\n const isUnavailable = (date: Date) => isDayUnavailable(date, minDate, maxDate, disabledDates);\n const [value, setValue] = useControllable<Date | null>(valueProp, defaultValue ?? null, (next) =>\n onValueChange?.(next, {\n range: next\n ? getSelectionRange(\n next,\n selectionRange,\n firstDayOfWeek,\n workWeekDays ?? DEFAULT_WORK_WEEK_DAYS,\n isUnavailable,\n )\n : [],\n }),\n );\n\n /** Commits a day (or `null`) as local midnight; nothing is emitted when it is the same day. */\n const commit = (next: Date | null) => {\n const normalized = next ? startOfDay(next) : null;\n const unchanged = normalized ? isSameDay(normalized, value) : value === null;\n if (!unchanged) setValue(normalized);\n };\n\n // Today is unknown in the server HTML and the hydration render (the two clocks may name\n // different days); the browser applies it once hydrated.\n const isClient = useIsClient();\n const today = todayProp ?? (isClient ? new Date() : null);\n\n React.useEffect(() => {\n if (locale !== undefined && !isValidLocaleTag(locale)) {\n warnOnce(\n `Calendar:invalid-locale:${locale}`,\n `Calendar: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as in ` +\n '\"en-US\"). The runtime default locale formats the dates instead, so the server and the ' +\n 'browser may render different text.',\n );\n }\n }, [locale]);\n const hasDate = todayProp !== undefined || initialVisibleDate !== undefined || value !== null;\n React.useEffect(() => {\n // Effects run only in the browser, where `isClient` is false after a hydration render alone.\n if (!isClient && !hasDate) {\n warnOnce(\n 'Calendar:hydration-date',\n 'Calendar: rendered on the server without `today`, `initialVisibleDate` or `value`, so ' +\n \"the month shown first comes from the server's clock and the browser may show another \" +\n 'month. Pass `today` or `initialVisibleDate`.',\n );\n }\n }, [isClient, hasDate]);\n\n const field = useFieldContext();\n const {\n 'aria-required': fieldAriaRequired,\n 'aria-describedby': fieldDescribedBy,\n ...fieldProps\n } = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so the hint matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n },\n { labelable: false },\n );\n const isRequired = required ?? field?.required ?? false;\n // `group` does not allow aria-required (a consumer's included): the description says it.\n const requiredHintId = useId('calendar-required');\n const showRequiredHint = fieldAriaRequired !== undefined && String(fieldAriaRequired) !== 'false';\n\n const headingId = useId('calendar-heading');\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rootRef);\n\n useFormReset(rootRef, () => commit(defaultValue ?? null), form);\n\n const focusTabStop = () => {\n rootRef.current\n ?.querySelector<HTMLElement>('[data-wave-calendar-grid] button[tabindex=\"0\"]')\n ?.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...fieldProps}\n aria-describedby={joinIds(fieldDescribedBy, showRequiredHint && requiredHintId)}\n className={cn(\n calendarClassNames.root,\n 'relative inline-flex flex-col text-foreground',\n className,\n )}\n {...rest}\n ref={mergedRef}\n >\n <CalendarView\n value={value}\n onPick={commit}\n minDate={minDate}\n maxDate={maxDate}\n disabledDates={disabledDates}\n firstDayOfWeek={firstDayOfWeek}\n locale={locale}\n today={today}\n initialVisibleDate={initialVisibleDate}\n showMonthPicker={showMonthPicker}\n showWeekNumbers={showWeekNumbers}\n firstWeekOfYear={firstWeekOfYear}\n showGoToToday={showGoToToday}\n markedDates={markedDates}\n renderDay={renderDay}\n dayLabel={dayLabel}\n selectionRange={selectionRange}\n workWeekDays={workWeekDays}\n labels={labels}\n headingAs=\"div\"\n headingId={headingId}\n partClassNames={CALENDAR_PART_CLASS_NAMES}\n />\n {showRequiredHint && (\n <span id={requiredHintId} hidden>\n {labels?.required ?? 'Required'}\n </span>\n )}\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n value={value ? formatISODate(value) : ''}\n required={isRequired}\n onInvalid={focusTabStop}\n />\n </div>\n );\n};\n\nCalendar.displayName = 'Calendar';\n"],"mappings":"+vBAuVA,IAAMgE,GACJ,2IAGIC,GACJ,sKAGIC,EACJ,wJAGIC,GAA+C,CAAC,EAAG,EAAG,EAAG,EAAG,CAAC,EAGnE,SAASC,GAAQ,EAAwB,CACvC,IAAMC,EAAkB,CAAC,EACzB,IAAK,IAAIC,EAAI,EAAGA,EAAIC,EAAK,OAAQ,GAAK,EAAGF,EAAM,KAAKE,EAAK,MAAMD,EAAGA,EAAI,CAAC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GAAIqJ,EAAgB,OAAA,GACvB,SAAAnC,IAAQ,UAAY,UACjB,CAAA,GAER,EAAAlH,EAAA,IAAA,CAACpB,GAAAA,YAAD,CACE,KAAK,OACC,OACA,QACN,MAAO6C,EAAQlF,EAAAA,cAAckF,CAAK,EAAI,GACtC,SAAU2H,GACV,UAAWO,EACZ,CAAA,CACE,GAET,EAEA,EAAS,YAAc"}
@@ -0,0 +1,352 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { warnOnce as t } from "../../lib/dev.mjs";
4
+ import { calendarClassNames as n } from "../../lib/classNames.mjs";
5
+ import { addDays as r, addMonths as i, isSameDay as a, makeDate as o, startOfDay as s, startOfMonth as c } from "../../lib/date.mjs";
6
+ import { useControllable as l } from "../../hooks/useControllable.mjs";
7
+ import { useId as ee } from "../../hooks/useId.mjs";
8
+ import { useMergedRefs as u } from "../../hooks/useMergedRefs.mjs";
9
+ import { useIsClient as te } from "../../hooks/useIsClient.mjs";
10
+ import { focusableDisabledProps as ne, joinIds as d, preventIfDisabled as f } from "../../lib/aria.mjs";
11
+ import { useFieldContext as p, useFieldControl as re } from "../../hooks/useFieldControl.mjs";
12
+ import { disabledStyles as m, focusRing as h } from "../../lib/styles.mjs";
13
+ import { ChevronLeftIcon as ie, ChevronRightIcon as ae } from "../../lib/icons.mjs";
14
+ import { useFormReset as oe } from "../../hooks/useFormReset.mjs";
15
+ import { HiddenInput as se } from "../internal/HiddenInput.mjs";
16
+ import { isOwnEvent as ce } from "../../lib/events.mjs";
17
+ import { clampDate as g, formatDecade as le, formatISODate as _, formatMonthShort as ue, formatMonthYear as de, formatYear as fe, getCalendarDays as pe, getDecadeStart as v, getDecadeYears as me, getSelectionRange as he, getYearMonths as ge, isDateInRange as _e, isDayUnavailable as ve, isMonthOutOfRange as ye, isSameMonth as y, isValidLocaleTag as be, isYearOutOfRange as b } from "./dateUtils.mjs";
18
+ import { CalendarDayGrid as xe, CalendarPickerGrid as Se } from "./Calendar.views.mjs";
19
+ import * as x from "react";
20
+ import { Fragment as Ce, jsx as S, jsxs as C } from "react/jsx-runtime";
21
+ //#region src/components/input/Calendar.tsx
22
+ var we = "flex h-8 w-8 items-center justify-center rounded bg-transparent p-0 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover", Te = "flex h-8 items-center justify-center rounded bg-transparent p-0 px-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover", Ee = "flex h-8 items-center justify-center rounded bg-transparent p-0 px-3 text-body-1 text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover", De = [
23
+ 1,
24
+ 2,
25
+ 3,
26
+ 4,
27
+ 5
28
+ ];
29
+ function Oe(e) {
30
+ let t = [];
31
+ for (let n = 0; n < e.length; n += 7) t.push(e.slice(n, n + 7));
32
+ return t;
33
+ }
34
+ function w(e, t) {
35
+ return e >= t - 1 && e <= t + 10;
36
+ }
37
+ function T(e, t, n) {
38
+ return t && e < t.getFullYear() ? t.getFullYear() : n && e > n.getFullYear() ? n.getFullYear() : e;
39
+ }
40
+ var E = ({ value: t, onPick: n, minDate: l, maxDate: u, disabledDates: te, firstDayOfWeek: d, locale: p, today: re, initialVisibleDate: oe, showMonthPicker: se = !0, showWeekNumbers: be, firstWeekOfYear: E, markedDates: ke, renderDay: D, dayLabel: Ae, selectionRange: je = "day", workWeekDays: Me = De, showGoToToday: Ne = !1, onClose: O, closeLabel: Pe, labels: k, headingAs: Fe, headingId: A, partClassNames: j }) => {
41
+ let M = re === void 0 ? s(/* @__PURE__ */ new Date()) : re && s(re), [Ie, Le] = x.useState("day"), N = se ? Ie : "day";
42
+ Ie !== N && Le(N);
43
+ let [P, F] = x.useState(() => c(g(t ?? oe ?? M ?? /* @__PURE__ */ new Date(), l, u))), [Re, I] = x.useState(null), [L, R] = x.useState(() => P.getFullYear()), [ze, z] = x.useState(null), [B, Be] = x.useState(() => v(P.getFullYear())), [Ve, V] = x.useState(null), H = x.useRef(null), He = x.useRef(!1), [Ue, We] = x.useState(0), U = ee("calendar-grid"), Ge = ee("calendar-heading-hint"), Ke = t ? _(t) : "", [qe, Je] = x.useState(Ke);
44
+ if (qe !== Ke && (Je(Ke), t)) {
45
+ y(t, P) || (F(c(g(t, l, u))), I(null));
46
+ let e = T(t.getFullYear(), l, u);
47
+ R(e), z(null), Be(v(e)), V(null);
48
+ }
49
+ let Ye = (e) => ve(e, l, u, te), Xe = new Set(t ? he(t, je, d, Me, Ye).map(_) : []), W = x.useMemo(() => Oe(pe(P, d)), [P, d]), Ze = (e) => !!e && y(e, P), Qe = (e) => !!e && e >= W[0][0] && e <= W[W.length - 1][6], G = M && g(M, l, u), $e = g(P, l, u), K = Qe(Re) ? Re : Ze(t) ? s(t) : Ze(G) ? G : Ze($e) ? $e : P, et = _(K), tt = (e) => {
50
+ let t = g(e, l, u);
51
+ I(t), y(t, P) || F(c(t));
52
+ }, nt = (e) => {
53
+ let t = i(P, e), n = g(i(K, e), l, u);
54
+ F(t), I(y(n, t) ? n : null);
55
+ }, rt = (e) => {
56
+ a(e, K) || I(e);
57
+ }, it = l && c(l), at = u && c(u), ot = (e) => g(c(e), it, at), st = (e) => !!e && e.getFullYear() === L, ct = ot(o(L, 0, 1)), q = st(ze) ? ze : st(t) ? c(t) : st(G) ? c(G) : st(ct) ? ct : o(L, 0, 1), lt = (e) => {
58
+ let t = ot(e);
59
+ z(t), R(t.getFullYear());
60
+ }, ut = (e) => {
61
+ let t = L + e, n = ot(i(q, e * 12));
62
+ R(t), z(n.getFullYear() === t ? n : null);
63
+ }, dt = T(B, l, u), J = Ve !== null && w(Ve, B) ? Ve : t && w(t.getFullYear(), B) ? t.getFullYear() : G && w(G.getFullYear(), B) ? G.getFullYear() : w(dt, B) ? dt : B, ft = (e, t) => {
64
+ let n = T(e, l, u);
65
+ V(n), Be(w(n, t) ? t : v(n));
66
+ }, pt = (e) => {
67
+ let t = B + e * 10, n = T(J + e * 10, l, u);
68
+ Be(t), V(w(n, t) ? n : null);
69
+ }, Y = (e) => {
70
+ He.current = !0, Le(e);
71
+ }, mt = () => {
72
+ let e = g(M ?? s(/* @__PURE__ */ new Date()), l, u);
73
+ F(c(e)), I(e), We((e) => e + 1), Y("day");
74
+ }, ht = () => {
75
+ I(K), R(K.getFullYear()), z(c(K)), Y("month");
76
+ }, gt = () => {
77
+ z(q), Be(v(q.getFullYear())), V(q.getFullYear()), Y("year");
78
+ }, _t = (e) => {
79
+ let t = (e.getFullYear() - K.getFullYear()) * 12 + (e.getMonth() - K.getMonth()), n = g(i(K, t), l, u);
80
+ F(e), I(y(n, e) ? n : null), Y("day");
81
+ }, vt = (e) => {
82
+ let t = e.getFullYear(), n = ot(o(t, q.getMonth(), 1));
83
+ R(t), z(n.getFullYear() === t ? n : null), Y("month");
84
+ }, yt = (e) => {
85
+ e.key === "Escape" && N !== "day" && ce(e) && (e.defaultPrevented || e.nativeEvent.isComposing || (e.preventDefault(), Y(N === "year" ? "month" : "day")));
86
+ }, bt = N === "day" ? _(P) : N === "month" ? L : B, xt = N === "day" ? et : N === "month" ? _(q) : J, St = x.useRef(null), Ct = x.useRef(!1);
87
+ x.useEffect(() => {
88
+ let e = (e) => {
89
+ let t = e.target;
90
+ Ct.current = !!t && (!!H.current?.contains(t) || !!St.current?.contains(t));
91
+ };
92
+ return document.addEventListener("focusin", e), () => document.removeEventListener("focusin", e);
93
+ }, []);
94
+ let wt = x.useRef(N);
95
+ x.useLayoutEffect(() => {
96
+ let e = wt.current !== N;
97
+ wt.current = N;
98
+ let t = He.current;
99
+ He.current = !1;
100
+ let n = H.current;
101
+ if (!n) return;
102
+ let r = n.ownerDocument.activeElement, i = e && Ct.current && (!r || r === n.ownerDocument.body);
103
+ if (!t && !i && (!r || !n.contains(r))) return;
104
+ let a = n.querySelector("button[tabindex=\"0\"]");
105
+ a && a !== r && a.focus();
106
+ }, [
107
+ N,
108
+ bt,
109
+ xt,
110
+ Ue
111
+ ]);
112
+ let Tt, Et, X, Z, Q, $;
113
+ N === "day" ? (Tt = k?.previousMonth ?? "Previous month", Et = k?.nextMonth ?? "Next month", X = !!l && r(P, -1) < s(l), Z = !!u && i(P, 1) > s(u), Q = nt, $ = de(P, p)) : N === "month" ? (Tt = k?.previousYear ?? "Previous year", Et = k?.nextYear ?? "Next year", X = b(L - 1, l, u), Z = b(L + 1, l, u), Q = ut, $ = fe(o(L, 0, 1), p)) : (Tt = k?.previousDecade ?? "Previous decade", Et = k?.nextDecade ?? "Next decade", X = b(B - 1, l, void 0) || b(B - 10, void 0, u), Z = b(B + 10, void 0, u) || b(B + 19, l, void 0), Q = pt, $ = le(B, p));
114
+ let Dt = !!M && !_e(M, l, u), Ot = se && N !== "year" ? N : null, kt = N === "day" ? k?.chooseMonth ?? "Choose a month" : k?.chooseYear ?? "Choose a year", At;
115
+ if (N === "day") At = /* @__PURE__ */ S(xe, {
116
+ ref: H,
117
+ id: U,
118
+ headingId: A,
119
+ viewMonth: P,
120
+ weeks: W,
121
+ focusTarget: K,
122
+ selectedDays: Xe,
123
+ today: M,
124
+ firstDayOfWeek: d,
125
+ locale: p,
126
+ showWeekNumbers: be,
127
+ firstWeekOfYear: E,
128
+ markedDates: ke,
129
+ renderDay: D,
130
+ dayLabel: Ae,
131
+ labels: k,
132
+ isUnavailable: Ye,
133
+ onMoveFocus: tt,
134
+ onDayFocus: rt,
135
+ onPick: n,
136
+ partClassNames: j
137
+ });
138
+ else if (N === "month") {
139
+ let e = ge(L);
140
+ At = /* @__PURE__ */ S(Se, {
141
+ ref: H,
142
+ id: U,
143
+ headingId: A,
144
+ cells: e.map((e) => ({
145
+ date: e,
146
+ text: ue(e, p),
147
+ label: de(e, p),
148
+ selected: !!t && y(e, t),
149
+ current: !!M && y(e, M),
150
+ outside: !1,
151
+ unavailable: ye(e, l, u)
152
+ })),
153
+ focusIndex: q.getMonth(),
154
+ onMoveFocus: (e) => lt(i(q, e)),
155
+ onPage: (e) => lt(i(q, e * 12)),
156
+ onCellFocus: (e) => {
157
+ y(e, q) || z(e);
158
+ },
159
+ onPick: _t,
160
+ onKeyDown: yt,
161
+ partClassNames: {
162
+ grid: j?.grid,
163
+ cell: j?.month
164
+ }
165
+ });
166
+ } else {
167
+ let e = me(B);
168
+ At = /* @__PURE__ */ S(Se, {
169
+ ref: H,
170
+ id: U,
171
+ headingId: A,
172
+ cells: e.map((e) => {
173
+ let n = e.getFullYear();
174
+ return {
175
+ date: e,
176
+ text: fe(e, p),
177
+ selected: t?.getFullYear() === n,
178
+ current: M?.getFullYear() === n,
179
+ outside: n < B || n > B + 9,
180
+ unavailable: b(n, l, u)
181
+ };
182
+ }),
183
+ focusIndex: J - (B - 1),
184
+ onMoveFocus: (e) => ft(J + e, B),
185
+ onPage: (e) => ft(J + e * 10, B + e * 10),
186
+ onCellFocus: (e) => {
187
+ e.getFullYear() !== J && V(e.getFullYear());
188
+ },
189
+ onPick: vt,
190
+ onKeyDown: yt,
191
+ partClassNames: {
192
+ grid: j?.grid,
193
+ cell: j?.year
194
+ }
195
+ });
196
+ }
197
+ return /* @__PURE__ */ C(Ce, { children: [
198
+ /* @__PURE__ */ C("div", {
199
+ ref: St,
200
+ className: e(j?.header, "mb-2 flex items-center justify-between gap-2"),
201
+ onKeyDown: yt,
202
+ children: [
203
+ /* @__PURE__ */ S("button", {
204
+ type: "button",
205
+ "aria-label": Tt,
206
+ "aria-controls": U,
207
+ ...ne(X),
208
+ onClick: f(X, () => Q(-1)),
209
+ className: e(j?.previousMonthButton, we, h, m),
210
+ children: /* @__PURE__ */ S(ie, { className: "wave-rtl:-scale-x-100" })
211
+ }),
212
+ /* @__PURE__ */ S(Fe, {
213
+ id: A,
214
+ "aria-live": "polite",
215
+ className: e(j?.heading, "text-body-1 font-semibold"),
216
+ children: Ot ? /* @__PURE__ */ S("button", {
217
+ type: "button",
218
+ "aria-describedby": Ge,
219
+ onClick: Ot === "day" ? ht : gt,
220
+ className: e(j?.headingButton, Te, h),
221
+ children: $
222
+ }) : $
223
+ }),
224
+ Ot && /* @__PURE__ */ S("span", {
225
+ id: Ge,
226
+ hidden: !0,
227
+ children: kt
228
+ }),
229
+ /* @__PURE__ */ S("button", {
230
+ type: "button",
231
+ "aria-label": Et,
232
+ "aria-controls": U,
233
+ ...ne(Z),
234
+ onClick: f(Z, () => Q(1)),
235
+ className: e(j?.nextMonthButton, we, h, m),
236
+ children: /* @__PURE__ */ S(ae, { className: "wave-rtl:-scale-x-100" })
237
+ })
238
+ ]
239
+ }),
240
+ At,
241
+ (Ne || O) && /* @__PURE__ */ C("div", {
242
+ className: e(j?.footer, "mt-2 flex items-center justify-end gap-2"),
243
+ onKeyDown: yt,
244
+ children: [Ne && /* @__PURE__ */ S("button", {
245
+ type: "button",
246
+ disabled: Dt,
247
+ onClick: mt,
248
+ className: e(j?.todayButton, Ee, "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100"),
249
+ children: k?.goToToday ?? "Go to today"
250
+ }), O && /* @__PURE__ */ S("button", {
251
+ type: "button",
252
+ onClick: O,
253
+ className: e(j?.closeButton, Ee, "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100"),
254
+ children: Pe ?? "Close"
255
+ })]
256
+ })
257
+ ] });
258
+ };
259
+ E.displayName = "CalendarView";
260
+ var ke = {
261
+ header: n.header,
262
+ previousMonthButton: n.previousButton,
263
+ heading: n.heading,
264
+ headingButton: n.headingButton,
265
+ nextMonthButton: n.nextButton,
266
+ grid: n.grid,
267
+ weekday: n.weekday,
268
+ day: n.day,
269
+ month: n.month,
270
+ year: n.year,
271
+ weekNumberHeader: n.weekNumberHeader,
272
+ weekNumber: n.weekNumber,
273
+ markedDot: n.markedDot,
274
+ footer: n.footer,
275
+ todayButton: n.todayButton
276
+ }, D = ({ value: r, defaultValue: i, onValueChange: o, minDate: c, maxDate: ne, disabledDates: f, firstDayOfWeek: m = 0, locale: h, today: ie, initialVisibleDate: ae, showMonthPicker: ce = !0, showWeekNumbers: g, firstWeekOfYear: le, showGoToToday: ue, markedDates: de, renderDay: fe, dayLabel: pe, selectionRange: v = "day", workWeekDays: me, labels: ge, name: _e, form: ye, required: y, id: b, "aria-label": xe, "aria-labelledby": Se, "aria-describedby": Ce, "aria-invalid": we, "aria-required": Te, className: Ee, ref: Oe, ...w }) => {
277
+ let T = (e) => ve(e, c, ne, f), [D, Ae] = l(r, i ?? null, (e) => o?.(e, { range: e ? he(e, v, m, me ?? De, T) : [] })), je = (e) => {
278
+ let t = e ? s(e) : null;
279
+ (t ? a(t, D) : D === null) || Ae(t);
280
+ }, Me = te(), Ne = ie ?? (Me ? /* @__PURE__ */ new Date() : null);
281
+ x.useEffect(() => {
282
+ h !== void 0 && !be(h) && t(`Calendar:invalid-locale:${h}`, `Calendar: \`locale\` "${h}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats the dates instead, so the server and the browser may render different text.`);
283
+ }, [h]);
284
+ let O = ie !== void 0 || ae !== void 0 || D !== null;
285
+ x.useEffect(() => {
286
+ !Me && !O && t("Calendar:hydration-date", "Calendar: rendered on the server without `today`, `initialVisibleDate` or `value`, so the month shown first comes from the server's clock and the browser may show another month. Pass `today` or `initialVisibleDate`.");
287
+ }, [Me, O]);
288
+ let Pe = p(), { "aria-required": k, "aria-describedby": Fe, ...A } = re({
289
+ id: b,
290
+ "aria-label": xe,
291
+ "aria-labelledby": Se,
292
+ "aria-describedby": Ce,
293
+ "aria-invalid": we,
294
+ "aria-required": Te ?? y
295
+ }, { labelable: !1 }), j = y ?? Pe?.required ?? !1, M = ee("calendar-required"), Ie = k !== void 0 && String(k) !== "false", Le = ee("calendar-heading"), N = x.useRef(null), P = u(Oe, N);
296
+ oe(N, () => je(i ?? null), ye);
297
+ let F = () => {
298
+ N.current?.querySelector("[data-wave-calendar-grid] button[tabindex=\"0\"]")?.focus();
299
+ };
300
+ return /* @__PURE__ */ C("div", {
301
+ role: "group",
302
+ ...A,
303
+ "aria-describedby": d(Fe, Ie && M),
304
+ className: e(n.root, "relative inline-flex flex-col text-foreground", Ee),
305
+ ...w,
306
+ ref: P,
307
+ children: [
308
+ /* @__PURE__ */ S(E, {
309
+ value: D,
310
+ onPick: je,
311
+ minDate: c,
312
+ maxDate: ne,
313
+ disabledDates: f,
314
+ firstDayOfWeek: m,
315
+ locale: h,
316
+ today: Ne,
317
+ initialVisibleDate: ae,
318
+ showMonthPicker: ce,
319
+ showWeekNumbers: g,
320
+ firstWeekOfYear: le,
321
+ showGoToToday: ue,
322
+ markedDates: de,
323
+ renderDay: fe,
324
+ dayLabel: pe,
325
+ selectionRange: v,
326
+ workWeekDays: me,
327
+ labels: ge,
328
+ headingAs: "div",
329
+ headingId: Le,
330
+ partClassNames: ke
331
+ }),
332
+ Ie && /* @__PURE__ */ S("span", {
333
+ id: M,
334
+ hidden: !0,
335
+ children: ge?.required ?? "Required"
336
+ }),
337
+ /* @__PURE__ */ S(se, {
338
+ type: "text",
339
+ name: _e,
340
+ form: ye,
341
+ value: D ? _(D) : "",
342
+ required: j,
343
+ onInvalid: F
344
+ })
345
+ ]
346
+ });
347
+ };
348
+ D.displayName = "Calendar";
349
+ //#endregion
350
+ export { D as Calendar, E as CalendarView };
351
+
352
+ //# sourceMappingURL=Calendar.mjs.map