@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
|
@@ -0,0 +1,604 @@
|
|
|
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-base.tsx
|
|
32
|
+
var calendar_base_exports = {};
|
|
33
|
+
__export(calendar_base_exports, {
|
|
34
|
+
CalendarBase: () => CalendarBase
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(calendar_base_exports);
|
|
37
|
+
var import_react3 = require("react");
|
|
38
|
+
var import_visually_hidden = require("@react-aria/visually-hidden");
|
|
39
|
+
var import_button2 = require("@sytechui/button");
|
|
40
|
+
var import_shared_utils3 = require("@sytechui/shared-utils");
|
|
41
|
+
var import_framer_motion3 = require("framer-motion");
|
|
42
|
+
var import_i18n4 = require("@react-aria/i18n");
|
|
43
|
+
var import_framer_utils = require("@sytechui/framer-utils");
|
|
44
|
+
|
|
45
|
+
// src/chevron-left.tsx
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var ChevronLeftIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
"svg",
|
|
49
|
+
{
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
fill: "none",
|
|
52
|
+
focusable: "false",
|
|
53
|
+
height: "1em",
|
|
54
|
+
role: "presentation",
|
|
55
|
+
viewBox: "0 0 16 16",
|
|
56
|
+
width: "1em",
|
|
57
|
+
...props,
|
|
58
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
d: "M10 3.33334L6 8.00001L10 12.6667",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeLinejoin: "round",
|
|
65
|
+
strokeWidth: "1.5"
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// src/chevron-right.tsx
|
|
72
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
73
|
+
var ChevronRightIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
74
|
+
"svg",
|
|
75
|
+
{
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
fill: "none",
|
|
78
|
+
focusable: "false",
|
|
79
|
+
height: "1em",
|
|
80
|
+
role: "presentation",
|
|
81
|
+
viewBox: "0 0 16 16",
|
|
82
|
+
width: "1em",
|
|
83
|
+
...props,
|
|
84
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
85
|
+
"path",
|
|
86
|
+
{
|
|
87
|
+
d: "M6 3.33334L10 8.00001L6 12.6667",
|
|
88
|
+
stroke: "currentColor",
|
|
89
|
+
strokeLinecap: "round",
|
|
90
|
+
strokeLinejoin: "round",
|
|
91
|
+
strokeWidth: "1.5"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// src/calendar-month.tsx
|
|
98
|
+
var import_date2 = require("@internationalized/date");
|
|
99
|
+
var import_i18n2 = require("@react-aria/i18n");
|
|
100
|
+
var import_calendar2 = require("@react-aria/calendar");
|
|
101
|
+
var import_framer_motion = require("framer-motion");
|
|
102
|
+
var import_shared_utils2 = require("@sytechui/shared-utils");
|
|
103
|
+
|
|
104
|
+
// src/calendar-cell.tsx
|
|
105
|
+
var import_date = require("@internationalized/date");
|
|
106
|
+
var import_calendar = require("@react-aria/calendar");
|
|
107
|
+
var import_i18n = require("@react-aria/i18n");
|
|
108
|
+
var import_focus = require("@react-aria/focus");
|
|
109
|
+
var import_interactions = require("@react-aria/interactions");
|
|
110
|
+
var import_react = require("react");
|
|
111
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
112
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
113
|
+
function CalendarCell(originalProps) {
|
|
114
|
+
const { state, slots, isPickerVisible, currentMonth, classNames, firstDayOfWeek, ...props } = originalProps;
|
|
115
|
+
const ref = (0, import_react.useRef)(null);
|
|
116
|
+
const {
|
|
117
|
+
cellProps,
|
|
118
|
+
buttonProps,
|
|
119
|
+
isPressed,
|
|
120
|
+
isSelected,
|
|
121
|
+
isDisabled,
|
|
122
|
+
isFocused,
|
|
123
|
+
isInvalid,
|
|
124
|
+
formattedDate
|
|
125
|
+
} = (0, import_calendar.useCalendarCell)(
|
|
126
|
+
{
|
|
127
|
+
...props,
|
|
128
|
+
isDisabled: !(0, import_date.isSameMonth)(props.date, currentMonth) || isPickerVisible
|
|
129
|
+
},
|
|
130
|
+
state,
|
|
131
|
+
ref
|
|
132
|
+
);
|
|
133
|
+
const isUnavailable = state.isCellUnavailable(props.date);
|
|
134
|
+
const isLastSelectedBeforeDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.add({ days: 1 }));
|
|
135
|
+
const isFirstSelectedAfterDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.subtract({ days: 1 }));
|
|
136
|
+
const highlightedRange = "highlightedRange" in state && state.highlightedRange;
|
|
137
|
+
const isSelectionStart = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.start) : false;
|
|
138
|
+
const isSelectionEnd = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.end) : false;
|
|
139
|
+
const { locale } = (0, import_i18n.useLocale)();
|
|
140
|
+
const dayOfWeek = (0, import_date.getDayOfWeek)(props.date, locale, firstDayOfWeek);
|
|
141
|
+
const isRangeStart = isSelected && (isFirstSelectedAfterDisabled || dayOfWeek === 0 || props.date.day === 1);
|
|
142
|
+
const isRangeEnd = isSelected && (isLastSelectedBeforeDisabled || dayOfWeek === 6 || props.date.day === currentMonth.calendar.getDaysInMonth(currentMonth));
|
|
143
|
+
const { focusProps, isFocusVisible } = (0, import_focus.useFocusRing)();
|
|
144
|
+
const { hoverProps, isHovered } = (0, import_interactions.useHover)({
|
|
145
|
+
isDisabled: isDisabled || isUnavailable || state.isReadOnly
|
|
146
|
+
});
|
|
147
|
+
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)(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
...(0, import_shared_utils.mergeProps)(buttonProps, hoverProps, focusProps),
|
|
151
|
+
ref,
|
|
152
|
+
className: slots == null ? void 0 : slots.cellButton({ class: classNames == null ? void 0 : classNames.cellButton }),
|
|
153
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled && !isInvalid),
|
|
154
|
+
"data-focus-visible": (0, import_shared_utils.dataAttr)(isFocused && isFocusVisible),
|
|
155
|
+
"data-hover": (0, import_shared_utils.dataAttr)(isHovered),
|
|
156
|
+
"data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
|
|
157
|
+
"data-outside-month": (0, import_shared_utils.dataAttr)(!(0, import_date.isSameMonth)(props.date, currentMonth)),
|
|
158
|
+
"data-pressed": (0, import_shared_utils.dataAttr)(isPressed && !state.isReadOnly),
|
|
159
|
+
"data-range-end": (0, import_shared_utils.dataAttr)(isRangeEnd),
|
|
160
|
+
"data-range-selection": (0, import_shared_utils.dataAttr)(isSelected && "highlightedRange" in state),
|
|
161
|
+
"data-range-start": (0, import_shared_utils.dataAttr)(isRangeStart),
|
|
162
|
+
"data-readonly": (0, import_shared_utils.dataAttr)(state.isReadOnly),
|
|
163
|
+
"data-selected": (0, import_shared_utils.dataAttr)(isSelected),
|
|
164
|
+
"data-selection-end": (0, import_shared_utils.dataAttr)(isSelectionEnd),
|
|
165
|
+
"data-selection-start": (0, import_shared_utils.dataAttr)(isSelectionStart),
|
|
166
|
+
"data-today": (0, import_shared_utils.dataAttr)((0, import_date.isToday)(props.date, state.timeZone)),
|
|
167
|
+
"data-unavailable": (0, import_shared_utils.dataAttr)(isUnavailable),
|
|
168
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formattedDate })
|
|
169
|
+
}
|
|
170
|
+
) });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/calendar-transitions.ts
|
|
174
|
+
var transition = {
|
|
175
|
+
type: "spring",
|
|
176
|
+
bounce: 0,
|
|
177
|
+
duration: 0.3
|
|
178
|
+
};
|
|
179
|
+
var slideVariants = {
|
|
180
|
+
enter: (direction) => ({
|
|
181
|
+
x: `${direction * 100}%`
|
|
182
|
+
}),
|
|
183
|
+
center: {
|
|
184
|
+
x: "0%"
|
|
185
|
+
},
|
|
186
|
+
exit: (direction) => ({
|
|
187
|
+
x: `${direction * -100}%`
|
|
188
|
+
})
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/calendar-context.ts
|
|
192
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
193
|
+
var [CalendarProvider, useCalendarContext] = (0, import_react_utils.createContext)({
|
|
194
|
+
name: "CalendarContext",
|
|
195
|
+
strict: true,
|
|
196
|
+
errorMessage: "useContext: `context` is undefined. Seems you forgot to wrap component within the CalendarProvider"
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/calendar-month.tsx
|
|
200
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
201
|
+
function CalendarMonth(props) {
|
|
202
|
+
const { startDate, direction, currentMonth, firstDayOfWeek } = props;
|
|
203
|
+
const { locale } = (0, import_i18n2.useLocale)();
|
|
204
|
+
const weeksInMonth = (0, import_date2.getWeeksInMonth)(startDate, locale, firstDayOfWeek);
|
|
205
|
+
const { state, slots, weekdayStyle, isHeaderExpanded, disableAnimation, classNames } = useCalendarContext();
|
|
206
|
+
const { gridProps, headerProps, weekDays } = (0, import_calendar2.useCalendarGrid)(
|
|
207
|
+
{
|
|
208
|
+
...props,
|
|
209
|
+
weekdayStyle,
|
|
210
|
+
endDate: (0, import_date2.endOfMonth)(startDate),
|
|
211
|
+
firstDayOfWeek
|
|
212
|
+
},
|
|
213
|
+
state
|
|
214
|
+
);
|
|
215
|
+
const bodyContent = [...new Array(weeksInMonth).keys()].map((weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
216
|
+
"tr",
|
|
217
|
+
{
|
|
218
|
+
className: slots == null ? void 0 : slots.gridBodyRow({ class: classNames == null ? void 0 : classNames.gridBodyRow }),
|
|
219
|
+
"data-slot": "grid-body-row",
|
|
220
|
+
inert: isHeaderExpanded ? true : void 0,
|
|
221
|
+
children: state.getDatesInWeek(weekIndex, startDate).map(
|
|
222
|
+
(date, i) => date ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
223
|
+
CalendarCell,
|
|
224
|
+
{
|
|
225
|
+
classNames,
|
|
226
|
+
currentMonth: startDate,
|
|
227
|
+
date,
|
|
228
|
+
firstDayOfWeek,
|
|
229
|
+
isPickerVisible: isHeaderExpanded,
|
|
230
|
+
slots,
|
|
231
|
+
state
|
|
232
|
+
},
|
|
233
|
+
i
|
|
234
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("td", {}, i)
|
|
235
|
+
)
|
|
236
|
+
},
|
|
237
|
+
weekIndex
|
|
238
|
+
));
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
240
|
+
"table",
|
|
241
|
+
{
|
|
242
|
+
...gridProps,
|
|
243
|
+
"aria-hidden": (0, import_shared_utils2.dataAttr)(isHeaderExpanded),
|
|
244
|
+
className: slots == null ? void 0 : slots.grid({ class: classNames == null ? void 0 : classNames.grid }),
|
|
245
|
+
"data-slot": "grid",
|
|
246
|
+
tabIndex: -1,
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
249
|
+
"thead",
|
|
250
|
+
{
|
|
251
|
+
...headerProps,
|
|
252
|
+
className: slots == null ? void 0 : slots.gridHeader({ class: classNames == null ? void 0 : classNames.gridHeader }),
|
|
253
|
+
"data-slot": "grid-header",
|
|
254
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
255
|
+
"tr",
|
|
256
|
+
{
|
|
257
|
+
className: slots == null ? void 0 : slots.gridHeaderRow({ class: classNames == null ? void 0 : classNames.gridHeaderRow }),
|
|
258
|
+
"data-slot": "grid-header-row",
|
|
259
|
+
children: weekDays.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
260
|
+
"th",
|
|
261
|
+
{
|
|
262
|
+
className: slots == null ? void 0 : slots.gridHeaderCell({ class: classNames == null ? void 0 : classNames.gridHeaderCell }),
|
|
263
|
+
"data-slot": "grid-header-cell",
|
|
264
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: day })
|
|
265
|
+
},
|
|
266
|
+
index
|
|
267
|
+
))
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
),
|
|
272
|
+
disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
273
|
+
"tbody",
|
|
274
|
+
{
|
|
275
|
+
className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
|
|
276
|
+
"data-slot": "grid-body",
|
|
277
|
+
tabIndex: isHeaderExpanded ? -1 : 0,
|
|
278
|
+
children: bodyContent
|
|
279
|
+
},
|
|
280
|
+
currentMonth
|
|
281
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
282
|
+
import_framer_motion.m.tbody,
|
|
283
|
+
{
|
|
284
|
+
animate: "center",
|
|
285
|
+
className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
|
|
286
|
+
custom: direction,
|
|
287
|
+
"data-slot": "grid-body",
|
|
288
|
+
exit: "exit",
|
|
289
|
+
initial: "enter",
|
|
290
|
+
variants: slideVariants,
|
|
291
|
+
children: bodyContent
|
|
292
|
+
},
|
|
293
|
+
currentMonth
|
|
294
|
+
)
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/calendar-header.tsx
|
|
301
|
+
var import_i18n3 = require("@react-aria/i18n");
|
|
302
|
+
var import_framer_motion2 = require("framer-motion");
|
|
303
|
+
var import_button = require("@sytechui/button");
|
|
304
|
+
var import_react2 = require("react");
|
|
305
|
+
|
|
306
|
+
// src/chevron-down.tsx
|
|
307
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
308
|
+
var ChevronDownIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
309
|
+
"svg",
|
|
310
|
+
{
|
|
311
|
+
"aria-hidden": "true",
|
|
312
|
+
fill: "none",
|
|
313
|
+
focusable: "false",
|
|
314
|
+
height: "1em",
|
|
315
|
+
role: "presentation",
|
|
316
|
+
viewBox: "0 0 24 24",
|
|
317
|
+
width: "1em",
|
|
318
|
+
...props,
|
|
319
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
320
|
+
"path",
|
|
321
|
+
{
|
|
322
|
+
d: "M19 9L12 15L5 9",
|
|
323
|
+
stroke: "currentColor",
|
|
324
|
+
strokeLinecap: "round",
|
|
325
|
+
strokeLinejoin: "round",
|
|
326
|
+
strokeWidth: "1.5"
|
|
327
|
+
}
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// src/calendar-header.tsx
|
|
333
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
334
|
+
function CalendarHeader(props) {
|
|
335
|
+
const { direction, date, currentMonth, buttonPickerProps } = props;
|
|
336
|
+
const {
|
|
337
|
+
state,
|
|
338
|
+
slots,
|
|
339
|
+
headerRef,
|
|
340
|
+
showMonthAndYearPickers,
|
|
341
|
+
isHeaderExpanded,
|
|
342
|
+
setIsHeaderExpanded,
|
|
343
|
+
disableAnimation,
|
|
344
|
+
classNames
|
|
345
|
+
} = useCalendarContext();
|
|
346
|
+
const monthAndYearDateFormatter = (0, import_i18n3.useDateFormatter)({
|
|
347
|
+
month: "long",
|
|
348
|
+
era: currentMonth.calendar.identifier === "gregory" && currentMonth.era === "BC" ? "short" : void 0,
|
|
349
|
+
calendar: currentMonth.calendar.identifier,
|
|
350
|
+
timeZone: state.timeZone,
|
|
351
|
+
year: "numeric"
|
|
352
|
+
});
|
|
353
|
+
const monthDateContent = monthAndYearDateFormatter.format(date.toDate(state.timeZone));
|
|
354
|
+
const headerTitle = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
355
|
+
"span",
|
|
356
|
+
{
|
|
357
|
+
"aria-hidden": true,
|
|
358
|
+
className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
|
|
359
|
+
"data-slot": "title",
|
|
360
|
+
children: monthDateContent
|
|
361
|
+
},
|
|
362
|
+
currentMonth.month
|
|
363
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
364
|
+
import_framer_motion2.m.span,
|
|
365
|
+
{
|
|
366
|
+
animate: "center",
|
|
367
|
+
"aria-hidden": true,
|
|
368
|
+
className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
|
|
369
|
+
custom: direction,
|
|
370
|
+
"data-slot": "title",
|
|
371
|
+
exit: "exit",
|
|
372
|
+
initial: "enter",
|
|
373
|
+
variants: isHeaderExpanded ? {} : slideVariants,
|
|
374
|
+
children: monthDateContent
|
|
375
|
+
},
|
|
376
|
+
currentMonth.month
|
|
377
|
+
) });
|
|
378
|
+
const headerProps = {
|
|
379
|
+
ref: headerRef,
|
|
380
|
+
className: slots == null ? void 0 : slots.header({ class: classNames == null ? void 0 : classNames.header }),
|
|
381
|
+
"data-slot": "header"
|
|
382
|
+
};
|
|
383
|
+
const handleKeyDown = (0, import_react2.useCallback)(
|
|
384
|
+
(e) => {
|
|
385
|
+
if (e.key === "Escape") {
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
e.stopPropagation();
|
|
388
|
+
setIsHeaderExpanded == null ? void 0 : setIsHeaderExpanded(false);
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
[setIsHeaderExpanded]
|
|
392
|
+
);
|
|
393
|
+
return showMonthAndYearPickers ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
394
|
+
import_button.Button,
|
|
395
|
+
{
|
|
396
|
+
...headerProps,
|
|
397
|
+
"aria-label": "switch to year and month view",
|
|
398
|
+
disableAnimation,
|
|
399
|
+
endContent: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChevronDownIcon, { className: "chevron-icon" }),
|
|
400
|
+
onKeyDown: handleKeyDown,
|
|
401
|
+
...buttonPickerProps,
|
|
402
|
+
children: headerTitle
|
|
403
|
+
}
|
|
404
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("header", { ...headerProps, children: headerTitle });
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/calendar-picker.tsx
|
|
408
|
+
var import_time_picker = require("@sytechui/time-picker");
|
|
409
|
+
|
|
410
|
+
// src/use-calendar-picker.ts
|
|
411
|
+
function useCalendarPicker(_props) {
|
|
412
|
+
const { slots, state, isHeaderExpanded, classNames } = useCalendarContext();
|
|
413
|
+
return {
|
|
414
|
+
state,
|
|
415
|
+
slots,
|
|
416
|
+
classNames,
|
|
417
|
+
isHeaderExpanded
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/calendar-picker.tsx
|
|
422
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
423
|
+
function CalendarPicker(props) {
|
|
424
|
+
const { state, slots, classNames, isHeaderExpanded } = useCalendarPicker(props);
|
|
425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
426
|
+
"div",
|
|
427
|
+
{
|
|
428
|
+
className: slots == null ? void 0 : slots.pickerWrapper({
|
|
429
|
+
class: classNames == null ? void 0 : classNames.pickerWrapper
|
|
430
|
+
}),
|
|
431
|
+
"data-slot": "picker-wrapper",
|
|
432
|
+
inert: !isHeaderExpanded ? true : void 0,
|
|
433
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
434
|
+
import_time_picker.TimePicker,
|
|
435
|
+
{
|
|
436
|
+
isMonth: true,
|
|
437
|
+
isYear: true,
|
|
438
|
+
isDay: false,
|
|
439
|
+
value: state.focusedDate,
|
|
440
|
+
onChange: (date) => {
|
|
441
|
+
state.setFocusedDate(
|
|
442
|
+
state.focusedDate.set({
|
|
443
|
+
year: date.year,
|
|
444
|
+
month: date.month
|
|
445
|
+
})
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// src/calendar-base.tsx
|
|
455
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
456
|
+
var import_react4 = require("react");
|
|
457
|
+
var domAnimation = () => import("@sytechui/dom-animation").then((res) => res.default);
|
|
458
|
+
var PopLayoutWrapper = (0, import_react3.forwardRef)(
|
|
459
|
+
(props, ref) => {
|
|
460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref, ...props });
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
PopLayoutWrapper.displayName = "HeroUI - PopLayoutWrapper";
|
|
464
|
+
function CalendarBase(props) {
|
|
465
|
+
const {
|
|
466
|
+
Component = "div",
|
|
467
|
+
showHelper,
|
|
468
|
+
topContent,
|
|
469
|
+
bottomContent,
|
|
470
|
+
calendarProps,
|
|
471
|
+
nextButtonProps,
|
|
472
|
+
prevButtonProps,
|
|
473
|
+
buttonPickerProps,
|
|
474
|
+
errorMessageProps,
|
|
475
|
+
calendarRef: ref,
|
|
476
|
+
errorMessage,
|
|
477
|
+
firstDayOfWeek,
|
|
478
|
+
...otherProps
|
|
479
|
+
} = props;
|
|
480
|
+
const { state, slots, visibleMonths, showMonthAndYearPickers, disableAnimation, classNames } = useCalendarContext();
|
|
481
|
+
const [direction, setDirection] = (0, import_react3.useState)(0);
|
|
482
|
+
const { direction: localeDirection } = (0, import_i18n4.useLocale)();
|
|
483
|
+
const currentMonth = state.visibleRange.start;
|
|
484
|
+
const headers = [];
|
|
485
|
+
const calendars = [];
|
|
486
|
+
const isRTL = localeDirection === "rtl";
|
|
487
|
+
for (let i = 0; i < visibleMonths; i++) {
|
|
488
|
+
let d = currentMonth.add({ months: i });
|
|
489
|
+
headers.push(
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react3.Fragment, { children: [
|
|
491
|
+
i === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
492
|
+
import_button2.Button,
|
|
493
|
+
{
|
|
494
|
+
...isRTL ? nextButtonProps : prevButtonProps,
|
|
495
|
+
onPress: (0, import_shared_utils3.chain)(
|
|
496
|
+
isRTL ? nextButtonProps.onPress : prevButtonProps.onPress,
|
|
497
|
+
() => setDirection(-1)
|
|
498
|
+
),
|
|
499
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronLeftIcon, {})
|
|
500
|
+
}
|
|
501
|
+
),
|
|
502
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
503
|
+
CalendarHeader,
|
|
504
|
+
{
|
|
505
|
+
buttonPickerProps,
|
|
506
|
+
currentMonth,
|
|
507
|
+
date: d,
|
|
508
|
+
direction
|
|
509
|
+
}
|
|
510
|
+
),
|
|
511
|
+
i === visibleMonths - 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
512
|
+
import_button2.Button,
|
|
513
|
+
{
|
|
514
|
+
...isRTL ? prevButtonProps : nextButtonProps,
|
|
515
|
+
onPress: (0, import_shared_utils3.chain)(
|
|
516
|
+
isRTL ? prevButtonProps.onPress : nextButtonProps.onPress,
|
|
517
|
+
() => setDirection(1)
|
|
518
|
+
),
|
|
519
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChevronRightIcon, {})
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
] }, `calendar-header-${i}`)
|
|
523
|
+
);
|
|
524
|
+
const calendarMonthContent = /* @__PURE__ */ (0, import_react4.createElement)(
|
|
525
|
+
CalendarMonth,
|
|
526
|
+
{
|
|
527
|
+
...props,
|
|
528
|
+
key: `calendar-month-${i}`,
|
|
529
|
+
currentMonth: currentMonth.month,
|
|
530
|
+
direction,
|
|
531
|
+
firstDayOfWeek,
|
|
532
|
+
startDate: d
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
calendars.push(
|
|
536
|
+
showMonthAndYearPickers ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react3.Fragment, { children: [
|
|
537
|
+
calendarMonthContent,
|
|
538
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarPicker, { currentMonth, date: d })
|
|
539
|
+
] }, `calendar-month-with-pickers-${i}`) : calendarMonthContent
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
const calendarContent = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
544
|
+
"div",
|
|
545
|
+
{
|
|
546
|
+
className: slots == null ? void 0 : slots.headerWrapper({ class: classNames == null ? void 0 : classNames.headerWrapper }),
|
|
547
|
+
"data-slot": "header-wrapper",
|
|
548
|
+
children: headers
|
|
549
|
+
},
|
|
550
|
+
"header-wrapper"
|
|
551
|
+
),
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
className: slots == null ? void 0 : slots.gridWrapper({ class: classNames == null ? void 0 : classNames.gridWrapper }),
|
|
556
|
+
"data-slot": "grid-wrapper",
|
|
557
|
+
children: calendars
|
|
558
|
+
},
|
|
559
|
+
"grid-wrapper"
|
|
560
|
+
)
|
|
561
|
+
] });
|
|
562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Component, { ...(0, import_shared_utils3.mergeProps)(calendarProps, otherProps), ref, children: [
|
|
563
|
+
topContent,
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_visually_hidden.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { children: calendarProps["aria-label"] }) }),
|
|
565
|
+
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)(
|
|
566
|
+
import_framer_utils.ResizablePanel,
|
|
567
|
+
{
|
|
568
|
+
className: slots == null ? void 0 : slots.content({ class: classNames == null ? void 0 : classNames.content }),
|
|
569
|
+
"data-slot": "content",
|
|
570
|
+
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 }) }) }) })
|
|
571
|
+
}
|
|
572
|
+
),
|
|
573
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_visually_hidden.VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
574
|
+
"button",
|
|
575
|
+
{
|
|
576
|
+
"aria-label": nextButtonProps["aria-label"],
|
|
577
|
+
disabled: nextButtonProps.isDisabled,
|
|
578
|
+
tabIndex: -1,
|
|
579
|
+
onClick: () => state.focusNextPage()
|
|
580
|
+
}
|
|
581
|
+
) }),
|
|
582
|
+
state.isValueInvalid && showHelper && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
583
|
+
"div",
|
|
584
|
+
{
|
|
585
|
+
className: slots == null ? void 0 : slots.helperWrapper({ class: classNames == null ? void 0 : classNames.helperWrapper }),
|
|
586
|
+
"data-slot": "helper-wrapper",
|
|
587
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
588
|
+
"span",
|
|
589
|
+
{
|
|
590
|
+
...errorMessageProps,
|
|
591
|
+
className: slots == null ? void 0 : slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage }),
|
|
592
|
+
"data-slot": "error-message",
|
|
593
|
+
children: errorMessage || "Selected date unavailable."
|
|
594
|
+
}
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
),
|
|
598
|
+
bottomContent
|
|
599
|
+
] });
|
|
600
|
+
}
|
|
601
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
602
|
+
0 && (module.exports = {
|
|
603
|
+
CalendarBase
|
|
604
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
CalendarBase
|
|
4
|
+
} from "./chunk-ZJZG3P2K.mjs";
|
|
5
|
+
import "./chunk-HUKPVIZ5.mjs";
|
|
6
|
+
import "./chunk-MUYVZHWM.mjs";
|
|
7
|
+
import "./chunk-IDU5RSFL.mjs";
|
|
8
|
+
import "./chunk-JJRY4BYN.mjs";
|
|
9
|
+
import "./chunk-CPBF6DM2.mjs";
|
|
10
|
+
import "./chunk-MDGP3JHC.mjs";
|
|
11
|
+
import "./chunk-IFK7FCNU.mjs";
|
|
12
|
+
import "./chunk-JQFIYCMS.mjs";
|
|
13
|
+
import "./chunk-MCZLP73P.mjs";
|
|
14
|
+
import "./chunk-5CY7DCRB.mjs";
|
|
15
|
+
export {
|
|
16
|
+
CalendarBase
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
3
|
+
import { CalendarReturnType, SlotsToClasses, CalendarSlots } from '@sytechui/theme';
|
|
4
|
+
import { AriaCalendarCellProps } from '@react-aria/calendar';
|
|
5
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
6
|
+
import { CalendarDate } from '@internationalized/date';
|
|
7
|
+
|
|
8
|
+
interface CalendarCellProps extends HTMLHeroUIProps<"td">, AriaCalendarCellProps {
|
|
9
|
+
state: CalendarState | RangeCalendarState;
|
|
10
|
+
isPickerVisible?: boolean;
|
|
11
|
+
slots?: CalendarReturnType;
|
|
12
|
+
classNames?: SlotsToClasses<CalendarSlots>;
|
|
13
|
+
currentMonth: CalendarDate;
|
|
14
|
+
firstDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
|
|
15
|
+
}
|
|
16
|
+
declare function CalendarCell(originalProps: CalendarCellProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { CalendarCell, type CalendarCellProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
3
|
+
import { CalendarReturnType, SlotsToClasses, CalendarSlots } from '@sytechui/theme';
|
|
4
|
+
import { AriaCalendarCellProps } from '@react-aria/calendar';
|
|
5
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
6
|
+
import { CalendarDate } from '@internationalized/date';
|
|
7
|
+
|
|
8
|
+
interface CalendarCellProps extends HTMLHeroUIProps<"td">, AriaCalendarCellProps {
|
|
9
|
+
state: CalendarState | RangeCalendarState;
|
|
10
|
+
isPickerVisible?: boolean;
|
|
11
|
+
slots?: CalendarReturnType;
|
|
12
|
+
classNames?: SlotsToClasses<CalendarSlots>;
|
|
13
|
+
currentMonth: CalendarDate;
|
|
14
|
+
firstDayOfWeek?: "sun" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat";
|
|
15
|
+
}
|
|
16
|
+
declare function CalendarCell(originalProps: CalendarCellProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { CalendarCell, type CalendarCellProps };
|