@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,293 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/use-range-calendar.ts
|
|
22
|
+
var use_range_calendar_exports = {};
|
|
23
|
+
__export(use_range_calendar_exports, {
|
|
24
|
+
useRangeCalendar: () => useRangeCalendar
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(use_range_calendar_exports);
|
|
27
|
+
var import_react2 = require("react");
|
|
28
|
+
var import_react_utils2 = require("@sytechui/react-utils");
|
|
29
|
+
var import_calendar = require("@react-aria/calendar");
|
|
30
|
+
var import_calendar2 = require("@react-stately/calendar");
|
|
31
|
+
var import_date2 = require("@internationalized/date");
|
|
32
|
+
var import_shared_utils2 = require("@sytechui/shared-utils");
|
|
33
|
+
var import_theme2 = require("@sytechui/theme");
|
|
34
|
+
|
|
35
|
+
// src/use-calendar-base.ts
|
|
36
|
+
var import_date = require("@internationalized/date");
|
|
37
|
+
var import_system = require("@sytechui/system");
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_theme = require("@sytechui/theme");
|
|
40
|
+
var import_utils = require("@react-stately/utils");
|
|
41
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
42
|
+
var import_i18n = require("@react-aria/i18n");
|
|
43
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
44
|
+
function useCalendarBase(originalProps) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
46
|
+
const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.calendar.variantKeys);
|
|
47
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
48
|
+
const { locale, direction } = (0, import_i18n.useLocale)();
|
|
49
|
+
const isRTL = direction === "rtl";
|
|
50
|
+
const calendarProp = (0, import_date.createCalendar)(
|
|
51
|
+
new import_date.DateFormatter(locale).resolvedOptions().calendar
|
|
52
|
+
);
|
|
53
|
+
const gregorianYearOffset = (0, import_shared_utils.getGregorianYearOffset)(calendarProp.identifier);
|
|
54
|
+
const {
|
|
55
|
+
ref,
|
|
56
|
+
as,
|
|
57
|
+
children,
|
|
58
|
+
className,
|
|
59
|
+
topContent,
|
|
60
|
+
bottomContent,
|
|
61
|
+
showHelper = true,
|
|
62
|
+
firstDayOfWeek,
|
|
63
|
+
calendarWidth = 256,
|
|
64
|
+
visibleMonths: visibleMonthsProp = 1,
|
|
65
|
+
weekdayStyle = "narrow",
|
|
66
|
+
navButtonProps = {},
|
|
67
|
+
isHeaderExpanded: isHeaderExpandedProp,
|
|
68
|
+
isHeaderDefaultExpanded,
|
|
69
|
+
onHeaderExpandedChange = () => {
|
|
70
|
+
},
|
|
71
|
+
createCalendar: createCalendarProp = (_a = globalContext == null ? void 0 : globalContext.createCalendar) != null ? _a : null,
|
|
72
|
+
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),
|
|
73
|
+
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),
|
|
74
|
+
prevButtonProps: prevButtonPropsProp,
|
|
75
|
+
nextButtonProps: nextButtonPropsProp,
|
|
76
|
+
errorMessage,
|
|
77
|
+
classNames,
|
|
78
|
+
...otherProps
|
|
79
|
+
} = props;
|
|
80
|
+
const Component = as || "div";
|
|
81
|
+
const visibleMonths = (0, import_shared_utils.clamp)(visibleMonthsProp, 1, 3);
|
|
82
|
+
const showMonthAndYearPickers = originalProps.showMonthAndYearPickers && visibleMonths === 1;
|
|
83
|
+
const domRef = (0, import_react_utils.useDOMRef)(ref);
|
|
84
|
+
const handleHeaderExpandedChange = (0, import_react.useCallback)(
|
|
85
|
+
(isExpanded) => {
|
|
86
|
+
onHeaderExpandedChange(isExpanded || false);
|
|
87
|
+
},
|
|
88
|
+
[onHeaderExpandedChange]
|
|
89
|
+
);
|
|
90
|
+
const [isHeaderExpanded, setIsHeaderExpanded] = (0, import_utils.useControlledState)(
|
|
91
|
+
isHeaderExpandedProp,
|
|
92
|
+
isHeaderDefaultExpanded != null ? isHeaderDefaultExpanded : false,
|
|
93
|
+
handleHeaderExpandedChange
|
|
94
|
+
);
|
|
95
|
+
const visibleDuration = (0, import_react.useMemo)(() => ({ months: visibleMonths }), [visibleMonths]);
|
|
96
|
+
const hasMultipleMonths = visibleMonths > 1;
|
|
97
|
+
const shouldFilterDOMProps = typeof Component === "string";
|
|
98
|
+
const slots = (0, import_react.useMemo)(
|
|
99
|
+
() => (0, import_theme.calendar)({
|
|
100
|
+
...variantProps,
|
|
101
|
+
showMonthAndYearPickers,
|
|
102
|
+
isRange: !!originalProps.isRange,
|
|
103
|
+
isHeaderWrapperExpanded: isHeaderExpanded,
|
|
104
|
+
className,
|
|
105
|
+
isRTL
|
|
106
|
+
}),
|
|
107
|
+
[(0, import_shared_utils.objectToDeps)(variantProps), showMonthAndYearPickers, isHeaderExpanded, className]
|
|
108
|
+
);
|
|
109
|
+
const disableAnimation = (_g = (_f = originalProps.disableAnimation) != null ? _f : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _g : false;
|
|
110
|
+
const commonButtonProps = {
|
|
111
|
+
size: "sm",
|
|
112
|
+
variant: "light",
|
|
113
|
+
radius: "full",
|
|
114
|
+
isIconOnly: true,
|
|
115
|
+
disableAnimation,
|
|
116
|
+
...navButtonProps
|
|
117
|
+
};
|
|
118
|
+
const baseProps = {
|
|
119
|
+
"data-slot": "base",
|
|
120
|
+
"data-has-multiple-months": (0, import_shared_utils.dataAttr)(hasMultipleMonths),
|
|
121
|
+
style: {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
"--visible-months": typeof visibleMonths === "number" ? `${visibleMonths}` : visibleMonths,
|
|
124
|
+
"--calendar-width": typeof calendarWidth === "number" ? `${calendarWidth}px` : calendarWidth
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const getPrevButtonProps = (props2 = {}) => {
|
|
128
|
+
return {
|
|
129
|
+
"data-slot": "prev-button",
|
|
130
|
+
tabIndex: isHeaderExpanded ? -1 : 0,
|
|
131
|
+
className: slots.prevButton({ class: classNames == null ? void 0 : classNames.prevButton }),
|
|
132
|
+
...(0, import_shared_utils.mergeProps)(commonButtonProps, prevButtonPropsProp, props2)
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
const getNextButtonProps = (props2 = {}) => {
|
|
136
|
+
return {
|
|
137
|
+
"data-slot": "next-button",
|
|
138
|
+
tabIndex: isHeaderExpanded ? -1 : 0,
|
|
139
|
+
className: slots.nextButton({ class: classNames == null ? void 0 : classNames.nextButton }),
|
|
140
|
+
...(0, import_shared_utils.mergeProps)(commonButtonProps, nextButtonPropsProp, props2)
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const getErrorMessageProps = (props2 = {}) => {
|
|
144
|
+
return {
|
|
145
|
+
"data-slot": "error-message",
|
|
146
|
+
className: slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage }),
|
|
147
|
+
...props2
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
Component,
|
|
152
|
+
children,
|
|
153
|
+
domRef,
|
|
154
|
+
slots,
|
|
155
|
+
locale,
|
|
156
|
+
minValue,
|
|
157
|
+
maxValue,
|
|
158
|
+
baseProps,
|
|
159
|
+
showHelper,
|
|
160
|
+
firstDayOfWeek,
|
|
161
|
+
weekdayStyle,
|
|
162
|
+
visibleMonths,
|
|
163
|
+
visibleDuration,
|
|
164
|
+
shouldFilterDOMProps,
|
|
165
|
+
isHeaderExpanded,
|
|
166
|
+
showMonthAndYearPickers,
|
|
167
|
+
disableAnimation,
|
|
168
|
+
createCalendar: createCalendarProp,
|
|
169
|
+
getPrevButtonProps,
|
|
170
|
+
getNextButtonProps,
|
|
171
|
+
getErrorMessageProps,
|
|
172
|
+
setIsHeaderExpanded,
|
|
173
|
+
topContent,
|
|
174
|
+
bottomContent,
|
|
175
|
+
errorMessage,
|
|
176
|
+
classNames,
|
|
177
|
+
otherProps
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/use-range-calendar.ts
|
|
182
|
+
function useRangeCalendar({
|
|
183
|
+
buttonPickerProps: buttonPickerPropsProp,
|
|
184
|
+
className,
|
|
185
|
+
...originalProps
|
|
186
|
+
}) {
|
|
187
|
+
const {
|
|
188
|
+
Component,
|
|
189
|
+
slots,
|
|
190
|
+
children,
|
|
191
|
+
domRef,
|
|
192
|
+
locale,
|
|
193
|
+
showHelper,
|
|
194
|
+
firstDayOfWeek,
|
|
195
|
+
minValue,
|
|
196
|
+
maxValue,
|
|
197
|
+
weekdayStyle,
|
|
198
|
+
visibleDuration,
|
|
199
|
+
shouldFilterDOMProps,
|
|
200
|
+
isHeaderExpanded,
|
|
201
|
+
visibleMonths,
|
|
202
|
+
disableAnimation,
|
|
203
|
+
createCalendar: createCalendarProp,
|
|
204
|
+
showMonthAndYearPickers,
|
|
205
|
+
baseProps,
|
|
206
|
+
getPrevButtonProps,
|
|
207
|
+
getNextButtonProps,
|
|
208
|
+
getErrorMessageProps,
|
|
209
|
+
setIsHeaderExpanded,
|
|
210
|
+
topContent,
|
|
211
|
+
bottomContent,
|
|
212
|
+
errorMessage,
|
|
213
|
+
classNames,
|
|
214
|
+
otherProps
|
|
215
|
+
} = useCalendarBase({ ...originalProps, isRange: true });
|
|
216
|
+
const headerRef = (0, import_react2.useRef)(null);
|
|
217
|
+
const state = (0, import_calendar2.useRangeCalendarState)({
|
|
218
|
+
...originalProps,
|
|
219
|
+
locale,
|
|
220
|
+
minValue,
|
|
221
|
+
maxValue,
|
|
222
|
+
visibleDuration,
|
|
223
|
+
createCalendar: !createCalendarProp || typeof createCalendarProp !== "function" ? import_date2.createCalendar : createCalendarProp
|
|
224
|
+
});
|
|
225
|
+
const { title, calendarProps, prevButtonProps, nextButtonProps, errorMessageProps } = (0, import_calendar.useRangeCalendar)(originalProps, state, domRef);
|
|
226
|
+
const baseStyles = (0, import_theme2.cn)(classNames == null ? void 0 : classNames.base, className);
|
|
227
|
+
const buttonPickerProps = {
|
|
228
|
+
...buttonPickerPropsProp,
|
|
229
|
+
onPress: (0, import_shared_utils2.chain)(buttonPickerPropsProp == null ? void 0 : buttonPickerPropsProp.onPress, () => setIsHeaderExpanded(!isHeaderExpanded))
|
|
230
|
+
};
|
|
231
|
+
const getBaseCalendarProps = (props = {}) => {
|
|
232
|
+
return {
|
|
233
|
+
...baseProps,
|
|
234
|
+
Component,
|
|
235
|
+
showHelper,
|
|
236
|
+
firstDayOfWeek,
|
|
237
|
+
topContent,
|
|
238
|
+
bottomContent,
|
|
239
|
+
buttonPickerProps,
|
|
240
|
+
calendarRef: domRef,
|
|
241
|
+
calendarProps,
|
|
242
|
+
prevButtonProps: getPrevButtonProps(prevButtonProps),
|
|
243
|
+
nextButtonProps: getNextButtonProps(nextButtonProps),
|
|
244
|
+
errorMessageProps: getErrorMessageProps(errorMessageProps),
|
|
245
|
+
className: slots.base({ class: baseStyles }),
|
|
246
|
+
errorMessage,
|
|
247
|
+
...(0, import_react_utils2.filterDOMProps)(otherProps, {
|
|
248
|
+
enabled: shouldFilterDOMProps
|
|
249
|
+
}),
|
|
250
|
+
...props
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
const context = (0, import_react2.useMemo)(
|
|
254
|
+
() => ({
|
|
255
|
+
state,
|
|
256
|
+
slots,
|
|
257
|
+
headerRef,
|
|
258
|
+
weekdayStyle,
|
|
259
|
+
isHeaderExpanded,
|
|
260
|
+
setIsHeaderExpanded,
|
|
261
|
+
visibleMonths,
|
|
262
|
+
showMonthAndYearPickers,
|
|
263
|
+
classNames,
|
|
264
|
+
disableAnimation
|
|
265
|
+
}),
|
|
266
|
+
[
|
|
267
|
+
state,
|
|
268
|
+
slots,
|
|
269
|
+
classNames,
|
|
270
|
+
weekdayStyle,
|
|
271
|
+
isHeaderExpanded,
|
|
272
|
+
setIsHeaderExpanded,
|
|
273
|
+
visibleMonths,
|
|
274
|
+
disableAnimation,
|
|
275
|
+
showMonthAndYearPickers
|
|
276
|
+
]
|
|
277
|
+
);
|
|
278
|
+
return {
|
|
279
|
+
Component,
|
|
280
|
+
children,
|
|
281
|
+
domRef,
|
|
282
|
+
context,
|
|
283
|
+
state,
|
|
284
|
+
slots,
|
|
285
|
+
title,
|
|
286
|
+
classNames,
|
|
287
|
+
getBaseCalendarProps
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
291
|
+
0 && (module.exports = {
|
|
292
|
+
useRangeCalendar
|
|
293
|
+
});
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
declare function getYearRange(start?: DateValue | null, end?: DateValue | null): DateValue[];
|
|
4
|
+
declare function addMonths(date: DateValue, months: number): DateValue;
|
|
5
|
+
declare function getMonthsInYear(year: DateValue): DateValue[];
|
|
6
|
+
|
|
7
|
+
export { addMonths, getMonthsInYear, getYearRange };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DateValue } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
declare function getYearRange(start?: DateValue | null, end?: DateValue | null): DateValue[];
|
|
4
|
+
declare function addMonths(date: DateValue, months: number): DateValue;
|
|
5
|
+
declare function getMonthsInYear(year: DateValue): DateValue[];
|
|
6
|
+
|
|
7
|
+
export { addMonths, getMonthsInYear, getYearRange };
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/utils.ts
|
|
22
|
+
var utils_exports = {};
|
|
23
|
+
__export(utils_exports, {
|
|
24
|
+
addMonths: () => addMonths,
|
|
25
|
+
getMonthsInYear: () => getMonthsInYear,
|
|
26
|
+
getYearRange: () => getYearRange
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
var import_date = require("@internationalized/date");
|
|
30
|
+
function getYearRange(start, end) {
|
|
31
|
+
const years = [];
|
|
32
|
+
if (!start || !end) {
|
|
33
|
+
return years;
|
|
34
|
+
}
|
|
35
|
+
let current = (0, import_date.startOfYear)(start);
|
|
36
|
+
while (current.compare(end) <= 0) {
|
|
37
|
+
years.push(current);
|
|
38
|
+
current = (0, import_date.startOfYear)(current.add({ years: 1 }));
|
|
39
|
+
}
|
|
40
|
+
return years;
|
|
41
|
+
}
|
|
42
|
+
function addMonths(date, months) {
|
|
43
|
+
return date.add({ months });
|
|
44
|
+
}
|
|
45
|
+
function getMonthsInYear(year) {
|
|
46
|
+
const firstMonth = (0, import_date.startOfYear)(year);
|
|
47
|
+
const months = [firstMonth];
|
|
48
|
+
while (months.length < 12) {
|
|
49
|
+
const prevMonth = months[months.length - 1];
|
|
50
|
+
months.push(addMonths(prevMonth, 1));
|
|
51
|
+
}
|
|
52
|
+
return months;
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
addMonths,
|
|
57
|
+
getMonthsInYear,
|
|
58
|
+
getYearRange
|
|
59
|
+
});
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/utils.ts
|
|
4
|
+
import { startOfYear } from "@internationalized/date";
|
|
5
|
+
function getYearRange(start, end) {
|
|
6
|
+
const years = [];
|
|
7
|
+
if (!start || !end) {
|
|
8
|
+
return years;
|
|
9
|
+
}
|
|
10
|
+
let current = startOfYear(start);
|
|
11
|
+
while (current.compare(end) <= 0) {
|
|
12
|
+
years.push(current);
|
|
13
|
+
current = startOfYear(current.add({ years: 1 }));
|
|
14
|
+
}
|
|
15
|
+
return years;
|
|
16
|
+
}
|
|
17
|
+
function addMonths(date, months) {
|
|
18
|
+
return date.add({ months });
|
|
19
|
+
}
|
|
20
|
+
function getMonthsInYear(year) {
|
|
21
|
+
const firstMonth = startOfYear(year);
|
|
22
|
+
const months = [firstMonth];
|
|
23
|
+
while (months.length < 12) {
|
|
24
|
+
const prevMonth = months[months.length - 1];
|
|
25
|
+
months.push(addMonths(prevMonth, 1));
|
|
26
|
+
}
|
|
27
|
+
return months;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
addMonths,
|
|
31
|
+
getMonthsInYear,
|
|
32
|
+
getYearRange
|
|
33
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sytechui/calendar",
|
|
3
|
+
"version": "2.2.32",
|
|
4
|
+
"description": "A calendar displays one or more date grids and allows users to select a single date.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"calendar"
|
|
7
|
+
],
|
|
8
|
+
"author": "HeroUI <support@heroui.com>",
|
|
9
|
+
"homepage": "https://heroui.com",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/heroui-inc/heroui.git",
|
|
22
|
+
"directory": "packages/components/calendar"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/heroui-inc/heroui/issues"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@sytechui/system": ">=2.4.18",
|
|
29
|
+
"@sytechui/theme": ">=2.4.24",
|
|
30
|
+
"framer-motion": ">=11.5.6 || >=12.0.0-alpha.1",
|
|
31
|
+
"react": ">=18 || >=19.0.0-rc.0",
|
|
32
|
+
"react-dom": ">=18 || >=19.0.0-rc.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@internationalized/date": "3.12.0",
|
|
36
|
+
"@react-aria/calendar": "3.9.5",
|
|
37
|
+
"@react-aria/focus": "3.21.5",
|
|
38
|
+
"@react-aria/i18n": "3.12.16",
|
|
39
|
+
"@react-stately/calendar": "3.9.3",
|
|
40
|
+
"@react-types/button": "3.15.1",
|
|
41
|
+
"@react-aria/visually-hidden": "3.8.31",
|
|
42
|
+
"@react-stately/utils": "3.11.0",
|
|
43
|
+
"@react-types/calendar": "3.8.3",
|
|
44
|
+
"@react-aria/interactions": "3.27.1",
|
|
45
|
+
"@react-types/shared": "3.33.1",
|
|
46
|
+
"scroll-into-view-if-needed": "3.0.10",
|
|
47
|
+
"@sytechui/react-utils": "2.1.14",
|
|
48
|
+
"@sytechui/shared-utils": "2.1.12",
|
|
49
|
+
"@sytechui/framer-utils": "2.1.28",
|
|
50
|
+
"@sytechui/use-aria-button": "2.2.22",
|
|
51
|
+
"@sytechui/shared-icons": "2.1.10",
|
|
52
|
+
"@sytechui/button": "2.2.32",
|
|
53
|
+
"@sytechui/time-picker": "2.0.2",
|
|
54
|
+
"@sytechui/dom-animation": "2.1.10"
|
|
55
|
+
},
|
|
56
|
+
"clean-package": "../../../clean-package.config.json",
|
|
57
|
+
"module": "dist/index.mjs",
|
|
58
|
+
"types": "dist/index.d.ts",
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"import": "./dist/index.mjs",
|
|
63
|
+
"require": "./dist/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./package.json": "./package.json"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"build": "tsup src --dts",
|
|
69
|
+
"build:fast": "tsup src",
|
|
70
|
+
"dev": "pnpm build:fast --watch",
|
|
71
|
+
"clean": "rimraf dist .turbo",
|
|
72
|
+
"typecheck": "tsc --noEmit"
|
|
73
|
+
}
|
|
74
|
+
}
|