@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,97 @@
|
|
|
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/calendar-cell.tsx
|
|
22
|
+
var calendar_cell_exports = {};
|
|
23
|
+
__export(calendar_cell_exports, {
|
|
24
|
+
CalendarCell: () => CalendarCell
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(calendar_cell_exports);
|
|
27
|
+
var import_date = require("@internationalized/date");
|
|
28
|
+
var import_calendar = require("@react-aria/calendar");
|
|
29
|
+
var import_i18n = require("@react-aria/i18n");
|
|
30
|
+
var import_focus = require("@react-aria/focus");
|
|
31
|
+
var import_interactions = require("@react-aria/interactions");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
function CalendarCell(originalProps) {
|
|
36
|
+
const { state, slots, isPickerVisible, currentMonth, classNames, firstDayOfWeek, ...props } = originalProps;
|
|
37
|
+
const ref = (0, import_react.useRef)(null);
|
|
38
|
+
const {
|
|
39
|
+
cellProps,
|
|
40
|
+
buttonProps,
|
|
41
|
+
isPressed,
|
|
42
|
+
isSelected,
|
|
43
|
+
isDisabled,
|
|
44
|
+
isFocused,
|
|
45
|
+
isInvalid,
|
|
46
|
+
formattedDate
|
|
47
|
+
} = (0, import_calendar.useCalendarCell)(
|
|
48
|
+
{
|
|
49
|
+
...props,
|
|
50
|
+
isDisabled: !(0, import_date.isSameMonth)(props.date, currentMonth) || isPickerVisible
|
|
51
|
+
},
|
|
52
|
+
state,
|
|
53
|
+
ref
|
|
54
|
+
);
|
|
55
|
+
const isUnavailable = state.isCellUnavailable(props.date);
|
|
56
|
+
const isLastSelectedBeforeDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.add({ days: 1 }));
|
|
57
|
+
const isFirstSelectedAfterDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.subtract({ days: 1 }));
|
|
58
|
+
const highlightedRange = "highlightedRange" in state && state.highlightedRange;
|
|
59
|
+
const isSelectionStart = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.start) : false;
|
|
60
|
+
const isSelectionEnd = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.end) : false;
|
|
61
|
+
const { locale } = (0, import_i18n.useLocale)();
|
|
62
|
+
const dayOfWeek = (0, import_date.getDayOfWeek)(props.date, locale, firstDayOfWeek);
|
|
63
|
+
const isRangeStart = isSelected && (isFirstSelectedAfterDisabled || dayOfWeek === 0 || props.date.day === 1);
|
|
64
|
+
const isRangeEnd = isSelected && (isLastSelectedBeforeDisabled || dayOfWeek === 6 || props.date.day === currentMonth.calendar.getDaysInMonth(currentMonth));
|
|
65
|
+
const { focusProps, isFocusVisible } = (0, import_focus.useFocusRing)();
|
|
66
|
+
const { hoverProps, isHovered } = (0, import_interactions.useHover)({
|
|
67
|
+
isDisabled: isDisabled || isUnavailable || state.isReadOnly
|
|
68
|
+
});
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.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_runtime.jsx)(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
...(0, import_shared_utils.mergeProps)(buttonProps, hoverProps, focusProps),
|
|
73
|
+
ref,
|
|
74
|
+
className: slots == null ? void 0 : slots.cellButton({ class: classNames == null ? void 0 : classNames.cellButton }),
|
|
75
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled && !isInvalid),
|
|
76
|
+
"data-focus-visible": (0, import_shared_utils.dataAttr)(isFocused && isFocusVisible),
|
|
77
|
+
"data-hover": (0, import_shared_utils.dataAttr)(isHovered),
|
|
78
|
+
"data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
|
|
79
|
+
"data-outside-month": (0, import_shared_utils.dataAttr)(!(0, import_date.isSameMonth)(props.date, currentMonth)),
|
|
80
|
+
"data-pressed": (0, import_shared_utils.dataAttr)(isPressed && !state.isReadOnly),
|
|
81
|
+
"data-range-end": (0, import_shared_utils.dataAttr)(isRangeEnd),
|
|
82
|
+
"data-range-selection": (0, import_shared_utils.dataAttr)(isSelected && "highlightedRange" in state),
|
|
83
|
+
"data-range-start": (0, import_shared_utils.dataAttr)(isRangeStart),
|
|
84
|
+
"data-readonly": (0, import_shared_utils.dataAttr)(state.isReadOnly),
|
|
85
|
+
"data-selected": (0, import_shared_utils.dataAttr)(isSelected),
|
|
86
|
+
"data-selection-end": (0, import_shared_utils.dataAttr)(isSelectionEnd),
|
|
87
|
+
"data-selection-start": (0, import_shared_utils.dataAttr)(isSelectionStart),
|
|
88
|
+
"data-today": (0, import_shared_utils.dataAttr)((0, import_date.isToday)(props.date, state.timeZone)),
|
|
89
|
+
"data-unavailable": (0, import_shared_utils.dataAttr)(isUnavailable),
|
|
90
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: formattedDate })
|
|
91
|
+
}
|
|
92
|
+
) });
|
|
93
|
+
}
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
CalendarCell
|
|
97
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as _react_types_calendar from '@react-types/calendar';
|
|
3
|
+
import { ContextType } from './use-calendar-base.mjs';
|
|
4
|
+
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
5
|
+
import '@react-types/shared';
|
|
6
|
+
import '@sytechui/system/src/types';
|
|
7
|
+
import '@internationalized/date';
|
|
8
|
+
import 'tailwind-variants';
|
|
9
|
+
import '@sytechui/system';
|
|
10
|
+
import '@sytechui/theme';
|
|
11
|
+
import '@react-aria/calendar';
|
|
12
|
+
import '@react-types/button';
|
|
13
|
+
import '@sytechui/button';
|
|
14
|
+
import '@sytechui/react-utils';
|
|
15
|
+
|
|
16
|
+
declare const CalendarProvider: react.Provider<ContextType<CalendarState | RangeCalendarState<_react_types_calendar.DateValue>>>;
|
|
17
|
+
declare const useCalendarContext: () => ContextType<CalendarState | RangeCalendarState<_react_types_calendar.DateValue>>;
|
|
18
|
+
|
|
19
|
+
export { CalendarProvider, useCalendarContext };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as _react_types_calendar from '@react-types/calendar';
|
|
3
|
+
import { ContextType } from './use-calendar-base.js';
|
|
4
|
+
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
5
|
+
import '@react-types/shared';
|
|
6
|
+
import '@sytechui/system/src/types';
|
|
7
|
+
import '@internationalized/date';
|
|
8
|
+
import 'tailwind-variants';
|
|
9
|
+
import '@sytechui/system';
|
|
10
|
+
import '@sytechui/theme';
|
|
11
|
+
import '@react-aria/calendar';
|
|
12
|
+
import '@react-types/button';
|
|
13
|
+
import '@sytechui/button';
|
|
14
|
+
import '@sytechui/react-utils';
|
|
15
|
+
|
|
16
|
+
declare const CalendarProvider: react.Provider<ContextType<CalendarState | RangeCalendarState<_react_types_calendar.DateValue>>>;
|
|
17
|
+
declare const useCalendarContext: () => ContextType<CalendarState | RangeCalendarState<_react_types_calendar.DateValue>>;
|
|
18
|
+
|
|
19
|
+
export { CalendarProvider, useCalendarContext };
|
|
@@ -0,0 +1,38 @@
|
|
|
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/calendar-context.ts
|
|
22
|
+
var calendar_context_exports = {};
|
|
23
|
+
__export(calendar_context_exports, {
|
|
24
|
+
CalendarProvider: () => CalendarProvider,
|
|
25
|
+
useCalendarContext: () => useCalendarContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(calendar_context_exports);
|
|
28
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
29
|
+
var [CalendarProvider, useCalendarContext] = (0, import_react_utils.createContext)({
|
|
30
|
+
name: "CalendarContext",
|
|
31
|
+
strict: true,
|
|
32
|
+
errorMessage: "useContext: `context` is undefined. Seems you forgot to wrap component within the CalendarProvider"
|
|
33
|
+
});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
CalendarProvider,
|
|
37
|
+
useCalendarContext
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@sytechui/button';
|
|
3
|
+
import { CalendarDate } from '@internationalized/date';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
interface CalendarHeaderProps extends HTMLHeroUIProps<"header"> {
|
|
7
|
+
direction: number;
|
|
8
|
+
date: CalendarDate;
|
|
9
|
+
currentMonth: CalendarDate;
|
|
10
|
+
buttonPickerProps?: ButtonProps;
|
|
11
|
+
}
|
|
12
|
+
declare function CalendarHeader(props: CalendarHeaderProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { CalendarHeader, type CalendarHeaderProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ButtonProps } from '@sytechui/button';
|
|
3
|
+
import { CalendarDate } from '@internationalized/date';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
interface CalendarHeaderProps extends HTMLHeroUIProps<"header"> {
|
|
7
|
+
direction: number;
|
|
8
|
+
date: CalendarDate;
|
|
9
|
+
currentMonth: CalendarDate;
|
|
10
|
+
buttonPickerProps?: ButtonProps;
|
|
11
|
+
}
|
|
12
|
+
declare function CalendarHeader(props: CalendarHeaderProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { CalendarHeader, type CalendarHeaderProps };
|
|
@@ -0,0 +1,156 @@
|
|
|
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/calendar-header.tsx
|
|
22
|
+
var calendar_header_exports = {};
|
|
23
|
+
__export(calendar_header_exports, {
|
|
24
|
+
CalendarHeader: () => CalendarHeader
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(calendar_header_exports);
|
|
27
|
+
var import_i18n = require("@react-aria/i18n");
|
|
28
|
+
var import_framer_motion = require("framer-motion");
|
|
29
|
+
var import_button = require("@sytechui/button");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
|
|
32
|
+
// src/calendar-transitions.ts
|
|
33
|
+
var slideVariants = {
|
|
34
|
+
enter: (direction) => ({
|
|
35
|
+
x: `${direction * 100}%`
|
|
36
|
+
}),
|
|
37
|
+
center: {
|
|
38
|
+
x: "0%"
|
|
39
|
+
},
|
|
40
|
+
exit: (direction) => ({
|
|
41
|
+
x: `${direction * -100}%`
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/chevron-down.tsx
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var ChevronDownIcon = (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 24 24",
|
|
56
|
+
width: "1em",
|
|
57
|
+
...props,
|
|
58
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
d: "M19 9L12 15L5 9",
|
|
62
|
+
stroke: "currentColor",
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeLinejoin: "round",
|
|
65
|
+
strokeWidth: "1.5"
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// src/calendar-context.ts
|
|
72
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
73
|
+
var [CalendarProvider, useCalendarContext] = (0, import_react_utils.createContext)({
|
|
74
|
+
name: "CalendarContext",
|
|
75
|
+
strict: true,
|
|
76
|
+
errorMessage: "useContext: `context` is undefined. Seems you forgot to wrap component within the CalendarProvider"
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/calendar-header.tsx
|
|
80
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
81
|
+
function CalendarHeader(props) {
|
|
82
|
+
const { direction, date, currentMonth, buttonPickerProps } = props;
|
|
83
|
+
const {
|
|
84
|
+
state,
|
|
85
|
+
slots,
|
|
86
|
+
headerRef,
|
|
87
|
+
showMonthAndYearPickers,
|
|
88
|
+
isHeaderExpanded,
|
|
89
|
+
setIsHeaderExpanded,
|
|
90
|
+
disableAnimation,
|
|
91
|
+
classNames
|
|
92
|
+
} = useCalendarContext();
|
|
93
|
+
const monthAndYearDateFormatter = (0, import_i18n.useDateFormatter)({
|
|
94
|
+
month: "long",
|
|
95
|
+
era: currentMonth.calendar.identifier === "gregory" && currentMonth.era === "BC" ? "short" : void 0,
|
|
96
|
+
calendar: currentMonth.calendar.identifier,
|
|
97
|
+
timeZone: state.timeZone,
|
|
98
|
+
year: "numeric"
|
|
99
|
+
});
|
|
100
|
+
const monthDateContent = monthAndYearDateFormatter.format(date.toDate(state.timeZone));
|
|
101
|
+
const headerTitle = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
102
|
+
"span",
|
|
103
|
+
{
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
|
|
106
|
+
"data-slot": "title",
|
|
107
|
+
children: monthDateContent
|
|
108
|
+
},
|
|
109
|
+
currentMonth.month
|
|
110
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
111
|
+
import_framer_motion.m.span,
|
|
112
|
+
{
|
|
113
|
+
animate: "center",
|
|
114
|
+
"aria-hidden": true,
|
|
115
|
+
className: slots == null ? void 0 : slots.title({ class: classNames == null ? void 0 : classNames.title }),
|
|
116
|
+
custom: direction,
|
|
117
|
+
"data-slot": "title",
|
|
118
|
+
exit: "exit",
|
|
119
|
+
initial: "enter",
|
|
120
|
+
variants: isHeaderExpanded ? {} : slideVariants,
|
|
121
|
+
children: monthDateContent
|
|
122
|
+
},
|
|
123
|
+
currentMonth.month
|
|
124
|
+
) });
|
|
125
|
+
const headerProps = {
|
|
126
|
+
ref: headerRef,
|
|
127
|
+
className: slots == null ? void 0 : slots.header({ class: classNames == null ? void 0 : classNames.header }),
|
|
128
|
+
"data-slot": "header"
|
|
129
|
+
};
|
|
130
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
131
|
+
(e) => {
|
|
132
|
+
if (e.key === "Escape") {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
setIsHeaderExpanded == null ? void 0 : setIsHeaderExpanded(false);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[setIsHeaderExpanded]
|
|
139
|
+
);
|
|
140
|
+
return showMonthAndYearPickers ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
141
|
+
import_button.Button,
|
|
142
|
+
{
|
|
143
|
+
...headerProps,
|
|
144
|
+
"aria-label": "switch to year and month view",
|
|
145
|
+
disableAnimation,
|
|
146
|
+
endContent: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChevronDownIcon, { className: "chevron-icon" }),
|
|
147
|
+
onKeyDown: handleKeyDown,
|
|
148
|
+
...buttonPickerProps,
|
|
149
|
+
children: headerTitle
|
|
150
|
+
}
|
|
151
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("header", { ...headerProps, children: headerTitle });
|
|
152
|
+
}
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
CalendarHeader
|
|
156
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalendarDate } from '@internationalized/date';
|
|
3
|
+
import { CalendarPropsBase } from '@react-types/calendar';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
interface CalendarMonthProps extends HTMLHeroUIProps<"table">, CalendarPropsBase {
|
|
7
|
+
startDate: CalendarDate;
|
|
8
|
+
currentMonth: number;
|
|
9
|
+
direction: number;
|
|
10
|
+
}
|
|
11
|
+
declare function CalendarMonth(props: CalendarMonthProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { CalendarMonth, type CalendarMonthProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalendarDate } from '@internationalized/date';
|
|
3
|
+
import { CalendarPropsBase } from '@react-types/calendar';
|
|
4
|
+
import { HTMLHeroUIProps } from '@sytechui/system';
|
|
5
|
+
|
|
6
|
+
interface CalendarMonthProps extends HTMLHeroUIProps<"table">, CalendarPropsBase {
|
|
7
|
+
startDate: CalendarDate;
|
|
8
|
+
currentMonth: number;
|
|
9
|
+
direction: number;
|
|
10
|
+
}
|
|
11
|
+
declare function CalendarMonth(props: CalendarMonthProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { CalendarMonth, type CalendarMonthProps };
|
|
@@ -0,0 +1,226 @@
|
|
|
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/calendar-month.tsx
|
|
22
|
+
var calendar_month_exports = {};
|
|
23
|
+
__export(calendar_month_exports, {
|
|
24
|
+
CalendarMonth: () => CalendarMonth
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(calendar_month_exports);
|
|
27
|
+
var import_date2 = require("@internationalized/date");
|
|
28
|
+
var import_i18n2 = require("@react-aria/i18n");
|
|
29
|
+
var import_calendar2 = require("@react-aria/calendar");
|
|
30
|
+
var import_framer_motion = require("framer-motion");
|
|
31
|
+
var import_shared_utils2 = require("@sytechui/shared-utils");
|
|
32
|
+
|
|
33
|
+
// src/calendar-cell.tsx
|
|
34
|
+
var import_date = require("@internationalized/date");
|
|
35
|
+
var import_calendar = require("@react-aria/calendar");
|
|
36
|
+
var import_i18n = require("@react-aria/i18n");
|
|
37
|
+
var import_focus = require("@react-aria/focus");
|
|
38
|
+
var import_interactions = require("@react-aria/interactions");
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_shared_utils = require("@sytechui/shared-utils");
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
function CalendarCell(originalProps) {
|
|
43
|
+
const { state, slots, isPickerVisible, currentMonth, classNames, firstDayOfWeek, ...props } = originalProps;
|
|
44
|
+
const ref = (0, import_react.useRef)(null);
|
|
45
|
+
const {
|
|
46
|
+
cellProps,
|
|
47
|
+
buttonProps,
|
|
48
|
+
isPressed,
|
|
49
|
+
isSelected,
|
|
50
|
+
isDisabled,
|
|
51
|
+
isFocused,
|
|
52
|
+
isInvalid,
|
|
53
|
+
formattedDate
|
|
54
|
+
} = (0, import_calendar.useCalendarCell)(
|
|
55
|
+
{
|
|
56
|
+
...props,
|
|
57
|
+
isDisabled: !(0, import_date.isSameMonth)(props.date, currentMonth) || isPickerVisible
|
|
58
|
+
},
|
|
59
|
+
state,
|
|
60
|
+
ref
|
|
61
|
+
);
|
|
62
|
+
const isUnavailable = state.isCellUnavailable(props.date);
|
|
63
|
+
const isLastSelectedBeforeDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.add({ days: 1 }));
|
|
64
|
+
const isFirstSelectedAfterDisabled = !isDisabled && !isInvalid && state.isCellUnavailable(props.date.subtract({ days: 1 }));
|
|
65
|
+
const highlightedRange = "highlightedRange" in state && state.highlightedRange;
|
|
66
|
+
const isSelectionStart = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.start) : false;
|
|
67
|
+
const isSelectionEnd = isSelected && highlightedRange ? (0, import_date.isSameDay)(props.date, highlightedRange.end) : false;
|
|
68
|
+
const { locale } = (0, import_i18n.useLocale)();
|
|
69
|
+
const dayOfWeek = (0, import_date.getDayOfWeek)(props.date, locale, firstDayOfWeek);
|
|
70
|
+
const isRangeStart = isSelected && (isFirstSelectedAfterDisabled || dayOfWeek === 0 || props.date.day === 1);
|
|
71
|
+
const isRangeEnd = isSelected && (isLastSelectedBeforeDisabled || dayOfWeek === 6 || props.date.day === currentMonth.calendar.getDaysInMonth(currentMonth));
|
|
72
|
+
const { focusProps, isFocusVisible } = (0, import_focus.useFocusRing)();
|
|
73
|
+
const { hoverProps, isHovered } = (0, import_interactions.useHover)({
|
|
74
|
+
isDisabled: isDisabled || isUnavailable || state.isReadOnly
|
|
75
|
+
});
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.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_runtime.jsx)(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
...(0, import_shared_utils.mergeProps)(buttonProps, hoverProps, focusProps),
|
|
80
|
+
ref,
|
|
81
|
+
className: slots == null ? void 0 : slots.cellButton({ class: classNames == null ? void 0 : classNames.cellButton }),
|
|
82
|
+
"data-disabled": (0, import_shared_utils.dataAttr)(isDisabled && !isInvalid),
|
|
83
|
+
"data-focus-visible": (0, import_shared_utils.dataAttr)(isFocused && isFocusVisible),
|
|
84
|
+
"data-hover": (0, import_shared_utils.dataAttr)(isHovered),
|
|
85
|
+
"data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
|
|
86
|
+
"data-outside-month": (0, import_shared_utils.dataAttr)(!(0, import_date.isSameMonth)(props.date, currentMonth)),
|
|
87
|
+
"data-pressed": (0, import_shared_utils.dataAttr)(isPressed && !state.isReadOnly),
|
|
88
|
+
"data-range-end": (0, import_shared_utils.dataAttr)(isRangeEnd),
|
|
89
|
+
"data-range-selection": (0, import_shared_utils.dataAttr)(isSelected && "highlightedRange" in state),
|
|
90
|
+
"data-range-start": (0, import_shared_utils.dataAttr)(isRangeStart),
|
|
91
|
+
"data-readonly": (0, import_shared_utils.dataAttr)(state.isReadOnly),
|
|
92
|
+
"data-selected": (0, import_shared_utils.dataAttr)(isSelected),
|
|
93
|
+
"data-selection-end": (0, import_shared_utils.dataAttr)(isSelectionEnd),
|
|
94
|
+
"data-selection-start": (0, import_shared_utils.dataAttr)(isSelectionStart),
|
|
95
|
+
"data-today": (0, import_shared_utils.dataAttr)((0, import_date.isToday)(props.date, state.timeZone)),
|
|
96
|
+
"data-unavailable": (0, import_shared_utils.dataAttr)(isUnavailable),
|
|
97
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: formattedDate })
|
|
98
|
+
}
|
|
99
|
+
) });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/calendar-transitions.ts
|
|
103
|
+
var slideVariants = {
|
|
104
|
+
enter: (direction) => ({
|
|
105
|
+
x: `${direction * 100}%`
|
|
106
|
+
}),
|
|
107
|
+
center: {
|
|
108
|
+
x: "0%"
|
|
109
|
+
},
|
|
110
|
+
exit: (direction) => ({
|
|
111
|
+
x: `${direction * -100}%`
|
|
112
|
+
})
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/calendar-context.ts
|
|
116
|
+
var import_react_utils = require("@sytechui/react-utils");
|
|
117
|
+
var [CalendarProvider, useCalendarContext] = (0, import_react_utils.createContext)({
|
|
118
|
+
name: "CalendarContext",
|
|
119
|
+
strict: true,
|
|
120
|
+
errorMessage: "useContext: `context` is undefined. Seems you forgot to wrap component within the CalendarProvider"
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// src/calendar-month.tsx
|
|
124
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
125
|
+
function CalendarMonth(props) {
|
|
126
|
+
const { startDate, direction, currentMonth, firstDayOfWeek } = props;
|
|
127
|
+
const { locale } = (0, import_i18n2.useLocale)();
|
|
128
|
+
const weeksInMonth = (0, import_date2.getWeeksInMonth)(startDate, locale, firstDayOfWeek);
|
|
129
|
+
const { state, slots, weekdayStyle, isHeaderExpanded, disableAnimation, classNames } = useCalendarContext();
|
|
130
|
+
const { gridProps, headerProps, weekDays } = (0, import_calendar2.useCalendarGrid)(
|
|
131
|
+
{
|
|
132
|
+
...props,
|
|
133
|
+
weekdayStyle,
|
|
134
|
+
endDate: (0, import_date2.endOfMonth)(startDate),
|
|
135
|
+
firstDayOfWeek
|
|
136
|
+
},
|
|
137
|
+
state
|
|
138
|
+
);
|
|
139
|
+
const bodyContent = [...new Array(weeksInMonth).keys()].map((weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
140
|
+
"tr",
|
|
141
|
+
{
|
|
142
|
+
className: slots == null ? void 0 : slots.gridBodyRow({ class: classNames == null ? void 0 : classNames.gridBodyRow }),
|
|
143
|
+
"data-slot": "grid-body-row",
|
|
144
|
+
inert: isHeaderExpanded ? true : void 0,
|
|
145
|
+
children: state.getDatesInWeek(weekIndex, startDate).map(
|
|
146
|
+
(date, i) => date ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
147
|
+
CalendarCell,
|
|
148
|
+
{
|
|
149
|
+
classNames,
|
|
150
|
+
currentMonth: startDate,
|
|
151
|
+
date,
|
|
152
|
+
firstDayOfWeek,
|
|
153
|
+
isPickerVisible: isHeaderExpanded,
|
|
154
|
+
slots,
|
|
155
|
+
state
|
|
156
|
+
},
|
|
157
|
+
i
|
|
158
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", {}, i)
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
weekIndex
|
|
162
|
+
));
|
|
163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
164
|
+
"table",
|
|
165
|
+
{
|
|
166
|
+
...gridProps,
|
|
167
|
+
"aria-hidden": (0, import_shared_utils2.dataAttr)(isHeaderExpanded),
|
|
168
|
+
className: slots == null ? void 0 : slots.grid({ class: classNames == null ? void 0 : classNames.grid }),
|
|
169
|
+
"data-slot": "grid",
|
|
170
|
+
tabIndex: -1,
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
173
|
+
"thead",
|
|
174
|
+
{
|
|
175
|
+
...headerProps,
|
|
176
|
+
className: slots == null ? void 0 : slots.gridHeader({ class: classNames == null ? void 0 : classNames.gridHeader }),
|
|
177
|
+
"data-slot": "grid-header",
|
|
178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
179
|
+
"tr",
|
|
180
|
+
{
|
|
181
|
+
className: slots == null ? void 0 : slots.gridHeaderRow({ class: classNames == null ? void 0 : classNames.gridHeaderRow }),
|
|
182
|
+
"data-slot": "grid-header-row",
|
|
183
|
+
children: weekDays.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
184
|
+
"th",
|
|
185
|
+
{
|
|
186
|
+
className: slots == null ? void 0 : slots.gridHeaderCell({ class: classNames == null ? void 0 : classNames.gridHeaderCell }),
|
|
187
|
+
"data-slot": "grid-header-cell",
|
|
188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: day })
|
|
189
|
+
},
|
|
190
|
+
index
|
|
191
|
+
))
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
disableAnimation ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
197
|
+
"tbody",
|
|
198
|
+
{
|
|
199
|
+
className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
|
|
200
|
+
"data-slot": "grid-body",
|
|
201
|
+
tabIndex: isHeaderExpanded ? -1 : 0,
|
|
202
|
+
children: bodyContent
|
|
203
|
+
},
|
|
204
|
+
currentMonth
|
|
205
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
206
|
+
import_framer_motion.m.tbody,
|
|
207
|
+
{
|
|
208
|
+
animate: "center",
|
|
209
|
+
className: slots == null ? void 0 : slots.gridBody({ class: classNames == null ? void 0 : classNames.gridBody }),
|
|
210
|
+
custom: direction,
|
|
211
|
+
"data-slot": "grid-body",
|
|
212
|
+
exit: "exit",
|
|
213
|
+
initial: "enter",
|
|
214
|
+
variants: slideVariants,
|
|
215
|
+
children: bodyContent
|
|
216
|
+
},
|
|
217
|
+
currentMonth
|
|
218
|
+
)
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
224
|
+
0 && (module.exports = {
|
|
225
|
+
CalendarMonth
|
|
226
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalendarPickerProps } from './use-calendar-picker.mjs';
|
|
3
|
+
import '@sytechui/theme';
|
|
4
|
+
import 'tailwind-variants';
|
|
5
|
+
import '@react-types/calendar';
|
|
6
|
+
import '@react-stately/calendar';
|
|
7
|
+
import '@internationalized/date';
|
|
8
|
+
import '@sytechui/system';
|
|
9
|
+
|
|
10
|
+
declare function CalendarPicker(props: CalendarPickerProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { CalendarPicker };
|