@ankhorage/zora 28.9.0 → 28.10.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/dist/capabilities/index.js +52 -5
  4. package/dist/capabilities/index.js.map +4 -4
  5. package/dist/features/calendar/adapters/inbound/Calendar.d.ts +1 -1
  6. package/dist/features/calendar/adapters/inbound/Calendar.d.ts.map +1 -1
  7. package/dist/features/calendar/adapters/inbound/Calendar.js +207 -75
  8. package/dist/features/calendar/adapters/inbound/Calendar.js.map +1 -1
  9. package/dist/features/calendar/calendarMeta.d.ts +106 -4
  10. package/dist/features/calendar/calendarMeta.d.ts.map +1 -1
  11. package/dist/features/calendar/calendarMeta.js +44 -4
  12. package/dist/features/calendar/calendarMeta.js.map +1 -1
  13. package/dist/features/calendar/public.d.ts +1 -1
  14. package/dist/features/calendar/public.d.ts.map +1 -1
  15. package/dist/features/calendar/public.js.map +1 -1
  16. package/dist/features/data-table/dataTableMeta.d.ts +10 -0
  17. package/dist/features/data-table/dataTableMeta.d.ts.map +1 -1
  18. package/dist/features/data-table/dataTableMeta.js +7 -0
  19. package/dist/features/data-table/dataTableMeta.js.map +1 -1
  20. package/dist/types/calendar.d.ts +40 -19
  21. package/dist/types/calendar.d.ts.map +1 -1
  22. package/dist/types/calendar.js.map +1 -1
  23. package/package.json +76 -1
  24. package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +95 -0
  25. package/src/features/calendar/adapters/inbound/Calendar.tsx +425 -135
  26. package/src/features/calendar/calendarMeta.ts +44 -4
  27. package/src/features/calendar/public.test.ts +8 -5
  28. package/src/features/calendar/public.ts +4 -0
  29. package/src/features/data-table/adapters/inbound/DataTable.test.tsx +52 -1
  30. package/src/features/data-table/dataTableMeta.test.ts +8 -1
  31. package/src/features/data-table/dataTableMeta.ts +7 -0
  32. package/src/features/registry/componentMeta.test.ts +1 -0
  33. package/src/types/calendar.ts +44 -19
  34. package/web-dist/chunks/Accordion-59x6e7bs.js +200 -0
  35. package/web-dist/chunks/Accordion-q2yxtdzc.js +426 -0
  36. package/web-dist/components/calendar/Calendar.d.ts +2 -2
  37. package/web-dist/components/calendar/Calendar.dependency-2.d.ts +165 -0
  38. package/web-dist/components/calendar/Calendar.js +2 -1
  39. package/web-dist/components/calendar/Calendar.types-0.d.ts +45 -19
  40. package/web-dist/components/calendar/index.d.ts +1 -1
  41. package/web-dist/components/date-picker/DatePicker.js +2 -1
  42. package/web-dist/components/time-grid/TimeGrid.js +4 -198
  43. package/web-dist/manifest.json +6 -2
  44. package/web-dist/chunks/Accordion-v3bmbnfh.js +0 -237
@@ -0,0 +1,426 @@
1
+ 'use client';
2
+ import {
3
+ withZoraThemeScope
4
+ } from "./Accordion-zhgty1ae.js";
5
+ import {
6
+ Button2
7
+ } from "./Accordion-e6ettgh0.js";
8
+ import {
9
+ View2
10
+ } from "./Accordion-k9n1yse4.js";
11
+ import {
12
+ GridView2
13
+ } from "./Accordion-0zk0xp73.js";
14
+ import {
15
+ TimeGrid2
16
+ } from "./Accordion-59x6e7bs.js";
17
+ import {
18
+ Text2
19
+ } from "./Accordion-6gc0jw1n.js";
20
+
21
+ // src/features/calendar/adapters/inbound/Calendar.tsx
22
+ import React from "react";
23
+
24
+ // src/features/calendar/application/createCalendarMonth.ts
25
+ function createCalendarMonth(month, weekStartsOn) {
26
+ const firstDay = startOfLocalMonth(month);
27
+ const leadingDays = (firstDay.getDay() - weekStartsOn + 7) % 7;
28
+ return Array.from({ length: 42 }, (_, index) => {
29
+ const date = new Date(firstDay.getFullYear(), firstDay.getMonth(), index - leadingDays + 1);
30
+ return {
31
+ date,
32
+ id: formatLocalDate(date),
33
+ inDisplayedMonth: date.getMonth() === firstDay.getMonth()
34
+ };
35
+ });
36
+ }
37
+ function formatLocalDate(value) {
38
+ const year = String(value.getFullYear()).padStart(4, "0");
39
+ const month = String(value.getMonth() + 1).padStart(2, "0");
40
+ const day = String(value.getDate()).padStart(2, "0");
41
+ return `${year}-${month}-${day}`;
42
+ }
43
+ function startOfLocalMonth(value) {
44
+ return new Date(value.getFullYear(), value.getMonth(), 1);
45
+ }
46
+
47
+ // src/features/calendar/application/isCalendarDateDisabled.ts
48
+ function isCalendarDateDisabled({
49
+ date,
50
+ disabledDateIds,
51
+ isDateDisabled,
52
+ maxDate,
53
+ minDate
54
+ }) {
55
+ return minDate !== undefined && compareLocalDates(date, minDate) < 0 || maxDate !== undefined && compareLocalDates(date, maxDate) > 0 || disabledDateIds.has(formatCalendarDate(date)) || isDateDisabled?.(date) === true;
56
+ }
57
+ function compareLocalDates(left, right) {
58
+ return startOfLocalDay(left).getTime() - startOfLocalDay(right).getTime();
59
+ }
60
+ function startOfLocalDay(value) {
61
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
62
+ }
63
+ function formatCalendarDate(value) {
64
+ const year = String(value.getFullYear()).padStart(4, "0");
65
+ const month = String(value.getMonth() + 1).padStart(2, "0");
66
+ const day = String(value.getDate()).padStart(2, "0");
67
+ return `${year}-${month}-${day}`;
68
+ }
69
+
70
+ // src/features/calendar/adapters/inbound/Calendar.tsx
71
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
72
+ var GRID_COLUMNS = 7;
73
+ var GRID_ROWS = 6;
74
+ var MINUTES_PER_DAY = 24 * 60;
75
+ var Calendar2 = withZoraThemeScope(CalendarInner);
76
+ function CalendarInner(props) {
77
+ const {
78
+ defaultDisplayedDate,
79
+ defaultDisplayedMonth,
80
+ defaultView = "month",
81
+ density = "regular",
82
+ displayedDate: controlledDisplayedDate,
83
+ displayedMonth: controlledDisplayedMonth,
84
+ events = [],
85
+ locale,
86
+ onDateChange,
87
+ onDisplayedMonthChange,
88
+ onEventActivate,
89
+ onViewChange,
90
+ timeZone,
91
+ view: controlledView,
92
+ weekStartsOn = 0
93
+ } = props;
94
+ const [uncontrolledDate, setUncontrolledDate] = React.useState(() => parseCalendarDate(defaultDisplayedDate) ?? startOfLocalDay2(defaultDisplayedMonth ?? props.selectedDate ?? props.minDate ?? new Date));
95
+ const [uncontrolledView, setUncontrolledView] = React.useState(defaultView);
96
+ const displayedDate = parseCalendarDate(controlledDisplayedDate) ?? startOfLocalDay2(controlledDisplayedMonth ?? uncontrolledDate);
97
+ const view = controlledView ?? uncontrolledView;
98
+ const setDisplayedDate = React.useCallback((value) => {
99
+ const next = startOfLocalDay2(value);
100
+ if (controlledDisplayedDate === undefined && controlledDisplayedMonth === undefined)
101
+ setUncontrolledDate(next);
102
+ onDisplayedMonthChange?.(startOfLocalMonth2(next));
103
+ onDateChange?.({ date: formatCalendarDate2(next) });
104
+ }, [controlledDisplayedDate, controlledDisplayedMonth, onDateChange, onDisplayedMonthChange]);
105
+ const setView = React.useCallback((next) => {
106
+ if (controlledView === undefined)
107
+ setUncontrolledView(next);
108
+ onViewChange?.({ view: next });
109
+ }, [controlledView, onViewChange]);
110
+ const navigate = React.useCallback((offset) => setDisplayedDate(view === "month" ? addMonths(displayedDate, offset) : addDays(displayedDate, offset * (view === "week" ? 7 : 1))), [displayedDate, setDisplayedDate, view]);
111
+ return /* @__PURE__ */ jsxs(View2, {
112
+ accessibilityLabel: "Calendar",
113
+ gap: density === "compact" ? "s" : "m",
114
+ testID: props.testID,
115
+ children: [
116
+ /* @__PURE__ */ jsxs(View2, {
117
+ align: "center",
118
+ direction: "row",
119
+ justify: "space-between",
120
+ children: [
121
+ /* @__PURE__ */ jsx(Button2, {
122
+ interactionPolicy: props.interactionPolicy,
123
+ onPress: () => navigate(-1),
124
+ size: "s",
125
+ testID: withTestId(props.testID, "previous"),
126
+ variant: "ghost",
127
+ children: "Previous"
128
+ }),
129
+ /* @__PURE__ */ jsx(Text2, {
130
+ accessibilityRole: "header",
131
+ align: "center",
132
+ variant: "label",
133
+ weight: "semiBold",
134
+ children: formatViewLabel(displayedDate, locale, view)
135
+ }),
136
+ /* @__PURE__ */ jsx(Button2, {
137
+ interactionPolicy: props.interactionPolicy,
138
+ onPress: () => navigate(1),
139
+ size: "s",
140
+ testID: withTestId(props.testID, "next"),
141
+ variant: "ghost",
142
+ children: "Next"
143
+ })
144
+ ]
145
+ }),
146
+ /* @__PURE__ */ jsxs(View2, {
147
+ direction: "row",
148
+ justify: "space-between",
149
+ children: [
150
+ ["day", "week", "month"].map((candidate) => /* @__PURE__ */ jsx(Button2, {
151
+ interactionPolicy: props.interactionPolicy,
152
+ onPress: () => setView(candidate),
153
+ size: "s",
154
+ testID: withTestId(props.testID, `view-${candidate}`),
155
+ variant: view === candidate ? "solid" : "ghost",
156
+ children: candidate
157
+ }, candidate)),
158
+ /* @__PURE__ */ jsx(Button2, {
159
+ interactionPolicy: props.interactionPolicy,
160
+ onPress: () => setDisplayedDate(new Date),
161
+ size: "s",
162
+ testID: withTestId(props.testID, "today"),
163
+ variant: "ghost",
164
+ children: "Today"
165
+ })
166
+ ]
167
+ }),
168
+ view === "month" ? /* @__PURE__ */ jsx(CalendarMonth, {
169
+ ...props,
170
+ activateEvent: (id) => onEventActivate?.({ eventId: id }),
171
+ cellSize: density === "compact" ? 42 : 48,
172
+ displayedDate,
173
+ events,
174
+ timeZone,
175
+ weekStartsOn,
176
+ onSelectDate: (date) => {
177
+ setDisplayedDate(date);
178
+ props.onSelectedDateChange?.(date);
179
+ }
180
+ }) : /* @__PURE__ */ jsx(CalendarTimeView, {
181
+ activateEvent: (id) => onEventActivate?.({ eventId: id }),
182
+ displayedDate,
183
+ events,
184
+ interactionPolicy: props.interactionPolicy,
185
+ locale,
186
+ testID: props.testID,
187
+ timeZone,
188
+ view,
189
+ weekStartsOn
190
+ })
191
+ ]
192
+ });
193
+ }
194
+ function CalendarMonth({
195
+ activateEvent,
196
+ cellSize,
197
+ displayedDate,
198
+ events,
199
+ onSelectDate,
200
+ timeZone,
201
+ weekStartsOn,
202
+ ...props
203
+ }) {
204
+ const cells = React.useMemo(() => createCalendarMonth(displayedDate, weekStartsOn), [displayedDate, weekStartsOn]);
205
+ const gridItems = React.useMemo(() => cells.map((cell, index) => ({
206
+ height: cellSize,
207
+ id: cell.id,
208
+ width: cellSize,
209
+ x: index % GRID_COLUMNS * cellSize,
210
+ y: Math.floor(index / GRID_COLUMNS) * cellSize
211
+ })), [cellSize, cells]);
212
+ const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
213
+ const disabledDateIds = React.useMemo(() => new Set((props.disabledDates ?? []).map(formatCalendarDate2)), [props.disabledDates]);
214
+ const eventsByDate = React.useMemo(() => createEventsByDate(events, cells.map((cell) => cell.date), timeZone), [cells, events, timeZone]);
215
+ return /* @__PURE__ */ jsxs(Fragment, {
216
+ children: [
217
+ /* @__PURE__ */ jsx(View2, {
218
+ direction: "row",
219
+ children: createWeekdayLabels(props.locale, weekStartsOn).map((weekday) => /* @__PURE__ */ jsx(View2, {
220
+ width: cellSize,
221
+ children: /* @__PURE__ */ jsx(Text2, {
222
+ align: "center",
223
+ emphasis: "muted",
224
+ variant: "caption",
225
+ weight: "semiBold",
226
+ children: weekday.label
227
+ })
228
+ }, weekday.id))
229
+ }),
230
+ /* @__PURE__ */ jsx(GridView2, {
231
+ contentHeight: cellSize * GRID_ROWS,
232
+ contentWidth: cellSize * GRID_COLUMNS,
233
+ height: cellSize * GRID_ROWS,
234
+ interactionPolicy: props.interactionPolicy,
235
+ items: gridItems,
236
+ overscanPixels: 0,
237
+ renderItem: (item) => {
238
+ const cell = cellsById.get(item.id);
239
+ if (!cell)
240
+ return null;
241
+ const selected = props.selectedDate !== null && props.selectedDate !== undefined && isSameLocalDay(props.selectedDate, cell.date);
242
+ const disabled = isCalendarDateDisabled({
243
+ date: cell.date,
244
+ disabledDateIds,
245
+ isDateDisabled: props.isDateDisabled,
246
+ maxDate: props.maxDate,
247
+ minDate: props.minDate
248
+ });
249
+ const event = eventsByDate.get(cell.id)?.[0];
250
+ return /* @__PURE__ */ jsxs(View2, {
251
+ gap: "xxs",
252
+ children: [
253
+ /* @__PURE__ */ jsx(Button2, {
254
+ accessibilityState: { disabled, selected },
255
+ color: selected ? "primary" : "neutral",
256
+ disabled,
257
+ interactionPolicy: props.interactionPolicy,
258
+ onPress: () => onSelectDate(cell.date),
259
+ size: "s",
260
+ testID: withTestId(props.testID, `day-${cell.id}`),
261
+ variant: selected ? "solid" : cell.inDisplayedMonth ? "ghost" : "outline",
262
+ children: cell.date.getDate()
263
+ }),
264
+ props.density !== "compact" && event ? /* @__PURE__ */ jsx(Button2, {
265
+ interactionPolicy: props.interactionPolicy,
266
+ onPress: () => activateEvent(event.id),
267
+ size: "s",
268
+ testID: withTestId(props.testID, `event-${event.id}`),
269
+ variant: "outline",
270
+ children: event.title
271
+ }) : null
272
+ ]
273
+ });
274
+ },
275
+ testID: withTestId(props.testID, "grid"),
276
+ viewportInteraction: "locked",
277
+ width: cellSize * GRID_COLUMNS
278
+ })
279
+ ]
280
+ });
281
+ }
282
+ function CalendarTimeView({
283
+ activateEvent,
284
+ displayedDate,
285
+ events,
286
+ interactionPolicy,
287
+ locale,
288
+ testID,
289
+ timeZone,
290
+ view,
291
+ weekStartsOn
292
+ }) {
293
+ const dates = view === "day" ? [displayedDate] : createWeek(displayedDate, weekStartsOn);
294
+ const eventById = new Map(events.map((event) => [event.id, event]));
295
+ return /* @__PURE__ */ jsx(TimeGrid2, {
296
+ contentWidth: MINUTES_PER_DAY,
297
+ height: Math.min(56 * dates.length, 336),
298
+ interactionPolicy,
299
+ intervals: createTimeGridIntervals(events, dates, timeZone),
300
+ lanes: dates.map((date) => ({ height: 56, id: formatCalendarDate2(date) })),
301
+ onIntervalPress: (interval) => activateEvent(interval.id),
302
+ overscanPixels: 0,
303
+ renderInterval: (interval) => /* @__PURE__ */ jsx(Text2, {
304
+ variant: "caption",
305
+ children: eventById.get(interval.id)?.title
306
+ }),
307
+ renderLaneLabel: (lane) => /* @__PURE__ */ jsx(Text2, {
308
+ variant: "caption",
309
+ children: formatDayLabel(parseCalendarDate(lane.id) ?? displayedDate, locale)
310
+ }),
311
+ testID: withTestId(testID, view),
312
+ width: 320
313
+ });
314
+ }
315
+ function createWeekdayLabels(locale, weekStartsOn) {
316
+ const formatter = new Intl.DateTimeFormat(locale, { weekday: "short" });
317
+ return Array.from({ length: GRID_COLUMNS }, (_, index) => ({
318
+ id: String(index),
319
+ label: formatter.format(addDays(new Date(2023, 0, 1), (weekStartsOn + index) % GRID_COLUMNS))
320
+ }));
321
+ }
322
+ function createWeek(date, weekStartsOn) {
323
+ const first = addDays(date, -((date.getDay() - weekStartsOn + GRID_COLUMNS) % GRID_COLUMNS));
324
+ return Array.from({ length: GRID_COLUMNS }, (_, index) => addDays(first, index));
325
+ }
326
+ function createEventsByDate(events, dates, timeZone) {
327
+ return new Map(dates.map((date) => [
328
+ formatCalendarDate2(date),
329
+ events.filter((event) => eventIntersectsDate(event, formatCalendarDate2(date), timeZone))
330
+ ]));
331
+ }
332
+ function createTimeGridIntervals(events, dates, timeZone) {
333
+ return dates.flatMap((date) => events.flatMap((event) => {
334
+ const dateId = formatCalendarDate2(date);
335
+ if (!isTemporalTimedEvent(event))
336
+ return [];
337
+ if (!eventIntersectsDate(event, dateId, timeZone))
338
+ return [];
339
+ const zone = timeZone ?? event.range.timeZone;
340
+ const start = getZonedDateTimeParts(event.range.start, zone);
341
+ const end = getZonedDateTimeParts(resolveTimedEnd(event), zone);
342
+ const startMinute = start.date === dateId ? start.hour * 60 + start.minute : 0;
343
+ const endMinute = end.date === dateId ? end.hour * 60 + end.minute : MINUTES_PER_DAY;
344
+ return [
345
+ {
346
+ extent: Math.max(1, endMinute - startMinute),
347
+ id: event.id,
348
+ laneId: dateId,
349
+ start: startMinute
350
+ }
351
+ ];
352
+ }));
353
+ }
354
+ function eventIntersectsDate(event, date, timeZone) {
355
+ if (!isTemporalTimedEvent(event))
356
+ return event.range.start <= date && date < (event.range.end ?? addDaysToDate(event.range.start, event.range.duration));
357
+ const zone = timeZone ?? event.range.timeZone;
358
+ return getZonedDateTimeParts(event.range.start, zone).date <= date && date <= getZonedDateTimeParts(resolveTimedEnd(event), zone).date;
359
+ }
360
+ function isTemporalTimedEvent(event) {
361
+ return event.range.allDay === false;
362
+ }
363
+ function resolveTimedEnd(event) {
364
+ return event.range.end ?? new Date(Date.parse(event.range.start) + parseDurationMinutes(event.range.duration) * 60000).toISOString();
365
+ }
366
+ function getZonedDateTimeParts(instant, timeZone) {
367
+ const parts = new Intl.DateTimeFormat("en-CA", {
368
+ day: "2-digit",
369
+ hour: "2-digit",
370
+ hourCycle: "h23",
371
+ minute: "2-digit",
372
+ month: "2-digit",
373
+ timeZone,
374
+ year: "numeric"
375
+ }).formatToParts(new Date(instant));
376
+ const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));
377
+ return {
378
+ date: `${values.year}-${values.month}-${values.day}`,
379
+ hour: Number(values.hour),
380
+ minute: Number(values.minute)
381
+ };
382
+ }
383
+ function parseDurationMinutes(duration) {
384
+ const match = /^PT(?:(\d+)H)?(?:(\d+)M)?$/.exec(duration ?? "PT60M");
385
+ return match ? Number(match[1] ?? 0) * 60 + Number(match[2] ?? 0) : 60;
386
+ }
387
+ function addDaysToDate(start, duration) {
388
+ return formatCalendarDate2(addDays(parseCalendarDate(start) ?? new Date, Math.max(1, Math.ceil(parseDurationMinutes(duration) / MINUTES_PER_DAY))));
389
+ }
390
+ function parseCalendarDate(value) {
391
+ if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value))
392
+ return;
393
+ const [year, month, day] = value.split("-").map(Number);
394
+ return year === undefined || month === undefined || day === undefined ? undefined : new Date(year, month - 1, day);
395
+ }
396
+ function addDays(date, count) {
397
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + count);
398
+ }
399
+ function addMonths(month, count) {
400
+ const year = month.getFullYear();
401
+ const targetMonth = month.getMonth() + count;
402
+ const lastDay = new Date(year, targetMonth + 1, 0).getDate();
403
+ return new Date(year, targetMonth, Math.min(month.getDate(), lastDay));
404
+ }
405
+ function startOfLocalMonth2(value) {
406
+ return new Date(value.getFullYear(), value.getMonth(), 1);
407
+ }
408
+ function startOfLocalDay2(value) {
409
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
410
+ }
411
+ function formatCalendarDate2(value) {
412
+ return `${String(value.getFullYear()).padStart(4, "0")}-${String(value.getMonth() + 1).padStart(2, "0")}-${String(value.getDate()).padStart(2, "0")}`;
413
+ }
414
+ function isSameLocalDay(left, right) {
415
+ return formatCalendarDate2(left) === formatCalendarDate2(right);
416
+ }
417
+ function formatViewLabel(value, locale, view) {
418
+ return new Intl.DateTimeFormat(locale, view === "month" ? { month: "long", year: "numeric" } : { day: "numeric", month: "short", year: "numeric" }).format(value);
419
+ }
420
+ function formatDayLabel(value, locale) {
421
+ return new Intl.DateTimeFormat(locale, { day: "numeric", weekday: "short" }).format(value);
422
+ }
423
+ function withTestId(testID, suffix) {
424
+ return testID === undefined ? undefined : `${testID}-${suffix}`;
425
+ }
426
+ export { Calendar2 };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import type { CalendarProps } from './Calendar.types-0.js';
4
4
 
5
- /*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */
5
+ /*** Renders controlled month, week, and day Calendar views through GridView and TimeGrid. */
6
6
  export declare const Calendar: (props: CalendarProps) => React.ReactElement | null;
7
- export type { CalendarDensity, CalendarProps, CalendarView, CalendarWeekStart } from './Calendar.types-0.js';
7
+ export type { CalendarDateChangeEvent, CalendarDensity, CalendarEventActivateEvent, CalendarManifestProps, CalendarProps, CalendarView, CalendarViewChangeEvent, CalendarWeekStart } from './Calendar.types-0.js';
8
8
  export type { TemporalAllDayEvent, TemporalAllDayRange, TemporalAvailability, TemporalDataValue, TemporalDate, TemporalDuration, TemporalEvent, TemporalEventStatus, TemporalInstant, TemporalInteroperabilityData, TemporalParticipant, TemporalRange, TemporalRecurrence, TemporalRecurrenceException, TemporalRecurrenceRule, TemporalReminder, TemporalTimeZone, TemporalTimedEvent, TemporalTimedRange, TemporalTone } from './Calendar.types-1.js';
@@ -0,0 +1,165 @@
1
+ /** A calendar date without a time or timezone, represented as `YYYY-MM-DD`. */
2
+ export type TemporalDate = `${number}-${number}-${number}`;
3
+
4
+ /** A UTC ISO-8601 instant, represented as an RFC 3339 string ending in `Z`. */
5
+ export type TemporalInstant = `${string}Z`;
6
+
7
+ /** An IANA timezone identifier such as `Europe/Zurich`. */
8
+ export type TemporalTimeZone = string;
9
+
10
+ /** An ISO-8601 duration string such as `PT30M` or `-PT15M`. */
11
+ export type TemporalDuration = string;
12
+
13
+ /**
14
+ * This contract describes serializable shape, not runtime validation. Consumers must validate
15
+ * RFC 3339 instants, ISO calendar dates and durations, IANA zone identifiers, positive non-zero
16
+ * intervals, ordered ranges, and finite JSON numbers at their input boundary.
17
+ */
18
+ export type TemporalDataValue = boolean | null | number | string | readonly TemporalDataValue[] | {
19
+ readonly [key: string]: TemporalDataValue;
20
+ };
21
+
22
+ /**
23
+ * A timed interval with exactly one exclusive end. Recurring timed events retain the local
24
+ * wall-clock time derived from `start` in `timeZone` across DST transitions; a recurrence engine
25
+ * materializes each occurrence as its corresponding UTC instant.
26
+ */
27
+ export type TemporalTimedRange = {
28
+ readonly allDay: false;
29
+ readonly start: TemporalInstant;
30
+ readonly end: TemporalInstant;
31
+ readonly duration?: never;
32
+ readonly timeZone: TemporalTimeZone;
33
+ } | {
34
+ readonly allDay: false;
35
+ readonly start: TemporalInstant;
36
+ readonly end?: never;
37
+ readonly duration: TemporalDuration;
38
+ readonly timeZone: TemporalTimeZone;
39
+ };
40
+
41
+ /**
42
+ * A timezone-free all-day calendar-date interval with exactly one exclusive end. `end` is the
43
+ * first day not included, so a one-day event from `2026-10-24` ends on `2026-10-25`.
44
+ */
45
+ export type TemporalAllDayRange = {
46
+ readonly allDay: true;
47
+ readonly start: TemporalDate;
48
+ readonly end: TemporalDate;
49
+ readonly duration?: never;
50
+ } | {
51
+ readonly allDay: true;
52
+ readonly start: TemporalDate;
53
+ readonly end?: never;
54
+ readonly duration: TemporalDuration;
55
+ };
56
+
57
+ /** A timed or all-day interval with exactly one way to define its exclusive end. */
58
+ export type TemporalRange = TemporalAllDayRange | TemporalTimedRange;
59
+
60
+ /** The availability an event contributes without disclosing its details. */
61
+ export type TemporalAvailability = 'free' | 'busy' | 'tentative' | 'unavailable';
62
+
63
+ /** A provider-neutral lifecycle state for a scheduled event. */
64
+ export type TemporalEventStatus = 'cancelled' | 'confirmed' | 'draft' | 'tentative';
65
+
66
+ /** A semantic theme treatment that later ZORA renderers resolve through their active theme. */
67
+ export type TemporalTone = 'accent' | 'critical' | 'info' | 'neutral' | 'positive' | 'warning';
68
+
69
+ /** A person or organization participating in an event without provider-specific identity objects. */
70
+ export interface TemporalParticipant {
71
+ readonly id?: string;
72
+ readonly name?: string;
73
+ readonly email?: string;
74
+ readonly role?: 'optional' | 'organizer' | 'required' | 'resource';
75
+ readonly response?: 'accepted' | 'declined' | 'delegated' | 'needs-action' | 'tentative';
76
+ }
77
+
78
+ /**
79
+ * A reminder relative to the event start or exclusive end. A negative ISO duration fires before
80
+ * that reference point; a positive duration fires after it.
81
+ */
82
+ export interface TemporalReminder {
83
+ readonly id: string;
84
+ readonly offset: TemporalDuration;
85
+ readonly reference: 'end' | 'start';
86
+ readonly channel?: 'display' | 'email' | 'push';
87
+ }
88
+
89
+ /**
90
+ * One normalized recurrence rule. `until` has the same value type as DTSTART: a date for all-day
91
+ * series and a UTC instant for timed series. Adapter layers map this to and from RFC 5545 RRULE.
92
+ */
93
+ export interface TemporalRecurrenceRule<TValue extends TemporalDate | TemporalInstant> {
94
+ readonly frequency: 'daily' | 'monthly' | 'weekly' | 'yearly';
95
+ readonly interval?: number;
96
+ readonly count?: number;
97
+ readonly until?: TValue;
98
+ readonly weekdays?: readonly ('friday' | 'monday' | 'saturday' | 'sunday' | 'thursday' | 'tuesday' | 'wednesday')[];
99
+ readonly monthDays?: readonly number[];
100
+ readonly months?: readonly number[];
101
+ }
102
+
103
+ /**
104
+ * Recurrence data retained independently from provider-specific series representations. `dates`
105
+ * and `excludedDates` correspond to RFC 5545 RDATE and EXDATE and use the DTSTART value type.
106
+ */
107
+ export interface TemporalRecurrence<TValue extends TemporalDate | TemporalInstant> {
108
+ readonly rules: readonly TemporalRecurrenceRule<TValue>[];
109
+ readonly dates?: readonly TValue[];
110
+ readonly excludedDates?: readonly TValue[];
111
+ }
112
+
113
+ /**
114
+ * A detached occurrence that replaces or cancels one generated recurrence instance. `recurrenceId`
115
+ * is the original scheduled DTSTART value: for timed DST series, the UTC instant materialized from
116
+ * that occurrence's wall-clock time in the series timezone; for all-day series, its calendar date.
117
+ */
118
+ export interface TemporalRecurrenceException<TValue extends TemporalDate | TemporalInstant, TRange extends TemporalRange> {
119
+ readonly recurrenceId: TValue;
120
+ readonly status: 'cancelled' | 'replacement';
121
+ readonly range?: TRange;
122
+ readonly title?: string;
123
+ }
124
+
125
+ /** Lossless serialized data that an interoperability adapter must round-trip without exposing its runtime. */
126
+ export interface TemporalInteroperabilityData {
127
+ readonly format: 'icalendar' | 'jcal' | 'provider';
128
+ readonly value: TemporalDataValue;
129
+ }
130
+
131
+ interface TemporalEventBase {
132
+ readonly id: string;
133
+ readonly title: string;
134
+ readonly description?: string;
135
+ readonly location?: string;
136
+ readonly conferenceUrl?: string;
137
+ readonly calendarId?: string;
138
+ readonly tone?: TemporalTone;
139
+ readonly availability?: TemporalAvailability;
140
+ readonly status?: TemporalEventStatus;
141
+ readonly resourceIds?: readonly string[];
142
+ readonly organizer?: TemporalParticipant;
143
+ readonly attendees?: readonly TemporalParticipant[];
144
+ readonly reminders?: readonly TemporalReminder[];
145
+ readonly editable?: boolean;
146
+ readonly metadata?: Readonly<Record<string, TemporalDataValue>>;
147
+ readonly interoperability?: readonly TemporalInteroperabilityData[];
148
+ }
149
+
150
+ /** A provider-neutral timed event with instant-based recurrence values. */
151
+ export interface TemporalTimedEvent extends TemporalEventBase {
152
+ readonly range: TemporalTimedRange;
153
+ readonly recurrence?: TemporalRecurrence<TemporalInstant>;
154
+ readonly recurrenceExceptions?: readonly TemporalRecurrenceException<TemporalInstant, TemporalTimedRange>[];
155
+ }
156
+
157
+ /** A provider-neutral all-day event with date-based recurrence values. */
158
+ export interface TemporalAllDayEvent extends TemporalEventBase {
159
+ readonly range: TemporalAllDayRange;
160
+ readonly recurrence?: TemporalRecurrence<TemporalDate>;
161
+ readonly recurrenceExceptions?: readonly TemporalRecurrenceException<TemporalDate, TemporalAllDayRange>[];
162
+ }
163
+
164
+ /** Provider-neutral, serializable event data shared by future Calendar and Scheduler presentations. */
165
+ export type TemporalEvent = TemporalAllDayEvent | TemporalTimedEvent;
@@ -6,10 +6,11 @@ import"../../chunks/Accordion-fkftnxgw.js";
6
6
  import"../../chunks/Accordion-e6ettgh0.js";
7
7
  import"../../chunks/Accordion-k9n1yse4.js";
8
8
  import"../../chunks/Accordion-0zk0xp73.js";
9
+ import"../../chunks/Accordion-59x6e7bs.js";
9
10
  import"../../chunks/Accordion-6gc0jw1n.js";
10
11
  import {
11
12
  Calendar2
12
- } from "../../chunks/Accordion-v3bmbnfh.js";
13
+ } from "../../chunks/Accordion-q2yxtdzc.js";
13
14
  export {
14
15
  Calendar2 as Calendar
15
16
  };
@@ -1,27 +1,53 @@
1
1
  import type { ZoraBaseProps } from './Calendar.dependency-0.js';
2
2
 
3
+ import type { TemporalDate, TemporalEvent, TemporalTimeZone } from './Calendar.dependency-2.js';
4
+
3
5
  export type CalendarDensity = 'regular' | 'compact';
4
6
 
5
- export type CalendarView = 'month';
7
+ export type CalendarView = 'day' | 'month' | 'week';
6
8
 
7
9
  export type CalendarWeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6;
8
10
 
9
- /** Public Calendar state uses local calendar dates, never UTC instants. */
10
- export interface CalendarProps extends ZoraBaseProps {
11
- /** The only currently implemented Calendar presentation. */
12
- view?: CalendarView;
13
- density?: CalendarDensity;
14
- /** A local date within the controlled month to display. */
15
- displayedMonth?: Date;
16
- /** Initial local month when displayedMonth is not controlled. */
17
- defaultDisplayedMonth?: Date;
18
- onDisplayedMonthChange?: (month: Date) => void;
19
- selectedDate?: Date | null;
20
- onSelectedDateChange?: (date: Date) => void;
21
- locale?: string;
22
- weekStartsOn?: CalendarWeekStart;
23
- minDate?: Date;
24
- maxDate?: Date;
25
- disabledDates?: readonly Date[];
26
- isDateDisabled?: (date: Date) => boolean;
11
+ /** Serializable payload for a controlled Calendar date. */
12
+ export interface CalendarDateChangeEvent {
13
+ readonly date: TemporalDate;
14
+ }
15
+
16
+ /** Serializable payload for a controlled Calendar view. */
17
+ export interface CalendarViewChangeEvent {
18
+ readonly view: CalendarView;
19
+ }
20
+
21
+ /** Serializable payload emitted when an event is activated. */
22
+ export interface CalendarEventActivateEvent {
23
+ readonly eventId: string;
24
+ }
25
+
26
+ /** Serializable props accepted by a direct Calendar manifest node. */
27
+ export interface CalendarManifestProps {
28
+ readonly view?: CalendarView;
29
+ readonly displayedDate?: TemporalDate;
30
+ readonly defaultDisplayedDate?: TemporalDate;
31
+ readonly events?: readonly TemporalEvent[];
32
+ readonly timeZone?: TemporalTimeZone;
33
+ readonly locale?: string;
34
+ readonly weekStartsOn?: CalendarWeekStart;
35
+ readonly density?: CalendarDensity;
36
+ }
37
+
38
+ /** Code API retaining DatePicker's local-Date compatibility alongside manifest data. */
39
+ export interface CalendarProps extends ZoraBaseProps, CalendarManifestProps {
40
+ readonly displayedMonth?: Date;
41
+ readonly defaultDisplayedMonth?: Date;
42
+ readonly onDisplayedMonthChange?: (month: Date) => void;
43
+ readonly selectedDate?: Date | null;
44
+ readonly onSelectedDateChange?: (date: Date) => void;
45
+ readonly onDateChange?: (event: CalendarDateChangeEvent) => void;
46
+ readonly defaultView?: CalendarView;
47
+ readonly onViewChange?: (event: CalendarViewChangeEvent) => void;
48
+ readonly onEventActivate?: (event: CalendarEventActivateEvent) => void;
49
+ readonly minDate?: Date;
50
+ readonly maxDate?: Date;
51
+ readonly disabledDates?: readonly Date[];
52
+ readonly isDateDisabled?: (date: Date) => boolean;
27
53
  }