beez-ui 2.7.1 → 3.0.1

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 (110) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +43 -13
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/dist/components/account-menu.d.ts +4 -3
  5. package/dist/components/account-menu.js +63 -54
  6. package/dist/components/alert.d.ts +15 -15
  7. package/dist/components/alert.js +289 -270
  8. package/dist/components/animated-theme-toggler.js +1 -1
  9. package/dist/components/avatar.d.ts +56 -31
  10. package/dist/components/avatar.js +394 -277
  11. package/dist/components/badge.d.ts +8 -28
  12. package/dist/components/badge.js +55 -108
  13. package/dist/components/calendar.d.ts +36 -26
  14. package/dist/components/calendar.js +132 -1227
  15. package/dist/components/card.d.ts +36 -25
  16. package/dist/components/card.js +895 -72
  17. package/dist/components/carousel.d.ts +63 -47
  18. package/dist/components/carousel.js +496 -777
  19. package/dist/components/data-table.d.ts +5 -4
  20. package/dist/components/data-table.js +7 -6
  21. package/dist/components/dialog-surface.d.ts +23 -1
  22. package/dist/components/dialog-surface.js +99 -3
  23. package/dist/components/dialog.d.ts +80 -45
  24. package/dist/components/dialog.js +258 -503
  25. package/dist/components/dropdown-menu.d.ts +56 -73
  26. package/dist/components/dropdown-menu.js +79 -714
  27. package/dist/components/field.d.ts +3 -1
  28. package/dist/components/field.js +49 -39
  29. package/dist/components/filter-presets-bar.js +2 -2
  30. package/dist/components/filter-query-bar.js +1 -1
  31. package/dist/components/hover-card.d.ts +42 -41
  32. package/dist/components/hover-card.js +57 -483
  33. package/dist/components/pagination.d.ts +53 -31
  34. package/dist/components/pagination.js +176 -412
  35. package/dist/components/popover.d.ts +11 -23
  36. package/dist/components/popover.js +19 -304
  37. package/dist/components/{alert-dialog.d.ts → primitives/alert-dialog.d.ts} +17 -5
  38. package/dist/components/{alert-dialog.js → primitives/alert-dialog.js} +102 -54
  39. package/dist/components/primitives/avatar.d.ts +46 -0
  40. package/dist/components/primitives/avatar.js +268 -0
  41. package/dist/components/primitives/calendar.d.ts +37 -0
  42. package/dist/components/primitives/calendar.js +1250 -0
  43. package/dist/components/primitives/carousel.d.ts +106 -0
  44. package/dist/components/primitives/carousel.js +928 -0
  45. package/dist/components/primitives/dialog.d.ts +62 -0
  46. package/dist/components/primitives/dialog.js +490 -0
  47. package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
  48. package/dist/components/primitives/dropdown-menu-items.js +265 -0
  49. package/dist/components/primitives/dropdown-menu.d.ts +64 -0
  50. package/dist/components/primitives/dropdown-menu.js +557 -0
  51. package/dist/components/primitives/hover-card.d.ts +50 -0
  52. package/dist/components/primitives/hover-card.js +507 -0
  53. package/dist/components/primitives/pagination.d.ts +65 -0
  54. package/dist/components/primitives/pagination.js +373 -0
  55. package/dist/components/primitives/popover.d.ts +22 -0
  56. package/dist/components/primitives/popover.js +213 -0
  57. package/dist/components/primitives/select.d.ts +36 -0
  58. package/dist/components/primitives/select.js +407 -0
  59. package/dist/components/primitives/tooltip.d.ts +30 -0
  60. package/dist/components/primitives/tooltip.js +277 -0
  61. package/dist/components/radio-group.d.ts +30 -17
  62. package/dist/components/radio-group.js +266 -315
  63. package/dist/components/rich-link-editor.js +1 -1
  64. package/dist/components/select.d.ts +51 -42
  65. package/dist/components/select.js +163 -495
  66. package/dist/components/skeleton.d.ts +16 -15
  67. package/dist/components/skeleton.js +99 -205
  68. package/dist/components/split-button.js +1 -1
  69. package/dist/components/switch.d.ts +3 -6
  70. package/dist/components/switch.js +163 -170
  71. package/dist/components/tabs.d.ts +3 -11
  72. package/dist/components/tabs.js +61 -75
  73. package/dist/components/themed-toaster.d.ts +1 -1
  74. package/dist/components/themed-toaster.js +1 -1
  75. package/dist/components/toaster.d.ts +1 -1
  76. package/dist/components/toaster.js +1 -1
  77. package/dist/components/tooltip.d.ts +36 -31
  78. package/dist/components/tooltip.js +44 -284
  79. package/dist/constants/alert.d.ts +5 -1
  80. package/dist/constants/alert.js +5 -1
  81. package/dist/constants/avatar.d.ts +29 -1
  82. package/dist/constants/avatar.js +25 -0
  83. package/dist/constants/calendar.d.ts +12 -0
  84. package/dist/constants/calendar.js +12 -0
  85. package/dist/constants/card.d.ts +23 -0
  86. package/dist/constants/card.js +20 -0
  87. package/dist/constants/carousel.d.ts +31 -13
  88. package/dist/constants/carousel.js +32 -11
  89. package/dist/constants/dialog.d.ts +6 -1
  90. package/dist/constants/dialog.js +5 -1
  91. package/dist/constants/dropdown-menu.d.ts +2 -2
  92. package/dist/constants/dropdown-menu.js +2 -2
  93. package/dist/constants/pagination.d.ts +13 -2
  94. package/dist/constants/pagination.js +13 -2
  95. package/dist/constants/select.d.ts +4 -2
  96. package/dist/constants/select.js +4 -2
  97. package/dist/constants/switch.d.ts +5 -16
  98. package/dist/constants/switch.js +6 -14
  99. package/dist/hooks/use-today.d.ts +7 -0
  100. package/dist/hooks/use-today.js +50 -0
  101. package/dist/hooks.d.ts +1 -0
  102. package/dist/hooks.js +1 -0
  103. package/dist/index.d.ts +0 -1
  104. package/dist/index.js +0 -1
  105. package/dist/motion/glide-indicator.d.ts +1 -1
  106. package/dist/motion/glide-indicator.js +1 -1
  107. package/dist/motion/presence.d.ts +0 -1
  108. package/dist/motion/presence.js +0 -1
  109. package/dist/styles.css +1 -1
  110. package/package.json +1 -6
@@ -1,1250 +1,155 @@
1
1
  "use client";
2
2
  import { c as _c } from "react/compiler-runtime";
3
3
  /**
4
- * Arc's Calendar (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md) on react-day-picker: round day cells
5
- * on a 4px grid, the month title on the left with quiet pill controls on the right, today marked by a dot under its
6
- * number, a selected disc that glides between days and an optional Today button. react-day-picker keeps selection
7
- * modes, ranges, dropdowns, locales and keyboard navigation; only the design and the motion come from Arc.
4
+ * Arc's Calendar (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md) as a closed component: one month for
5
+ * picking one date, with a sliding month change, a gliding selected disc and an optional Today button. It renders on
6
+ * the internal react-day-picker composition, which keeps keyboard navigation and accessible day labels.
8
7
  */
9
8
  import * as React from "react";
10
- import { flushSync } from "react-dom";
11
- import { es } from "react-day-picker/locale";
12
- import { DayPicker, UI, dateMatchModifiers, getDefaultClassNames, useDayPicker } from "react-day-picker";
13
- import { animate, frame } from "motion/react";
14
- import { CALENDAR_COPY, CALENDAR_MONTH_ENTER_OPACITY, CALENDAR_MONTH_SPRING, CALENDAR_MONTHS_PER_YEAR, CALENDAR_SELECTED_DAY_SELECTOR, CALENDAR_SELECTION_DISC_ATTRIBUTE, CALENDAR_SELECTION_ENTER_SCALE, CALENDAR_SELECTION_EXIT_DURATION_S } from "../constants/calendar.js";
15
- import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
16
- import { useIsHydrated } from "../hooks/use-is-hydrated.js";
17
- import { ARC_DURATION, ARC_EASE, ARC_SPRING_MORPH, ARC_SPRING_SNAPPY } from "../motion/arc-tokens.js";
18
- import { MOTION_MONTH_DISTANCE } from "../motion/tokens.js";
19
- import { cn } from "../lib/utils.js";
20
- import { controlButtonVariants } from "./control-button.js";
21
- import { ChevronLeft, ChevronRight, ChevronDown } from "lucide-react";
22
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- const CalendarSettingsContext = React.createContext({ todayLabel: CALENDAR_COPY.today });
24
- /** Arc's quiet header control: a fill on hover-capable pointers, a short press and a dimmed, inert disabled state. */
25
- const calendarHeaderControlClassName = "h-8 rounded-full p-0 text-text-secondary select-none transition-[color,background-color,opacity,scale] duration-(--duration-fast) ease-(--ease-standard) motion-reduce:transition-none hover-fine:not-aria-disabled:bg-surface-muted hover-fine:not-aria-disabled:text-foreground active:not-aria-disabled:scale-[.96] motion-reduce:active:scale-100 aria-disabled:pointer-events-none aria-disabled:cursor-default aria-disabled:opacity-35";
9
+ import { enUS, es } from "react-day-picker/locale";
10
+ import { CALENDAR_COPY, CALENDAR_DEFAULT_LOCALE, CALENDAR_LOCALE_SEPARATOR, CALENDAR_TRANSLATED_LANGUAGE } from "../constants/calendar.js";
11
+ import { useToday } from "../hooks/use-today.js";
12
+ import { Calendar as CalendarPrimitive } from "./primitives/calendar.js";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export { useToday };
26
15
  /**
27
- * A month grid for picking a day, several days or a range, controlled or uncontrolled like react-day-picker.
28
- * @param props - Every react-day-picker prop plus the Arc additions `showToday` and `todayLabel`.
29
- * @returns The calendar, in Spanish by default.
30
- */
31
- function Calendar(t0) {
32
- const $ = _c(65);
33
- let className;
34
- let classNames;
35
- let components;
36
- let formatters;
37
- let props;
38
- let t1;
39
- let t2;
40
- let t3;
41
- let t4;
42
- let t5;
43
- let t6;
44
- if ($[0] !== t0) {
45
- ({className, classNames, showOutsideDays: t1, captionLayout: t2, buttonVariant: t3, locale: t4, formatters, components, showToday: t5, todayLabel: t6, ...props} = t0);
46
- $[0] = t0;
47
- $[1] = className;
48
- $[2] = classNames;
49
- $[3] = components;
50
- $[4] = formatters;
51
- $[5] = props;
52
- $[6] = t1;
53
- $[7] = t2;
54
- $[8] = t3;
55
- $[9] = t4;
56
- $[10] = t5;
57
- $[11] = t6;
58
- } else {
59
- className = $[1];
60
- classNames = $[2];
61
- components = $[3];
62
- formatters = $[4];
63
- props = $[5];
64
- t1 = $[6];
65
- t2 = $[7];
66
- t3 = $[8];
67
- t4 = $[9];
68
- t5 = $[10];
69
- t6 = $[11];
70
- }
71
- const showOutsideDays = t1 === undefined ? true : t1;
72
- const captionLayout = t2 === undefined ? "label" : t2;
73
- const buttonVariant = t3 === undefined ? "ghost" : t3;
74
- const locale = t4 === undefined ? es : t4;
75
- const showToday = t5 === undefined ? false : t5;
76
- const todayLabel = t6 === undefined ? CALENDAR_COPY.today : t6;
77
- const defaultClassNames = getDefaultClassNames();
78
- const isRange = props.mode === "range";
79
- let t7;
80
- if ($[12] !== todayLabel) {
81
- t7 = { todayLabel };
82
- $[12] = todayLabel;
83
- $[13] = t7;
84
- } else {
85
- t7 = $[13];
86
- }
87
- const settings = t7;
88
- const t8 = CalendarSettingsContext;
89
- const T0 = DayPicker;
90
- const t9 = cn("group/calendar bg-background p-2 text-foreground [--cell-radius:var(--radius-pill)] [--cell-size:--spacing(9)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent", String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className);
91
- let t10;
92
- if ($[14] !== locale?.code) {
93
- t10 = (date) => date.toLocaleString(locale?.code, { month: "short" });
94
- $[14] = locale?.code;
95
- $[15] = t10;
96
- } else {
97
- t10 = $[15];
98
- }
99
- let t11;
100
- if ($[16] !== formatters || $[17] !== t10) {
101
- t11 = {
102
- formatMonthDropdown: t10,
103
- ...formatters
104
- };
105
- $[16] = formatters;
106
- $[17] = t10;
107
- $[18] = t11;
108
- } else {
109
- t11 = $[18];
110
- }
111
- const t12 = cn("w-fit", defaultClassNames.root);
112
- const t13 = cn("relative flex flex-col gap-6 md:flex-row", defaultClassNames.months);
113
- const t14 = cn("group/calendar-month relative flex w-full flex-col gap-3", defaultClassNames.month);
114
- const t15 = cn("absolute end-0 top-0 z-20 flex items-center gap-0.5", defaultClassNames.nav);
115
- const t16 = cn(controlButtonVariants({ variant: buttonVariant }), calendarHeaderControlClassName, "size-8", defaultClassNames.button_previous);
116
- const t17 = cn(controlButtonVariants({ variant: buttonVariant }), calendarHeaderControlClassName, "size-8", defaultClassNames.button_next);
117
- const t18 = cn("flex h-8 w-full items-center justify-start pe-18", showToday && "after:invisible after:me-0.5 after:shrink-0 after:px-[11px] after:text-sm after:leading-none after:font-medium after:whitespace-nowrap after:content-[attr(data-today-label)]", defaultClassNames.month_caption);
118
- const t19 = cn("flex h-8 w-full min-w-0 items-center justify-start gap-1.5 text-base font-medium", defaultClassNames.dropdowns);
119
- const t20 = cn("relative rounded-(--radius-control)", defaultClassNames.dropdown_root);
120
- const t21 = cn("absolute inset-0 bg-popover opacity-0", defaultClassNames.dropdown);
121
- const t22 = cn("font-medium whitespace-nowrap tabular-nums select-none", captionLayout === "label" ? "min-w-0 truncate text-base" : "flex items-center gap-1 rounded-(--radius-control) text-base [&>svg]:size-3.5 [&>svg]:text-text-muted", defaultClassNames.caption_label);
122
- const t23 = cn("w-full border-collapse", defaultClassNames.month_grid);
123
- const t24 = cn("flex", !isRange && "gap-1", defaultClassNames.weekdays);
124
- const t25 = cn("flex-1 text-xs leading-6 font-medium text-text-muted select-none", defaultClassNames.weekday);
125
- const t26 = cn("mt-1 flex w-full", !isRange && "gap-1", defaultClassNames.week);
126
- const t27 = cn("w-(--cell-size) select-none", defaultClassNames.week_number_header);
127
- const t28 = cn("text-xs text-text-muted select-none", defaultClassNames.week_number);
128
- const t29 = cn("group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)", props.showWeekNumber ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)" : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)", defaultClassNames.day);
129
- const t30 = cn("relative isolate z-0 rounded-l-(--cell-radius) bg-surface-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-surface-muted", defaultClassNames.range_start);
130
- const t31 = cn("rounded-none", defaultClassNames.range_middle);
131
- const t32 = cn("relative isolate z-0 rounded-r-(--cell-radius) bg-surface-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-surface-muted", defaultClassNames.range_end);
132
- const t33 = cn(defaultClassNames.today);
133
- const t34 = cn(defaultClassNames.outside);
134
- const t35 = cn(defaultClassNames.disabled);
135
- const t36 = cn("invisible", defaultClassNames.hidden);
136
- let t37;
137
- if ($[19] !== classNames || $[20] !== t12 || $[21] !== t13 || $[22] !== t14 || $[23] !== t15 || $[24] !== t16 || $[25] !== t17 || $[26] !== t18 || $[27] !== t19 || $[28] !== t20 || $[29] !== t21 || $[30] !== t22 || $[31] !== t23 || $[32] !== t24 || $[33] !== t25 || $[34] !== t26 || $[35] !== t27 || $[36] !== t28 || $[37] !== t29 || $[38] !== t30 || $[39] !== t31 || $[40] !== t32 || $[41] !== t33 || $[42] !== t34 || $[43] !== t35 || $[44] !== t36) {
138
- t37 = {
139
- root: t12,
140
- months: t13,
141
- month: t14,
142
- nav: t15,
143
- button_previous: t16,
144
- button_next: t17,
145
- month_caption: t18,
146
- dropdowns: t19,
147
- dropdown_root: t20,
148
- dropdown: t21,
149
- caption_label: t22,
150
- month_grid: t23,
151
- weekdays: t24,
152
- weekday: t25,
153
- week: t26,
154
- week_number_header: t27,
155
- week_number: t28,
156
- day: t29,
157
- range_start: t30,
158
- range_middle: t31,
159
- range_end: t32,
160
- today: t33,
161
- outside: t34,
162
- disabled: t35,
163
- hidden: t36,
164
- ...classNames
165
- };
166
- $[19] = classNames;
167
- $[20] = t12;
168
- $[21] = t13;
169
- $[22] = t14;
170
- $[23] = t15;
171
- $[24] = t16;
172
- $[25] = t17;
173
- $[26] = t18;
174
- $[27] = t19;
175
- $[28] = t20;
176
- $[29] = t21;
177
- $[30] = t22;
178
- $[31] = t23;
179
- $[32] = t24;
180
- $[33] = t25;
181
- $[34] = t26;
182
- $[35] = t27;
183
- $[36] = t28;
184
- $[37] = t29;
185
- $[38] = t30;
186
- $[39] = t31;
187
- $[40] = t32;
188
- $[41] = t33;
189
- $[42] = t34;
190
- $[43] = t35;
191
- $[44] = t36;
192
- $[45] = t37;
193
- } else {
194
- t37 = $[45];
195
- }
196
- let t38;
197
- if ($[46] !== showToday) {
198
- t38 = showToday ? {
199
- Nav: CalendarNav,
200
- MonthCaption: CalendarMonthCaption
201
- } : {};
202
- $[46] = showToday;
203
- $[47] = t38;
204
- } else {
205
- t38 = $[47];
206
- }
207
- let t39;
208
- if ($[48] !== components || $[49] !== t38) {
209
- t39 = {
210
- Root: CalendarRoot,
211
- Chevron: CalendarChevron,
212
- DayButton: CalendarDayButtonSlot,
213
- Month: CalendarMonth,
214
- ...t38,
215
- WeekNumber: CalendarWeekNumber,
216
- ...components
217
- };
218
- $[48] = components;
219
- $[49] = t38;
220
- $[50] = t39;
221
- } else {
222
- t39 = $[50];
223
- }
224
- let t40;
225
- if ($[51] !== T0 || $[52] !== captionLayout || $[53] !== locale || $[54] !== props || $[55] !== showOutsideDays || $[56] !== t11 || $[57] !== t37 || $[58] !== t39 || $[59] !== t9) {
226
- t40 = /* @__PURE__ */ _jsx(T0, {
227
- showOutsideDays,
228
- className: t9,
229
- captionLayout,
230
- locale,
231
- formatters: t11,
232
- classNames: t37,
233
- components: t39,
234
- ...props
235
- });
236
- $[51] = T0;
237
- $[52] = captionLayout;
238
- $[53] = locale;
239
- $[54] = props;
240
- $[55] = showOutsideDays;
241
- $[56] = t11;
242
- $[57] = t37;
243
- $[58] = t39;
244
- $[59] = t9;
245
- $[60] = t40;
246
- } else {
247
- t40 = $[60];
248
- }
249
- let t41;
250
- if ($[61] !== settings || $[62] !== t40 || $[63] !== t8.Provider) {
251
- t41 = /* @__PURE__ */ _jsx(t8.Provider, {
252
- value: settings,
253
- children: t40
254
- });
255
- $[61] = settings;
256
- $[62] = t40;
257
- $[63] = t8.Provider;
258
- $[64] = t41;
259
- } else {
260
- t41 = $[64];
261
- }
262
- return t41;
263
- }
264
- /*
265
- * The slots below live at module level so their component identity is stable across renders. Inline slot functions
266
- * would be new component types on every render: React would remount the whole calendar (Root wraps it) and every month
267
- * would lose its state, which cancels the month slide and the selected disc glide when nothing memoizes them.
16
+ * Maps a BCP 47 locale to react-day-picker's localization. Only Spanish and English locale data ship with beez-ui,
17
+ * so other languages take their month and weekday names from `Intl` and keep English accessible labels.
18
+ * @param locale - BCP 47 locale such as `es-AR`.
19
+ * @returns The react-day-picker locale and, for untranslated languages, `Intl` formatters.
268
20
  */
269
- /** The calendar root, tagged with `data-slot="calendar"`. */
270
- function CalendarRoot(t0) {
271
- const $ = _c(10);
272
- let className;
273
- let props;
274
- let rootRef;
275
- if ($[0] !== t0) {
276
- ({className, rootRef, ...props} = t0);
277
- $[0] = t0;
278
- $[1] = className;
279
- $[2] = props;
280
- $[3] = rootRef;
281
- } else {
282
- className = $[1];
283
- props = $[2];
284
- rootRef = $[3];
285
- }
286
- let t1;
287
- if ($[4] !== className) {
288
- t1 = cn(className);
289
- $[4] = className;
290
- $[5] = t1;
291
- } else {
292
- t1 = $[5];
293
- }
294
- let t2;
295
- if ($[6] !== props || $[7] !== rootRef || $[8] !== t1) {
296
- t2 = /* @__PURE__ */ _jsx("div", {
297
- "data-slot": "calendar",
298
- ref: rootRef,
299
- className: t1,
300
- ...props
301
- });
302
- $[6] = props;
303
- $[7] = rootRef;
304
- $[8] = t1;
305
- $[9] = t2;
306
- } else {
307
- t2 = $[9];
308
- }
309
- return t2;
310
- }
311
- /** Arc's chevrons for the month controls and the caption dropdowns. */
312
- function CalendarChevron(t0) {
313
- const $ = _c(19);
314
- let className;
315
- let orientation;
316
- let props;
317
- if ($[0] !== t0) {
318
- ({className, orientation, ...props} = t0);
319
- $[0] = t0;
320
- $[1] = className;
321
- $[2] = orientation;
322
- $[3] = props;
323
- } else {
324
- className = $[1];
325
- orientation = $[2];
326
- props = $[3];
327
- }
328
- if (orientation === "left") {
329
- let t1;
330
- if ($[4] !== className) {
331
- t1 = cn("size-4", className);
332
- $[4] = className;
333
- $[5] = t1;
334
- } else {
335
- t1 = $[5];
336
- }
337
- let t2;
338
- if ($[6] !== props || $[7] !== t1) {
339
- t2 = /* @__PURE__ */ _jsx(ChevronLeft, {
340
- className: t1,
341
- strokeWidth: 1.75,
342
- ...props
343
- });
344
- $[6] = props;
345
- $[7] = t1;
346
- $[8] = t2;
347
- } else {
348
- t2 = $[8];
349
- }
350
- return t2;
351
- }
352
- if (orientation === "right") {
353
- let t1;
354
- if ($[9] !== className) {
355
- t1 = cn("size-4", className);
356
- $[9] = className;
357
- $[10] = t1;
358
- } else {
359
- t1 = $[10];
360
- }
361
- let t2;
362
- if ($[11] !== props || $[12] !== t1) {
363
- t2 = /* @__PURE__ */ _jsx(ChevronRight, {
364
- className: t1,
365
- strokeWidth: 1.75,
366
- ...props
367
- });
368
- $[11] = props;
369
- $[12] = t1;
370
- $[13] = t2;
371
- } else {
372
- t2 = $[13];
21
+ function resolveCalendarLocale(locale) {
22
+ const language = locale.split(CALENDAR_LOCALE_SEPARATOR)[0]?.toLowerCase();
23
+ if (language === CALENDAR_TRANSLATED_LANGUAGE.spanish) return { dayPickerLocale: es };
24
+ if (language === CALENDAR_TRANSLATED_LANGUAGE.english) return { dayPickerLocale: enUS };
25
+ const captionFormat = new Intl.DateTimeFormat(locale, {
26
+ month: "long",
27
+ year: "numeric"
28
+ });
29
+ const weekdayFormat = new Intl.DateTimeFormat(locale, { weekday: "short" });
30
+ return {
31
+ dayPickerLocale: enUS,
32
+ formatters: {
33
+ formatCaption: (month) => captionFormat.format(month),
34
+ formatWeekdayName: (weekday) => weekdayFormat.format(weekday)
373
35
  }
374
- return t2;
375
- }
376
- let t1;
377
- if ($[14] !== className) {
378
- t1 = cn("size-4", className);
379
- $[14] = className;
380
- $[15] = t1;
381
- } else {
382
- t1 = $[15];
383
- }
384
- let t2;
385
- if ($[16] !== props || $[17] !== t1) {
386
- t2 = /* @__PURE__ */ _jsx(ChevronDown, {
387
- className: t1,
388
- ...props
389
- });
390
- $[16] = props;
391
- $[17] = t1;
392
- $[18] = t2;
393
- } else {
394
- t2 = $[18];
395
- }
396
- return t2;
397
- }
398
- /** The day button slot, which reads the calendar locale for `data-day`. */
399
- function CalendarDayButtonSlot(props) {
400
- const $ = _c(3);
401
- const { dayPickerProps } = useDayPicker();
402
- let t0;
403
- if ($[0] !== dayPickerProps.locale || $[1] !== props) {
404
- t0 = /* @__PURE__ */ _jsx(CalendarDayButton, {
405
- locale: dayPickerProps.locale,
406
- ...props
407
- });
408
- $[0] = dayPickerProps.locale;
409
- $[1] = props;
410
- $[2] = t0;
411
- } else {
412
- t0 = $[2];
413
- }
414
- return t0;
415
- }
416
- /** The month caption, carrying the Today label its reserved space is sized from. Used only with `showToday`. */
417
- function CalendarMonthCaption(t0) {
418
- const $ = _c(5);
419
- let props;
420
- if ($[0] !== t0) {
421
- const { calendarMonth: _calendarMonth, displayIndex: _displayIndex, ...t1 } = t0;
422
- props = t1;
423
- $[0] = t0;
424
- $[1] = props;
425
- } else {
426
- props = $[1];
427
- }
428
- const { todayLabel } = React.useContext(CalendarSettingsContext);
429
- let t1;
430
- if ($[2] !== props || $[3] !== todayLabel) {
431
- t1 = /* @__PURE__ */ _jsx("div", {
432
- "data-today-label": todayLabel,
433
- ...props
434
- });
435
- $[2] = props;
436
- $[3] = todayLabel;
437
- $[4] = t1;
438
- } else {
439
- t1 = $[4];
440
- }
441
- return t1;
442
- }
443
- /** A week number cell sized like a day. */
444
- function CalendarWeekNumber(t0) {
445
- const $ = _c(8);
446
- let children;
447
- let props;
448
- if ($[0] !== t0) {
449
- ({children, ...props} = t0);
450
- $[0] = t0;
451
- $[1] = children;
452
- $[2] = props;
453
- } else {
454
- children = $[1];
455
- props = $[2];
456
- }
457
- let t1;
458
- if ($[3] !== children) {
459
- t1 = /* @__PURE__ */ _jsx("div", {
460
- className: "flex size-(--cell-size) items-center justify-center text-center",
461
- children
462
- });
463
- $[3] = children;
464
- $[4] = t1;
465
- } else {
466
- t1 = $[4];
467
- }
468
- let t2;
469
- if ($[5] !== props || $[6] !== t1) {
470
- t2 = /* @__PURE__ */ _jsx("td", {
471
- ...props,
472
- children: t1
473
- });
474
- $[5] = props;
475
- $[6] = t1;
476
- $[7] = t2;
477
- } else {
478
- t2 = $[7];
479
- }
480
- return t2;
481
- }
482
- /**
483
- * react-day-picker's month navigation with Arc's Today button in front of the arrows. Used only with `showToday`,
484
- * so the default navigation stays untouched otherwise.
485
- * @param props - Navigation handlers and the neighbouring months react-day-picker passes to its `Nav` slot.
486
- * @returns The navigation landmark.
487
- */
488
- function CalendarNav(t0) {
489
- const $ = _c(51);
490
- let navProps;
491
- let nextMonth;
492
- let onNextClick;
493
- let onPreviousClick;
494
- let previousMonth;
495
- if ($[0] !== t0) {
496
- ({onPreviousClick, onNextClick, previousMonth, nextMonth, ...navProps} = t0);
497
- $[0] = t0;
498
- $[1] = navProps;
499
- $[2] = nextMonth;
500
- $[3] = onNextClick;
501
- $[4] = onPreviousClick;
502
- $[5] = previousMonth;
503
- } else {
504
- navProps = $[1];
505
- nextMonth = $[2];
506
- onNextClick = $[3];
507
- onPreviousClick = $[4];
508
- previousMonth = $[5];
509
- }
510
- const { components, classNames, styles, labels: t1 } = useDayPicker();
511
- const { labelPrevious, labelNext } = t1;
512
- let t2;
513
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
514
- t2 = /* @__PURE__ */ _jsx(CalendarTodayButton, {});
515
- $[6] = t2;
516
- } else {
517
- t2 = $[6];
518
- }
519
- const T0 = components.PreviousMonthButton;
520
- const t3 = classNames[UI.PreviousMonthButton];
521
- const t4 = styles?.[UI.PreviousMonthButton];
522
- const t5 = previousMonth ? undefined : -1;
523
- const t6 = previousMonth ? undefined : true;
524
- let t7;
525
- if ($[7] !== labelPrevious || $[8] !== previousMonth) {
526
- t7 = labelPrevious(previousMonth);
527
- $[7] = labelPrevious;
528
- $[8] = previousMonth;
529
- $[9] = t7;
530
- } else {
531
- t7 = $[9];
532
- }
533
- let t8;
534
- if ($[10] !== onPreviousClick || $[11] !== previousMonth) {
535
- t8 = (event) => {
536
- if (previousMonth) {
537
- onPreviousClick?.(event);
538
- }
539
- };
540
- $[10] = onPreviousClick;
541
- $[11] = previousMonth;
542
- $[12] = t8;
543
- } else {
544
- t8 = $[12];
545
- }
546
- const t9 = previousMonth ? undefined : true;
547
- const t10 = classNames[UI.Chevron];
548
- const t11 = styles?.[UI.Chevron];
549
- let t12;
550
- if ($[13] !== components.Chevron || $[14] !== t10 || $[15] !== t11 || $[16] !== t9) {
551
- t12 = /* @__PURE__ */ _jsx(components.Chevron, {
552
- disabled: t9,
553
- className: t10,
554
- style: t11,
555
- orientation: "left"
556
- });
557
- $[13] = components.Chevron;
558
- $[14] = t10;
559
- $[15] = t11;
560
- $[16] = t9;
561
- $[17] = t12;
562
- } else {
563
- t12 = $[17];
564
- }
565
- let t13;
566
- if ($[18] !== components.PreviousMonthButton || $[19] !== t12 || $[20] !== t3 || $[21] !== t4 || $[22] !== t5 || $[23] !== t6 || $[24] !== t7 || $[25] !== t8) {
567
- t13 = /* @__PURE__ */ _jsx(T0, {
568
- type: "button",
569
- className: t3,
570
- style: t4,
571
- tabIndex: t5,
572
- "aria-disabled": t6,
573
- "aria-label": t7,
574
- onClick: t8,
575
- children: t12
576
- });
577
- $[18] = components.PreviousMonthButton;
578
- $[19] = t12;
579
- $[20] = t3;
580
- $[21] = t4;
581
- $[22] = t5;
582
- $[23] = t6;
583
- $[24] = t7;
584
- $[25] = t8;
585
- $[26] = t13;
586
- } else {
587
- t13 = $[26];
588
- }
589
- const T1 = components.NextMonthButton;
590
- const t14 = classNames[UI.NextMonthButton];
591
- const t15 = styles?.[UI.NextMonthButton];
592
- const t16 = nextMonth ? undefined : -1;
593
- const t17 = nextMonth ? undefined : true;
594
- let t18;
595
- if ($[27] !== labelNext || $[28] !== nextMonth) {
596
- t18 = labelNext(nextMonth);
597
- $[27] = labelNext;
598
- $[28] = nextMonth;
599
- $[29] = t18;
600
- } else {
601
- t18 = $[29];
602
- }
603
- let t19;
604
- if ($[30] !== nextMonth || $[31] !== onNextClick) {
605
- t19 = (event_0) => {
606
- if (nextMonth) {
607
- onNextClick?.(event_0);
608
- }
609
- };
610
- $[30] = nextMonth;
611
- $[31] = onNextClick;
612
- $[32] = t19;
613
- } else {
614
- t19 = $[32];
615
- }
616
- const t20 = nextMonth ? undefined : true;
617
- const t21 = classNames[UI.Chevron];
618
- const t22 = styles?.[UI.Chevron];
619
- let t23;
620
- if ($[33] !== components.Chevron || $[34] !== t20 || $[35] !== t21 || $[36] !== t22) {
621
- t23 = /* @__PURE__ */ _jsx(components.Chevron, {
622
- disabled: t20,
623
- className: t21,
624
- style: t22,
625
- orientation: "right"
626
- });
627
- $[33] = components.Chevron;
628
- $[34] = t20;
629
- $[35] = t21;
630
- $[36] = t22;
631
- $[37] = t23;
632
- } else {
633
- t23 = $[37];
634
- }
635
- let t24;
636
- if ($[38] !== components.NextMonthButton || $[39] !== t14 || $[40] !== t15 || $[41] !== t16 || $[42] !== t17 || $[43] !== t18 || $[44] !== t19 || $[45] !== t23) {
637
- t24 = /* @__PURE__ */ _jsx(T1, {
638
- type: "button",
639
- className: t14,
640
- style: t15,
641
- tabIndex: t16,
642
- "aria-disabled": t17,
643
- "aria-label": t18,
644
- onClick: t19,
645
- children: t23
646
- });
647
- $[38] = components.NextMonthButton;
648
- $[39] = t14;
649
- $[40] = t15;
650
- $[41] = t16;
651
- $[42] = t17;
652
- $[43] = t18;
653
- $[44] = t19;
654
- $[45] = t23;
655
- $[46] = t24;
656
- } else {
657
- t24 = $[46];
658
- }
659
- let t25;
660
- if ($[47] !== navProps || $[48] !== t13 || $[49] !== t24) {
661
- t25 = /* @__PURE__ */ _jsxs("nav", {
662
- ...navProps,
663
- children: [
664
- t2,
665
- t13,
666
- t24
667
- ]
668
- });
669
- $[47] = navProps;
670
- $[48] = t13;
671
- $[49] = t24;
672
- $[50] = t25;
673
- } else {
674
- t25 = $[50];
675
- }
676
- return t25;
677
- }
678
- /** Whether two dates fall in the same calendar month. */
679
- function isSameMonth(firstDate, secondDate) {
680
- return firstDate.getFullYear() === secondDate.getFullYear() && firstDate.getMonth() === secondDate.getMonth();
681
- }
682
- /** Months elapsed since year zero, so two dates can be compared by calendar month alone. */
683
- function toMonthIndex(date) {
684
- return date.getFullYear() * CALENDAR_MONTHS_PER_YEAR + date.getMonth();
685
- }
686
- /** Whether two dates fall on the same calendar day, read in the dates' own time zone. */
687
- function isSameDate(firstDate, secondDate) {
688
- return isSameMonth(firstDate, secondDate) && firstDate.getDate() === secondDate.getDate();
689
- }
690
- /**
691
- * Finds the rendered day of a date inside the displayed months, so its modifiers can be read from DayPicker.
692
- * @param months - Months DayPicker displays.
693
- * @param date - Date to look for.
694
- * @returns The day in its own month, or `undefined` when that month is not displayed.
695
- */
696
- function findDisplayedDay(months, date) {
697
- return months.flatMap((month) => month.weeks.flatMap((week) => week.days)).find((day) => !day.outside && isSameDate(day.date, date));
36
+ };
698
37
  }
699
38
  /**
700
- * Arc's Today button. Today is DayPicker's own (the `today` prop, or today in its `timeZone`), so the button always
701
- * agrees with the day marked as today; it is only read once hydrated, so server markup never depends on the server
702
- * clock, and until then the button rests dimmed.
703
- * @returns A button that brings today into view and selects it in single mode when it is not disabled.
39
+ * A month grid for picking one date. Days before `minDate`, after `maxDate` or matched by `disabledDates` are blocked,
40
+ * and navigation stops at the months of `minDate` and `maxDate`.
41
+ * @param props - Arc's calendar props plus `todayLabel`.
42
+ * @returns The calendar, in Spanish by default.
704
43
  */
705
- function CalendarTodayButton() {
706
- const $ = _c(39);
707
- const { months, goToMonth, getModifiers, select, isSelected, dayPickerProps } = useDayPicker();
708
- const { todayLabel } = React.useContext(CalendarSettingsContext);
709
- const isHydrated = useIsHydrated();
710
- const today = isHydrated ? dayPickerProps.today : undefined;
711
- let t0;
712
- if ($[0] !== months || $[1] !== today) {
713
- t0 = today && months.some((month) => isSameMonth(month.date, today));
714
- $[0] = months;
715
- $[1] = today;
716
- $[2] = t0;
717
- } else {
718
- t0 = $[2];
719
- }
720
- const isTodayShown = Boolean(t0);
721
- let t1;
722
- if ($[3] !== months || $[4] !== today) {
723
- t1 = today && findDisplayedDay(months, today);
724
- $[3] = months;
725
- $[4] = today;
726
- $[5] = t1;
727
- } else {
728
- t1 = $[5];
729
- }
730
- const todayDay = t1;
731
- let t2;
732
- if ($[6] !== getModifiers || $[7] !== todayDay) {
733
- t2 = todayDay ? getModifiers(todayDay) : undefined;
734
- $[6] = getModifiers;
735
- $[7] = todayDay;
736
- $[8] = t2;
737
- } else {
738
- t2 = $[8];
739
- }
740
- const displayedTodayModifiers = t2;
741
- let t3;
742
- if ($[9] !== dayPickerProps || $[10] !== displayedTodayModifiers || $[11] !== today) {
743
- t3 = displayedTodayModifiers ? displayedTodayModifiers.disabled || displayedTodayModifiers.hidden : Boolean(today && (dateMatchModifiers(today, dayPickerProps.disabled ?? []) || dateMatchModifiers(today, dayPickerProps.hidden ?? [])));
744
- $[9] = dayPickerProps;
745
- $[10] = displayedTodayModifiers;
746
- $[11] = today;
747
- $[12] = t3;
748
- } else {
749
- t3 = $[12];
750
- }
751
- const isTodayBlocked = t3;
752
- const isTodaySelectable = Boolean(today && select && dayPickerProps.mode === "single" && !isTodayBlocked);
44
+ function Calendar(t0) {
45
+ const $ = _c(30);
46
+ const { value, onChange, month, onMonthChange, minDate, maxDate, disabledDates, locale: t1, className, showToday: t2, todayLabel: t3 } = t0;
47
+ const locale = t1 === undefined ? CALENDAR_DEFAULT_LOCALE : t1;
48
+ const showToday = t2 === undefined ? false : t2;
49
+ const todayLabel = t3 === undefined ? CALENDAR_COPY.today : t3;
50
+ const today = useToday();
753
51
  let t4;
754
- if ($[13] !== isSelected || $[14] !== today) {
755
- t4 = today && isSelected?.(today);
756
- $[13] = isSelected;
757
- $[14] = today;
758
- $[15] = t4;
52
+ if ($[0] !== locale) {
53
+ t4 = resolveCalendarLocale(locale);
54
+ $[0] = locale;
55
+ $[1] = t4;
759
56
  } else {
760
- t4 = $[15];
57
+ t4 = $[1];
761
58
  }
762
- const isTodaySelected = Boolean(t4);
763
- const isTodayOutOfRange = Boolean(today && (dayPickerProps.startMonth && toMonthIndex(today) < toMonthIndex(dayPickerProps.startMonth) || dayPickerProps.endMonth && toMonthIndex(today) > toMonthIndex(dayPickerProps.endMonth)));
764
- const isIdle = !today || !isTodayShown && isTodayOutOfRange || isTodayShown && (!isTodaySelectable || isTodaySelected);
59
+ const { dayPickerLocale, formatters } = t4;
765
60
  let t5;
766
- if ($[16] !== getModifiers || $[17] !== months || $[18] !== select) {
767
- t5 = {
768
- months,
769
- getModifiers,
770
- select
771
- };
772
- $[16] = getModifiers;
773
- $[17] = months;
774
- $[18] = select;
775
- $[19] = t5;
776
- } else {
777
- t5 = $[19];
778
- }
779
- const latestDayPickerRef = React.useRef(t5);
780
- let t6;
781
- if ($[20] !== getModifiers || $[21] !== months || $[22] !== select) {
782
- t6 = () => {
783
- latestDayPickerRef.current = {
784
- months,
785
- getModifiers,
786
- select
787
- };
788
- };
789
- $[20] = getModifiers;
790
- $[21] = months;
791
- $[22] = select;
792
- $[23] = t6;
793
- } else {
794
- t6 = $[23];
795
- }
796
- React.useLayoutEffect(t6);
797
- let t7;
798
- if ($[24] !== today) {
799
- t7 = (event) => {
800
- const latest = latestDayPickerRef.current;
801
- const todayDay_0 = today && findDisplayedDay(latest.months, today);
802
- if (!todayDay_0) {
803
- return;
804
- }
805
- const modifiers = latest.getModifiers(todayDay_0);
806
- if (modifiers.disabled || modifiers.hidden) {
807
- return;
808
- }
809
- const selectSingle = latest.select;
810
- selectSingle?.(todayDay_0.date, modifiers, event);
811
- };
812
- $[24] = today;
813
- $[25] = t7;
814
- } else {
815
- t7 = $[25];
816
- }
817
- const selectDisplayedToday = t7;
818
- let t8;
819
- if ($[26] !== goToMonth || $[27] !== isIdle || $[28] !== isTodaySelectable || $[29] !== isTodaySelected || $[30] !== isTodayShown || $[31] !== selectDisplayedToday || $[32] !== today) {
820
- t8 = (event_0) => {
821
- if (isIdle || !today) {
822
- return;
823
- }
824
- const shouldSelect = isTodaySelectable && !isTodaySelected;
825
- if (!isTodayShown) {
826
- flushSync(() => goToMonth(today));
827
- }
828
- if (shouldSelect) {
829
- selectDisplayedToday(event_0);
830
- }
831
- };
832
- $[26] = goToMonth;
833
- $[27] = isIdle;
834
- $[28] = isTodaySelectable;
835
- $[29] = isTodaySelected;
836
- $[30] = isTodayShown;
837
- $[31] = selectDisplayedToday;
838
- $[32] = today;
839
- $[33] = t8;
840
- } else {
841
- t8 = $[33];
842
- }
843
- const handleClick = t8;
844
- const t9 = isIdle || undefined;
845
- let t10;
846
- if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
847
- t10 = cn(calendarHeaderControlClassName, "inline-flex cursor-pointer items-center border-0 bg-transparent px-[11px] text-sm leading-none font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [-webkit-tap-highlight-color:transparent]");
848
- $[34] = t10;
849
- } else {
850
- t10 = $[34];
851
- }
852
- let t11;
853
- if ($[35] !== handleClick || $[36] !== t9 || $[37] !== todayLabel) {
854
- t11 = /* @__PURE__ */ _jsx("button", {
855
- type: "button",
856
- "data-slot": "calendar-today",
857
- "aria-disabled": t9,
858
- className: t10,
859
- onClick: handleClick,
860
- children: todayLabel
861
- });
862
- $[35] = handleClick;
863
- $[36] = t9;
864
- $[37] = todayLabel;
865
- $[38] = t11;
866
- } else {
867
- t11 = $[38];
868
- }
869
- return t11;
870
- }
871
- /** Offset of a day button inside its month, from layout offsets, so press scales and the month slide never skew it. */
872
- function measureDayOffset(day, month) {
873
- let horizontalOffset = 0;
874
- let verticalOffset = 0;
875
- let node = day;
876
- while (node && node !== month) {
877
- horizontalOffset += node.offsetLeft;
878
- verticalOffset += node.offsetTop;
879
- node = node.offsetParent;
880
- }
881
- return {
882
- x: horizontalOffset,
883
- y: verticalOffset
884
- };
885
- }
886
- /**
887
- * Arc's selected disc for one month in single selection mode. It glides on a spring between two days of the same
888
- * month, retargets mid-flight on a new pick, grows in when the selection enters the month and fades out when it leaves.
889
- * While it paints the selection the month carries {@link CALENDAR_SELECTION_DISC_ATTRIBUTE}, so the selected day drops
890
- * its own fill; before hydration, and in other modes, the day keeps that fill.
891
- * @param monthRef - The month container the disc is positioned in.
892
- * @param monthTime - The month being displayed, so a month change jumps the disc instead of gliding it.
893
- * @param isEnabled - Whether the calendar is in single selection mode.
894
- * @returns The ref for the disc element.
895
- */
896
- function useSelectionDisc(monthRef, monthTime, isEnabled) {
897
- const $ = _c(12);
898
- const discRef = React.useRef(null);
899
- let t0;
900
- if ($[0] !== monthTime) {
901
- t0 = {
902
- dayKey: null,
903
- monthTime
904
- };
905
- $[0] = monthTime;
906
- $[1] = t0;
907
- } else {
908
- t0 = $[1];
909
- }
910
- const placementRef = React.useRef(t0);
911
- let t1;
912
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
913
- t1 = [];
914
- $[2] = t1;
915
- } else {
916
- t1 = $[2];
917
- }
918
- const animationsRef = React.useRef(t1);
919
- const reduceMotion = usePrefersReducedMotion();
920
- let t2;
921
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
922
- t2 = () => {
923
- animationsRef.current.forEach(_temp);
924
- animationsRef.current = [];
925
- };
926
- $[3] = t2;
927
- } else {
928
- t2 = $[3];
929
- }
930
- const stopAnimations = t2;
931
- let t3;
932
- if ($[4] !== isEnabled || $[5] !== monthRef || $[6] !== monthTime || $[7] !== reduceMotion) {
933
- t3 = () => {
934
- const month = monthRef.current;
935
- const disc = discRef.current;
936
- if (!month || !disc) {
937
- return;
938
- }
939
- const selectedDay = isEnabled ? month.querySelector(CALENDAR_SELECTED_DAY_SELECTOR) : null;
940
- const dayKey = selectedDay?.getAttribute("data-day") ?? null;
941
- const previous = placementRef.current;
942
- if (previous.dayKey === dayKey && previous.monthTime === monthTime) {
943
- return;
944
- }
945
- placementRef.current = {
946
- dayKey,
947
- monthTime
948
- };
949
- stopAnimations();
950
- if (!selectedDay) {
951
- month.removeAttribute(CALENDAR_SELECTION_DISC_ATTRIBUTE);
952
- if (previous.dayKey === null) {
953
- return;
954
- }
955
- const fade = reduceMotion ? { duration: 0 } : {
956
- duration: CALENDAR_SELECTION_EXIT_DURATION_S,
957
- ease: [...ARC_EASE.standard]
958
- };
959
- animationsRef.current = [animate(disc, {
960
- opacity: 0,
961
- scale: CALENDAR_SELECTION_ENTER_SCALE
962
- }, fade)];
963
- return;
964
- }
965
- const offset = measureDayOffset(selectedDay, month);
966
- disc.style.width = `${selectedDay.offsetWidth}px`;
967
- disc.style.height = `${selectedDay.offsetHeight}px`;
968
- month.setAttribute(CALENDAR_SELECTION_DISC_ATTRIBUTE, "visible");
969
- const isGlide = previous.dayKey !== null && previous.monthTime === monthTime && !reduceMotion;
970
- if (isGlide) {
971
- animationsRef.current = [animate(disc, {
972
- x: offset.x,
973
- y: offset.y
974
- }, ARC_SPRING_MORPH)];
975
- return;
976
- }
977
- const isEntering = previous.dayKey === null;
978
- animationsRef.current = [animate(disc, {
979
- x: offset.x,
980
- y: offset.y
981
- }, { duration: 0 })];
982
- if (isEntering && !reduceMotion) {
983
- animationsRef.current.push(animate(disc, { opacity: [0, 1] }, {
984
- duration: ARC_DURATION.fast,
985
- ease: [...ARC_EASE.enter]
986
- }), animate(disc, { scale: [CALENDAR_SELECTION_ENTER_SCALE, 1] }, ARC_SPRING_SNAPPY));
61
+ if ($[2] !== value) {
62
+ t5 = () => value ?? undefined;
63
+ $[2] = value;
64
+ $[3] = t5;
65
+ } else {
66
+ t5 = $[3];
67
+ }
68
+ const [initialMonth] = React.useState(t5);
69
+ let matchers;
70
+ if ($[4] !== disabledDates || $[5] !== maxDate || $[6] !== minDate) {
71
+ matchers = [];
72
+ if (minDate) {
73
+ let t6;
74
+ if ($[8] !== minDate) {
75
+ t6 = { before: minDate };
76
+ $[8] = minDate;
77
+ $[9] = t6;
987
78
  } else {
988
- animationsRef.current.push(animate(disc, {
989
- opacity: 1,
990
- scale: 1
991
- }, { duration: 0 }));
992
- }
993
- };
994
- $[4] = isEnabled;
995
- $[5] = monthRef;
996
- $[6] = monthTime;
997
- $[7] = reduceMotion;
998
- $[8] = t3;
999
- } else {
1000
- t3 = $[8];
1001
- }
1002
- React.useLayoutEffect(t3);
1003
- let t4;
1004
- let t5;
1005
- if ($[9] !== monthRef) {
1006
- t4 = () => {
1007
- const month_0 = monthRef.current;
1008
- const disc_0 = discRef.current;
1009
- if (!month_0 || !disc_0 || typeof ResizeObserver === "undefined") {
1010
- return;
79
+ t6 = $[9];
1011
80
  }
1012
- const observer = new ResizeObserver(() => {
1013
- const selectedDay_0 = month_0.querySelector(CALENDAR_SELECTED_DAY_SELECTOR);
1014
- if (!selectedDay_0 || placementRef.current.dayKey === null) {
1015
- return;
1016
- }
1017
- stopAnimations();
1018
- const offset_0 = measureDayOffset(selectedDay_0, month_0);
1019
- disc_0.style.width = `${selectedDay_0.offsetWidth}px`;
1020
- disc_0.style.height = `${selectedDay_0.offsetHeight}px`;
1021
- animationsRef.current = [animate(disc_0, {
1022
- x: offset_0.x,
1023
- y: offset_0.y,
1024
- opacity: 1,
1025
- scale: 1
1026
- }, { duration: 0 })];
1027
- });
1028
- observer.observe(month_0);
1029
- return () => {
1030
- observer.disconnect();
1031
- stopAnimations();
1032
- };
1033
- };
1034
- t5 = [monthRef, stopAnimations];
1035
- $[9] = monthRef;
1036
- $[10] = t4;
1037
- $[11] = t5;
1038
- } else {
1039
- t4 = $[10];
1040
- t5 = $[11];
1041
- }
1042
- React.useEffect(t4, t5);
1043
- return discRef;
1044
- }
1045
- function _temp(animation) {
1046
- return animation.stop();
1047
- }
1048
- /**
1049
- * Renders one displayed month and slides it in from the side the user navigated from, on Arc's month spring.
1050
- * DayPicker keys months by display position, so this instance survives navigation and can
1051
- * compare the new month with the previous one. The first render and reduced motion stay static.
1052
- * @param props - DayPicker month properties, including the month being displayed.
1053
- * @returns The month container with its caption, grid and selected disc.
1054
- */
1055
- function CalendarMonth(t0) {
1056
- const $ = _c(16);
1057
- let calendarMonth;
1058
- let children;
1059
- let displayIndex;
1060
- let props;
1061
- if ($[0] !== t0) {
1062
- ({calendarMonth, displayIndex, children, ...props} = t0);
1063
- $[0] = t0;
1064
- $[1] = calendarMonth;
1065
- $[2] = children;
1066
- $[3] = displayIndex;
1067
- $[4] = props;
1068
- } else {
1069
- calendarMonth = $[1];
1070
- children = $[2];
1071
- displayIndex = $[3];
1072
- props = $[4];
1073
- }
1074
- const monthRef = React.useRef(null);
1075
- const monthTime = calendarMonth.date.getTime();
1076
- const previousMonthTimeRef = React.useRef(monthTime);
1077
- const reduceMotion = usePrefersReducedMotion();
1078
- const { dayPickerProps } = useDayPicker();
1079
- const discRef = useSelectionDisc(monthRef, monthTime, dayPickerProps.mode === "single");
1080
- let t1;
1081
- let t2;
1082
- if ($[5] !== monthTime || $[6] !== reduceMotion) {
1083
- t1 = () => {
1084
- const previousMonthTime = previousMonthTimeRef.current;
1085
- previousMonthTimeRef.current = monthTime;
1086
- const element = monthRef.current;
1087
- if (!element || reduceMotion || previousMonthTime === monthTime) {
1088
- return;
1089
- }
1090
- const isForward = monthTime > previousMonthTime;
1091
- const isRightToLeft = getComputedStyle(element).direction === "rtl";
1092
- const direction = isForward !== isRightToLeft ? 1 : -1;
1093
- const original = {
1094
- opacity: element.style.opacity,
1095
- transform: element.style.transform
1096
- };
1097
- const restore = () => {
1098
- element.style.opacity = original.opacity;
1099
- element.style.transform = original.transform;
1100
- };
1101
- const animation = animate(element, {
1102
- opacity: [CALENDAR_MONTH_ENTER_OPACITY, 1],
1103
- transform: [`translateX(${direction * MOTION_MONTH_DISTANCE}px)`, "translateX(0px)"]
1104
- }, CALENDAR_MONTH_SPRING);
1105
- let isActive = true;
1106
- animation.then(() => frame.postRender(() => {
1107
- if (isActive) {
1108
- restore();
1109
- }
1110
- }));
1111
- return () => {
1112
- isActive = false;
1113
- animation.cancel();
1114
- restore();
1115
- };
1116
- };
1117
- t2 = [monthTime, reduceMotion];
1118
- $[5] = monthTime;
1119
- $[6] = reduceMotion;
1120
- $[7] = t1;
1121
- $[8] = t2;
1122
- } else {
1123
- t1 = $[7];
1124
- t2 = $[8];
1125
- }
1126
- React.useLayoutEffect(t1, t2);
1127
- let t3;
1128
- if ($[9] !== discRef) {
1129
- t3 = /* @__PURE__ */ _jsx("span", {
1130
- ref: discRef,
1131
- "aria-hidden": "true",
1132
- "data-slot": "calendar-selection",
1133
- className: "pointer-events-none absolute top-0 left-0 z-0 rounded-full bg-accent opacity-0"
1134
- });
1135
- $[9] = discRef;
1136
- $[10] = t3;
1137
- } else {
1138
- t3 = $[10];
1139
- }
1140
- let t4;
1141
- if ($[11] !== children || $[12] !== displayIndex || $[13] !== props || $[14] !== t3) {
1142
- t4 = /* @__PURE__ */ _jsxs("div", {
1143
- ref: monthRef,
1144
- "data-slot": "calendar-month",
1145
- "data-display-index": displayIndex,
1146
- ...props,
1147
- children: [t3, children]
1148
- });
1149
- $[11] = children;
1150
- $[12] = displayIndex;
1151
- $[13] = props;
1152
- $[14] = t3;
1153
- $[15] = t4;
1154
- } else {
1155
- t4 = $[15];
1156
- }
1157
- return t4;
1158
- }
1159
- /**
1160
- * One day of the grid: a round cell whose fill answers hover on fine pointers, presses in slightly and marks today
1161
- * with a dot under its number that takes the number's colour.
1162
- * @param props - react-day-picker day button properties plus the locale used for `data-day`.
1163
- * @returns The day button.
1164
- */
1165
- function CalendarDayButton(t0) {
1166
- const $ = _c(21);
1167
- let className;
1168
- let day;
1169
- let locale;
1170
- let modifiers;
1171
- let props;
1172
- if ($[0] !== t0) {
1173
- ({className, day, modifiers, locale, ...props} = t0);
1174
- $[0] = t0;
1175
- $[1] = className;
1176
- $[2] = day;
1177
- $[3] = locale;
1178
- $[4] = modifiers;
1179
- $[5] = props;
1180
- } else {
1181
- className = $[1];
1182
- day = $[2];
1183
- locale = $[3];
1184
- modifiers = $[4];
1185
- props = $[5];
1186
- }
1187
- const defaultClassNames = getDefaultClassNames();
1188
- const ref = React.useRef(null);
1189
- let t1;
1190
- let t2;
1191
- if ($[6] !== modifiers.focused) {
1192
- t1 = () => {
1193
- if (modifiers.focused) {
1194
- ref.current?.focus();
81
+ matchers.push(t6);
82
+ }
83
+ if (maxDate) {
84
+ let t6;
85
+ if ($[10] !== maxDate) {
86
+ t6 = { after: maxDate };
87
+ $[10] = maxDate;
88
+ $[11] = t6;
89
+ } else {
90
+ t6 = $[11];
1195
91
  }
1196
- };
1197
- t2 = [modifiers.focused];
1198
- $[6] = modifiers.focused;
1199
- $[7] = t1;
1200
- $[8] = t2;
92
+ matchers.push(t6);
93
+ }
94
+ if (disabledDates) {
95
+ matchers.push(disabledDates);
96
+ }
97
+ $[4] = disabledDates;
98
+ $[5] = maxDate;
99
+ $[6] = minDate;
100
+ $[7] = matchers;
1201
101
  } else {
1202
- t1 = $[7];
1203
- t2 = $[8];
102
+ matchers = $[7];
1204
103
  }
1205
- React.useEffect(t1, t2);
1206
- const isSelectedSingle = Boolean(modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle);
1207
- const t3 = "button";
1208
- let t4;
1209
- if ($[9] !== day.date || $[10] !== locale?.code) {
1210
- t4 = day.date.toLocaleDateString(locale?.code);
1211
- $[9] = day.date;
1212
- $[10] = locale?.code;
1213
- $[11] = t4;
104
+ const disabled = matchers;
105
+ const t6 = value ?? undefined;
106
+ let t7;
107
+ if ($[12] !== onChange) {
108
+ t7 = (_selected, triggerDate) => onChange?.(triggerDate);
109
+ $[12] = onChange;
110
+ $[13] = t7;
1214
111
  } else {
1215
- t4 = $[11];
112
+ t7 = $[13];
1216
113
  }
1217
- const t5 = modifiers.range_start;
1218
- const t6 = modifiers.range_end;
1219
- const t7 = modifiers.range_middle;
1220
- const t8 = modifiers.today || undefined;
1221
- const t9 = cn("relative isolate z-10 flex aspect-square w-full min-w-(--cell-size) cursor-pointer flex-col items-center justify-center gap-1 rounded-(--cell-radius) border-0 bg-transparent p-0 text-sm leading-none font-normal text-foreground tabular-nums outline-none select-none [-webkit-tap-highlight-color:transparent] [&>span]:text-xs [&>span]:opacity-70", "transition-[color,background-color,scale] duration-(--duration-fast) ease-(--ease-standard) motion-reduce:transition-none", "hover-fine:not-disabled:not-data-[selected-single=true]:not-data-[range-start=true]:not-data-[range-end=true]:bg-surface-muted active:not-disabled:scale-[.94] motion-reduce:active:scale-100", "focus-visible:ring-3 focus-visible:ring-ring/50 group-data-[focused=true]/day:ring-3 group-data-[focused=true]/day:ring-ring/50", modifiers.outside && "text-text-muted", modifiers.disabled && "cursor-default text-text-muted opacity-40", modifiers.today && "font-medium after:pointer-events-none after:absolute after:bottom-[18%] after:left-1/2 after:size-1 after:-translate-x-1/2 after:rounded-full after:bg-current", "data-[selected-single=true]:bg-accent data-[selected-single=true]:font-medium data-[selected-single=true]:text-accent-foreground group-data-[selection-disc=visible]/calendar-month:data-[selected-single=true]:bg-transparent", "data-[range-start=true]:bg-accent data-[range-start=true]:text-accent-foreground data-[range-end=true]:bg-accent data-[range-end=true]:text-accent-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-surface-muted data-[range-middle=true]:text-foreground", defaultClassNames.day, className);
1222
- let t10;
1223
- if ($[12] !== isSelectedSingle || $[13] !== modifiers.range_end || $[14] !== modifiers.range_middle || $[15] !== modifiers.range_start || $[16] !== props || $[17] !== t4 || $[18] !== t8 || $[19] !== t9) {
1224
- t10 = /* @__PURE__ */ _jsx("button", {
1225
- ref,
1226
- type: t3,
1227
- "data-day": t4,
1228
- "data-selected-single": isSelectedSingle,
1229
- "data-range-start": t5,
1230
- "data-range-end": t6,
1231
- "data-range-middle": t7,
1232
- "data-today": t8,
1233
- className: t9,
1234
- ...props
114
+ let t8;
115
+ if ($[14] !== className || $[15] !== dayPickerLocale || $[16] !== disabled || $[17] !== formatters || $[18] !== initialMonth || $[19] !== locale || $[20] !== maxDate || $[21] !== minDate || $[22] !== month || $[23] !== onMonthChange || $[24] !== showToday || $[25] !== t6 || $[26] !== t7 || $[27] !== today || $[28] !== todayLabel) {
116
+ t8 = /* @__PURE__ */ _jsx(CalendarPrimitive, {
117
+ mode: "single",
118
+ selected: t6,
119
+ onSelect: t7,
120
+ today,
121
+ month,
122
+ defaultMonth: initialMonth,
123
+ onMonthChange,
124
+ startMonth: minDate,
125
+ endMonth: maxDate,
126
+ disabled,
127
+ locale: dayPickerLocale,
128
+ lang: locale,
129
+ formatters,
130
+ className,
131
+ showToday,
132
+ todayLabel
1235
133
  });
1236
- $[12] = isSelectedSingle;
1237
- $[13] = modifiers.range_end;
1238
- $[14] = modifiers.range_middle;
1239
- $[15] = modifiers.range_start;
1240
- $[16] = props;
1241
- $[17] = t4;
1242
- $[18] = t8;
1243
- $[19] = t9;
1244
- $[20] = t10;
1245
- } else {
1246
- t10 = $[20];
1247
- }
1248
- return t10;
1249
- }
1250
- export { Calendar, CalendarDayButton };
134
+ $[14] = className;
135
+ $[15] = dayPickerLocale;
136
+ $[16] = disabled;
137
+ $[17] = formatters;
138
+ $[18] = initialMonth;
139
+ $[19] = locale;
140
+ $[20] = maxDate;
141
+ $[21] = minDate;
142
+ $[22] = month;
143
+ $[23] = onMonthChange;
144
+ $[24] = showToday;
145
+ $[25] = t6;
146
+ $[26] = t7;
147
+ $[27] = today;
148
+ $[28] = todayLabel;
149
+ $[29] = t8;
150
+ } else {
151
+ t8 = $[29];
152
+ }
153
+ return t8;
154
+ }
155
+ export { Calendar };