@sytechui/calendar 2.2.32

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -0
  3. package/dist/calendar-base.d.mts +23 -0
  4. package/dist/calendar-base.d.ts +23 -0
  5. package/dist/calendar-base.js +604 -0
  6. package/dist/calendar-base.mjs +17 -0
  7. package/dist/calendar-cell.d.mts +18 -0
  8. package/dist/calendar-cell.d.ts +18 -0
  9. package/dist/calendar-cell.js +97 -0
  10. package/dist/calendar-cell.mjs +7 -0
  11. package/dist/calendar-context.d.mts +19 -0
  12. package/dist/calendar-context.d.ts +19 -0
  13. package/dist/calendar-context.js +38 -0
  14. package/dist/calendar-context.mjs +9 -0
  15. package/dist/calendar-header.d.mts +14 -0
  16. package/dist/calendar-header.d.ts +14 -0
  17. package/dist/calendar-header.js +156 -0
  18. package/dist/calendar-header.mjs +10 -0
  19. package/dist/calendar-month.d.mts +13 -0
  20. package/dist/calendar-month.d.ts +13 -0
  21. package/dist/calendar-month.js +226 -0
  22. package/dist/calendar-month.mjs +10 -0
  23. package/dist/calendar-picker.d.mts +12 -0
  24. package/dist/calendar-picker.d.ts +12 -0
  25. package/dist/calendar-picker.js +83 -0
  26. package/dist/calendar-picker.mjs +9 -0
  27. package/dist/calendar-transitions.d.mts +10 -0
  28. package/dist/calendar-transitions.d.ts +10 -0
  29. package/dist/calendar-transitions.js +48 -0
  30. package/dist/calendar-transitions.mjs +9 -0
  31. package/dist/calendar.d.mts +24 -0
  32. package/dist/calendar.d.ts +24 -0
  33. package/dist/calendar.js +876 -0
  34. package/dist/calendar.mjs +20 -0
  35. package/dist/chevron-down.d.mts +6 -0
  36. package/dist/chevron-down.d.ts +6 -0
  37. package/dist/chevron-down.js +54 -0
  38. package/dist/chevron-down.mjs +7 -0
  39. package/dist/chevron-left.d.mts +6 -0
  40. package/dist/chevron-left.d.ts +6 -0
  41. package/dist/chevron-left.js +54 -0
  42. package/dist/chevron-left.mjs +7 -0
  43. package/dist/chevron-right.d.mts +6 -0
  44. package/dist/chevron-right.d.ts +6 -0
  45. package/dist/chevron-right.js +54 -0
  46. package/dist/chevron-right.mjs +7 -0
  47. package/dist/chunk-5CY7DCRB.mjs +24 -0
  48. package/dist/chunk-AJXW2JXW.mjs +23 -0
  49. package/dist/chunk-BEC3B3UO.mjs +23 -0
  50. package/dist/chunk-CPBF6DM2.mjs +120 -0
  51. package/dist/chunk-DN6I5LXB.mjs +125 -0
  52. package/dist/chunk-H34OUI62.mjs +157 -0
  53. package/dist/chunk-HUKPVIZ5.mjs +31 -0
  54. package/dist/chunk-IDU5RSFL.mjs +93 -0
  55. package/dist/chunk-IFK7FCNU.mjs +42 -0
  56. package/dist/chunk-JJRY4BYN.mjs +31 -0
  57. package/dist/chunk-JQFIYCMS.mjs +19 -0
  58. package/dist/chunk-MCZLP73P.mjs +14 -0
  59. package/dist/chunk-MDGP3JHC.mjs +74 -0
  60. package/dist/chunk-MUYVZHWM.mjs +31 -0
  61. package/dist/chunk-OEB7VI2R.mjs +125 -0
  62. package/dist/chunk-ZJZG3P2K.mjs +181 -0
  63. package/dist/index.d.mts +21 -0
  64. package/dist/index.d.ts +21 -0
  65. package/dist/index.js +1020 -0
  66. package/dist/index.mjs +36 -0
  67. package/dist/range-calendar.d.mts +24 -0
  68. package/dist/range-calendar.d.ts +24 -0
  69. package/dist/range-calendar.js +876 -0
  70. package/dist/range-calendar.mjs +20 -0
  71. package/dist/use-calendar-base.d.mts +1224 -0
  72. package/dist/use-calendar-base.d.ts +1224 -0
  73. package/dist/use-calendar-base.js +174 -0
  74. package/dist/use-calendar-base.mjs +7 -0
  75. package/dist/use-calendar-picker.d.mts +482 -0
  76. package/dist/use-calendar-picker.d.ts +482 -0
  77. package/dist/use-calendar-picker.js +49 -0
  78. package/dist/use-calendar-picker.mjs +8 -0
  79. package/dist/use-calendar.d.mts +494 -0
  80. package/dist/use-calendar.d.ts +494 -0
  81. package/dist/use-calendar.js +293 -0
  82. package/dist/use-calendar.mjs +8 -0
  83. package/dist/use-range-calendar.d.mts +498 -0
  84. package/dist/use-range-calendar.d.ts +498 -0
  85. package/dist/use-range-calendar.js +293 -0
  86. package/dist/use-range-calendar.mjs +8 -0
  87. package/dist/utils.d.mts +7 -0
  88. package/dist/utils.d.ts +7 -0
  89. package/dist/utils.js +59 -0
  90. package/dist/utils.mjs +33 -0
  91. package/package.json +74 -0
@@ -0,0 +1,876 @@
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/calendar.tsx
32
+ var calendar_exports = {};
33
+ __export(calendar_exports, {
34
+ default: () => calendar_default
35
+ });
36
+ module.exports = __toCommonJS(calendar_exports);
37
+ var import_system2 = require("@sytechui/system");
38
+
39
+ // src/use-calendar.ts
40
+ var import_react2 = require("react");
41
+ var import_react_utils2 = require("@sytechui/react-utils");
42
+ var import_calendar = require("@react-aria/calendar");
43
+ var import_calendar2 = require("@react-stately/calendar");
44
+ var import_date2 = require("@internationalized/date");
45
+ var import_shared_utils2 = require("@sytechui/shared-utils");
46
+ var import_theme2 = require("@sytechui/theme");
47
+
48
+ // src/use-calendar-base.ts
49
+ var import_date = require("@internationalized/date");
50
+ var import_system = require("@sytechui/system");
51
+ var import_react = require("react");
52
+ var import_theme = require("@sytechui/theme");
53
+ var import_utils = require("@react-stately/utils");
54
+ var import_react_utils = require("@sytechui/react-utils");
55
+ var import_i18n = require("@react-aria/i18n");
56
+ var import_shared_utils = require("@sytechui/shared-utils");
57
+ function useCalendarBase(originalProps) {
58
+ var _a, _b, _c, _d, _e, _f, _g;
59
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.calendar.variantKeys);
60
+ const globalContext = (0, import_system.useProviderContext)();
61
+ const { locale, direction } = (0, import_i18n.useLocale)();
62
+ const isRTL = direction === "rtl";
63
+ const calendarProp = (0, import_date.createCalendar)(
64
+ new import_date.DateFormatter(locale).resolvedOptions().calendar
65
+ );
66
+ const gregorianYearOffset = (0, import_shared_utils.getGregorianYearOffset)(calendarProp.identifier);
67
+ const {
68
+ ref,
69
+ as,
70
+ children,
71
+ className,
72
+ topContent,
73
+ bottomContent,
74
+ showHelper = true,
75
+ firstDayOfWeek,
76
+ calendarWidth = 256,
77
+ visibleMonths: visibleMonthsProp = 1,
78
+ weekdayStyle = "narrow",
79
+ navButtonProps = {},
80
+ isHeaderExpanded: isHeaderExpandedProp,
81
+ isHeaderDefaultExpanded,
82
+ onHeaderExpandedChange = () => {
83
+ },
84
+ createCalendar: createCalendarProp = (_a = globalContext == null ? void 0 : globalContext.createCalendar) != null ? _a : null,
85
+ minValue = (_c = (_b = globalContext == null ? void 0 : globalContext.defaultDates) == null ? void 0 : _b.minDate) != null ? _c : new import_date.CalendarDate(calendarProp, 1900 + gregorianYearOffset, 1, 1),
86
+ maxValue = (_e = (_d = globalContext == null ? void 0 : globalContext.defaultDates) == null ? void 0 : _d.maxDate) != null ? _e : new import_date.CalendarDate(calendarProp, 2099 + gregorianYearOffset, 12, 31),
87
+ prevButtonProps: prevButtonPropsProp,
88
+ nextButtonProps: nextButtonPropsProp,
89
+ errorMessage,
90
+ classNames,
91
+ ...otherProps
92
+ } = props;
93
+ const Component = as || "div";
94
+ const visibleMonths = (0, import_shared_utils.clamp)(visibleMonthsProp, 1, 3);
95
+ const showMonthAndYearPickers = originalProps.showMonthAndYearPickers && visibleMonths === 1;
96
+ const domRef = (0, import_react_utils.useDOMRef)(ref);
97
+ const handleHeaderExpandedChange = (0, import_react.useCallback)(
98
+ (isExpanded) => {
99
+ onHeaderExpandedChange(isExpanded || false);
100
+ },
101
+ [onHeaderExpandedChange]
102
+ );
103
+ const [isHeaderExpanded, setIsHeaderExpanded] = (0, import_utils.useControlledState)(
104
+ isHeaderExpandedProp,
105
+ isHeaderDefaultExpanded != null ? isHeaderDefaultExpanded : false,
106
+ handleHeaderExpandedChange
107
+ );
108
+ const visibleDuration = (0, import_react.useMemo)(() => ({ months: visibleMonths }), [visibleMonths]);
109
+ const hasMultipleMonths = visibleMonths > 1;
110
+ const shouldFilterDOMProps = typeof Component === "string";
111
+ const slots = (0, import_react.useMemo)(
112
+ () => (0, import_theme.calendar)({
113
+ ...variantProps,
114
+ showMonthAndYearPickers,
115
+ isRange: !!originalProps.isRange,
116
+ isHeaderWrapperExpanded: isHeaderExpanded,
117
+ className,
118
+ isRTL
119
+ }),
120
+ [(0, import_shared_utils.objectToDeps)(variantProps), showMonthAndYearPickers, isHeaderExpanded, className]
121
+ );
122
+ const disableAnimation = (_g = (_f = originalProps.disableAnimation) != null ? _f : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _g : false;
123
+ const commonButtonProps = {
124
+ size: "sm",
125
+ variant: "light",
126
+ radius: "full",
127
+ isIconOnly: true,
128
+ disableAnimation,
129
+ ...navButtonProps
130
+ };
131
+ const baseProps = {
132
+ "data-slot": "base",
133
+ "data-has-multiple-months": (0, import_shared_utils.dataAttr)(hasMultipleMonths),
134
+ style: {
135
+ // @ts-ignore
136
+ "--visible-months": typeof visibleMonths === "number" ? `${visibleMonths}` : visibleMonths,
137
+ "--calendar-width": typeof calendarWidth === "number" ? `${calendarWidth}px` : calendarWidth
138
+ }
139
+ };
140
+ const getPrevButtonProps = (props2 = {}) => {
141
+ return {
142
+ "data-slot": "prev-button",
143
+ tabIndex: isHeaderExpanded ? -1 : 0,
144
+ className: slots.prevButton({ class: classNames == null ? void 0 : classNames.prevButton }),
145
+ ...(0, import_shared_utils.mergeProps)(commonButtonProps, prevButtonPropsProp, props2)
146
+ };
147
+ };
148
+ const getNextButtonProps = (props2 = {}) => {
149
+ return {
150
+ "data-slot": "next-button",
151
+ tabIndex: isHeaderExpanded ? -1 : 0,
152
+ className: slots.nextButton({ class: classNames == null ? void 0 : classNames.nextButton }),
153
+ ...(0, import_shared_utils.mergeProps)(commonButtonProps, nextButtonPropsProp, props2)
154
+ };
155
+ };
156
+ const getErrorMessageProps = (props2 = {}) => {
157
+ return {
158
+ "data-slot": "error-message",
159
+ className: slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage }),
160
+ ...props2
161
+ };
162
+ };
163
+ return {
164
+ Component,
165
+ children,
166
+ domRef,
167
+ slots,
168
+ locale,
169
+ minValue,
170
+ maxValue,
171
+ baseProps,
172
+ showHelper,
173
+ firstDayOfWeek,
174
+ weekdayStyle,
175
+ visibleMonths,
176
+ visibleDuration,
177
+ shouldFilterDOMProps,
178
+ isHeaderExpanded,
179
+ showMonthAndYearPickers,
180
+ disableAnimation,
181
+ createCalendar: createCalendarProp,
182
+ getPrevButtonProps,
183
+ getNextButtonProps,
184
+ getErrorMessageProps,
185
+ setIsHeaderExpanded,
186
+ topContent,
187
+ bottomContent,
188
+ errorMessage,
189
+ classNames,
190
+ otherProps
191
+ };
192
+ }
193
+
194
+ // src/use-calendar.ts
195
+ function useCalendar({
196
+ buttonPickerProps: buttonPickerPropsProp,
197
+ className,
198
+ ...originalProps
199
+ }) {
200
+ const {
201
+ Component,
202
+ slots,
203
+ children,
204
+ domRef,
205
+ locale,
206
+ minValue,
207
+ maxValue,
208
+ showHelper,
209
+ firstDayOfWeek,
210
+ weekdayStyle,
211
+ visibleDuration,
212
+ baseProps,
213
+ disableAnimation,
214
+ shouldFilterDOMProps,
215
+ isHeaderExpanded,
216
+ visibleMonths,
217
+ createCalendar: createCalendarProp,
218
+ showMonthAndYearPickers,
219
+ getPrevButtonProps,
220
+ getNextButtonProps,
221
+ getErrorMessageProps,
222
+ setIsHeaderExpanded,
223
+ topContent,
224
+ bottomContent,
225
+ errorMessage,
226
+ classNames,
227
+ otherProps
228
+ } = useCalendarBase(originalProps);
229
+ const headerRef = (0, import_react2.useRef)(null);
230
+ const state = (0, import_calendar2.useCalendarState)({
231
+ ...originalProps,
232
+ locale,
233
+ minValue,
234
+ maxValue,
235
+ visibleDuration,
236
+ createCalendar: !createCalendarProp || typeof createCalendarProp !== "function" ? import_date2.createCalendar : createCalendarProp
237
+ });
238
+ const { title, calendarProps, prevButtonProps, nextButtonProps, errorMessageProps } = (0, import_calendar.useCalendar)(originalProps, state);
239
+ const baseStyles = (0, import_theme2.cn)(classNames == null ? void 0 : classNames.base, className);
240
+ const buttonPickerProps = {
241
+ ...(0, import_shared_utils2.mergeProps)(buttonPickerPropsProp, { isDisabled: originalProps.isDisabled }),
242
+ onPress: (0, import_shared_utils2.chain)(buttonPickerPropsProp == null ? void 0 : buttonPickerPropsProp.onPress, () => setIsHeaderExpanded(!isHeaderExpanded))
243
+ };
244
+ const getBaseCalendarProps = (props = {}) => {
245
+ return {
246
+ ...baseProps,
247
+ Component,
248
+ showHelper,
249
+ firstDayOfWeek,
250
+ topContent,
251
+ bottomContent,
252
+ buttonPickerProps,
253
+ calendarRef: domRef,
254
+ calendarProps,
255
+ prevButtonProps: getPrevButtonProps(prevButtonProps),
256
+ nextButtonProps: getNextButtonProps(nextButtonProps),
257
+ errorMessageProps: getErrorMessageProps(errorMessageProps),
258
+ className: slots.base({ class: baseStyles }),
259
+ errorMessage,
260
+ ...(0, import_react_utils2.filterDOMProps)(otherProps, {
261
+ enabled: shouldFilterDOMProps
262
+ }),
263
+ ...props
264
+ };
265
+ };
266
+ const context = (0, import_react2.useMemo)(
267
+ () => ({
268
+ state,
269
+ slots,
270
+ headerRef,
271
+ weekdayStyle,
272
+ isHeaderExpanded,
273
+ setIsHeaderExpanded,
274
+ visibleMonths,
275
+ classNames,
276
+ showMonthAndYearPickers,
277
+ disableAnimation
278
+ }),
279
+ [
280
+ state,
281
+ slots,
282
+ classNames,
283
+ weekdayStyle,
284
+ isHeaderExpanded,
285
+ setIsHeaderExpanded,
286
+ visibleMonths,
287
+ disableAnimation,
288
+ showMonthAndYearPickers
289
+ ]
290
+ );
291
+ return {
292
+ Component,
293
+ children,
294
+ domRef,
295
+ context,
296
+ state,
297
+ slots,
298
+ title,
299
+ classNames,
300
+ getBaseCalendarProps
301
+ };
302
+ }
303
+
304
+ // src/calendar-context.ts
305
+ var import_react_utils3 = require("@sytechui/react-utils");
306
+ var [CalendarProvider, useCalendarContext] = (0, import_react_utils3.createContext)({
307
+ name: "CalendarContext",
308
+ strict: true,
309
+ errorMessage: "useContext: `context` is undefined. Seems you forgot to wrap component within the CalendarProvider"
310
+ });
311
+
312
+ // src/calendar-base.tsx
313
+ var import_react5 = require("react");
314
+ var import_visually_hidden = require("@react-aria/visually-hidden");
315
+ var import_button2 = require("@sytechui/button");
316
+ var import_shared_utils5 = require("@sytechui/shared-utils");
317
+ var import_framer_motion3 = require("framer-motion");
318
+ var import_i18n5 = require("@react-aria/i18n");
319
+ var import_framer_utils = require("@sytechui/framer-utils");
320
+
321
+ // src/chevron-left.tsx
322
+ var import_jsx_runtime = require("react/jsx-runtime");
323
+ var ChevronLeftIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
324
+ "svg",
325
+ {
326
+ "aria-hidden": "true",
327
+ fill: "none",
328
+ focusable: "false",
329
+ height: "1em",
330
+ role: "presentation",
331
+ viewBox: "0 0 16 16",
332
+ width: "1em",
333
+ ...props,
334
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
335
+ "path",
336
+ {
337
+ d: "M10 3.33334L6 8.00001L10 12.6667",
338
+ stroke: "currentColor",
339
+ strokeLinecap: "round",
340
+ strokeLinejoin: "round",
341
+ strokeWidth: "1.5"
342
+ }
343
+ )
344
+ }
345
+ );
346
+
347
+ // src/chevron-right.tsx
348
+ var import_jsx_runtime2 = require("react/jsx-runtime");
349
+ var ChevronRightIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
350
+ "svg",
351
+ {
352
+ "aria-hidden": "true",
353
+ fill: "none",
354
+ focusable: "false",
355
+ height: "1em",
356
+ role: "presentation",
357
+ viewBox: "0 0 16 16",
358
+ width: "1em",
359
+ ...props,
360
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
361
+ "path",
362
+ {
363
+ d: "M6 3.33334L10 8.00001L6 12.6667",
364
+ stroke: "currentColor",
365
+ strokeLinecap: "round",
366
+ strokeLinejoin: "round",
367
+ strokeWidth: "1.5"
368
+ }
369
+ )
370
+ }
371
+ );
372
+
373
+ // src/calendar-month.tsx
374
+ var import_date4 = require("@internationalized/date");
375
+ var import_i18n3 = require("@react-aria/i18n");
376
+ var import_calendar4 = require("@react-aria/calendar");
377
+ var import_framer_motion = require("framer-motion");
378
+ var import_shared_utils4 = require("@sytechui/shared-utils");
379
+
380
+ // src/calendar-cell.tsx
381
+ var import_date3 = require("@internationalized/date");
382
+ var import_calendar3 = require("@react-aria/calendar");
383
+ var import_i18n2 = require("@react-aria/i18n");
384
+ var import_focus = require("@react-aria/focus");
385
+ var import_interactions = require("@react-aria/interactions");
386
+ var import_react3 = require("react");
387
+ var import_shared_utils3 = require("@sytechui/shared-utils");
388
+ var import_jsx_runtime3 = require("react/jsx-runtime");
389
+ function CalendarCell(originalProps) {
390
+ const { state, slots, isPickerVisible, currentMonth, classNames, firstDayOfWeek, ...props } = originalProps;
391
+ const ref = (0, import_react3.useRef)(null);
392
+ const {
393
+ cellProps,
394
+ buttonProps,
395
+ isPressed,
396
+ isSelected,
397
+ isDisabled,
398
+ isFocused,
399
+ isInvalid,
400
+ formattedDate
401
+ } = (0, import_calendar3.useCalendarCell)(
402
+ {
403
+ ...props,
404
+ isDisabled: !(0, import_date3.isSameMonth)(props.date, currentMonth) || isPickerVisible
405
+ },
406
+ state,
407
+ ref
408
+ );
409
+ const isUnavailable = state.isCellUnavailable(props.date);
410
+ const isLastSelectedBeforeDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.add({ days: 1 }));
411
+ const isFirstSelectedAfterDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.subtract({ days: 1 }));
412
+ const highlightedRange = "highlightedRange" in state && state.highlightedRange;
413
+ const isSelectionStart = isSelected && highlightedRange ? (0, import_date3.isSameDay)(props.date, highlightedRange.start) : false;
414
+ const isSelectionEnd = isSelected && highlightedRange ? (0, import_date3.isSameDay)(props.date, highlightedRange.end) : false;
415
+ const { locale } = (0, import_i18n2.useLocale)();
416
+ const dayOfWeek = (0, import_date3.getDayOfWeek)(props.date, locale, firstDayOfWeek);
417
+ const isRangeStart = isSelected && (isFirstSelectedAfterDisabled || dayOfWeek === 0 || props.date.day === 1);
418
+ const isRangeEnd = isSelected && (isLastSelectedBeforeDisabled || dayOfWeek === 6 || props.date.day === currentMonth.calendar.getDaysInMonth(currentMonth));
419
+ const { focusProps, isFocusVisible } = (0, import_focus.useFocusRing)();
420
+ const { hoverProps, isHovered } = (0, import_interactions.useHover)({
421
+ isDisabled: isDisabled || isUnavailable || state.isReadOnly
422
+ });
423
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { className: slots == null ? void 0 : slots.cell({ class: classNames == null ? void 0 : classNames.cell }), "data-slot": "cell", ...cellProps, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
424
+ "span",
425
+ {
426
+ ...(0, import_shared_utils3.mergeProps)(buttonProps, hoverProps, focusProps),
427
+ ref,
428
+ className: slots == null ? void 0 : slots.cellButton({ class: classNames == null ? void 0 : classNames.cellButton }),
429
+ "data-disabled": (0, import_shared_utils3.dataAttr)(isDisabled && !isInvalid),
430
+ "data-focus-visible": (0, import_shared_utils3.dataAttr)(isFocused && isFocusVisible),
431
+ "data-hover": (0, import_shared_utils3.dataAttr)(isHovered),
432
+ "data-invalid": (0, import_shared_utils3.dataAttr)(isInvalid),
433
+ "data-outside-month": (0, import_shared_utils3.dataAttr)(!(0, import_date3.isSameMonth)(props.date, currentMonth)),
434
+ "data-pressed": (0, import_shared_utils3.dataAttr)(isPressed && !state.isReadOnly),
435
+ "data-range-end": (0, import_shared_utils3.dataAttr)(isRangeEnd),
436
+ "data-range-selection": (0, import_shared_utils3.dataAttr)(isSelected && "highlightedRange" in state),
437
+ "data-range-start": (0, import_shared_utils3.dataAttr)(isRangeStart),
438
+ "data-readonly": (0, import_shared_utils3.dataAttr)(state.isReadOnly),
439
+ "data-selected": (0, import_shared_utils3.dataAttr)(isSelected),
440
+ "data-selection-end": (0, import_shared_utils3.dataAttr)(isSelectionEnd),
441
+ "data-selection-start": (0, import_shared_utils3.dataAttr)(isSelectionStart),
442
+ "data-today": (0, import_shared_utils3.dataAttr)((0, import_date3.isToday)(props.date, state.timeZone)),
443
+ "data-unavailable": (0, import_shared_utils3.dataAttr)(isUnavailable),
444
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formattedDate })
445
+ }
446
+ ) });
447
+ }
448
+
449
+ // src/calendar-transitions.ts
450
+ var transition = {
451
+ type: "spring",
452
+ bounce: 0,
453
+ duration: 0.3
454
+ };
455
+ var slideVariants = {
456
+ enter: (direction) => ({
457
+ x: `${direction * 100}%`
458
+ }),
459
+ center: {
460
+ x: "0%"
461
+ },
462
+ exit: (direction) => ({
463
+ x: `${direction * -100}%`
464
+ })
465
+ };
466
+
467
+ // src/calendar-month.tsx
468
+ var import_jsx_runtime4 = require("react/jsx-runtime");
469
+ function CalendarMonth(props) {
470
+ const { startDate, direction, currentMonth, firstDayOfWeek } = props;
471
+ const { locale } = (0, import_i18n3.useLocale)();
472
+ const weeksInMonth = (0, import_date4.getWeeksInMonth)(startDate, locale, firstDayOfWeek);
473
+ const { state, slots, weekdayStyle, isHeaderExpanded, disableAnimation, classNames } = useCalendarContext();
474
+ const { gridProps, headerProps, weekDays } = (0, import_calendar4.useCalendarGrid)(
475
+ {
476
+ ...props,
477
+ weekdayStyle,
478
+ endDate: (0, import_date4.endOfMonth)(startDate),
479
+ firstDayOfWeek
480
+ },
481
+ state
482
+ );
483
+ const bodyContent = [...new Array(weeksInMonth).keys()].map((weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
484
+ "tr",
485
+ {
486
+ className: slots == null ? void 0 : slots.gridBodyRow({ class: classNames == null ? void 0 : classNames.gridBodyRow }),
487
+ "data-slot": "grid-body-row",
488
+ inert: isHeaderExpanded ? true : void 0,
489
+ children: state.getDatesInWeek(weekIndex, startDate).map(
490
+ (date, i) => date ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
491
+ CalendarCell,
492
+ {
493
+ classNames,
494
+ currentMonth: startDate,
495
+ date,
496
+ firstDayOfWeek,
497
+ isPickerVisible: isHeaderExpanded,
498
+ slots,
499
+ state
500
+ },
501
+ i
502
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", {}, i)
503
+ )
504
+ },
505
+ weekIndex
506
+ ));
507
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
508
+ "table",
509
+ {
510
+ ...gridProps,
511
+ "aria-hidden": (0, import_shared_utils4.dataAttr)(isHeaderExpanded),
512
+ className: slots == null ? void 0 : slots.grid({ class: classNames == null ? void 0 : classNames.grid }),
513
+ "data-slot": "grid",
514
+ tabIndex: -1,
515
+ children: [
516
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
517
+ "thead",
518
+ {
519
+ ...headerProps,
520
+ className: slots == null ? void 0 : slots.gridHeader({ class: classNames == null ? void 0 : classNames.gridHeader }),
521
+ "data-slot": "grid-header",
522
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
523
+ "tr",
524
+ {
525
+ className: slots == null ? void 0 : slots.gridHeaderRow({ class: classNames == null ? void 0 : classNames.gridHeaderRow }),
526
+ "data-slot": "grid-header-row",
527
+ children: weekDays.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
528
+ "th",
529
+ {
530
+ className: slots == null ? void 0 : slots.gridHeaderCell({ class: classNames == null ? void 0 : classNames.gridHeaderCell }),
531
+ "data-slot": "grid-header-cell",
532
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: day })
533
+ },
534
+ index
535
+ ))
536
+ }
537
+ )
538
+ }
539
+ ),
540
+ disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
541
+ "tbody",
542
+ {
543
+ className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
544
+ "data-slot": "grid-body",
545
+ tabIndex: isHeaderExpanded ? -1 : 0,
546
+ children: bodyContent
547
+ },
548
+ currentMonth
549
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
550
+ import_framer_motion.m.tbody,
551
+ {
552
+ animate: "center",
553
+ className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
554
+ custom: direction,
555
+ "data-slot": "grid-body",
556
+ exit: "exit",
557
+ initial: "enter",
558
+ variants: slideVariants,
559
+ children: bodyContent
560
+ },
561
+ currentMonth
562
+ )
563
+ ]
564
+ }
565
+ );
566
+ }
567
+
568
+ // src/calendar-header.tsx
569
+ var import_i18n4 = require("@react-aria/i18n");
570
+ var import_framer_motion2 = require("framer-motion");
571
+ var import_button = require("@sytechui/button");
572
+ var import_react4 = require("react");
573
+
574
+ // src/chevron-down.tsx
575
+ var import_jsx_runtime5 = require("react/jsx-runtime");
576
+ var ChevronDownIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
577
+ "svg",
578
+ {
579
+ "aria-hidden": "true",
580
+ fill: "none",
581
+ focusable: "false",
582
+ height: "1em",
583
+ role: "presentation",
584
+ viewBox: "0 0 24 24",
585
+ width: "1em",
586
+ ...props,
587
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
588
+ "path",
589
+ {
590
+ d: "M19 9L12 15L5 9",
591
+ stroke: "currentColor",
592
+ strokeLinecap: "round",
593
+ strokeLinejoin: "round",
594
+ strokeWidth: "1.5"
595
+ }
596
+ )
597
+ }
598
+ );
599
+
600
+ // src/calendar-header.tsx
601
+ var import_jsx_runtime6 = require("react/jsx-runtime");
602
+ function CalendarHeader(props) {
603
+ const { direction, date, currentMonth, buttonPickerProps } = props;
604
+ const {
605
+ state,
606
+ slots,
607
+ headerRef,
608
+ showMonthAndYearPickers,
609
+ isHeaderExpanded,
610
+ setIsHeaderExpanded,
611
+ disableAnimation,
612
+ classNames
613
+ } = useCalendarContext();
614
+ const monthAndYearDateFormatter = (0, import_i18n4.useDateFormatter)({
615
+ month: "long",
616
+ era: currentMonth.calendar.identifier === "gregory" && currentMonth.era === "BC" ? "short" : void 0,
617
+ calendar: currentMonth.calendar.identifier,
618
+ timeZone: state.timeZone,
619
+ year: "numeric"
620
+ });
621
+ const monthDateContent = monthAndYearDateFormatter.format(date.toDate(state.timeZone));
622
+ const headerTitle = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
623
+ "span",
624
+ {
625
+ "aria-hidden": true,
626
+ className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
627
+ "data-slot": "title",
628
+ children: monthDateContent
629
+ },
630
+ currentMonth.month
631
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
632
+ import_framer_motion2.m.span,
633
+ {
634
+ animate: "center",
635
+ "aria-hidden": true,
636
+ className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
637
+ custom: direction,
638
+ "data-slot": "title",
639
+ exit: "exit",
640
+ initial: "enter",
641
+ variants: isHeaderExpanded ? {} : slideVariants,
642
+ children: monthDateContent
643
+ },
644
+ currentMonth.month
645
+ ) });
646
+ const headerProps = {
647
+ ref: headerRef,
648
+ className: slots == null ? void 0 : slots.header({ class: classNames == null ? void 0 : classNames.header }),
649
+ "data-slot": "header"
650
+ };
651
+ const handleKeyDown = (0, import_react4.useCallback)(
652
+ (e) => {
653
+ if (e.key === "Escape") {
654
+ e.preventDefault();
655
+ e.stopPropagation();
656
+ setIsHeaderExpanded == null ? void 0 : setIsHeaderExpanded(false);
657
+ }
658
+ },
659
+ [setIsHeaderExpanded]
660
+ );
661
+ return showMonthAndYearPickers ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
662
+ import_button.Button,
663
+ {
664
+ ...headerProps,
665
+ "aria-label": "switch to year and month view",
666
+ disableAnimation,
667
+ endContent: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronDownIcon, { className: "chevron-icon" }),
668
+ onKeyDown: handleKeyDown,
669
+ ...buttonPickerProps,
670
+ children: headerTitle
671
+ }
672
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("header", { ...headerProps, children: headerTitle });
673
+ }
674
+
675
+ // src/calendar-picker.tsx
676
+ var import_time_picker = require("@sytechui/time-picker");
677
+
678
+ // src/use-calendar-picker.ts
679
+ function useCalendarPicker(_props) {
680
+ const { slots, state, isHeaderExpanded, classNames } = useCalendarContext();
681
+ return {
682
+ state,
683
+ slots,
684
+ classNames,
685
+ isHeaderExpanded
686
+ };
687
+ }
688
+
689
+ // src/calendar-picker.tsx
690
+ var import_jsx_runtime7 = require("react/jsx-runtime");
691
+ function CalendarPicker(props) {
692
+ const { state, slots, classNames, isHeaderExpanded } = useCalendarPicker(props);
693
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
694
+ "div",
695
+ {
696
+ className: slots == null ? void 0 : slots.pickerWrapper({
697
+ class: classNames == null ? void 0 : classNames.pickerWrapper
698
+ }),
699
+ "data-slot": "picker-wrapper",
700
+ inert: !isHeaderExpanded ? true : void 0,
701
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
702
+ import_time_picker.TimePicker,
703
+ {
704
+ isMonth: true,
705
+ isYear: true,
706
+ isDay: false,
707
+ value: state.focusedDate,
708
+ onChange: (date) => {
709
+ state.setFocusedDate(
710
+ state.focusedDate.set({
711
+ year: date.year,
712
+ month: date.month
713
+ })
714
+ );
715
+ }
716
+ }
717
+ )
718
+ }
719
+ );
720
+ }
721
+
722
+ // src/calendar-base.tsx
723
+ var import_jsx_runtime8 = require("react/jsx-runtime");
724
+ var import_react6 = require("react");
725
+ var domAnimation = () => import("@sytechui/dom-animation").then((res) => res.default);
726
+ var PopLayoutWrapper = (0, import_react5.forwardRef)(
727
+ (props, ref) => {
728
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref, ...props });
729
+ }
730
+ );
731
+ PopLayoutWrapper.displayName = "HeroUI - PopLayoutWrapper";
732
+ function CalendarBase(props) {
733
+ const {
734
+ Component = "div",
735
+ showHelper,
736
+ topContent,
737
+ bottomContent,
738
+ calendarProps,
739
+ nextButtonProps,
740
+ prevButtonProps,
741
+ buttonPickerProps,
742
+ errorMessageProps,
743
+ calendarRef: ref,
744
+ errorMessage,
745
+ firstDayOfWeek,
746
+ ...otherProps
747
+ } = props;
748
+ const { state, slots, visibleMonths, showMonthAndYearPickers, disableAnimation, classNames } = useCalendarContext();
749
+ const [direction, setDirection] = (0, import_react5.useState)(0);
750
+ const { direction: localeDirection } = (0, import_i18n5.useLocale)();
751
+ const currentMonth = state.visibleRange.start;
752
+ const headers = [];
753
+ const calendars = [];
754
+ const isRTL = localeDirection === "rtl";
755
+ for (let i = 0; i < visibleMonths; i++) {
756
+ let d = currentMonth.add({ months: i });
757
+ headers.push(
758
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Fragment, { children: [
759
+ i === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
760
+ import_button2.Button,
761
+ {
762
+ ...isRTL ? nextButtonProps : prevButtonProps,
763
+ onPress: (0, import_shared_utils5.chain)(
764
+ isRTL ? nextButtonProps.onPress : prevButtonProps.onPress,
765
+ () => setDirection(-1)
766
+ ),
767
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronLeftIcon, {})
768
+ }
769
+ ),
770
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
771
+ CalendarHeader,
772
+ {
773
+ buttonPickerProps,
774
+ currentMonth,
775
+ date: d,
776
+ direction
777
+ }
778
+ ),
779
+ i === visibleMonths - 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
780
+ import_button2.Button,
781
+ {
782
+ ...isRTL ? prevButtonProps : nextButtonProps,
783
+ onPress: (0, import_shared_utils5.chain)(
784
+ isRTL ? prevButtonProps.onPress : nextButtonProps.onPress,
785
+ () => setDirection(1)
786
+ ),
787
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronRightIcon, {})
788
+ }
789
+ )
790
+ ] }, `calendar-header-${i}`)
791
+ );
792
+ const calendarMonthContent = /* @__PURE__ */ (0, import_react6.createElement)(
793
+ CalendarMonth,
794
+ {
795
+ ...props,
796
+ key: `calendar-month-${i}`,
797
+ currentMonth: currentMonth.month,
798
+ direction,
799
+ firstDayOfWeek,
800
+ startDate: d
801
+ }
802
+ );
803
+ calendars.push(
804
+ showMonthAndYearPickers ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Fragment, { children: [
805
+ calendarMonthContent,
806
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarPicker, { currentMonth, date: d })
807
+ ] }, `calendar-month-with-pickers-${i}`) : calendarMonthContent
808
+ );
809
+ }
810
+ const calendarContent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
811
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
812
+ "div",
813
+ {
814
+ className: slots == null ? void 0 : slots.headerWrapper({ class: classNames == null ? void 0 : classNames.headerWrapper }),
815
+ "data-slot": "header-wrapper",
816
+ children: headers
817
+ },
818
+ "header-wrapper"
819
+ ),
820
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
821
+ "div",
822
+ {
823
+ className: slots == null ? void 0 : slots.gridWrapper({ class: classNames == null ? void 0 : classNames.gridWrapper }),
824
+ "data-slot": "grid-wrapper",
825
+ children: calendars
826
+ },
827
+ "grid-wrapper"
828
+ )
829
+ ] });
830
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Component, { ...(0, import_shared_utils5.mergeProps)(calendarProps, otherProps), ref, children: [
831
+ topContent,
832
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_visually_hidden.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { children: calendarProps["aria-label"] }) }),
833
+ disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: slots == null ? void 0 : slots.content({ class: classNames == null ? void 0 : classNames.content }), "data-slot": "content", children: calendarContent }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
834
+ import_framer_utils.ResizablePanel,
835
+ {
836
+ className: slots == null ? void 0 : slots.content({ class: classNames == null ? void 0 : classNames.content }),
837
+ "data-slot": "content",
838
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_framer_motion3.AnimatePresence, { custom: direction, initial: false, mode: "popLayout", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PopLayoutWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_framer_motion3.MotionConfig, { transition, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_framer_motion3.LazyMotion, { features: domAnimation, children: calendarContent }) }) }) })
839
+ }
840
+ ),
841
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_visually_hidden.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
842
+ "button",
843
+ {
844
+ "aria-label": nextButtonProps["aria-label"],
845
+ disabled: nextButtonProps.isDisabled,
846
+ tabIndex: -1,
847
+ onClick: () => state.focusNextPage()
848
+ }
849
+ ) }),
850
+ state.isValueInvalid && showHelper && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
851
+ "div",
852
+ {
853
+ className: slots == null ? void 0 : slots.helperWrapper({ class: classNames == null ? void 0 : classNames.helperWrapper }),
854
+ "data-slot": "helper-wrapper",
855
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
856
+ "span",
857
+ {
858
+ ...errorMessageProps,
859
+ className: slots == null ? void 0 : slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage }),
860
+ "data-slot": "error-message",
861
+ children: errorMessage || "Selected date unavailable."
862
+ }
863
+ )
864
+ }
865
+ ),
866
+ bottomContent
867
+ ] });
868
+ }
869
+
870
+ // src/calendar.tsx
871
+ var import_jsx_runtime9 = require("react/jsx-runtime");
872
+ var Calendar = (0, import_system2.forwardRef)(function Calendar2(props, ref) {
873
+ const { context, getBaseCalendarProps } = useCalendar({ ...props, ref });
874
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CalendarProvider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CalendarBase, { ...getBaseCalendarProps() }) });
875
+ });
876
+ var calendar_default = Calendar;