@servicetitan/anvil2 1.46.2 → 1.46.4

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 (180) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{Avatar-CyGjhToG.js → Avatar-3d5Kv2CF.js} +2 -2
  3. package/dist/{Avatar-CyGjhToG.js.map → Avatar-3d5Kv2CF.js.map} +1 -1
  4. package/dist/{Avatar-D07f9NH_.js → Avatar-DJ3oJNsv.js} +2 -2
  5. package/dist/{Avatar-D07f9NH_.js.map → Avatar-DJ3oJNsv.js.map} +1 -1
  6. package/dist/Avatar.js +2 -2
  7. package/dist/{Calendar-X9qUi6Vx.js → Calendar-BqOvsaby.js} +246 -195
  8. package/dist/Calendar-BqOvsaby.js.map +1 -0
  9. package/dist/Calendar.js +1 -1
  10. package/dist/{Checkbox-CcYtto5f.js → Checkbox-C5PX8wur.js} +2 -2
  11. package/dist/{Checkbox-CcYtto5f.js.map → Checkbox-C5PX8wur.js.map} +1 -1
  12. package/dist/{Checkbox-BDohwHXQ.js → Checkbox-DAODkzN3.js} +2 -2
  13. package/dist/{Checkbox-BDohwHXQ.js.map → Checkbox-DAODkzN3.js.map} +1 -1
  14. package/dist/Checkbox.js +2 -2
  15. package/dist/{Chip-Bz-vlQ4D.js → Chip-DLU13qe-.js} +2 -2
  16. package/dist/{Chip-Bz-vlQ4D.js.map → Chip-DLU13qe-.js.map} +1 -1
  17. package/dist/Chip.js +1 -1
  18. package/dist/{Combobox-DQmW8Tyl.js → Combobox-DO8cIvRQ.js} +6 -6
  19. package/dist/{Combobox-DQmW8Tyl.js.map → Combobox-DO8cIvRQ.js.map} +1 -1
  20. package/dist/Combobox.js +1 -1
  21. package/dist/{DateField-C43nfkbx.js → DateField-DLqKbCcm.js} +35 -101
  22. package/dist/DateField-DLqKbCcm.js.map +1 -0
  23. package/dist/DateField.js +1 -1
  24. package/dist/{DateFieldRange-g7n5QYww.js → DateFieldRange-DI-iF-sd.js} +54 -55
  25. package/dist/DateFieldRange-DI-iF-sd.js.map +1 -0
  26. package/dist/DateFieldRange.js +1 -1
  27. package/dist/{DateFieldSingle-D3tneqeG.js → DateFieldSingle-BXakaSIE.js} +50 -52
  28. package/dist/DateFieldSingle-BXakaSIE.js.map +1 -0
  29. package/dist/DateFieldSingle.js +1 -1
  30. package/dist/{DateFieldYearless-3JBVj3wn.js → DateFieldYearless-BmeKGaDc.js} +2 -2
  31. package/dist/{DateFieldYearless-3JBVj3wn.js.map → DateFieldYearless-BmeKGaDc.js.map} +1 -1
  32. package/dist/DateFieldYearless.js +1 -1
  33. package/dist/{DaysOfTheWeek-RcPgDoM3.js → DaysOfTheWeek-DPH13VCK.js} +3 -3
  34. package/dist/{DaysOfTheWeek-RcPgDoM3.js.map → DaysOfTheWeek-DPH13VCK.js.map} +1 -1
  35. package/dist/DaysOfTheWeek.js +1 -1
  36. package/dist/{Dialog-FNJ16gY6.js → Dialog-xsgqM6e1.js} +13 -20
  37. package/dist/Dialog-xsgqM6e1.js.map +1 -0
  38. package/dist/Dialog.js +1 -1
  39. package/dist/DndSort.js +46 -6
  40. package/dist/DndSort.js.map +1 -1
  41. package/dist/{Drawer-DT31CMRd.js → Drawer-DpN7wUNy.js} +14 -21
  42. package/dist/Drawer-DpN7wUNy.js.map +1 -0
  43. package/dist/Drawer.js +1 -1
  44. package/dist/{FieldLabel-BP8QK5UR.js → FieldLabel-Bgl3iu13.js} +2 -2
  45. package/dist/{FieldLabel-BP8QK5UR.js.map → FieldLabel-Bgl3iu13.js.map} +1 -1
  46. package/dist/FieldLabel.js +1 -1
  47. package/dist/{InputMask-CPuYMcw9.js → InputMask-B13KumrK.js} +2 -2
  48. package/dist/{InputMask-CPuYMcw9.js.map → InputMask-B13KumrK.js.map} +1 -1
  49. package/dist/InputMask.js +1 -1
  50. package/dist/{ListView-BJI8BQJ-.js → ListView-C-cVQZHp.js} +3 -3
  51. package/dist/{ListView-BJI8BQJ-.js.map → ListView-C-cVQZHp.js.map} +1 -1
  52. package/dist/ListView.js +1 -1
  53. package/dist/{Listbox-CUhMbFm2.js → Listbox-DxGx630W.js} +2 -2
  54. package/dist/{Listbox-CUhMbFm2.js.map → Listbox-DxGx630W.js.map} +1 -1
  55. package/dist/Listbox.js +1 -1
  56. package/dist/{Menu-t_11BIhU.js → Menu-DUZqzpwg.js} +6 -8
  57. package/dist/Menu-DUZqzpwg.js.map +1 -0
  58. package/dist/Menu.js +1 -1
  59. package/dist/{NumberField-Bjf9Tyvf.js → NumberField-DWPAy1eG.js} +7 -7
  60. package/dist/{NumberField-Bjf9Tyvf.js.map → NumberField-DWPAy1eG.js.map} +1 -1
  61. package/dist/NumberField.css +9 -6
  62. package/dist/NumberField.js +1 -1
  63. package/dist/{Page-BAyXnhz2.js → Page-CRuqAlNu.js} +7 -7
  64. package/dist/{Page-BAyXnhz2.js.map → Page-CRuqAlNu.js.map} +1 -1
  65. package/dist/Page.js +1 -1
  66. package/dist/{Pagination-DCBic619.js → Pagination-B_G9QcHf.js} +3 -3
  67. package/dist/{Pagination-DCBic619.js.map → Pagination-B_G9QcHf.js.map} +1 -1
  68. package/dist/Pagination.js +1 -1
  69. package/dist/{Popover-CrksxqKk.js → Popover-v8R920kj.js} +135 -200
  70. package/dist/Popover-v8R920kj.js.map +1 -0
  71. package/dist/Popover.js +1 -1
  72. package/dist/{ProgressBar-CgsAW2d8.js → ProgressBar-BWN2yv1s.js} +2 -2
  73. package/dist/{ProgressBar-CgsAW2d8.js.map → ProgressBar-BWN2yv1s.js.map} +1 -1
  74. package/dist/ProgressBar.js +1 -1
  75. package/dist/{Radio-C_rvxw74.js → Radio-C5riI-do.js} +2 -2
  76. package/dist/{Radio-C_rvxw74.js.map → Radio-C5riI-do.js.map} +1 -1
  77. package/dist/Radio.js +2 -2
  78. package/dist/{RadioGroup-DxBblSrx.js → RadioGroup-B7O06pVu.js} +2 -2
  79. package/dist/{RadioGroup-DxBblSrx.js.map → RadioGroup-B7O06pVu.js.map} +1 -1
  80. package/dist/{SearchField-Bb0uObwG.js → SearchField-CbwGErC4.js} +2 -2
  81. package/dist/{SearchField-Bb0uObwG.js.map → SearchField-CbwGErC4.js.map} +1 -1
  82. package/dist/SearchField.js +1 -1
  83. package/dist/{SegmentedControl-DC4BpdH5.js → SegmentedControl-CLDdes8W.js} +2 -2
  84. package/dist/{SegmentedControl-DC4BpdH5.js.map → SegmentedControl-CLDdes8W.js.map} +1 -1
  85. package/dist/SegmentedControl.js +1 -1
  86. package/dist/{SelectCard-DunNE9R3.js → SelectCard-Ca07K1FW.js} +3 -3
  87. package/dist/{SelectCard-DunNE9R3.js.map → SelectCard-Ca07K1FW.js.map} +1 -1
  88. package/dist/SelectCard.js +1 -1
  89. package/dist/{SelectTrigger-BYysLREL.js → SelectTrigger-CaXX1SHG.js} +3 -3
  90. package/dist/{SelectTrigger-BYysLREL.js.map → SelectTrigger-CaXX1SHG.js.map} +1 -1
  91. package/dist/SelectTrigger.js +1 -1
  92. package/dist/{SelectTriggerBase-DqUpJgzk.js → SelectTriggerBase-C7TLCna1.js} +3 -3
  93. package/dist/{SelectTriggerBase-DqUpJgzk.js.map → SelectTriggerBase-C7TLCna1.js.map} +1 -1
  94. package/dist/{SideNav-B9AWmF_H.js → SideNav-nqq5sAwz.js} +2 -2
  95. package/dist/{SideNav-B9AWmF_H.js.map → SideNav-nqq5sAwz.js.map} +1 -1
  96. package/dist/SideNav.js +1 -1
  97. package/dist/{Stepper-DHTrvfXw.js → Stepper-DQ_Hm-AI.js} +2 -2
  98. package/dist/{Stepper-DHTrvfXw.js.map → Stepper-DQ_Hm-AI.js.map} +1 -1
  99. package/dist/Stepper.js +1 -1
  100. package/dist/{Tab-0zx9hsw8.js → Tab-CzNx3IdF.js} +2 -2
  101. package/dist/{Tab-0zx9hsw8.js.map → Tab-CzNx3IdF.js.map} +1 -1
  102. package/dist/Tab.js +1 -1
  103. package/dist/{TextField-CFWs3lm9.js → TextField-D9gD-34Q.js} +3 -3
  104. package/dist/{TextField-CFWs3lm9.js.map → TextField-D9gD-34Q.js.map} +1 -1
  105. package/dist/{TextField-Cge6IRo5.js → TextField-uCHgwO5F.js} +2 -2
  106. package/dist/{TextField-Cge6IRo5.js.map → TextField-uCHgwO5F.js.map} +1 -1
  107. package/dist/TextField.js +1 -1
  108. package/dist/{Textarea-CXd3NKkW.js → Textarea-B2-6m291.js} +3 -3
  109. package/dist/{Textarea-CXd3NKkW.js.map → Textarea-B2-6m291.js.map} +1 -1
  110. package/dist/Textarea.js +1 -1
  111. package/dist/{TimeField-4v5aCwiG.js → TimeField-B5Jgy-Zg.js} +21 -8
  112. package/dist/TimeField-B5Jgy-Zg.js.map +1 -0
  113. package/dist/TimeField.js +1 -1
  114. package/dist/Toast.js +2 -2
  115. package/dist/{Toaster-bON5Xc1P.js → Toaster-CHyB-Mxs.js} +3 -3
  116. package/dist/{Toaster-bON5Xc1P.js.map → Toaster-CHyB-Mxs.js.map} +1 -1
  117. package/dist/{Toaster-D-rNSLTq.js → Toaster-CyiGDKMh.js} +3 -3
  118. package/dist/{Toaster-D-rNSLTq.js.map → Toaster-CyiGDKMh.js.map} +1 -1
  119. package/dist/{Toolbar-B2Jsuptz.js → Toolbar-DNErV9v8.js} +16 -15
  120. package/dist/Toolbar-DNErV9v8.js.map +1 -0
  121. package/dist/Toolbar.js +1 -1
  122. package/dist/{Tooltip-CtCLw_vx.js → Tooltip-DhtVlhah.js} +2 -2
  123. package/dist/{Tooltip-CtCLw_vx.js.map → Tooltip-DhtVlhah.js.map} +1 -1
  124. package/dist/Tooltip.js +1 -1
  125. package/dist/beta.js +1 -1
  126. package/dist/components/Calendar/Calendar.d.ts +5 -0
  127. package/dist/components/Calendar/CalendarNowButton.d.ts +3 -1
  128. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  129. package/dist/components/Dialog/internal/useInitialFocus.d.ts +15 -0
  130. package/dist/components/DndSort/internal/DndSortOverlay.d.ts +1 -1
  131. package/dist/components/NumberField/NumberField.d.ts +2 -2
  132. package/dist/components/Popover/Popover.d.ts +136 -1
  133. package/dist/components/Popover/PopoverTrigger.d.ts +0 -1
  134. package/dist/components/Popover/internal/PopoverContext.d.ts +5 -3
  135. package/dist/components/Popover/internal/usePopoverContext.d.ts +6 -4
  136. package/dist/components/Radio/Radio.d.ts +1 -1
  137. package/dist/hooks/useMergeRefs/useMergeRefs.d.ts +11 -0
  138. package/dist/index.js +43 -43
  139. package/dist/internal/components/index.d.ts +1 -0
  140. package/dist/internal/hooks/index.d.ts +2 -2
  141. package/dist/internal/hooks/useFocusWithin/useFocusWithin.d.ts +2 -1
  142. package/dist/internal/hooks/useKeyboardFocusables/useKeyboardFocusables.d.ts +0 -1
  143. package/dist/internal/hooks/useOnClickOutside/useOnClickOutside.d.ts +5 -1
  144. package/dist/internal/hooks/usePlatform/index.d.ts +1 -1
  145. package/dist/internal/index.d.ts +5 -0
  146. package/dist/internal/types/argTypes.d.ts +154 -0
  147. package/dist/internal/types/index.d.ts +1 -0
  148. package/dist/{useFocusWithin-BhhgRXdZ.js → useFocusWithin-hi77jsrB.js} +6 -3
  149. package/dist/useFocusWithin-hi77jsrB.js.map +1 -0
  150. package/dist/useInitialFocus-CAFMgbJG.js +130 -0
  151. package/dist/useInitialFocus-CAFMgbJG.js.map +1 -0
  152. package/dist/useMergeRefs-Dfmtq9cI.js +22 -0
  153. package/dist/useMergeRefs-Dfmtq9cI.js.map +1 -0
  154. package/dist/useMergeRefs.js +1 -1
  155. package/dist/{useOnClickOutside-B1ddwORK.js → useOnClickOutside-C5AZE_I6.js} +6 -65
  156. package/dist/useOnClickOutside-C5AZE_I6.js.map +1 -0
  157. package/dist/utils-Dh3aegV3.js +50 -0
  158. package/dist/utils-Dh3aegV3.js.map +1 -0
  159. package/package.json +1 -1
  160. package/dist/Calendar-X9qUi6Vx.js.map +0 -1
  161. package/dist/DateField-C43nfkbx.js.map +0 -1
  162. package/dist/DateFieldRange-g7n5QYww.js.map +0 -1
  163. package/dist/DateFieldSingle-D3tneqeG.js.map +0 -1
  164. package/dist/Dialog-FNJ16gY6.js.map +0 -1
  165. package/dist/Drawer-DT31CMRd.js.map +0 -1
  166. package/dist/Menu-t_11BIhU.js.map +0 -1
  167. package/dist/Popover-CrksxqKk.js.map +0 -1
  168. package/dist/TimeField-4v5aCwiG.js.map +0 -1
  169. package/dist/Toolbar-B2Jsuptz.js.map +0 -1
  170. package/dist/components/DateFieldSingle/internal/useDateFieldOrchestration.d.ts +0 -17
  171. package/dist/useDateFieldOrchestration-DyAc3gPJ.js +0 -138
  172. package/dist/useDateFieldOrchestration-DyAc3gPJ.js.map +0 -1
  173. package/dist/useDialogTransitionStates-C1TtiwA_.js +0 -64
  174. package/dist/useDialogTransitionStates-C1TtiwA_.js.map +0 -1
  175. package/dist/useFocusWithin-BhhgRXdZ.js.map +0 -1
  176. package/dist/useMergeRefs-Bde85AWI.js +0 -21
  177. package/dist/useMergeRefs-Bde85AWI.js.map +0 -1
  178. package/dist/useOnClickOutside-B1ddwORK.js.map +0 -1
  179. package/dist/usePopoverCloseDelayWorkaround-BZcjPkvT.js +0 -18
  180. package/dist/usePopoverCloseDelayWorkaround-BZcjPkvT.js.map +0 -1
@@ -9,8 +9,8 @@ import { c as cx } from './index-tZvMCc77.js';
9
9
  import { S as SrOnly } from './SrOnly-CTsYSuby.js';
10
10
  import { u as useSwipe } from './useSwipe-Cp-CJxLU.js';
11
11
  import { G as Grid } from './Grid-MGUC698u.js';
12
- import { S as SelectCard } from './SelectCard-DunNE9R3.js';
13
- import { u as useMergeRefs } from './useMergeRefs-Bde85AWI.js';
12
+ import { S as SelectCard } from './SelectCard-Ca07K1FW.js';
13
+ import { u as useMergeRefs } from './useMergeRefs-Dfmtq9cI.js';
14
14
  import { flushSync } from 'react-dom';
15
15
  import { u as useOptionallyControlledState } from './useOptionallyControlledState-DbDuos5L.js';
16
16
  import { u as usePrevious } from './usePrevious-Bvq-5auG.js';
@@ -8252,7 +8252,7 @@ function rangeUpdater(value, newDate, setValue, onSelection) {
8252
8252
 
8253
8253
  const CalendarNow = forwardRef(
8254
8254
  (props, ref) => {
8255
- const { onClick, ...rest } = props;
8255
+ const { onClick, onClickFixed, ...rest } = props;
8256
8256
  const {
8257
8257
  setFocusedDate,
8258
8258
  setSelectedMonth,
@@ -8271,7 +8271,8 @@ const CalendarNow = forwardRef(
8271
8271
  const nToday = DateTime.fromISO(DateTime.now().toISO(), {
8272
8272
  zone: defaultTimeZone
8273
8273
  }).startOf("day");
8274
- const onClickHandler = () => {
8274
+ const onClickHandler = (e) => {
8275
+ onClickFixed?.(e);
8275
8276
  setFocusedDate(nToday);
8276
8277
  setSelectedMonth(nToday.month);
8277
8278
  setSelectedYear(nToday.year);
@@ -9102,153 +9103,6 @@ const CalendarMonth = forwardRef(
9102
9103
  );
9103
9104
  CalendarMonth.displayName = "CalendarMonth";
9104
9105
 
9105
- const CalendarMonthSelection = forwardRef(({ onMonthSelection, ...props }, ref) => {
9106
- const { defaultTimeZone, maxDate, minDate, selectedMonth, selectedYear } = useCalendar();
9107
- const monthSelectionRef = useRef(null);
9108
- const combinedRef = useMergeRefs([ref, monthSelectionRef]);
9109
- const currentDate = useMemo(
9110
- () => DateTime.fromObject({ year: selectedYear, month: selectedMonth }).setZone(defaultTimeZone).startOf("day"),
9111
- [defaultTimeZone, selectedYear, selectedMonth]
9112
- );
9113
- const dates = useMemo(
9114
- () => Array.from({ length: 12 }, (_, i) => {
9115
- const date = DateTime.fromObject({
9116
- year: selectedYear,
9117
- month: 1
9118
- }).plus({
9119
- month: i
9120
- });
9121
- const disabled = minDate && date < minDate && !date.hasSame(minDate, "month") || maxDate && date > maxDate && !date.hasSame(maxDate, "month");
9122
- return {
9123
- month: date.month,
9124
- disabled: disabled ?? false
9125
- };
9126
- }),
9127
- [maxDate, minDate, selectedYear]
9128
- );
9129
- const classes = cx(styles$1["month-selection"], props.className);
9130
- const [focusedIndex, setFocusedIndex] = useState(selectedMonth - 1);
9131
- useEffect(() => {
9132
- if (minDate || maxDate) {
9133
- let index = dates.findIndex(({ month }) => month === selectedMonth);
9134
- while (dates[index].disabled && index < 11) {
9135
- index++;
9136
- }
9137
- setFocusedIndex(index);
9138
- } else {
9139
- setFocusedIndex(selectedMonth - 1);
9140
- }
9141
- }, [selectedMonth, minDate, maxDate, dates]);
9142
- const handleKeyDown = useCallback(
9143
- (e) => {
9144
- const target = e.target;
9145
- const cards = monthSelectionRef.current?.querySelectorAll(
9146
- "input[type='checkbox']"
9147
- );
9148
- if (!cards || cards.length === 0) {
9149
- return;
9150
- }
9151
- const cardArray = Array.from(cards);
9152
- const currentIndex = cardArray.indexOf(target);
9153
- if (currentIndex === -1) return;
9154
- const updateFocusedIndex = (index) => {
9155
- e.preventDefault();
9156
- cardArray[index].focus();
9157
- setFocusedIndex(index);
9158
- };
9159
- let newIndex;
9160
- switch (e.key) {
9161
- case "ArrowLeft":
9162
- newIndex = currentIndex > 0 ? currentIndex - 1 : 11;
9163
- while (dates[newIndex].disabled) {
9164
- newIndex = newIndex > 0 ? newIndex - 1 : 11;
9165
- }
9166
- updateFocusedIndex(newIndex);
9167
- break;
9168
- case "ArrowRight":
9169
- newIndex = currentIndex < 11 ? currentIndex + 1 : 0;
9170
- while (dates[newIndex].disabled) {
9171
- newIndex = newIndex < 11 ? newIndex + 1 : 0;
9172
- }
9173
- updateFocusedIndex(newIndex);
9174
- break;
9175
- case "ArrowUp":
9176
- if (currentIndex < 3) {
9177
- newIndex = currentIndex + 9;
9178
- } else {
9179
- newIndex = currentIndex - 3;
9180
- }
9181
- while (dates[newIndex].disabled) {
9182
- if (newIndex > 2) {
9183
- newIndex -= 3;
9184
- } else {
9185
- newIndex += 9;
9186
- }
9187
- }
9188
- updateFocusedIndex(newIndex);
9189
- break;
9190
- case "ArrowDown":
9191
- if (currentIndex > 8) {
9192
- newIndex = currentIndex - 9;
9193
- } else {
9194
- newIndex = currentIndex + 3;
9195
- }
9196
- while (dates[newIndex].disabled) {
9197
- if (newIndex < 9) {
9198
- newIndex += 3;
9199
- } else {
9200
- newIndex -= 9;
9201
- }
9202
- }
9203
- updateFocusedIndex(newIndex);
9204
- break;
9205
- case "Enter":
9206
- case " ":
9207
- e.preventDefault();
9208
- if (!dates[currentIndex].disabled) {
9209
- onMonthSelection(dates[currentIndex].month);
9210
- }
9211
- break;
9212
- }
9213
- },
9214
- [dates, onMonthSelection]
9215
- );
9216
- return /* @__PURE__ */ jsx(
9217
- "div",
9218
- {
9219
- ref: combinedRef,
9220
- "data-anv": "calendar-month-selection",
9221
- className: classes,
9222
- ...props,
9223
- children: /* @__PURE__ */ jsx("div", { role: "grid", "aria-label": "Calendar month selection", children: /* @__PURE__ */ jsx(
9224
- Grid,
9225
- {
9226
- templateColumns: "repeat(3, minmax(0, 1fr))",
9227
- gap: 3,
9228
- onKeyDown: handleKeyDown,
9229
- role: "row",
9230
- children: dates.map(({ month, disabled }, index) => /* @__PURE__ */ jsx("div", { role: "gridcell", children: /* @__PURE__ */ jsx(
9231
- SelectCard,
9232
- {
9233
- id: month.toString(),
9234
- disabled,
9235
- onChange: () => onMonthSelection(month),
9236
- checked: selectedMonth === month && selectedYear === currentDate.year,
9237
- checkboxProps: {
9238
- className: styles$1["selection-checkbox"],
9239
- tabIndex: focusedIndex === index ? 0 : -1
9240
- },
9241
- className: styles$1["selection-card"],
9242
- children: DateTime.fromObject({ month }).toFormat("MMMM")
9243
- }
9244
- ) }, month.toString()))
9245
- }
9246
- ) })
9247
- }
9248
- );
9249
- });
9250
- CalendarMonthSelection.displayName = "CalendarMonthSelection";
9251
-
9252
9106
  function memo(getDeps, fn, opts) {
9253
9107
  let deps = opts.initialDeps ?? [];
9254
9108
  let result;
@@ -10364,6 +10218,154 @@ const YearSelector = forwardRef(
10364
10218
  );
10365
10219
  YearSelector.displayName = "YearSelector";
10366
10220
 
10221
+ const CalendarMonthSelection = forwardRef(({ onMonthSelection, ...props }, ref) => {
10222
+ const { defaultTimeZone, maxDate, minDate, selectedMonth, selectedYear } = useCalendar();
10223
+ const monthSelectionRef = useRef(null);
10224
+ const combinedRef = useMergeRefs([ref, monthSelectionRef]);
10225
+ const currentDate = useMemo(
10226
+ () => DateTime.fromObject({ year: selectedYear, month: selectedMonth }).setZone(defaultTimeZone).startOf("day"),
10227
+ [defaultTimeZone, selectedYear, selectedMonth]
10228
+ );
10229
+ const dates = useMemo(
10230
+ () => Array.from({ length: 12 }, (_, i) => {
10231
+ const date = DateTime.fromObject({
10232
+ year: selectedYear,
10233
+ month: 1
10234
+ }).plus({
10235
+ month: i
10236
+ });
10237
+ const disabled = minDate && date < minDate && !date.hasSame(minDate, "month") || maxDate && date > maxDate && !date.hasSame(maxDate, "month");
10238
+ return {
10239
+ month: date.month,
10240
+ disabled: disabled ?? false
10241
+ };
10242
+ }),
10243
+ [maxDate, minDate, selectedYear]
10244
+ );
10245
+ const classes = cx(styles$1["month-selection"], props.className);
10246
+ const [focusedIndex, setFocusedIndex] = useState(selectedMonth - 1);
10247
+ useEffect(() => {
10248
+ if (minDate || maxDate) {
10249
+ let index = dates.findIndex(({ month }) => month === selectedMonth);
10250
+ while (dates[index].disabled && index < 11) {
10251
+ index++;
10252
+ }
10253
+ setFocusedIndex(index);
10254
+ } else {
10255
+ setFocusedIndex(selectedMonth - 1);
10256
+ }
10257
+ }, [selectedMonth, minDate, maxDate, dates]);
10258
+ const handleKeyDown = useCallback(
10259
+ (e) => {
10260
+ const target = e.target;
10261
+ const cards = monthSelectionRef.current?.querySelectorAll(
10262
+ "input[type='checkbox']"
10263
+ );
10264
+ if (!cards || cards.length === 0) {
10265
+ return;
10266
+ }
10267
+ const cardArray = Array.from(cards);
10268
+ const currentIndex = cardArray.indexOf(target);
10269
+ if (currentIndex === -1) return;
10270
+ const updateFocusedIndex = (index) => {
10271
+ e.preventDefault();
10272
+ cardArray[index].focus();
10273
+ setFocusedIndex(index);
10274
+ };
10275
+ let newIndex;
10276
+ switch (e.key) {
10277
+ case "ArrowLeft":
10278
+ newIndex = currentIndex > 0 ? currentIndex - 1 : 11;
10279
+ while (dates[newIndex].disabled) {
10280
+ newIndex = newIndex > 0 ? newIndex - 1 : 11;
10281
+ }
10282
+ updateFocusedIndex(newIndex);
10283
+ break;
10284
+ case "ArrowRight":
10285
+ newIndex = currentIndex < 11 ? currentIndex + 1 : 0;
10286
+ while (dates[newIndex].disabled) {
10287
+ newIndex = newIndex < 11 ? newIndex + 1 : 0;
10288
+ }
10289
+ updateFocusedIndex(newIndex);
10290
+ break;
10291
+ case "ArrowUp":
10292
+ if (currentIndex < 3) {
10293
+ newIndex = currentIndex + 9;
10294
+ } else {
10295
+ newIndex = currentIndex - 3;
10296
+ }
10297
+ while (dates[newIndex].disabled) {
10298
+ if (newIndex > 2) {
10299
+ newIndex -= 3;
10300
+ } else {
10301
+ newIndex += 9;
10302
+ }
10303
+ }
10304
+ updateFocusedIndex(newIndex);
10305
+ break;
10306
+ case "ArrowDown":
10307
+ if (currentIndex > 8) {
10308
+ newIndex = currentIndex - 9;
10309
+ } else {
10310
+ newIndex = currentIndex + 3;
10311
+ }
10312
+ while (dates[newIndex].disabled) {
10313
+ if (newIndex < 9) {
10314
+ newIndex += 3;
10315
+ } else {
10316
+ newIndex -= 9;
10317
+ }
10318
+ }
10319
+ updateFocusedIndex(newIndex);
10320
+ break;
10321
+ case "Enter":
10322
+ case " ":
10323
+ e.preventDefault();
10324
+ if (!dates[currentIndex].disabled) {
10325
+ onMonthSelection(dates[currentIndex].month);
10326
+ }
10327
+ break;
10328
+ }
10329
+ },
10330
+ [dates, onMonthSelection]
10331
+ );
10332
+ return /* @__PURE__ */ jsx(
10333
+ "div",
10334
+ {
10335
+ ref: combinedRef,
10336
+ "data-anv": "calendar-month-selection",
10337
+ className: classes,
10338
+ ...props,
10339
+ children: /* @__PURE__ */ jsx("div", { role: "grid", "aria-label": "Calendar month selection", children: /* @__PURE__ */ jsx(
10340
+ Grid,
10341
+ {
10342
+ templateColumns: "repeat(3, minmax(0, 1fr))",
10343
+ gap: 3,
10344
+ onKeyDown: handleKeyDown,
10345
+ role: "row",
10346
+ children: dates.map(({ month, disabled }, index) => /* @__PURE__ */ jsx("div", { role: "gridcell", children: /* @__PURE__ */ jsx(
10347
+ SelectCard,
10348
+ {
10349
+ id: month.toString(),
10350
+ disabled,
10351
+ onChange: () => onMonthSelection(month),
10352
+ checked: selectedMonth === month && selectedYear === currentDate.year,
10353
+ checkboxProps: {
10354
+ className: styles$1["selection-checkbox"],
10355
+ tabIndex: focusedIndex === index ? 0 : -1
10356
+ },
10357
+ className: styles$1["selection-card"],
10358
+ children: DateTime.fromObject({ month }).toFormat("MMMM")
10359
+ }
10360
+ ) }, month.toString()))
10361
+ }
10362
+ ) })
10363
+ }
10364
+ );
10365
+ });
10366
+ CalendarMonthSelection.displayName = "CalendarMonthSelection";
10367
+
10368
+ const toolbarFocusStates = ["month", "year", "next", "prev", "now"];
10367
10369
  const CalendarElement = forwardRef(
10368
10370
  (props, ref) => {
10369
10371
  const uid = useId();
@@ -10391,18 +10393,26 @@ const CalendarElement = forwardRef(
10391
10393
  range,
10392
10394
  className,
10393
10395
  _disableAutofocus,
10396
+ _disableFocus,
10394
10397
  ...remainingProps
10395
10398
  } = componentProps;
10396
10399
  const calendarRef = useRef(null);
10397
10400
  const combinedRef = useMergeRefs([ref, calendarRef]);
10398
10401
  const lastIValue = useRef(iValue);
10399
- const buttonsRef = useRef(void 0);
10400
10402
  const yearButtonRef = useRef(null);
10401
10403
  const monthButtonRef = useRef(null);
10404
+ const headerRef = useRef(null);
10405
+ const [toolbarFocus, setToolbarFocus] = useState(toolbarFocusStates[0]);
10402
10406
  const [calendarWidth, setCalendarWidth] = useState(
10403
10407
  void 0
10404
10408
  );
10405
10409
  const [calendarSelectionState, setCalendarSelectionState] = useState("day");
10410
+ const visibleHeaderButtons = useMemo(() => {
10411
+ if (calendarSelectionState !== "day") {
10412
+ return toolbarFocusStates.slice(0, 2);
10413
+ }
10414
+ return toolbarFocusStates;
10415
+ }, [calendarSelectionState]);
10406
10416
  useEffect(() => {
10407
10417
  if (!calendarRef.current || style?.width != null) return;
10408
10418
  const resizeObserver = new ResizeObserver((entries) => {
@@ -10567,41 +10577,45 @@ const CalendarElement = forwardRef(
10567
10577
  unavailableDates,
10568
10578
  unavailable,
10569
10579
  value,
10570
- startDay
10580
+ startDay,
10581
+ _disableAutofocus
10571
10582
  ]);
10572
- const updateHeaderButtons = useCallback(() => {
10573
- buttonsRef.current = calendarRef.current?.querySelectorAll(
10574
- "[data-calendar-header-button]"
10575
- );
10576
- }, []);
10577
- useEffect(() => {
10578
- updateHeaderButtons();
10579
- }, [updateHeaderButtons]);
10580
- const handleHeaderKeyDown = useCallback((e) => {
10581
- const target = e.target;
10582
- if (!buttonsRef.current || buttonsRef.current.length === 0) {
10583
- return;
10584
- }
10585
- const buttonArray = Array.from(buttonsRef.current);
10586
- const currentIndex = buttonArray.indexOf(target);
10587
- if (currentIndex === -1) return;
10588
- let newIndex;
10589
- switch (e.key) {
10590
- case "ArrowLeft":
10591
- e.preventDefault();
10592
- newIndex = currentIndex > 0 ? currentIndex - 1 : buttonArray.length - 1;
10593
- buttonArray[newIndex].focus();
10594
- break;
10595
- case "ArrowRight":
10596
- e.preventDefault();
10597
- newIndex = currentIndex < buttonArray.length - 1 ? currentIndex + 1 : 0;
10598
- buttonArray[newIndex].focus();
10599
- break;
10600
- }
10601
- }, []);
10583
+ const handleHeaderKeyDown = useCallback(
10584
+ (e) => {
10585
+ switch (e.key) {
10586
+ case "ArrowLeft":
10587
+ e.preventDefault();
10588
+ setToolbarFocus((previousToolbarFocus) => {
10589
+ const newToolbarFocus = previousToolbarFocus === visibleHeaderButtons[0] ? visibleHeaderButtons[visibleHeaderButtons.length - 1] : visibleHeaderButtons[visibleHeaderButtons.indexOf(previousToolbarFocus) - 1] ?? visibleHeaderButtons[visibleHeaderButtons.length - 1];
10590
+ const button = headerRef.current?.querySelector(
10591
+ `[data-calendar-header-button-name="${newToolbarFocus}"]`
10592
+ );
10593
+ if (button && "focus" in button && typeof button.focus === "function") {
10594
+ button.focus();
10595
+ }
10596
+ return newToolbarFocus;
10597
+ });
10598
+ break;
10599
+ case "ArrowRight":
10600
+ e.preventDefault();
10601
+ setToolbarFocus((previousToolbarFocus) => {
10602
+ const newToolbarFocus = previousToolbarFocus === visibleHeaderButtons[visibleHeaderButtons.length - 1] ? visibleHeaderButtons[0] : visibleHeaderButtons[visibleHeaderButtons.indexOf(previousToolbarFocus) + 1] ?? visibleHeaderButtons[0];
10603
+ const button = headerRef.current?.querySelector(
10604
+ `[data-calendar-header-button-name="${newToolbarFocus}"]`
10605
+ );
10606
+ if (button && "focus" in button && typeof button.focus === "function") {
10607
+ button.focus();
10608
+ }
10609
+ return newToolbarFocus;
10610
+ });
10611
+ }
10612
+ },
10613
+ [visibleHeaderButtons]
10614
+ );
10602
10615
  const handleMonthSelection = useCallback(
10603
10616
  (month) => {
10604
10617
  monthButtonRef.current?.focus();
10618
+ setToolbarFocus(toolbarFocusStates[0]);
10605
10619
  setSelectedMonth(month);
10606
10620
  setFocusedDate(
10607
10621
  DateTime.fromObject({
@@ -10612,12 +10626,14 @@ const CalendarElement = forwardRef(
10612
10626
  );
10613
10627
  setCalendarSelectionState("day");
10614
10628
  },
10629
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10615
10630
  [focusedDate]
10616
10631
  );
10617
10632
  const handleYearSelection = useCallback(
10618
10633
  (year) => {
10619
10634
  if (year === null) return;
10620
10635
  yearButtonRef.current?.focus();
10636
+ setToolbarFocus(toolbarFocusStates[1]);
10621
10637
  setSelectedYear(year);
10622
10638
  setFocusedDate(
10623
10639
  DateTime.fromObject({
@@ -10628,7 +10644,8 @@ const CalendarElement = forwardRef(
10628
10644
  );
10629
10645
  setCalendarSelectionState("day");
10630
10646
  },
10631
- [defaultTimeZone, focusedDate?.month]
10647
+ // eslint-disable-next-line react-hooks/exhaustive-deps
10648
+ [focusedDate?.month]
10632
10649
  );
10633
10650
  return /* @__PURE__ */ jsx(CalendarContext.Provider, { value: providerValue, children: /* @__PURE__ */ jsxs(
10634
10651
  "div",
@@ -10643,6 +10660,7 @@ const CalendarElement = forwardRef(
10643
10660
  /* @__PURE__ */ jsx("div", { className: styles$1["header"], children: /* @__PURE__ */ jsxs(
10644
10661
  "span",
10645
10662
  {
10663
+ ref: headerRef,
10646
10664
  "aria-label": "Calendar navigation",
10647
10665
  role: "toolbar",
10648
10666
  onKeyDown: handleHeaderKeyDown,
@@ -10652,29 +10670,62 @@ const CalendarElement = forwardRef(
10652
10670
  CalendarMonthButton,
10653
10671
  {
10654
10672
  ref: monthButtonRef,
10673
+ tabIndex: _disableFocus ? -1 : toolbarFocus === toolbarFocusStates[0] ? 0 : -1,
10655
10674
  "data-calendar-header-button": true,
10675
+ "data-calendar-header-button-name": toolbarFocusStates[0],
10656
10676
  calendarSelectionState,
10657
- onClick: () => setCalendarSelectionState(
10658
- (prev) => prev === "month" ? "day" : "month"
10659
- )
10677
+ onClick: () => {
10678
+ setCalendarSelectionState(
10679
+ (prev) => prev === "month" ? "day" : "month"
10680
+ );
10681
+ setToolbarFocus(toolbarFocusStates[0]);
10682
+ }
10660
10683
  }
10661
10684
  ),
10662
10685
  /* @__PURE__ */ jsx(
10663
10686
  CalendarYearButton,
10664
10687
  {
10665
10688
  ref: yearButtonRef,
10666
- tabIndex: -1,
10689
+ tabIndex: _disableFocus ? -1 : toolbarFocus === toolbarFocusStates[1] ? 0 : -1,
10667
10690
  "data-calendar-header-button": true,
10691
+ "data-calendar-header-button-name": toolbarFocusStates[1],
10668
10692
  calendarSelectionState,
10669
- onClick: () => setCalendarSelectionState(
10670
- (prev) => prev === "year" ? "day" : "year"
10671
- )
10693
+ onClick: () => {
10694
+ setCalendarSelectionState(
10695
+ (prev) => prev === "year" ? "day" : "year"
10696
+ );
10697
+ setToolbarFocus(toolbarFocusStates[1]);
10698
+ }
10672
10699
  }
10673
10700
  ),
10674
10701
  calendarSelectionState === "day" && /* @__PURE__ */ jsxs(Fragment, { children: [
10675
- /* @__PURE__ */ jsx(CalendarPrev, { tabIndex: -1, "data-calendar-header-button": true }),
10676
- /* @__PURE__ */ jsx(CalendarNext, { tabIndex: -1, "data-calendar-header-button": true }),
10677
- /* @__PURE__ */ jsx(CalendarNow, { tabIndex: -1, "data-calendar-header-button": true })
10702
+ /* @__PURE__ */ jsx(
10703
+ CalendarPrev,
10704
+ {
10705
+ tabIndex: _disableFocus ? -1 : toolbarFocus === toolbarFocusStates[2] ? 0 : -1,
10706
+ "data-calendar-header-button": true,
10707
+ "data-calendar-header-button-name": toolbarFocusStates[2],
10708
+ onClick: () => setToolbarFocus(toolbarFocusStates[2])
10709
+ }
10710
+ ),
10711
+ /* @__PURE__ */ jsx(
10712
+ CalendarNext,
10713
+ {
10714
+ tabIndex: _disableFocus ? -1 : toolbarFocus === toolbarFocusStates[3] ? 0 : -1,
10715
+ "data-calendar-header-button": true,
10716
+ "data-calendar-header-button-name": toolbarFocusStates[3],
10717
+ onClick: () => setToolbarFocus(toolbarFocusStates[3])
10718
+ }
10719
+ ),
10720
+ /* @__PURE__ */ jsx(
10721
+ CalendarNow,
10722
+ {
10723
+ tabIndex: _disableFocus ? -1 : toolbarFocus === toolbarFocusStates[4] ? 0 : -1,
10724
+ "data-calendar-header-button": true,
10725
+ "data-calendar-header-button-name": toolbarFocusStates[4],
10726
+ onClickFixed: () => setToolbarFocus(toolbarFocusStates[4])
10727
+ }
10728
+ )
10678
10729
  ] })
10679
10730
  ]
10680
10731
  }
@@ -10781,4 +10832,4 @@ const Calendar = Object.assign(CalendarElement, {
10781
10832
  });
10782
10833
 
10783
10834
  export { Calendar as C, DateTime as D, CalendarNow as a, CalendarYearButton as b, CalendarPrev as c, CalendarNext as d, CalendarMonthButton as e, CalendarMonth as f, isValidDate as i, toDateString as t };
10784
- //# sourceMappingURL=Calendar-X9qUi6Vx.js.map
10835
+ //# sourceMappingURL=Calendar-BqOvsaby.js.map