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