@zealakit/chrono-react 1.0.0-beta.1 → 1.0.0-beta.2
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/README.md +1 -0
- package/dist/calendar/components.d.ts +2 -2
- package/dist/calendar/components.js +10 -12
- package/dist/calendar/mini-calendar.js +6 -5
- package/dist/calendar/use-calendar.js +1 -3
- package/dist/calendar/use-mini-calendar.js +1 -1
- package/dist/date/bind-panel.js +1 -1
- package/dist/date/components.js +20 -29
- package/dist/date/utilities.d.ts +1 -1
- package/dist/date/utilities.js +1 -1
- package/dist/datetime/components.js +16 -21
- package/dist/datetime/use-datetime-panel.js +1 -1
- package/dist/shared/defined-options.d.ts +18 -0
- package/dist/shared/defined-options.js +9 -0
- package/dist/shared/merge-props.js +1 -3
- package/dist/shared/part.d.ts +1 -1
- package/dist/shared/slot.js +1 -4
- package/dist/shared/style-properties.js +1 -1
- package/dist/time/bind-panel.js +2 -2
- package/dist/time/components.d.ts +2 -2
- package/dist/time/components.js +16 -21
- package/dist/time/utilities.d.ts +1 -1
- package/dist/time/utilities.js +1 -1
- package/dist/vendor/core/calendar/availability.d.ts +2 -2
- package/dist/vendor/core/calendar/availability.js +4 -5
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +93 -145
- package/dist/vendor/core/calendar/controllers/drag-engine.js +15 -34
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +3 -2
- package/dist/vendor/core/calendar/controllers/shared.d.ts +9 -5
- package/dist/vendor/core/calendar/controllers/shared.js +8 -8
- package/dist/vendor/core/calendar/events/agenda-layout.js +4 -3
- package/dist/vendor/core/calendar/events/all-day-row.d.ts +1 -1
- package/dist/vendor/core/calendar/events/all-day-row.js +5 -5
- package/dist/vendor/core/calendar/events/background-layout.d.ts +1 -1
- package/dist/vendor/core/calendar/events/background-layout.js +6 -7
- package/dist/vendor/core/calendar/events/month-layout.js +6 -5
- package/dist/vendor/core/calendar/events/normalize.d.ts +2 -2
- package/dist/vendor/core/calendar/events/normalize.js +6 -9
- package/dist/vendor/core/calendar/events/now-indicator.d.ts +2 -2
- package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +4 -4
- package/dist/vendor/core/calendar/events/time-grid-layout.js +8 -15
- package/dist/vendor/core/calendar/events/types.d.ts +2 -2
- package/dist/vendor/core/calendar/index.d.ts +11 -11
- package/dist/vendor/core/calendar/index.js +5 -5
- package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +1 -9
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +12 -39
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +2 -5
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +1 -4
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +5 -4
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +33 -193
- package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
- package/dist/vendor/core/calendar/interaction/pointer.d.ts +1 -1
- package/dist/vendor/core/calendar/interaction/pointer.js +65 -15
- package/dist/vendor/core/calendar/interaction/selection.d.ts +1 -1
- package/dist/vendor/core/calendar/navigation/navigate.d.ts +3 -3
- package/dist/vendor/core/calendar/navigation/navigate.js +1 -3
- package/dist/vendor/core/calendar/navigation/range.js +1 -1
- package/dist/vendor/core/calendar/navigation/view-definition.d.ts +1 -1
- package/dist/vendor/core/calendar/navigation/view-definition.js +2 -1
- package/dist/vendor/core/calendar/recurrence/apply.js +7 -8
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +1 -1
- package/dist/vendor/core/calendar/recurrence/expand.js +14 -18
- package/dist/vendor/core/calendar/recurrence/pack.js +4 -7
- package/dist/vendor/core/calendar/recurrence/rrule.js +6 -16
- package/dist/vendor/core/calendar/recurrence/series.js +1 -3
- package/dist/vendor/core/calendar/recurrence/types.d.ts +1 -1
- package/dist/vendor/core/calendar/resources/resource-time-grid.js +1 -2
- package/dist/vendor/core/calendar/resources/timeline-layout.js +4 -6
- package/dist/vendor/core/calendar/resources/types.d.ts +7 -7
- package/dist/vendor/core/calendar/views/day.d.ts +5 -5
- package/dist/vendor/core/calendar/views/day.js +2 -5
- package/dist/vendor/core/calendar/views/mini-calendar.d.ts +8 -8
- package/dist/vendor/core/calendar/views/mini-calendar.js +1 -1
- package/dist/vendor/core/calendar/views/month-layout.d.ts +1 -1
- package/dist/vendor/core/calendar/views/month-layout.js +1 -1
- package/dist/vendor/core/calendar/views/time-grid-layout.js +1 -4
- package/dist/vendor/core/date/input/date-input-controller.d.ts +15 -15
- package/dist/vendor/core/date/input/date-input-controller.js +9 -21
- package/dist/vendor/core/date/input/date-range-input-controller.js +2 -5
- package/dist/vendor/core/date/input/parse.d.ts +2 -2
- package/dist/vendor/core/date/input/parse.js +3 -9
- package/dist/vendor/core/date/input/validity.js +1 -1
- package/dist/vendor/core/date/panel/panel-controller.d.ts +11 -11
- package/dist/vendor/core/date/panel/panel-controller.js +18 -40
- package/dist/vendor/core/date/presets.js +1 -2
- package/dist/vendor/core/date/selection/multiple.js +2 -5
- package/dist/vendor/core/date/selection/range.d.ts +2 -2
- package/dist/vendor/core/date/selection/range.js +2 -6
- package/dist/vendor/core/datetime/compose.d.ts +3 -3
- package/dist/vendor/core/datetime/constraints.d.ts +9 -9
- package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +2 -2
- package/dist/vendor/core/datetime/input/datetime-input-controller.js +12 -27
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +5 -16
- package/dist/vendor/core/datetime/input/parse.d.ts +2 -2
- package/dist/vendor/core/datetime/input/parse.js +2 -5
- package/dist/vendor/core/datetime/panel/controller.js +4 -10
- package/dist/vendor/core/datetime/panel/range-controller.js +4 -16
- package/dist/vendor/core/datetime/zone/day-instants.js +1 -3
- package/dist/vendor/core/datetime/zone/resolve.js +2 -4
- package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
- package/dist/vendor/core/dom/auto-scroll.js +57 -0
- package/dist/vendor/core/dom/drag-session.d.ts +25 -0
- package/dist/vendor/core/dom/drag-session.js +257 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +9 -4
- package/dist/vendor/core/foundation/a11y/announcer.js +15 -27
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +2 -2
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +2 -12
- package/dist/vendor/core/foundation/a11y/roving-focus.js +23 -2
- package/dist/vendor/core/foundation/constraints/availability-rules.js +2 -4
- package/dist/vendor/core/foundation/constraints/availability.d.ts +6 -6
- package/dist/vendor/core/foundation/constraints/availability.js +6 -16
- package/dist/vendor/core/foundation/constraints/date.d.ts +3 -3
- package/dist/vendor/core/foundation/constraints/index.d.ts +1 -1
- package/dist/vendor/core/foundation/constraints/range.d.ts +4 -4
- package/dist/vendor/core/foundation/constraints/range.js +1 -1
- package/dist/vendor/core/foundation/constraints/time.d.ts +5 -5
- package/dist/vendor/core/foundation/constraints/time.js +1 -1
- package/dist/vendor/core/foundation/grid/index.d.ts +2 -2
- package/dist/vendor/core/foundation/grid/month-grid.d.ts +2 -2
- package/dist/vendor/core/foundation/grid/time-axis.d.ts +3 -3
- package/dist/vendor/core/foundation/grid/time-axis.js +1 -1
- package/dist/vendor/core/foundation/input/index.d.ts +1 -1
- package/dist/vendor/core/foundation/input/index.js +1 -1
- package/dist/vendor/core/foundation/input/segment-engine.js +2 -6
- package/dist/vendor/core/foundation/locale/direction.js +1 -13
- package/dist/vendor/core/foundation/locale/format.js +1 -3
- package/dist/vendor/core/foundation/locale/hour-cycle.js +2 -6
- package/dist/vendor/core/foundation/locale/index.d.ts +1 -1
- package/dist/vendor/core/foundation/locale/index.js +1 -1
- package/dist/vendor/core/foundation/locale/resolve.js +12 -2
- package/dist/vendor/core/foundation/locale/week-info.js +1 -2
- package/dist/vendor/core/foundation/ranges/index.d.ts +1 -1
- package/dist/vendor/core/foundation/ranges/index.js +1 -1
- package/dist/vendor/core/foundation/ranges/interval.js +1 -3
- package/dist/vendor/core/foundation/store/controllable.d.ts +1 -1
- package/dist/vendor/core/foundation/store/ids.d.ts +8 -1
- package/dist/vendor/core/foundation/store/ids.js +10 -5
- package/dist/vendor/core/foundation/store/index.d.ts +2 -2
- package/dist/vendor/core/foundation/store/index.js +2 -2
- package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
- package/dist/vendor/core/foundation/store/with-optional.js +3 -0
- package/dist/vendor/core/foundation/values/convert.js +3 -7
- package/dist/vendor/core/foundation/values/epoch-day.js +1 -5
- package/dist/vendor/core/foundation/values/index.d.ts +1 -1
- package/dist/vendor/core/foundation/values/index.js +1 -1
- package/dist/vendor/core/foundation/values/iso.js +2 -4
- package/dist/vendor/core/foundation/values/plain-time.js +1 -3
- package/dist/vendor/core/foundation/values/zoned.js +2 -5
- package/dist/vendor/core/time/input/parse.d.ts +1 -1
- package/dist/vendor/core/time/input/parse.js +1 -3
- package/dist/vendor/core/time/input/time-input-controller.d.ts +18 -18
- package/dist/vendor/core/time/input/time-input-controller.js +12 -27
- package/dist/vendor/core/time/input/time-range-input-controller.js +3 -10
- package/dist/vendor/core/time/input/validity.js +1 -1
- package/dist/vendor/core/time/panel/time-panel-controller.d.ts +12 -12
- package/dist/vendor/core/time/panel/time-panel-controller.js +19 -49
- package/dist/vendor/core/time/selection/range.d.ts +3 -3
- package/dist/vendor/core/time/selection/slots.d.ts +9 -9
- package/dist/vendor/core/time/selection/slots.js +1 -3
- package/package.json +21 -28
- package/dist/vendor/core/foundation/store/global-state.d.ts +0 -1
- package/dist/vendor/core/foundation/store/global-state.js +0 -21
package/README.md
CHANGED
|
@@ -228,12 +228,12 @@ export declare const CalendarResourceGroupHeader: import("react").ForwardRefExot
|
|
|
228
228
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
229
229
|
/** The timeline root: `grid`, or `treegrid` when resources are grouped. Renders only in a timeline view. */
|
|
230
230
|
export declare const CalendarTimeline: import("react").ForwardRefExoticComponent<Omit<PartProps<"div">, "children"> & {
|
|
231
|
-
asChild?: boolean;
|
|
231
|
+
asChild?: boolean | undefined;
|
|
232
232
|
children?: (layout: TimelineLayout) => ReactNode;
|
|
233
233
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
234
234
|
/** The resource time grid root. Renders only in a resource day or week view. */
|
|
235
235
|
export declare const CalendarResourceGrid: import("react").ForwardRefExoticComponent<Omit<PartProps<"div">, "children"> & {
|
|
236
|
-
asChild?: boolean;
|
|
236
|
+
asChild?: boolean | undefined;
|
|
237
237
|
children?: (layout: ResourceTimeGridLayout) => ReactNode;
|
|
238
238
|
} & import("react").RefAttributes<HTMLElement>>;
|
|
239
239
|
export type CalendarTimelineHeaderCellProps = ResourcePartProps<"cell", TimelineHeaderCell>;
|
|
@@ -7,14 +7,15 @@ import { composeRefs } from "../shared/slot.js";
|
|
|
7
7
|
import { CalendarContext, useCalendarContext } from "./context.js";
|
|
8
8
|
import { splitCalendarProps } from "./options.js";
|
|
9
9
|
import { useCalendar } from "./use-calendar.js";
|
|
10
|
+
import { definedOptions } from "./../shared/defined-options.js";
|
|
10
11
|
const withChrono = (consumer, chrono) => mergeProps(consumer, chrono);
|
|
11
12
|
/** Creates the calendar. Props are the calendar options plus any `div` props. */
|
|
12
13
|
export const Calendar = forwardRef(function Calendar({ children, asChild, ...props }, ref) {
|
|
13
14
|
const [options, rest] = splitCalendarProps(props);
|
|
14
|
-
const calendar = useCalendar({
|
|
15
|
+
const calendar = useCalendar(definedOptions({
|
|
15
16
|
...options,
|
|
16
17
|
id: props.id,
|
|
17
|
-
});
|
|
18
|
+
}));
|
|
18
19
|
const { ref: rootRef, ...rootProps } = calendar.getRootProps();
|
|
19
20
|
const { id: _id, ...elementProps } = rest;
|
|
20
21
|
return (_jsx(CalendarContext.Provider, { value: calendar, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: children }) }));
|
|
@@ -22,9 +23,7 @@ export const Calendar = forwardRef(function Calendar({ children, asChild, ...pro
|
|
|
22
23
|
export const CalendarTitle = forwardRef(function CalendarTitle({ children, asChild, ...rest }, ref) {
|
|
23
24
|
const calendar = useCalendarContext("CalendarTitle");
|
|
24
25
|
const { title } = calendar.state;
|
|
25
|
-
return (_jsx(Part, { as: "h2", asChild: asChild, ref: ref, ...withChrono(rest, calendar.getTitleProps()), children: typeof children === "function"
|
|
26
|
-
? children(title)
|
|
27
|
-
: (children ?? title.text) }));
|
|
26
|
+
return (_jsx(Part, { as: "h2", asChild: asChild, ref: ref, ...withChrono(rest, calendar.getTitleProps()), children: typeof children === "function" ? children(title) : (children ?? title.text) }));
|
|
28
27
|
});
|
|
29
28
|
const NavButton = forwardRef(function NavButton({ kind, part, children, asChild, ...rest }, ref) {
|
|
30
29
|
const calendar = useCalendarContext(part);
|
|
@@ -32,13 +31,13 @@ const NavButton = forwardRef(function NavButton({ kind, part, children, asChild,
|
|
|
32
31
|
return (_jsx(Part, { as: "button", asChild: asChild, ref: ref, ...withChrono(rest, props), children: children ?? props["aria-label"] }));
|
|
33
32
|
});
|
|
34
33
|
export const CalendarPrevButton = forwardRef(function CalendarPrevButton(props, ref) {
|
|
35
|
-
return
|
|
34
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "prev", part: "CalendarPrevButton" });
|
|
36
35
|
});
|
|
37
36
|
export const CalendarNextButton = forwardRef(function CalendarNextButton(props, ref) {
|
|
38
|
-
return
|
|
37
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "next", part: "CalendarNextButton" });
|
|
39
38
|
});
|
|
40
39
|
export const CalendarTodayButton = forwardRef(function CalendarTodayButton(props, ref) {
|
|
41
|
-
return
|
|
40
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "today", part: "CalendarTodayButton" });
|
|
42
41
|
});
|
|
43
42
|
export const CalendarViewButton = forwardRef(function CalendarViewButton({ view, children, asChild, ...rest }, ref) {
|
|
44
43
|
const calendar = useCalendarContext("CalendarViewButton");
|
|
@@ -94,7 +93,7 @@ export const CalendarMonthGrid = forwardRef(function CalendarMonthGrid({ month =
|
|
|
94
93
|
const model = layout.months[month];
|
|
95
94
|
if (!model)
|
|
96
95
|
return null;
|
|
97
|
-
return (_jsxs(Part, { as: "table", asChild: asChild, ref: composeRefs(ref, tableRef), ...withChrono(rest, calendar.getGridProps(month)), children: [_jsx("thead", { children: _jsxs("tr", { children: [layout.weekNumbers ? _jsx("td", {}) : null, layout.weekdays.map((header) => (_jsx(CalendarWeekdayHeader, { header: header }, header.dayOfWeek)))] }) }), _jsx("tbody", { children: model.weeks.map((week) => (_jsxs("tr", { children: [layout.weekNumbers ?
|
|
96
|
+
return (_jsxs(Part, { as: "table", asChild: asChild, ref: composeRefs(ref, tableRef), ...withChrono(rest, calendar.getGridProps(month)), children: [_jsx("thead", { children: _jsxs("tr", { children: [layout.weekNumbers ? _jsx("td", {}) : null, layout.weekdays.map((header) => (_jsx(CalendarWeekdayHeader, { header: header }, header.dayOfWeek)))] }) }), _jsx("tbody", { children: model.weeks.map((week) => (_jsxs("tr", { children: [layout.weekNumbers ? _jsx(CalendarWeekNumber, { weekNumber: week.weekNumber }) : null, week.days
|
|
98
97
|
.filter((day) => !day.hidden)
|
|
99
98
|
.map((day) => (_jsx(CalendarCell, { day: day, children: children ? children(day) : undefined }, day.key)))] }, week.days[0]?.key))) })] }));
|
|
100
99
|
});
|
|
@@ -128,8 +127,7 @@ export const CalendarAgendaDay = forwardRef(function CalendarAgendaDay({ day, ch
|
|
|
128
127
|
export const CalendarEvents = forwardRef(function CalendarEvents({ day, children, asChild, ...rest }, ref) {
|
|
129
128
|
const calendar = useCalendarContext("CalendarEvents");
|
|
130
129
|
const segments = calendar.controller.getCellEventSegments(day);
|
|
131
|
-
const interacting = calendar.state.focus.mode === "interaction" &&
|
|
132
|
-
calendar.state.focus.cellKey === day.key;
|
|
130
|
+
const interacting = calendar.state.focus.mode === "interaction" && calendar.state.focus.cellKey === day.key;
|
|
133
131
|
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, {
|
|
134
132
|
role: "group",
|
|
135
133
|
"aria-label": calendar.state.messages.events,
|
|
@@ -236,7 +234,7 @@ export const CalendarSelectionPreview = forwardRef(function CalendarSelectionPre
|
|
|
236
234
|
if (Object.keys(props).length === 0) {
|
|
237
235
|
return null;
|
|
238
236
|
}
|
|
239
|
-
return
|
|
237
|
+
return _jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, props) });
|
|
240
238
|
});
|
|
241
239
|
/** One availability background piece (plan 11 V9). Render one per `state.backgrounds`. */
|
|
242
240
|
export const CalendarBackground = forwardRef(function CalendarBackground({ piece, asChild, children, ...rest }, ref) {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { mergeProps } from "../shared/merge-props.js";
|
|
5
5
|
import { Part } from "../shared/part.js";
|
|
6
6
|
import { composeRefs } from "../shared/slot.js";
|
|
7
7
|
import { MiniCalendarContext, useMiniCalendarContext } from "./context.js";
|
|
8
8
|
import { splitMiniCalendarProps } from "./options.js";
|
|
9
9
|
import { useMiniCalendar } from "./use-mini-calendar.js";
|
|
10
|
+
import { definedOptions } from "./../shared/defined-options.js";
|
|
10
11
|
const withChrono = (consumer, chrono) => mergeProps(consumer, chrono);
|
|
11
12
|
/** A small month calendar, optionally synced with a main `Calendar` through `syncWith`. */
|
|
12
13
|
export const MiniCalendar = forwardRef(function MiniCalendar({ children, asChild, ...props }, ref) {
|
|
13
14
|
const [options, rest] = splitMiniCalendarProps(props);
|
|
14
|
-
const mini = useMiniCalendar({
|
|
15
|
+
const mini = useMiniCalendar(definedOptions({
|
|
15
16
|
...options,
|
|
16
17
|
id: props.id,
|
|
17
|
-
});
|
|
18
|
+
}));
|
|
18
19
|
const { ref: rootRef, ...rootProps } = mini.getRootProps();
|
|
19
20
|
const { id: _id, ...elementProps } = rest;
|
|
20
21
|
return (_jsx(MiniCalendarContext.Provider, { value: mini, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: children }) }));
|
|
@@ -29,10 +30,10 @@ const NavButton = forwardRef(function NavButton({ kind, part, children, asChild,
|
|
|
29
30
|
return (_jsx(Part, { as: "button", asChild: asChild, ref: ref, ...withChrono(rest, props), children: children ?? props["aria-label"] }));
|
|
30
31
|
});
|
|
31
32
|
export const MiniCalendarPrevButton = forwardRef(function MiniCalendarPrevButton(props, ref) {
|
|
32
|
-
return
|
|
33
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "prev", part: "MiniCalendarPrevButton" });
|
|
33
34
|
});
|
|
34
35
|
export const MiniCalendarNextButton = forwardRef(function MiniCalendarNextButton(props, ref) {
|
|
35
|
-
return
|
|
36
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "next", part: "MiniCalendarNextButton" });
|
|
36
37
|
});
|
|
37
38
|
export const MiniCalendarWeekdayHeader = forwardRef(function MiniCalendarWeekdayHeader({ header, children, asChild, ...rest }, ref) {
|
|
38
39
|
const mini = useMiniCalendarContext("MiniCalendarWeekdayHeader");
|
|
@@ -128,9 +128,7 @@ export function useCalendar(options = {}) {
|
|
|
128
128
|
getTimelineRowProps: (row) => toReactProps(controller.getTimelineRowAttributes(row)),
|
|
129
129
|
getTimelineRowHeaderProps: (row) => ({
|
|
130
130
|
...toReactProps(controller.getTimelineRowHeaderAttributes(row)),
|
|
131
|
-
onClick: row.group
|
|
132
|
-
? () => controller.toggleResource(row.id)
|
|
133
|
-
: undefined,
|
|
131
|
+
onClick: row.group ? () => controller.toggleResource(row.id) : undefined,
|
|
134
132
|
}),
|
|
135
133
|
getTimelineCellProps: (row, slot) => toReactProps(controller.getTimelineCellAttributes(row, slot)),
|
|
136
134
|
getResourcePieceProps: (piece) => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createMiniCalendarController, } from "../vendor/core/calendar/index.js";
|
|
3
|
-
import { focusDateCell
|
|
3
|
+
import { focusDateCell } from "../vendor/core/foundation/index.js";
|
|
4
4
|
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
|
|
5
5
|
import { toReactProps } from "../shared/to-react-props.js";
|
|
6
6
|
import { modifiersOf } from "../shared/modifiers.js";
|
package/dist/date/bind-panel.js
CHANGED
|
@@ -13,7 +13,7 @@ function focusKeyOf(state) {
|
|
|
13
13
|
? `${focusedDate.year}-${String(focusedDate.month).padStart(2, "0")}`
|
|
14
14
|
: String(focusedDate.year);
|
|
15
15
|
}
|
|
16
|
-
//
|
|
16
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- the panels share one binding
|
|
17
17
|
export function useBoundPanel(controller, options) {
|
|
18
18
|
const rootRef = useRef(null);
|
|
19
19
|
const keyboardMove = useRef(false);
|
package/dist/date/components.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { mergeProps } from "../shared/merge-props.js";
|
|
5
5
|
import { Part } from "../shared/part.js";
|
|
6
6
|
import { composeRefs } from "../shared/slot.js";
|
|
7
7
|
import { DateFieldContext, DatePanelContext, useDateFieldContext, useDatePanelContext, } from "./context.js";
|
|
8
8
|
import { splitDateInputProps, splitDatePanelProps, splitDateRangeInputProps, splitDateRangePanelProps, splitMultiDatePanelProps, } from "./options.js";
|
|
9
9
|
import { useDateInput, useDateRangeInput } from "./use-date-input.js";
|
|
10
|
-
import { useDatePanel, useDateRangePanel, useMultiDatePanel
|
|
10
|
+
import { useDatePanel, useDateRangePanel, useMultiDatePanel } from "./use-date-panel.js";
|
|
11
11
|
const withChrono = (consumer, chrono) => mergeProps(consumer, chrono);
|
|
12
12
|
/** Hidden form inputs (A15). Rendered on the server too, so forms post without JS. */
|
|
13
13
|
function HiddenInputs({ inputs }) {
|
|
@@ -43,15 +43,13 @@ function FieldContent() {
|
|
|
43
43
|
/** A date field: segmented (default) or text. Use `DateInputSegment` parts for custom layouts. */
|
|
44
44
|
export const DateInput = forwardRef(function DateInput({ children, asChild, ...props }, ref) {
|
|
45
45
|
const [options, rest] = splitDateInputProps(props);
|
|
46
|
-
const input = useDateInput({
|
|
46
|
+
const input = useDateInput(definedOptions({
|
|
47
47
|
...options,
|
|
48
48
|
id: props.id,
|
|
49
|
-
});
|
|
49
|
+
}));
|
|
50
50
|
const { ref: rootRef, ...rootProps } = input.getRootProps();
|
|
51
51
|
const { id: _id, ...elementProps } = rest;
|
|
52
|
-
return (_jsx(DateFieldContext.Provider, { value: input, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [typeof children === "function"
|
|
53
|
-
? children(input.state)
|
|
54
|
-
: (children ?? _jsx(FieldContent, {})), _jsx(HiddenInputs, { inputs: input.state.hidden })] }) }));
|
|
52
|
+
return (_jsx(DateFieldContext.Provider, { value: input, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [typeof children === "function" ? children(input.state) : (children ?? _jsx(FieldContent, {})), _jsx(HiddenInputs, { inputs: input.state.hidden })] }) }));
|
|
55
53
|
});
|
|
56
54
|
function RangeField({ side, children, asChild, forwardedRef, ...rest }) {
|
|
57
55
|
const range = useRangeContext(side === "start" ? "DateRangeInputStart" : "DateRangeInputEnd");
|
|
@@ -61,11 +59,10 @@ function RangeField({ side, children, asChild, forwardedRef, ...rest }) {
|
|
|
61
59
|
...rootProps,
|
|
62
60
|
role: "group",
|
|
63
61
|
"aria-label": field.state.messages[side === "start" ? "startDate" : "endDate"],
|
|
64
|
-
}), children: typeof children === "function"
|
|
65
|
-
? children(field.state)
|
|
66
|
-
: (children ?? _jsx(FieldContent, {})) }) }));
|
|
62
|
+
}), children: typeof children === "function" ? children(field.state) : (children ?? _jsx(FieldContent, {})) }) }));
|
|
67
63
|
}
|
|
68
64
|
import { createContext, useContext } from "react";
|
|
65
|
+
import { definedOptions } from "./../shared/defined-options.js";
|
|
69
66
|
const RangeContext = createContext(null);
|
|
70
67
|
function useRangeContext(part) {
|
|
71
68
|
const value = useContext(RangeContext);
|
|
@@ -83,10 +80,10 @@ export const DateRangeInputEnd = forwardRef(function DateRangeInputEnd(props, re
|
|
|
83
80
|
/** Two date fields (start and end) in one group, in both modes. */
|
|
84
81
|
export const DateRangeInput = forwardRef(function DateRangeInput({ children, asChild, ...props }, ref) {
|
|
85
82
|
const [options, rest] = splitDateRangeInputProps(props);
|
|
86
|
-
const range = useDateRangeInput({
|
|
83
|
+
const range = useDateRangeInput(definedOptions({
|
|
87
84
|
...options,
|
|
88
85
|
id: props.id,
|
|
89
|
-
});
|
|
86
|
+
}));
|
|
90
87
|
const { ref: rootRef, ...rootProps } = range.getRootProps();
|
|
91
88
|
const { id: _id, ...elementProps } = rest;
|
|
92
89
|
return (_jsx(RangeContext.Provider, { value: range, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [children ?? (_jsxs(_Fragment, { children: [_jsx(DateRangeInputStart, {}), _jsx("span", { "aria-hidden": "true", children: "\u2013" }), _jsx(DateRangeInputEnd, {})] })), _jsx(HiddenInputs, { inputs: range.state.hidden })] }) }));
|
|
@@ -106,10 +103,10 @@ const NavButton = forwardRef(function NavButton({ kind, part, children, asChild,
|
|
|
106
103
|
return (_jsx(Part, { as: "button", asChild: asChild, ref: ref, ...withChrono(rest, props), children: children ?? props["aria-label"] }));
|
|
107
104
|
});
|
|
108
105
|
export const DatePanelPrevButton = forwardRef(function DatePanelPrevButton(props, ref) {
|
|
109
|
-
return
|
|
106
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "prev", part: "DatePanelPrevButton" });
|
|
110
107
|
});
|
|
111
108
|
export const DatePanelNextButton = forwardRef(function DatePanelNextButton(props, ref) {
|
|
112
|
-
return
|
|
109
|
+
return _jsx(NavButton, { ...props, ref: ref, kind: "next", part: "DatePanelNextButton" });
|
|
113
110
|
});
|
|
114
111
|
/** Shows today's month; with `selectToday` it also picks today. */
|
|
115
112
|
export const DatePanelTodayButton = forwardRef(function DatePanelTodayButton({ children, asChild, ...rest }, ref) {
|
|
@@ -128,14 +125,8 @@ export const DatePanelWeekNumber = forwardRef(function DatePanelWeekNumber({ wee
|
|
|
128
125
|
/** A day cell (`day`) or, at the month and year levels, a month or year cell (`cell`). */
|
|
129
126
|
export const DatePanelCell = forwardRef(function DatePanelCell({ day, cell, children, asChild, ...rest }, ref) {
|
|
130
127
|
const panel = useDatePanelContext("DatePanelCell");
|
|
131
|
-
const chrono = day
|
|
132
|
-
|
|
133
|
-
: panel.getLevelCellProps(cell);
|
|
134
|
-
const fallback = day
|
|
135
|
-
? day.hidden
|
|
136
|
-
? null
|
|
137
|
-
: day.date.day
|
|
138
|
-
: cell.text;
|
|
128
|
+
const chrono = day ? panel.getCellProps(day) : panel.getLevelCellProps(cell);
|
|
129
|
+
const fallback = day ? (day.hidden ? null : day.date.day) : cell.text;
|
|
139
130
|
return (_jsx(Part, { as: "td", asChild: asChild, ref: ref, ...withChrono(rest, chrono), children: children ?? fallback }));
|
|
140
131
|
});
|
|
141
132
|
/** The grid of the current level. Month and year levels render in the first grid only. */
|
|
@@ -147,7 +138,7 @@ export const DatePanelGrid = forwardRef(function DatePanelGrid({ month = 0, chil
|
|
|
147
138
|
const model = state.months[month];
|
|
148
139
|
if (!model)
|
|
149
140
|
return null;
|
|
150
|
-
body = (_jsxs(_Fragment, { children: [_jsx("thead", { children: _jsxs("tr", { children: [state.weekNumbers ? _jsx("td", {}) : null, state.weekdays.map((header) => (_jsx(DatePanelWeekdayHeader, { header: header }, header.dayOfWeek)))] }) }), _jsx("tbody", { children: model.weeks.map((week) => (_jsxs("tr", { children: [state.weekNumbers ?
|
|
141
|
+
body = (_jsxs(_Fragment, { children: [_jsx("thead", { children: _jsxs("tr", { children: [state.weekNumbers ? _jsx("td", {}) : null, state.weekdays.map((header) => (_jsx(DatePanelWeekdayHeader, { header: header }, header.dayOfWeek)))] }) }), _jsx("tbody", { children: model.weeks.map((week) => (_jsxs("tr", { children: [state.weekNumbers ? _jsx(DatePanelWeekNumber, { weekNumber: week.weekNumber }) : null, week.days.map((day) => (_jsx(DatePanelCell, { day: day, children: day.hidden ? null : children?.(day) }, `${day.date.month}-${day.date.day}`)))] }, `${model.key}-${week.days[0]?.date.day}-${week.days[0]?.date.month}`))) })] }));
|
|
151
142
|
}
|
|
152
143
|
else {
|
|
153
144
|
if (month !== 0)
|
|
@@ -175,28 +166,28 @@ function PanelRoot({ panel, forwardedRef, asChild, children, rest, }) {
|
|
|
175
166
|
/** A single-date panel. Compose it with `DatePanelGrid` and friends, or render it bare. */
|
|
176
167
|
export const DatePanel = forwardRef(function DatePanel({ children, asChild, ...props }, ref) {
|
|
177
168
|
const [options, rest] = splitDatePanelProps(props);
|
|
178
|
-
const panel = useDatePanel({
|
|
169
|
+
const panel = useDatePanel(definedOptions({
|
|
179
170
|
...options,
|
|
180
171
|
id: props.id,
|
|
181
|
-
});
|
|
172
|
+
}));
|
|
182
173
|
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, children: children }));
|
|
183
174
|
});
|
|
184
175
|
/** A range panel (two picks). Shows two months by default. */
|
|
185
176
|
export const DateRangePanel = forwardRef(function DateRangePanel({ children, asChild, months = 2, ...props }, ref) {
|
|
186
177
|
const [options, rest] = splitDateRangePanelProps(props);
|
|
187
|
-
const panel = useDateRangePanel({
|
|
178
|
+
const panel = useDateRangePanel(definedOptions({
|
|
188
179
|
...options,
|
|
189
180
|
months,
|
|
190
181
|
id: props.id,
|
|
191
|
-
});
|
|
182
|
+
}));
|
|
192
183
|
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, children: children }));
|
|
193
184
|
});
|
|
194
185
|
/** A panel that selects any number of dates. */
|
|
195
186
|
export const MultiDatePanel = forwardRef(function MultiDatePanel({ children, asChild, ...props }, ref) {
|
|
196
187
|
const [options, rest] = splitMultiDatePanelProps(props);
|
|
197
|
-
const panel = useMultiDatePanel({
|
|
188
|
+
const panel = useMultiDatePanel(definedOptions({
|
|
198
189
|
...options,
|
|
199
190
|
id: props.id,
|
|
200
|
-
});
|
|
191
|
+
}));
|
|
201
192
|
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, children: children }));
|
|
202
193
|
});
|
package/dist/date/utilities.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getPresetRange, matchPreset, parseDate
|
|
1
|
+
export { getPresetRange, matchPreset, parseDate } from "../vendor/core/date/index.js";
|
|
2
2
|
export { checkDateRange, compare, createAvailability, dateRangeLength, formatDate, fromInclusiveEndDate, getDateStatus, isDateInRange, isDateSelectable, isSameDay, normalizeDateRange, plainYearMonth, compareYearMonth, toIsoString, toPlainDate, toPlainYearMonth, } from "../vendor/core/foundation/index.js";
|
|
3
3
|
export type { DateInputOptions, DatePanelOptions, DateRangeInputOptions, DateRangePanelOptions, DateRangeValue, DateValidity, DateValue, DatePreset, MultiDatePanelOptions, MultiDateValue, PanelCell, PanelDay, PanelLevel, PanelState, PresetContext, RangeValidity, SegmentView, DateInputState, DateRangeInputState, } from "../vendor/core/date/index.js";
|
|
4
4
|
export type { PlainYearMonth } from "../vendor/core/foundation/index.js";
|
package/dist/date/utilities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Pure utilities and value helpers re-exported from core. No "use client":
|
|
2
2
|
// they stay ordinary functions in Server Components and server actions.
|
|
3
|
-
export { getPresetRange, matchPreset, parseDate
|
|
3
|
+
export { getPresetRange, matchPreset, parseDate } from "../vendor/core/date/index.js";
|
|
4
4
|
export { checkDateRange, compare, createAvailability, dateRangeLength, formatDate, fromInclusiveEndDate, getDateStatus, isDateInRange, isDateSelectable, isSameDay, normalizeDateRange, plainYearMonth, compareYearMonth, toIsoString, toPlainDate, toPlainYearMonth, } from "../vendor/core/foundation/index.js";
|
|
@@ -10,8 +10,9 @@ import { TimePanelColumn, TimePanelList } from "../time/components.js";
|
|
|
10
10
|
import { TimePanelContext } from "../time/context.js";
|
|
11
11
|
import { DateTimeFieldContext, DateTimePanelContext, useDateTimeFieldContext, useDateTimePanelContext, } from "./context.js";
|
|
12
12
|
import { splitDateTimeInputProps, splitDateTimePanelProps, splitDateTimeRangeInputProps, splitDateTimeRangePanelProps, } from "./options.js";
|
|
13
|
-
import { useDateTimeInput, useDateTimeRangeInput
|
|
14
|
-
import { useDateTimePanel, useDateTimeRangePanel
|
|
13
|
+
import { useDateTimeInput, useDateTimeRangeInput } from "./use-datetime-input.js";
|
|
14
|
+
import { useDateTimePanel, useDateTimeRangePanel } from "./use-datetime-panel.js";
|
|
15
|
+
import { definedOptions } from "./../shared/defined-options.js";
|
|
15
16
|
const withChrono = (consumer, chrono) => mergeProps(consumer, chrono);
|
|
16
17
|
/** Any date or time part of the segmented input. */
|
|
17
18
|
export const DateTimeInputSegment = forwardRef(function DateTimeInputSegment({ segment, children, asChild, ...rest }, ref) {
|
|
@@ -51,19 +52,17 @@ function FieldContent() {
|
|
|
51
52
|
}
|
|
52
53
|
return (_jsx(_Fragment, { children: state.segments.map((segment, index) => segment.type === "literal" ? (_jsx(DateTimeInputLiteral, { segment: segment }, index)) : (_jsx(DateTimeInputSegment, { segment: segment }, segment.type))) }));
|
|
53
54
|
}
|
|
54
|
-
const HiddenInputs = ({ inputs
|
|
55
|
+
const HiddenInputs = ({ inputs }) => (_jsx(_Fragment, { children: inputs.map((input) => (_jsx("input", { type: "hidden", name: input.name, value: input.value }, `${input.name}:${input.value}`))) }));
|
|
55
56
|
/** A date-time field: one group of segments, or a date field and a time field. */
|
|
56
57
|
export const DateTimeInput = forwardRef(function DateTimeInput({ children, asChild, ...props }, ref) {
|
|
57
58
|
const [options, rest] = splitDateTimeInputProps(props);
|
|
58
|
-
const input = useDateTimeInput({
|
|
59
|
+
const input = useDateTimeInput(definedOptions({
|
|
59
60
|
...options,
|
|
60
61
|
id: props.id,
|
|
61
|
-
});
|
|
62
|
+
}));
|
|
62
63
|
const { ref: rootRef, ...rootProps } = input.getRootProps();
|
|
63
64
|
const { id: _id, ...elementProps } = rest;
|
|
64
|
-
return (_jsx(DateTimeFieldContext.Provider, { value: input, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [typeof children === "function"
|
|
65
|
-
? children(input.state)
|
|
66
|
-
: (children ?? _jsx(FieldContent, {})), _jsx(HiddenInputs, { inputs: input.state.hidden })] }) }));
|
|
65
|
+
return (_jsx(DateTimeFieldContext.Provider, { value: input, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [typeof children === "function" ? children(input.state) : (children ?? _jsx(FieldContent, {})), _jsx(HiddenInputs, { inputs: input.state.hidden })] }) }));
|
|
67
66
|
});
|
|
68
67
|
const RangeContext = createContext(null);
|
|
69
68
|
function RangeField({ side, children, asChild, forwardedRef, ...rest }) {
|
|
@@ -76,9 +75,7 @@ function RangeField({ side, children, asChild, forwardedRef, ...rest }) {
|
|
|
76
75
|
...rootProps,
|
|
77
76
|
role: "group",
|
|
78
77
|
"aria-label": field.state.messages[side === "start" ? "startDateTime" : "endDateTime"],
|
|
79
|
-
}), children: typeof children === "function"
|
|
80
|
-
? children(field.state)
|
|
81
|
-
: (children ?? _jsx(FieldContent, {})) }) }));
|
|
78
|
+
}), children: typeof children === "function" ? children(field.state) : (children ?? _jsx(FieldContent, {})) }) }));
|
|
82
79
|
}
|
|
83
80
|
export const DateTimeRangeInputStart = forwardRef(function DateTimeRangeInputStart(props, ref) {
|
|
84
81
|
return _jsx(RangeField, { side: "start", forwardedRef: ref, ...props });
|
|
@@ -89,10 +86,10 @@ export const DateTimeRangeInputEnd = forwardRef(function DateTimeRangeInputEnd(p
|
|
|
89
86
|
/** Two date-time fields (start and end) in one group. */
|
|
90
87
|
export const DateTimeRangeInput = forwardRef(function DateTimeRangeInput({ children, asChild, ...props }, ref) {
|
|
91
88
|
const [options, rest] = splitDateTimeRangeInputProps(props);
|
|
92
|
-
const range = useDateTimeRangeInput({
|
|
89
|
+
const range = useDateTimeRangeInput(definedOptions({
|
|
93
90
|
...options,
|
|
94
91
|
id: props.id,
|
|
95
|
-
});
|
|
92
|
+
}));
|
|
96
93
|
const { id: _id, ...elementProps } = rest;
|
|
97
94
|
return (_jsx(RangeContext.Provider, { value: range, children: _jsxs(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(elementProps, range.getRootProps()), children: [children ?? (_jsxs(_Fragment, { children: [_jsx(DateTimeRangeInputStart, {}), _jsx("span", { "aria-hidden": "true", children: "\u2013" }), _jsx(DateTimeRangeInputEnd, {})] })), _jsx(HiddenInputs, { inputs: range.state.hidden })] }) }));
|
|
98
95
|
});
|
|
@@ -129,14 +126,12 @@ export const DateTimePanelTime = forwardRef(function DateTimePanelTime({ childre
|
|
|
129
126
|
/** The date range panel context of a range panel. */
|
|
130
127
|
export const DateTimeRangePanelDate = DateTimePanelDate;
|
|
131
128
|
function RangeTime({ which, children, asChild, forwardedRef, ...rest }) {
|
|
132
|
-
const panel = useDateTimePanelContext(which === "startTime"
|
|
133
|
-
? "DateTimeRangePanelStartTime"
|
|
134
|
-
: "DateTimeRangePanelEndTime");
|
|
129
|
+
const panel = useDateTimePanelContext(which === "startTime" ? "DateTimeRangePanelStartTime" : "DateTimeRangePanelEndTime");
|
|
135
130
|
const time = panel[which];
|
|
136
131
|
if (!time)
|
|
137
132
|
return null;
|
|
138
133
|
const { ref: rootRef, ...rootProps } = time.getRootProps();
|
|
139
|
-
return (_jsx(TimePanelContext.Provider, { value: time, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(forwardedRef, rootRef), ...withChrono(rest, rootProps), children: children ??
|
|
134
|
+
return (_jsx(TimePanelContext.Provider, { value: time, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(forwardedRef, rootRef), ...withChrono(rest, rootProps), children: children ?? _jsx(DefaultTime, { which: which === "startTime" ? "start" : "end" }) }) }));
|
|
140
135
|
}
|
|
141
136
|
export const DateTimeRangePanelStartTime = forwardRef(function DateTimeRangePanelStartTime(props, ref) {
|
|
142
137
|
return _jsx(RangeTime, { which: "startTime", forwardedRef: ref, ...props });
|
|
@@ -152,18 +147,18 @@ function PanelRoot({ panel, forwardedRef, asChild, children, rest, range, }) {
|
|
|
152
147
|
/** A date panel and a time panel composed by one controller. */
|
|
153
148
|
export const DateTimePanel = forwardRef(function DateTimePanel({ children, asChild, ...props }, ref) {
|
|
154
149
|
const [options, rest] = splitDateTimePanelProps(props);
|
|
155
|
-
const panel = useDateTimePanel({
|
|
150
|
+
const panel = useDateTimePanel(definedOptions({
|
|
156
151
|
...options,
|
|
157
152
|
id: props.id,
|
|
158
|
-
});
|
|
153
|
+
}));
|
|
159
154
|
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, range: false, children: children }));
|
|
160
155
|
});
|
|
161
156
|
/** A date range panel with a start time and an end time. */
|
|
162
157
|
export const DateTimeRangePanel = forwardRef(function DateTimeRangePanel({ children, asChild, ...props }, ref) {
|
|
163
158
|
const [options, rest] = splitDateTimeRangePanelProps(props);
|
|
164
|
-
const panel = useDateTimeRangePanel({
|
|
159
|
+
const panel = useDateTimeRangePanel(definedOptions({
|
|
165
160
|
...options,
|
|
166
161
|
id: props.id,
|
|
167
|
-
});
|
|
162
|
+
}));
|
|
168
163
|
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, range: true, children: children }));
|
|
169
164
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createDateTimePanelController, createDateTimeRangePanelController, } from "../vendor/core/datetime/index.js";
|
|
3
|
-
import { useEffect, useId, useLayoutEffect, useMemo, useState, useSyncExternalStore
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { useBoundPanel as useBoundDatePanel } from "../date/bind-panel.js";
|
|
5
5
|
import { useBoundPanel as useBoundTimePanel } from "../time/bind-panel.js";
|
|
6
6
|
import { toReactProps } from "../shared/to-react-props.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drop `undefined`-valued keys from a creation options object
|
|
3
|
+
* (00-foundation-3 §2.3).
|
|
4
|
+
*
|
|
5
|
+
* `exactOptionalPropertyTypes` treats an optional option as "absent", not
|
|
6
|
+
* "present and undefined". Creation paths let the controller's `??` defaults
|
|
7
|
+
* apply when a key is absent, so stripping the key is the same behaviour. Update
|
|
8
|
+
* paths (`controller.setOptions`) keep explicit `undefined` where it means
|
|
9
|
+
* "reset".
|
|
10
|
+
*
|
|
11
|
+
* Internal to the package; never exported.
|
|
12
|
+
*/
|
|
13
|
+
type Defined<T extends object> = {
|
|
14
|
+
[K in keyof T as T[K] extends undefined ? never : K]: Exclude<T[K], undefined>;
|
|
15
|
+
};
|
|
16
|
+
/** A copy of `value` without the keys whose value is `undefined`. */
|
|
17
|
+
export declare function definedOptions<T extends object>(value: T): Defined<T>;
|
|
18
|
+
export {};
|
|
@@ -19,9 +19,7 @@ export function mergeProps(consumer, chrono) {
|
|
|
19
19
|
}
|
|
20
20
|
for (const [key, value] of Object.entries(chrono)) {
|
|
21
21
|
const own = consumer[key];
|
|
22
|
-
if (/^on[A-Z]/.test(key) &&
|
|
23
|
-
typeof value === "function" &&
|
|
24
|
-
typeof own === "function") {
|
|
22
|
+
if (/^on[A-Z]/.test(key) && typeof value === "function" && typeof own === "function") {
|
|
25
23
|
merged[key] = (event, ...rest) => {
|
|
26
24
|
own(event, ...rest);
|
|
27
25
|
if (!event?.defaultPrevented)
|
package/dist/shared/part.d.ts
CHANGED
package/dist/shared/slot.js
CHANGED
|
@@ -33,10 +33,7 @@ export const Slot = forwardRef(function Slot({ children, ...rest }, forwardedRef
|
|
|
33
33
|
const merged = { ...childProps, ...rest };
|
|
34
34
|
const childClassName = typeof childProps.className === "string" ? childProps.className : "";
|
|
35
35
|
const slotClassName = typeof rest.className === "string" ? rest.className : "";
|
|
36
|
-
const className = [childClassName, slotClassName]
|
|
37
|
-
.filter(Boolean)
|
|
38
|
-
.join(" ")
|
|
39
|
-
.trim();
|
|
36
|
+
const className = [childClassName, slotClassName].filter(Boolean).join(" ").trim();
|
|
40
37
|
if (className) {
|
|
41
38
|
merged.className = className;
|
|
42
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { splitProperties
|
|
1
|
+
import { splitProperties } from "../vendor/core/foundation/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* The one place that turns Chrono layout numbers into inline styles
|
|
4
4
|
* (plan 05 R2): `--chrono-*` custom properties become a React `style` object.
|
package/dist/time/bind-panel.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { focusDateCell, scrollOptionIntoView
|
|
2
|
+
import { focusDateCell, scrollOptionIntoView } from "../vendor/core/foundation/index.js";
|
|
3
3
|
import { useEffect, useLayoutEffect, useMemo, useRef, useSyncExternalStore, } from "react";
|
|
4
4
|
import { modifiersOf } from "../shared/modifiers.js";
|
|
5
5
|
import { toReactProps } from "../shared/to-react-props.js";
|
|
6
6
|
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
7
7
|
const optionElement = (root, key) => root.querySelector(`[data-chrono-key="${key.replace(/["\\]/g, "\\$&")}"]`);
|
|
8
8
|
export function useBoundPanel(
|
|
9
|
-
//
|
|
9
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- the panels share one binding
|
|
10
10
|
controller, options) {
|
|
11
11
|
const rootRef = useRef(null);
|
|
12
12
|
const keyboardMove = useRef(false);
|
|
@@ -150,9 +150,9 @@ export declare const TimePanel: import("react").ForwardRefExoticComponent<Omit<P
|
|
|
150
150
|
onValueChange?: (value: import("../vendor/core/time/index.js").TimeValue, info: {
|
|
151
151
|
slot?: BookingSlot;
|
|
152
152
|
}) => void;
|
|
153
|
-
onValueCommit?: (value: import("../vendor/core/foundation/index.js").PlainTime, info: {
|
|
153
|
+
onValueCommit?: ((value: import("../vendor/core/foundation/index.js").PlainTime, info: {
|
|
154
154
|
slot?: BookingSlot;
|
|
155
|
-
}) => void;
|
|
155
|
+
}) => void) | undefined;
|
|
156
156
|
} & {
|
|
157
157
|
children?: ReactNode;
|
|
158
158
|
} & import("react").RefAttributes<HTMLElement>>;
|