calendar-components 0.0.0-stage → 0.7.3

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.
@@ -0,0 +1,273 @@
1
+ import { ChangeDetails, CalendarLabels, CalendarDay } from 'calendar-components-core';
2
+ import * as React from 'react';
3
+ import { d as CalendarComponentsPartProps, b as CalendarComponentsInteractionState } from '../types-BxqOsLkh.js';
4
+ export { C as CalendarComponentsEvent, a as CalendarComponentsHandlers, c as CalendarComponentsPartElementProps } from '../types-BxqOsLkh.js';
5
+
6
+ /**
7
+ * A schedule as a list: a section for each day that has something, its
8
+ * events in time order. The list, its sections and its items are React Aria
9
+ * Components' `GridList`, so the arrow keys, type to find, selection and the
10
+ * screen reader are theirs. These parts add the days, the words and this
11
+ * package's props.
12
+ */
13
+ type AgendaValueChangeDetails = ChangeDetails<"item-press">;
14
+ type AgendaRootState = {
15
+ empty: boolean;
16
+ };
17
+ interface AgendaRootActions {
18
+ /**
19
+ * Scrolls to a day's section, or to the first day after it when that day
20
+ * has nothing. `"today"` is today in the list's time zone. Returns false
21
+ * when there is no such day.
22
+ */
23
+ scrollToDay: (date: string | "today", options?: ScrollIntoViewOptions) => boolean;
24
+ }
25
+ interface AgendaRootProps extends CalendarComponentsPartProps<AgendaRootState, HTMLDivElement> {
26
+ /** The selected event's id. Use with `onValueChange` to control it. */
27
+ value?: string | null;
28
+ defaultValue?: string | null;
29
+ onValueChange?: (value: string | null, details: AgendaValueChangeDetails) => void;
30
+ /** A BCP 47 tag. Left out, it is the nearest React Aria `I18nProvider`'s, or the browser's. */
31
+ locale?: string;
32
+ /**
33
+ * The IANA time zone "today" is told in.
34
+ * @default this device's
35
+ */
36
+ timeZone?: string;
37
+ /** The list's name. Give this or `aria-labelledby`. */
38
+ "aria-label"?: string;
39
+ "aria-labelledby"?: string;
40
+ id?: string;
41
+ /** Your words for "all-day" and for how an event is read aloud. */
42
+ labels?: Partial<CalendarLabels>;
43
+ /** `Agenda.Day`s. */
44
+ children: React.ReactNode;
45
+ /** A ref to the list's actions: `actionsRef.current.scrollToDay("today")`. */
46
+ actionsRef?: React.RefObject<AgendaRootActions | null>;
47
+ /** What shows when there are no days. */
48
+ renderEmptyState?: () => React.ReactNode;
49
+ /**
50
+ * Draws only the rows in view, with React Aria's `Virtualizer`: for a schedule of months or years. The
51
+ * list must then scroll itself, so give it a height and `overflow: auto`. Pass sizes to say what a row
52
+ * and a day's heading are tall; an estimate is measured once the row is drawn.
53
+ * @default false
54
+ */
55
+ virtualized?: boolean | AgendaVirtualizedOptions;
56
+ }
57
+ /** What rows and headings are tall, in pixels: exact (`rowSize`), or a first guess that is measured (`estimatedRowSize`). */
58
+ interface AgendaVirtualizedOptions {
59
+ rowSize?: number;
60
+ /** @default 48 */
61
+ estimatedRowSize?: number;
62
+ headingSize?: number;
63
+ /** @default 32 */
64
+ estimatedHeadingSize?: number;
65
+ /** Pixels between rows. */
66
+ gap?: number;
67
+ }
68
+ /** Groups the days of a schedule. Renders React Aria's `GridList`, a `<div>` with the grid role. */
69
+ declare const AgendaRoot: React.ForwardRefExoticComponent<AgendaRootProps & React.RefAttributes<HTMLDivElement>>;
70
+ declare namespace AgendaRoot {
71
+ type Actions = AgendaRootActions;
72
+ type VirtualizedOptions = AgendaVirtualizedOptions;
73
+ type Props = AgendaRootProps;
74
+ type State = AgendaRootState;
75
+ type ValueChangeDetails = AgendaValueChangeDetails;
76
+ }
77
+
78
+ /** A day in the list, and its words in the locale. */
79
+ type AgendaDayState = {
80
+ date: string;
81
+ today: boolean;
82
+ weekend: boolean;
83
+ past: boolean;
84
+ weekdayLabel: string;
85
+ dayLabel: string;
86
+ label: string;
87
+ };
88
+
89
+ interface AgendaDayProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "className" | "style">, CalendarComponentsPartProps<AgendaDayState, HTMLDivElement> {
90
+ /** The day this section is. */
91
+ day: Pick<CalendarDay, "date">;
92
+ /** An `Agenda.DayHeader`, then the day's `Agenda.Event`s. */
93
+ children: React.ReactNode;
94
+ }
95
+ /**
96
+ * A day's section. Renders React Aria's `GridListSection`, a `<div>` with
97
+ * the rowgroup role; drawn as another element with `render`, it should stay
98
+ * one that can hold that role.
99
+ */
100
+ declare const AgendaDay: React.ForwardRefExoticComponent<AgendaDayProps & React.RefAttributes<HTMLDivElement>>;
101
+ declare namespace AgendaDay {
102
+ type Props = AgendaDayProps;
103
+ type State = AgendaDayState;
104
+ }
105
+
106
+ interface AgendaDayHeaderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "className" | "style">, CalendarComponentsPartProps<AgendaDayState, HTMLDivElement> {
107
+ /** Left out, it is the day in full, in the locale's words: "Monday, November 23". */
108
+ children?: React.ReactNode | ((state: AgendaDayState) => React.ReactNode);
109
+ }
110
+ /** A day's heading. Renders React Aria's `GridListHeader`, a `<div>`. */
111
+ declare const AgendaDayHeader: React.ForwardRefExoticComponent<AgendaDayHeaderProps & React.RefAttributes<HTMLDivElement>>;
112
+ declare namespace AgendaDayHeader {
113
+ type Props = AgendaDayHeaderProps;
114
+ type State = AgendaDayState;
115
+ }
116
+
117
+ /** An event as the list is given it: its id, and its start and end in minutes past midnight, left out when it is all day. */
118
+ type AgendaEventItem = {
119
+ id: string;
120
+ start?: number;
121
+ end?: number;
122
+ };
123
+ type AgendaEventState<E extends AgendaEventItem = AgendaEventItem> = CalendarComponentsInteractionState & {
124
+ /** The event you gave. */
125
+ event: E;
126
+ selected: boolean;
127
+ /** Its times in the locale's words: "7:00 AM". Empty for an all-day event. */
128
+ startLabel: string;
129
+ endLabel: string;
130
+ /** The same times in parts, to set the day period apart: `{ time: "7:00", dayPeriod: "AM" }`. Null for an all-day event. */
131
+ startParts: {
132
+ time: string;
133
+ dayPeriod: string;
134
+ } | null;
135
+ endParts: {
136
+ time: string;
137
+ dayPeriod: string;
138
+ } | null;
139
+ allDay: boolean;
140
+ };
141
+ interface AgendaEventProps<E extends AgendaEventItem = AgendaEventItem> extends CalendarComponentsPartProps<AgendaEventState<E>, HTMLDivElement> {
142
+ /** The event: its id, and its start and end in minutes past midnight. Leave the times out for one that is all day. */
143
+ event: E;
144
+ /** The event's name: what typing finds it by, and with its times what a screen reader says. */
145
+ label: string;
146
+ /** What a screen reader says instead of the name and times. */
147
+ "aria-label"?: string;
148
+ disabled?: boolean;
149
+ /** Called when it is pressed, or Enter is pressed on it: to open it. */
150
+ onAction?: () => void;
151
+ /** Left out, it is the name. */
152
+ children?: React.ReactNode | ((state: AgendaEventState<E>) => React.ReactNode);
153
+ }
154
+ declare const AgendaEvent: <E extends AgendaEventItem = AgendaEventItem>(props: AgendaEventProps<E> & React.RefAttributes<HTMLDivElement>) => React.ReactElement;
155
+ declare namespace AgendaEvent {
156
+ type Props = AgendaEventProps;
157
+ type State = AgendaEventState;
158
+ }
159
+
160
+ interface AgendaLoadMoreProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
161
+ /** Called when the end of the list comes into view: add the days after the last. */
162
+ onLoadMore?: () => void;
163
+ /** Whether more days are on their way: the row then shows its children, and is read as loading. */
164
+ loading?: boolean;
165
+ /**
166
+ * How far before the end to ask, as a multiple of the list's height.
167
+ * @default 1
168
+ */
169
+ scrollOffset?: number;
170
+ /** What shows while loading, such as a spinner. */
171
+ children?: React.ReactNode;
172
+ }
173
+ /**
174
+ * The end of a list that goes on, as Calendar's does on iOS: put it after the last `Agenda.Day`, and it asks
175
+ * for more days when it is scrolled to. Renders React Aria's `GridListLoadMoreItem`.
176
+ */
177
+ declare const AgendaLoadMore: React.ForwardRefExoticComponent<AgendaLoadMoreProps & React.RefAttributes<HTMLDivElement>>;
178
+ declare namespace AgendaLoadMore {
179
+ type Props = AgendaLoadMoreProps;
180
+ }
181
+
182
+ declare namespace index_parts {
183
+ export { AgendaDay as Day, AgendaDayHeader as DayHeader, AgendaEvent as Event, AgendaLoadMore as LoadMore, AgendaRoot as Root };
184
+ }
185
+
186
+ interface AgendaContextValue {
187
+ locale: string;
188
+ timeZone: string;
189
+ labels: CalendarLabels;
190
+ }
191
+ declare function useAgendaContext(part?: string): AgendaContextValue;
192
+
193
+ /**
194
+ * Identifies the list.
195
+ * @type {'agenda'}
196
+ */
197
+ declare const slot$2 = "data-slot";
198
+ /** Present when the list has no days (React Aria's). */
199
+ declare const empty = "data-empty";
200
+ /** Present while the list has keyboard focus (React Aria's). */
201
+ declare const focusVisible$1 = "data-focus-visible";
202
+
203
+ declare const AgendaRootDataAttributes_empty: typeof empty;
204
+ declare namespace AgendaRootDataAttributes {
205
+ export { AgendaRootDataAttributes_empty as empty, focusVisible$1 as focusVisible, slot$2 as slot };
206
+ }
207
+
208
+ /**
209
+ * Identifies a day's section. The day's heading carries `today` and `past` too.
210
+ * @type {'agenda-day'}
211
+ */
212
+ declare const slot$1 = "data-slot";
213
+ /**
214
+ * The day, as YYYY-MM-DD.
215
+ * @type {string}
216
+ */
217
+ declare const date$1 = "data-date";
218
+ /** Present on today. */
219
+ declare const today = "data-today";
220
+ /** Present on a weekend day, as the locale has the weekend. */
221
+ declare const weekend = "data-weekend";
222
+ /** Present on a day before today. */
223
+ declare const past = "data-past";
224
+
225
+ declare const AgendaDayDataAttributes_past: typeof past;
226
+ declare const AgendaDayDataAttributes_today: typeof today;
227
+ declare const AgendaDayDataAttributes_weekend: typeof weekend;
228
+ declare namespace AgendaDayDataAttributes {
229
+ export { date$1 as date, AgendaDayDataAttributes_past as past, slot$1 as slot, AgendaDayDataAttributes_today as today, AgendaDayDataAttributes_weekend as weekend };
230
+ }
231
+
232
+ /**
233
+ * Identifies an event's row.
234
+ * @type {'agenda-event'}
235
+ */
236
+ declare const slot = "data-slot";
237
+ /**
238
+ * The event's id.
239
+ * @type {string}
240
+ */
241
+ declare const value = "data-value";
242
+ /**
243
+ * The day it is on, as YYYY-MM-DD.
244
+ * @type {string}
245
+ */
246
+ declare const date = "data-date";
247
+ /** Present on an event with no times. */
248
+ declare const allDay = "data-all-day";
249
+ /** Present on the selected event (React Aria's). */
250
+ declare const selected = "data-selected";
251
+ /** Present while it is pressed. */
252
+ declare const pressed = "data-pressed";
253
+ /** Present while the pointer is over it (never on touch). */
254
+ declare const hovered = "data-hovered";
255
+ /** Present while it has keyboard focus. */
256
+ declare const focusVisible = "data-focus-visible";
257
+ /** Present when it is disabled. */
258
+ declare const disabled = "data-disabled";
259
+
260
+ declare const AgendaEventDataAttributes_allDay: typeof allDay;
261
+ declare const AgendaEventDataAttributes_date: typeof date;
262
+ declare const AgendaEventDataAttributes_disabled: typeof disabled;
263
+ declare const AgendaEventDataAttributes_focusVisible: typeof focusVisible;
264
+ declare const AgendaEventDataAttributes_hovered: typeof hovered;
265
+ declare const AgendaEventDataAttributes_pressed: typeof pressed;
266
+ declare const AgendaEventDataAttributes_selected: typeof selected;
267
+ declare const AgendaEventDataAttributes_slot: typeof slot;
268
+ declare const AgendaEventDataAttributes_value: typeof value;
269
+ declare namespace AgendaEventDataAttributes {
270
+ export { AgendaEventDataAttributes_allDay as allDay, AgendaEventDataAttributes_date as date, AgendaEventDataAttributes_disabled as disabled, AgendaEventDataAttributes_focusVisible as focusVisible, AgendaEventDataAttributes_hovered as hovered, AgendaEventDataAttributes_pressed as pressed, AgendaEventDataAttributes_selected as selected, AgendaEventDataAttributes_slot as slot, AgendaEventDataAttributes_value as value };
271
+ }
272
+
273
+ export { index_parts as Agenda, type AgendaContextValue, AgendaDayDataAttributes, AgendaDayDataAttributes as AgendaDayHeaderDataAttributes, type AgendaDayHeaderProps, type AgendaDayProps, type AgendaDayState, AgendaEventDataAttributes, type AgendaEventItem, type AgendaEventProps, type AgendaEventState, type AgendaLoadMoreProps, type AgendaRootActions, AgendaRootDataAttributes, type AgendaRootProps, type AgendaRootState, type AgendaValueChangeDetails, type AgendaVirtualizedOptions, CalendarComponentsInteractionState, CalendarComponentsPartProps, useAgendaContext as useAgenda };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import {
3
+ AgendaDayDataAttributes_exports,
4
+ AgendaEventDataAttributes_exports,
5
+ AgendaRootDataAttributes_exports,
6
+ index_parts_exports,
7
+ useAgendaContext
8
+ } from "../chunk-X27ZSAPJ.js";
9
+ import "../chunk-E6WBQCX3.js";
10
+ export {
11
+ index_parts_exports as Agenda,
12
+ AgendaDayDataAttributes_exports as AgendaDayDataAttributes,
13
+ AgendaDayDataAttributes_exports as AgendaDayHeaderDataAttributes,
14
+ AgendaEventDataAttributes_exports as AgendaEventDataAttributes,
15
+ AgendaRootDataAttributes_exports as AgendaRootDataAttributes,
16
+ useAgendaContext as useAgenda
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ // src/utils/useLatest.ts
9
+ import * as React from "react";
10
+ var useEarlyEffect = React.useInsertionEffect ?? React.useLayoutEffect;
11
+ function useLatest(value) {
12
+ const ref = React.useRef(value);
13
+ useEarlyEffect(() => {
14
+ ref.current = value;
15
+ });
16
+ return ref;
17
+ }
18
+
19
+ // src/internals/InteractionDataAttributes.ts
20
+ var hovered = "data-hovered";
21
+ var pressed = "data-pressed";
22
+ var focusVisible = "data-focus-visible";
23
+ var disabled = "data-disabled";
24
+
25
+ // src/internals/mergePartProps.ts
26
+ import { mergeProps } from "react-aria/mergeProps";
27
+ var skipped = /* @__PURE__ */ new WeakSet();
28
+ var nativeOf = (event) => event.nativeEvent ?? event;
29
+ var isSkipped = (event) => skipped.has(nativeOf(event));
30
+ var mapHandlers = (props, wrap) => Object.fromEntries(Object.entries(props).map(([key, value]) => [key, /^on[A-Z]/.test(key) && typeof value === "function" ? wrap(value) : value]));
31
+ var preventable = (event) => Object.assign(event, { preventCalendarComponentsHandler: () => void skipped.add(nativeOf(event)) });
32
+ var exposeSkip = (props) => mapHandlers(props, (fn) => (event) => fn(preventable(event)));
33
+ var guard = (props) => mapHandlers(props, (fn) => (event) => !isSkipped(event) && fn(event));
34
+ var mergePartProps = (user, ...own) => mergeProps(exposeSkip(user), ...own.map((props) => props && guard(props)));
35
+
36
+ // src/internals/renderElement.tsx
37
+ import * as React2 from "react";
38
+ import { mergeProps as mergeProps2 } from "react-aria/mergeProps";
39
+ import { mergeRefs } from "react-aria/mergeRefs";
40
+ var flag = (on) => on ? "" : void 0;
41
+ var REACT_19 = Number(React2.version.split(".")[0]) >= 19;
42
+ var elementRef = (element) => {
43
+ const carrier = element;
44
+ return REACT_19 ? carrier.props.ref : carrier.ref;
45
+ };
46
+ function toRenderFunction(render) {
47
+ if (!render || typeof render === "function") return render;
48
+ return (props) => React2.cloneElement(render, { ...mergeProps2(props, render.props), style: { ...props.style, ...render.props.style }, ref: mergeRefs(props.ref, elementRef(render)) });
49
+ }
50
+ var isStateFunction = (value) => typeof value === "function";
51
+ var resolve = (value, state) => isStateFunction(value) ? value(state) : value;
52
+ var kebab = (key) => key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
53
+ function stateAttributes(state, keys) {
54
+ const out = {};
55
+ for (const key of keys) {
56
+ const value = state[key];
57
+ out[`data-${kebab(key)}`] = typeof value === "boolean" ? flag(value) : typeof value === "string" || typeof value === "number" ? String(value) : void 0;
58
+ }
59
+ return out;
60
+ }
61
+ function renderElement(tag, { render, ...props }, state, attributes = []) {
62
+ const resolved = { ...exposeSkip(props), ...stateAttributes(state, attributes), className: resolve(props.className, state), style: resolve(props.style, state), children: resolve(props.children, state) };
63
+ const custom = toRenderFunction(render);
64
+ return custom ? custom(resolved, state) : React2.createElement(tag, resolved);
65
+ }
66
+ var presence = (props) => Object.fromEntries(Object.entries(props).map(([k, v]) => [k, k.startsWith("data-") && v === true ? "" : v]));
67
+ function ariaPart(tag, { className, style, render }, state) {
68
+ const custom = toRenderFunction(render);
69
+ return {
70
+ className: (r) => resolve(className, state(r)) ?? "",
71
+ style: (r) => resolve(style, state(r)),
72
+ render: (props, r) => custom ? custom(presence(props), state(r)) : React2.createElement(tag, presence(props))
73
+ };
74
+ }
75
+
76
+ // src/internals/slots.ts
77
+ var TIME_GRID_SLOTS = {
78
+ root: "time-grid",
79
+ hours: "time-grid-hours",
80
+ hour: "time-grid-hour",
81
+ dragTime: "time-grid-drag-time",
82
+ dayHeader: "time-grid-day-header",
83
+ allDay: "time-grid-all-day",
84
+ allDayEvent: "time-grid-all-day-event",
85
+ column: "time-grid-column",
86
+ line: "time-grid-line",
87
+ event: "time-grid-event",
88
+ eventContent: "time-grid-event-content",
89
+ eventResizeHandle: "time-grid-event-resize-handle",
90
+ now: "time-grid-now"
91
+ };
92
+ var DATE_GRID_SLOTS = {
93
+ root: "date-grid",
94
+ heading: "date-grid-heading",
95
+ previous: "date-grid-previous",
96
+ next: "date-grid-next",
97
+ grid: "date-grid-grid",
98
+ gridHeader: "date-grid-header",
99
+ gridHeaderRow: "date-grid-header-row",
100
+ headerCell: "date-grid-header-cell",
101
+ gridBody: "date-grid-body",
102
+ week: "date-grid-week",
103
+ cellWrapper: "date-grid-cell-wrapper",
104
+ cell: "date-grid-cell",
105
+ cellDetails: "date-grid-cell-details"
106
+ };
107
+ var AGENDA_SLOTS = {
108
+ root: "agenda",
109
+ day: "agenda-day",
110
+ dayHeader: "agenda-day-header",
111
+ event: "agenda-event",
112
+ loadMore: "agenda-load-more"
113
+ };
114
+
115
+ // src/utils/useChangeState.ts
116
+ import * as React3 from "react";
117
+ import { useControlledState } from "react-stately/useControlledState";
118
+ function useChangeState(value, defaultValue, onChange) {
119
+ const [current, setCurrent] = useControlledState(value, defaultValue);
120
+ const latest = useLatest({ current, onChange });
121
+ const set = React3.useCallback(
122
+ (next, details) => {
123
+ if (Object.is(next, latest.current.current)) return;
124
+ latest.current.onChange?.(next, details);
125
+ if (!details.isCanceled) setCurrent(next);
126
+ },
127
+ [latest, setCurrent]
128
+ );
129
+ return [current, set];
130
+ }
131
+
132
+ // src/utils/useNow.ts
133
+ import { nowOf } from "calendar-components-core";
134
+ import * as React4 from "react";
135
+ var listeners = /* @__PURE__ */ new Set();
136
+ var timer;
137
+ function subscribe(listener) {
138
+ listeners.add(listener);
139
+ const tick = () => {
140
+ for (const each of listeners) each();
141
+ timer = setTimeout(tick, 6e4 - Date.now() % 6e4 + 50);
142
+ };
143
+ if (listeners.size === 1) timer = setTimeout(tick, 6e4 - Date.now() % 6e4 + 50);
144
+ return () => {
145
+ listeners.delete(listener);
146
+ if (!listeners.size) clearTimeout(timer);
147
+ };
148
+ }
149
+ var cache = /* @__PURE__ */ new Map();
150
+ function snapshot(timeZone) {
151
+ const now = nowOf(timeZone);
152
+ const last = cache.get(timeZone);
153
+ if (last && last.date === now.date && last.minutes === now.minutes) return last;
154
+ cache.set(timeZone, now);
155
+ return now;
156
+ }
157
+ function useNow(timeZone) {
158
+ return React4.useSyncExternalStore(
159
+ subscribe,
160
+ () => snapshot(timeZone),
161
+ () => null
162
+ );
163
+ }
164
+ function useToday(timeZone) {
165
+ return React4.useSyncExternalStore(
166
+ subscribe,
167
+ () => snapshot(timeZone).date,
168
+ () => null
169
+ );
170
+ }
171
+
172
+ export {
173
+ __export,
174
+ mergePartProps,
175
+ toRenderFunction,
176
+ resolve,
177
+ stateAttributes,
178
+ renderElement,
179
+ ariaPart,
180
+ TIME_GRID_SLOTS,
181
+ DATE_GRID_SLOTS,
182
+ AGENDA_SLOTS,
183
+ useLatest,
184
+ useChangeState,
185
+ useNow,
186
+ useToday,
187
+ hovered,
188
+ pressed,
189
+ focusVisible,
190
+ disabled
191
+ };
192
+ //# sourceMappingURL=chunk-E6WBQCX3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/useLatest.ts","../src/internals/InteractionDataAttributes.ts","../src/internals/mergePartProps.ts","../src/internals/renderElement.tsx","../src/internals/slots.ts","../src/utils/useChangeState.ts","../src/utils/useNow.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n// Before layout effects, so they and every handler read this render's value; never written while rendering\nconst useEarlyEffect = React.useInsertionEffect ?? React.useLayoutEffect;\n\nexport function useLatest<T>(value: T): { readonly current: T } {\n const ref = React.useRef(value);\n useEarlyEffect(() => {\n ref.current = value;\n });\n return ref;\n}\n","/**\n * Present while the pointer is over the element (React Aria's `useHover`; never on touch).\n */\nexport const hovered = \"data-hovered\";\n\n/**\n * Present while the element is pressed (React Aria's `usePress`).\n */\nexport const pressed = \"data-pressed\";\n\n/**\n * Present while the element has keyboard focus (React Aria's `useFocusRing`).\n */\nexport const focusVisible = \"data-focus-visible\";\n\n/**\n * Present when the element is disabled.\n */\nexport const disabled = \"data-disabled\";\n","\"use client\";\n\nimport { mergeProps } from \"react-aria/mergeProps\";\n\nconst skipped = new WeakSet<object>();\nconst nativeOf = (event: object) => (event as { nativeEvent?: object }).nativeEvent ?? event;\n\nexport const isSkipped = (event: object) => skipped.has(nativeOf(event));\n\ntype Handler = (event: never) => void;\nconst mapHandlers = (props: object, wrap: (fn: (event: object) => void) => Handler) => Object.fromEntries(Object.entries(props).map(([key, value]) => [key, /^on[A-Z]/.test(key) && typeof value === \"function\" ? wrap(value) : value]));\n\nexport const preventable = <E extends object>(event: E) => Object.assign(event, { preventCalendarComponentsHandler: () => void skipped.add(nativeOf(event)) });\n\nexport const exposeSkip = (props: object) => mapHandlers(props, (fn) => (event: object) => fn(preventable(event)));\n\nconst guard = (props: object) => mapHandlers(props, (fn) => (event: object) => !isSkipped(event) && fn(event));\n\n// The user's handlers run first; preventCalendarComponentsHandler() in one skips the part's handlers for that event\nexport const mergePartProps = <T extends object>(user: object, ...own: (object | null | undefined)[]): T => mergeProps(exposeSkip(user), ...own.map((props) => props && guard(props))) as T;\n","\"use client\";\n\nimport * as React from \"react\";\nimport { mergeProps } from \"react-aria/mergeProps\";\nimport { mergeRefs } from \"react-aria/mergeRefs\";\nimport { exposeSkip } from \"./mergePartProps\";\nimport type { ElementProps, CalendarComponentsPartProps, RenderProp } from \"./types\";\n\n// Base UI's convention: a present state attribute is empty, an absent one is undefined\nexport const flag = (on: unknown): \"\" | undefined => (on ? \"\" : undefined);\n\n// React 19 moved an element's ref into its props\nconst REACT_19 = Number(React.version.split(\".\")[0]) >= 19;\n\ntype Children<S> = { children?: React.ReactNode | ((state: S) => React.ReactNode) };\n\ntype DataAttributes = { [data: `data-${string}`]: unknown };\ntype Input<S, E extends Element> = Omit<React.AllHTMLAttributes<E>, \"className\" | \"style\" | \"children\"> & { ref?: React.Ref<E> } & CalendarComponentsPartProps<S, E> & Children<S> & DataAttributes;\n\ntype RefCarrier<E> = { ref?: React.Ref<E>; props: { ref?: React.Ref<E> } };\n// React 19 moved an element's ref into its props\nexport const elementRef = <E,>(element: React.ReactElement): React.Ref<E> | undefined => {\n const carrier: RefCarrier<E> = element as React.ReactElement & RefCarrier<E>;\n return REACT_19 ? carrier.props.ref : carrier.ref;\n};\n\nexport function toRenderFunction<S, E extends Element>(render: RenderProp<S, E> | undefined): ((props: ElementProps<E>, state: S) => React.ReactElement) | undefined {\n if (!render || typeof render === \"function\") return render;\n // React Aria's mergeProps lets the last style win whole: the part's own (where an event is, how tall) is kept, with the element's over it.\n return (props) => React.cloneElement(render, { ...mergeProps(props, render.props), style: { ...props.style, ...(render.props.style as React.CSSProperties | undefined) }, ref: mergeRefs(props.ref, elementRef(render)) });\n}\n\nconst isStateFunction = <T, S>(value: T | ((state: S) => T)): value is (state: S) => T => typeof value === \"function\";\n\nexport const resolve = <T, S>(value: T | ((state: S) => T), state: S): T => (isStateFunction(value) ? value(state) : value);\n\nconst kebab = (key: string) => key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n\n// Base UI's state attributes: data-<key> for each listed key, \"\" for true and the value for a string or number\nexport function stateAttributes<S>(state: S, keys: readonly (keyof S & string)[]): Record<`data-${string}`, string | undefined> {\n const out: Record<`data-${string}`, string | undefined> = {};\n for (const key of keys) {\n const value = state[key];\n out[`data-${kebab(key)}`] = typeof value === \"boolean\" ? flag(value) : typeof value === \"string\" || typeof value === \"number\" ? String(value) : undefined;\n }\n return out;\n}\n\nexport function renderElement<S, E extends Element = HTMLElement>(tag: keyof React.JSX.IntrinsicElements, { render, ...props }: Input<S, E>, state: S, attributes: readonly (keyof S & string)[] = []) {\n // Every handler's event can skip the part's own handler (prevent…Handler), on every part.\n const resolved: ElementProps<E> = { ...(exposeSkip(props) as typeof props), ...stateAttributes(state, attributes), className: resolve(props.className, state), style: resolve(props.style, state), children: resolve(props.children, state) };\n const custom = toRenderFunction(render);\n return custom ? custom(resolved, state) : React.createElement(tag, resolved);\n}\n\n// React Aria writes its state attributes as \"true\"; this package's are empty when present, as Base UI's\nconst presence = <P extends object>(props: P): P => Object.fromEntries(Object.entries(props).map(([k, v]) => [k, k.startsWith(\"data-\") && v === true ? \"\" : v])) as P;\n\n/**\n * A part's className, style and render for a React Aria Components element whose render props are read as `state`.\n * It always renders through here, so a state attribute reads the same (\"\" when present) whether or not `render` is given.\n */\nexport function ariaPart<S, R, E extends Element>(tag: keyof React.JSX.IntrinsicElements, { className, style, render }: CalendarComponentsPartProps<S, E>, state: (renderProps: R) => S) {\n const custom = toRenderFunction(render);\n return {\n className: (r: R) => resolve(className, state(r)) ?? \"\",\n style: (r: R) => resolve(style, state(r)),\n render: (props: ElementProps<E>, r: R) => (custom ? custom(presence(props), state(r)) : React.createElement(tag, presence(props))),\n };\n}\n","/** What each part calls itself in `data-slot`: what a stylesheet selects by. */\nexport const TIME_GRID_SLOTS = {\n root: \"time-grid\",\n hours: \"time-grid-hours\",\n hour: \"time-grid-hour\",\n dragTime: \"time-grid-drag-time\",\n dayHeader: \"time-grid-day-header\",\n allDay: \"time-grid-all-day\",\n allDayEvent: \"time-grid-all-day-event\",\n column: \"time-grid-column\",\n line: \"time-grid-line\",\n event: \"time-grid-event\",\n eventContent: \"time-grid-event-content\",\n eventResizeHandle: \"time-grid-event-resize-handle\",\n now: \"time-grid-now\",\n} as const;\n\nexport const DATE_GRID_SLOTS = {\n root: \"date-grid\",\n heading: \"date-grid-heading\",\n previous: \"date-grid-previous\",\n next: \"date-grid-next\",\n grid: \"date-grid-grid\",\n gridHeader: \"date-grid-header\",\n gridHeaderRow: \"date-grid-header-row\",\n headerCell: \"date-grid-header-cell\",\n gridBody: \"date-grid-body\",\n week: \"date-grid-week\",\n cellWrapper: \"date-grid-cell-wrapper\",\n cell: \"date-grid-cell\",\n cellDetails: \"date-grid-cell-details\",\n} as const;\n\nexport const AGENDA_SLOTS = {\n root: \"agenda\",\n day: \"agenda-day\",\n dayHeader: \"agenda-day-header\",\n event: \"agenda-event\",\n loadMore: \"agenda-load-more\",\n} as const;\n","\"use client\";\n\nimport * as React from \"react\";\nimport type { ChangeDetails } from \"calendar-components-core\";\nimport { useControlledState } from \"react-stately/useControlledState\";\nimport { useLatest } from \"./useLatest\";\n\n// React Stately's controlled state with Base UI's onChange(value, details): the owner hears first and can cancel()\nexport function useChangeState<T, D extends ChangeDetails>(value: Exclude<T, undefined> | undefined, defaultValue: Exclude<T, undefined>, onChange: ((value: T, details: D) => void) | undefined) {\n const [current, setCurrent] = useControlledState<T>(value, defaultValue);\n const latest = useLatest({ current, onChange });\n const set = React.useCallback(\n (next: T, details: D): void => {\n if (Object.is(next, latest.current.current)) return;\n latest.current.onChange?.(next, details);\n if (!details.isCanceled) setCurrent(next);\n },\n [latest, setCurrent],\n );\n return [current, set] as const;\n}\n","\"use client\";\n\nimport { nowOf } from \"calendar-components-core\";\nimport * as React from \"react\";\n\ntype Now = { date: string; minutes: number };\n\nconst listeners = new Set<() => void>();\nlet timer: ReturnType<typeof setTimeout> | undefined;\n/** One tick for every subscriber, on the minute: when the clock's face changes. */\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n const tick = () => {\n for (const each of listeners) each();\n timer = setTimeout(tick, 60_000 - (Date.now() % 60_000) + 50);\n };\n if (listeners.size === 1) timer = setTimeout(tick, 60_000 - (Date.now() % 60_000) + 50);\n return () => {\n listeners.delete(listener);\n if (!listeners.size) clearTimeout(timer);\n };\n}\n\nconst cache = new Map<string, Now>();\n/** The same object until the minute changes, as useSyncExternalStore asks of a snapshot. */\nfunction snapshot(timeZone: string): Now {\n const now = nowOf(timeZone);\n const last = cache.get(timeZone);\n if (last && last.date === now.date && last.minutes === now.minutes) return last;\n cache.set(timeZone, now);\n return now;\n}\n\n/**\n * Today and the time it is in a zone, kept current: it rolls over at\n * midnight without a reload. Null while rendering on a server and in the\n * first pass in the browser, since the server's \"today\" may not be the\n * reader's, and the two must render alike.\n */\nexport function useNow(timeZone: string): Now | null {\n return React.useSyncExternalStore(\n subscribe,\n () => snapshot(timeZone),\n () => null,\n );\n}\n\n/**\n * Today in a zone, kept current: it changes at midnight and not before, so\n * what only asks which day it is does not redraw each minute. Null where\n * `useNow` is.\n */\nexport function useToday(timeZone: string): string | null {\n return React.useSyncExternalStore(\n subscribe,\n () => snapshot(timeZone).date,\n () => null,\n );\n}\n"],"mappings":";;;;;;;;AAEA,YAAY,WAAW;AAGvB,IAAM,iBAAuB,4BAA4B;AAElD,SAAS,UAAa,OAAmC;AAC9D,QAAM,MAAY,aAAO,KAAK;AAC9B,iBAAe,MAAM;AACnB,QAAI,UAAU;AAAA,EAChB,CAAC;AACD,SAAO;AACT;;;ACVO,IAAM,UAAU;AAKhB,IAAM,UAAU;AAKhB,IAAM,eAAe;AAKrB,IAAM,WAAW;;;AChBxB,SAAS,kBAAkB;AAE3B,IAAM,UAAU,oBAAI,QAAgB;AACpC,IAAM,WAAW,CAAC,UAAmB,MAAmC,eAAe;AAEhF,IAAM,YAAY,CAAC,UAAkB,QAAQ,IAAI,SAAS,KAAK,CAAC;AAGvE,IAAM,cAAc,CAAC,OAAe,SAAmD,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,WAAW,KAAK,GAAG,KAAK,OAAO,UAAU,aAAa,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC;AAEhO,IAAM,cAAc,CAAmB,UAAa,OAAO,OAAO,O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