@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
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import type { CalendarProps } from '../../../../types/calendar';
3
- /*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */
3
+ /*** Renders controlled month, week, and day Calendar views through GridView and TimeGrid. */
4
4
  export declare const Calendar: (props: CalendarProps) => React.ReactElement | null;
5
5
  //# sourceMappingURL=Calendar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAYhE,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,qDAAoC,CAAC"}
1
+ {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,4BAA4B,CAAC;AAoB9E,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,qDAAoC,CAAC"}
@@ -3,124 +3,256 @@ import { Button } from '../../../button/public.js';
3
3
  import { GridView } from '../../../grid-view/public.js';
4
4
  import { View } from '../../../layout/public.js';
5
5
  import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope.js';
6
+ import { TimeGrid } from '../../../time-grid/public.js';
6
7
  import { Text } from '../../../typography/public.js';
7
8
  import { createCalendarMonth } from '../../application/createCalendarMonth.js';
8
9
  import { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled.js';
9
10
  const GRID_COLUMNS = 7;
10
11
  const GRID_ROWS = 6;
11
- /*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */
12
+ const MINUTES_PER_DAY = 24 * 60;
13
+ /*** Renders controlled month, week, and day Calendar views through GridView and TimeGrid. */
12
14
  export const Calendar = withZoraThemeScope(CalendarInner);
13
- /*** Connects controlled Calendar state to the shared month grid presentation. */
14
- function CalendarInner({ defaultDisplayedMonth, density = 'regular', disabledDates = [], displayedMonth: controlledDisplayedMonth, interactionPolicy, isDateDisabled, locale, maxDate, minDate, onDisplayedMonthChange, onSelectedDateChange, selectedDate, testID, weekStartsOn = 0, }) {
15
- const [uncontrolledDisplayedMonth, setUncontrolledDisplayedMonth] = React.useState(() => startOfLocalMonth(defaultDisplayedMonth ?? selectedDate ?? minDate ?? new Date()));
16
- const displayedMonth = startOfLocalMonth(controlledDisplayedMonth ?? uncontrolledDisplayedMonth);
17
- const cellSize = density === 'compact' ? 42 : 48;
18
- const gridWidth = cellSize * GRID_COLUMNS;
19
- const gridHeight = cellSize * GRID_ROWS;
20
- const cells = React.useMemo(() => createCalendarMonth(displayedMonth, weekStartsOn), [displayedMonth, weekStartsOn]);
21
- const gridItems = React.useMemo(() => cells.map((cell, index) => ({
22
- height: cellSize,
23
- id: cell.id,
24
- width: cellSize,
25
- x: (index % GRID_COLUMNS) * cellSize,
26
- y: Math.floor(index / GRID_COLUMNS) * cellSize,
27
- })), [cellSize, cells]);
28
- const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
29
- const disabledDateIds = React.useMemo(() => new Set(disabledDates.map(formatCalendarDate)), [disabledDates]);
30
- const weekdays = React.useMemo(() => createWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);
31
- const setDisplayedMonth = React.useCallback((month) => {
32
- const nextMonth = startOfLocalMonth(month);
33
- if (controlledDisplayedMonth === undefined)
34
- setUncontrolledDisplayedMonth(nextMonth);
35
- onDisplayedMonthChange?.(nextMonth);
36
- }, [controlledDisplayedMonth, onDisplayedMonthChange]);
37
- const previousMonth = addMonths(displayedMonth, -1);
38
- const nextMonth = addMonths(displayedMonth, 1);
39
- return (<View accessibilityLabel="Calendar" gap={density === 'compact' ? 's' : 'm'} testID={testID}>
15
+ /*** Connects serializable manifest state and the DatePicker-compatible code API to Calendar views. */
16
+ function CalendarInner(props) {
17
+ const { defaultDisplayedDate, defaultDisplayedMonth, defaultView = 'month', density = 'regular', displayedDate: controlledDisplayedDate, displayedMonth: controlledDisplayedMonth, events = [], locale, onDateChange, onDisplayedMonthChange, onEventActivate, onViewChange, timeZone, view: controlledView, weekStartsOn = 0, } = props;
18
+ const [uncontrolledDate, setUncontrolledDate] = React.useState(() => parseCalendarDate(defaultDisplayedDate) ??
19
+ startOfLocalDay(defaultDisplayedMonth ?? props.selectedDate ?? props.minDate ?? new Date()));
20
+ const [uncontrolledView, setUncontrolledView] = React.useState(defaultView);
21
+ const displayedDate = parseCalendarDate(controlledDisplayedDate) ??
22
+ startOfLocalDay(controlledDisplayedMonth ?? uncontrolledDate);
23
+ const view = controlledView ?? uncontrolledView;
24
+ const setDisplayedDate = React.useCallback((value) => {
25
+ const next = startOfLocalDay(value);
26
+ if (controlledDisplayedDate === undefined && controlledDisplayedMonth === undefined)
27
+ setUncontrolledDate(next);
28
+ onDisplayedMonthChange?.(startOfLocalMonth(next));
29
+ onDateChange?.({ date: formatCalendarDate(next) });
30
+ }, [controlledDisplayedDate, controlledDisplayedMonth, onDateChange, onDisplayedMonthChange]);
31
+ const setView = React.useCallback((next) => {
32
+ if (controlledView === undefined)
33
+ setUncontrolledView(next);
34
+ onViewChange?.({ view: next });
35
+ }, [controlledView, onViewChange]);
36
+ const navigate = React.useCallback((offset) => setDisplayedDate(view === 'month'
37
+ ? addMonths(displayedDate, offset)
38
+ : addDays(displayedDate, offset * (view === 'week' ? 7 : 1))), [displayedDate, setDisplayedDate, view]);
39
+ return (<View accessibilityLabel="Calendar" gap={density === 'compact' ? 's' : 'm'} testID={props.testID}>
40
40
  <View align="center" direction="row" justify="space-between">
41
- <Button disabled={!monthIntersectsRange(previousMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => setDisplayedMonth(previousMonth)} size="s" variant="ghost">
41
+ <Button interactionPolicy={props.interactionPolicy} onPress={() => navigate(-1)} size="s" testID={withTestId(props.testID, 'previous')} variant="ghost">
42
42
  Previous
43
43
  </Button>
44
44
  <Text accessibilityRole="header" align="center" variant="label" weight="semiBold">
45
- {formatMonthLabel(displayedMonth, locale)}
45
+ {formatViewLabel(displayedDate, locale, view)}
46
46
  </Text>
47
- <Button disabled={!monthIntersectsRange(nextMonth, minDate, maxDate)} interactionPolicy={interactionPolicy} onPress={() => setDisplayedMonth(nextMonth)} size="s" variant="ghost">
47
+ <Button interactionPolicy={props.interactionPolicy} onPress={() => navigate(1)} size="s" testID={withTestId(props.testID, 'next')} variant="ghost">
48
48
  Next
49
49
  </Button>
50
50
  </View>
51
+ <View direction="row" justify="space-between">
52
+ {['day', 'week', 'month'].map((candidate) => (<Button key={candidate} interactionPolicy={props.interactionPolicy} onPress={() => setView(candidate)} size="s" testID={withTestId(props.testID, `view-${candidate}`)} variant={view === candidate ? 'solid' : 'ghost'}>
53
+ {candidate}
54
+ </Button>))}
55
+ <Button interactionPolicy={props.interactionPolicy} onPress={() => setDisplayedDate(new Date())} size="s" testID={withTestId(props.testID, 'today')} variant="ghost">
56
+ Today
57
+ </Button>
58
+ </View>
59
+ {view === 'month' ? (<CalendarMonth {...props} activateEvent={(id) => onEventActivate?.({ eventId: id })} cellSize={density === 'compact' ? 42 : 48} displayedDate={displayedDate} events={events} timeZone={timeZone} weekStartsOn={weekStartsOn} onSelectDate={(date) => {
60
+ setDisplayedDate(date);
61
+ props.onSelectedDateChange?.(date);
62
+ }}/>) : (<CalendarTimeView activateEvent={(id) => onEventActivate?.({ eventId: id })} displayedDate={displayedDate} events={events} interactionPolicy={props.interactionPolicy} locale={locale} testID={props.testID} timeZone={timeZone} view={view} weekStartsOn={weekStartsOn}/>)}
63
+ </View>);
64
+ }
65
+ /*** Renders the canonical GridView month geometry with stable event activation. */
66
+ function CalendarMonth({ activateEvent, cellSize, displayedDate, events, onSelectDate, timeZone, weekStartsOn, ...props }) {
67
+ const cells = React.useMemo(() => createCalendarMonth(displayedDate, weekStartsOn), [displayedDate, weekStartsOn]);
68
+ const gridItems = React.useMemo(() => cells.map((cell, index) => ({
69
+ height: cellSize,
70
+ id: cell.id,
71
+ width: cellSize,
72
+ x: (index % GRID_COLUMNS) * cellSize,
73
+ y: Math.floor(index / GRID_COLUMNS) * cellSize,
74
+ })), [cellSize, cells]);
75
+ const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);
76
+ const disabledDateIds = React.useMemo(() => new Set((props.disabledDates ?? []).map(formatCalendarDate)), [props.disabledDates]);
77
+ const eventsByDate = React.useMemo(() => createEventsByDate(events, cells.map((cell) => cell.date), timeZone), [cells, events, timeZone]);
78
+ return (<>
51
79
  <View direction="row">
52
- {weekdays.map((weekday) => (<View key={weekday.id} width={cellSize}>
80
+ {createWeekdayLabels(props.locale, weekStartsOn).map((weekday) => (<View key={weekday.id} width={cellSize}>
53
81
  <Text align="center" emphasis="muted" variant="caption" weight="semiBold">
54
82
  {weekday.label}
55
83
  </Text>
56
84
  </View>))}
57
85
  </View>
58
- <GridView contentHeight={gridHeight} contentWidth={gridWidth} height={gridHeight} interactionPolicy={interactionPolicy} items={gridItems} overscanPixels={0} renderItem={(item) => {
86
+ <GridView contentHeight={cellSize * GRID_ROWS} contentWidth={cellSize * GRID_COLUMNS} height={cellSize * GRID_ROWS} interactionPolicy={props.interactionPolicy} items={gridItems} overscanPixels={0} renderItem={(item) => {
59
87
  const cell = cellsById.get(item.id);
60
88
  if (!cell)
61
89
  return null;
62
- const selected = selectedDate !== null &&
63
- selectedDate !== undefined &&
64
- isSameLocalDay(selectedDate, cell.date);
90
+ const selected = props.selectedDate !== null &&
91
+ props.selectedDate !== undefined &&
92
+ isSameLocalDay(props.selectedDate, cell.date);
65
93
  const disabled = isCalendarDateDisabled({
66
94
  date: cell.date,
67
95
  disabledDateIds,
68
- isDateDisabled,
69
- maxDate,
70
- minDate,
96
+ isDateDisabled: props.isDateDisabled,
97
+ maxDate: props.maxDate,
98
+ minDate: props.minDate,
71
99
  });
72
- const selectCell = () => {
73
- if (!cell.inDisplayedMonth)
74
- setDisplayedMonth(cell.date);
75
- onSelectedDateChange?.(cell.date);
76
- };
77
- return (<Button accessibilityState={{ disabled, selected }} color={selected ? 'primary' : 'neutral'} disabled={disabled} interactionPolicy={interactionPolicy} onPress={selectCell} size="s" testID={testID ? `${testID}-day-${cell.id}` : undefined} variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}>
78
- {cell.date.getDate()}
79
- </Button>);
80
- }} testID={testID ? `${testID}-grid` : undefined} viewportInteraction="locked" width={gridWidth}/>
81
- </View>);
100
+ const event = eventsByDate.get(cell.id)?.[0];
101
+ return (<View gap="xxs">
102
+ <Button accessibilityState={{ disabled, selected }} color={selected ? 'primary' : 'neutral'} disabled={disabled} interactionPolicy={props.interactionPolicy} onPress={() => onSelectDate(cell.date)} size="s" testID={withTestId(props.testID, `day-${cell.id}`)} variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}>
103
+ {cell.date.getDate()}
104
+ </Button>
105
+ {props.density !== 'compact' && event ? (<Button interactionPolicy={props.interactionPolicy} onPress={() => activateEvent(event.id)} size="s" testID={withTestId(props.testID, `event-${event.id}`)} variant="outline">
106
+ {event.title}
107
+ </Button>) : null}
108
+ </View>);
109
+ }} testID={withTestId(props.testID, 'grid')} viewportInteraction="locked" width={cellSize * GRID_COLUMNS}/>
110
+ </>);
111
+ }
112
+ /*** Renders day and week event lanes through the existing TimeGrid foundation. */
113
+ function CalendarTimeView({ activateEvent, displayedDate, events, interactionPolicy, locale, testID, timeZone, view, weekStartsOn, }) {
114
+ const dates = view === 'day' ? [displayedDate] : createWeek(displayedDate, weekStartsOn);
115
+ const eventById = new Map(events.map((event) => [event.id, event]));
116
+ return (<TimeGrid contentWidth={MINUTES_PER_DAY} height={Math.min(56 * dates.length, 336)} interactionPolicy={interactionPolicy} intervals={createTimeGridIntervals(events, dates, timeZone)} lanes={dates.map((date) => ({ height: 56, id: formatCalendarDate(date) }))} onIntervalPress={(interval) => activateEvent(interval.id)} overscanPixels={0} renderInterval={(interval) => (<Text variant="caption">{eventById.get(interval.id)?.title}</Text>)} renderLaneLabel={(lane) => (<Text variant="caption">
117
+ {formatDayLabel(parseCalendarDate(lane.id) ?? displayedDate, locale)}
118
+ </Text>)} testID={withTestId(testID, view)} width={320}/>);
82
119
  }
83
- /*** Produces the ordered weekday labels for one local calendar week. */
120
+ /*** Produces weekday labels for one local calendar week. */
84
121
  function createWeekdayLabels(locale, weekStartsOn) {
85
122
  const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' });
86
- const sunday = new Date(2023, 0, 1);
87
- return Array.from({ length: GRID_COLUMNS }, (_, index) => {
88
- const day = new Date(sunday.getFullYear(), sunday.getMonth(), sunday.getDate() + ((weekStartsOn + index) % GRID_COLUMNS));
89
- return { id: String(index), label: formatter.format(day) };
90
- });
123
+ return Array.from({ length: GRID_COLUMNS }, (_, index) => ({
124
+ id: String(index),
125
+ label: formatter.format(addDays(new Date(2023, 0, 1), (weekStartsOn + index) % GRID_COLUMNS)),
126
+ }));
127
+ }
128
+ /*** Creates the visible local dates for a week view. */
129
+ function createWeek(date, weekStartsOn) {
130
+ const first = addDays(date, -((date.getDay() - weekStartsOn + GRID_COLUMNS) % GRID_COLUMNS));
131
+ return Array.from({ length: GRID_COLUMNS }, (_, index) => addDays(first, index));
132
+ }
133
+ /*** Indexes events by each displayed local date they intersect in the Calendar timezone. */
134
+ function createEventsByDate(events, dates, timeZone) {
135
+ return new Map(dates.map((date) => [
136
+ formatCalendarDate(date),
137
+ events.filter((event) => eventIntersectsDate(event, formatCalendarDate(date), timeZone)),
138
+ ]));
139
+ }
140
+ /*** Maps timed events into TimeGrid lane-local minute coordinates. */
141
+ function createTimeGridIntervals(events, dates, timeZone) {
142
+ return dates.flatMap((date) => events.flatMap((event) => {
143
+ const dateId = formatCalendarDate(date);
144
+ if (!isTemporalTimedEvent(event))
145
+ return [];
146
+ if (!eventIntersectsDate(event, dateId, timeZone))
147
+ return [];
148
+ const zone = timeZone ?? event.range.timeZone;
149
+ const start = getZonedDateTimeParts(event.range.start, zone);
150
+ const end = getZonedDateTimeParts(resolveTimedEnd(event), zone);
151
+ const startMinute = start.date === dateId ? start.hour * 60 + start.minute : 0;
152
+ const endMinute = end.date === dateId ? end.hour * 60 + end.minute : MINUTES_PER_DAY;
153
+ return [
154
+ {
155
+ extent: Math.max(1, endMinute - startMinute),
156
+ id: event.id,
157
+ laneId: dateId,
158
+ start: startMinute,
159
+ },
160
+ ];
161
+ }));
162
+ }
163
+ /*** Reports whether an event overlaps one local Calendar date. */
164
+ function eventIntersectsDate(event, date, timeZone) {
165
+ if (!isTemporalTimedEvent(event))
166
+ return (event.range.start <= date &&
167
+ date < (event.range.end ?? addDaysToDate(event.range.start, event.range.duration)));
168
+ const zone = timeZone ?? event.range.timeZone;
169
+ return (getZonedDateTimeParts(event.range.start, zone).date <= date &&
170
+ date <= getZonedDateTimeParts(resolveTimedEnd(event), zone).date);
171
+ }
172
+ /*** Narrows a serializable Calendar event to the instant-based timed variant. */
173
+ function isTemporalTimedEvent(event) {
174
+ return event.range.allDay === false;
175
+ }
176
+ /*** Resolves the exclusive timed end, including the existing duration alternative. */
177
+ function resolveTimedEnd(event) {
178
+ return (event.range.end ??
179
+ new Date(Date.parse(event.range.start) + parseDurationMinutes(event.range.duration) * 60_000).toISOString());
180
+ }
181
+ /*** Reads a UTC instant as a local date and wall-clock time in an IANA timezone. */
182
+ function getZonedDateTimeParts(instant, timeZone) {
183
+ const parts = new Intl.DateTimeFormat('en-CA', {
184
+ day: '2-digit',
185
+ hour: '2-digit',
186
+ hourCycle: 'h23',
187
+ minute: '2-digit',
188
+ month: '2-digit',
189
+ timeZone,
190
+ year: 'numeric',
191
+ }).formatToParts(new Date(instant));
192
+ const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));
193
+ return {
194
+ date: `${values.year}-${values.month}-${values.day}`,
195
+ hour: Number(values.hour),
196
+ minute: Number(values.minute),
197
+ };
91
198
  }
92
- /*** Moves a local month without carrying a day-of-month overflow into the target month. */
199
+ /*** Parses the bounded hour-and-minute duration form used for Calendar placement. */
200
+ function parseDurationMinutes(duration) {
201
+ const match = /^PT(?:(\d+)H)?(?:(\d+)M)?$/.exec(duration ?? 'PT60M');
202
+ return match ? Number(match[1] ?? 0) * 60 + Number(match[2] ?? 0) : 60;
203
+ }
204
+ /*** Adds a date-only duration without introducing a timezone. */
205
+ function addDaysToDate(start, duration) {
206
+ return formatCalendarDate(addDays(parseCalendarDate(start) ?? new Date(), Math.max(1, Math.ceil(parseDurationMinutes(duration) / MINUTES_PER_DAY))));
207
+ }
208
+ /*** Parses a local YYYY-MM-DD date without UTC conversion. */
209
+ function parseCalendarDate(value) {
210
+ if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value))
211
+ return undefined;
212
+ const [year, month, day] = value.split('-').map(Number);
213
+ return year === undefined || month === undefined || day === undefined
214
+ ? undefined
215
+ : new Date(year, month - 1, day);
216
+ }
217
+ /*** Moves a local calendar day. */
218
+ function addDays(date, count) {
219
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + count);
220
+ }
221
+ /*** Moves a local month without day overflow. */
93
222
  function addMonths(month, count) {
94
- return new Date(month.getFullYear(), month.getMonth() + count, 1);
223
+ const year = month.getFullYear();
224
+ const targetMonth = month.getMonth() + count;
225
+ const lastDay = new Date(year, targetMonth + 1, 0).getDate();
226
+ return new Date(year, targetMonth, Math.min(month.getDate(), lastDay));
95
227
  }
96
228
  /*** Normalizes a value to the first local day of its month. */
97
229
  function startOfLocalMonth(value) {
98
230
  return new Date(value.getFullYear(), value.getMonth(), 1);
99
231
  }
232
+ /*** Normalizes a value to its local calendar date. */
233
+ function startOfLocalDay(value) {
234
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
235
+ }
100
236
  /*** Formats a Date as a timezone-independent local calendar identifier. */
101
237
  function formatCalendarDate(value) {
102
- const year = String(value.getFullYear()).padStart(4, '0');
103
- const month = String(value.getMonth() + 1).padStart(2, '0');
104
- const day = String(value.getDate()).padStart(2, '0');
105
- return `${year}-${month}-${day}`;
238
+ return `${String(value.getFullYear()).padStart(4, '0')}-${String(value.getMonth() + 1).padStart(2, '0')}-${String(value.getDate()).padStart(2, '0')}`;
106
239
  }
107
240
  /*** Compares local calendar dates using their canonical date-only identifiers. */
108
- function compareLocalDates(left, right) {
109
- return formatCalendarDate(left).localeCompare(formatCalendarDate(right));
110
- }
111
- /*** Reports whether a candidate month contains at least one date inside the configured range. */
112
- function monthIntersectsRange(month, minDate, maxDate) {
113
- const first = startOfLocalMonth(month);
114
- const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);
115
- return ((!minDate || compareLocalDates(last, minDate) >= 0) &&
116
- (!maxDate || compareLocalDates(first, maxDate) <= 0));
117
- }
118
- /*** Reports whether two values identify the same local calendar day. */
119
241
  function isSameLocalDay(left, right) {
120
242
  return formatCalendarDate(left) === formatCalendarDate(right);
121
243
  }
122
- /*** Formats a display month with the caller's locale. */
123
- function formatMonthLabel(value, locale) {
124
- return new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(value);
244
+ /*** Formats the controlled view title. */
245
+ function formatViewLabel(value, locale, view) {
246
+ return new Intl.DateTimeFormat(locale, view === 'month'
247
+ ? { month: 'long', year: 'numeric' }
248
+ : { day: 'numeric', month: 'short', year: 'numeric' }).format(value);
249
+ }
250
+ /*** Formats a compact lane label for day and week views. */
251
+ function formatDayLabel(value, locale) {
252
+ return new Intl.DateTimeFormat(locale, { day: 'numeric', weekday: 'short' }).format(value);
253
+ }
254
+ /*** Resolves a test identifier suffix only when a test root is provided. */
255
+ function withTestId(testID, suffix) {
256
+ return testID === undefined ? undefined : `${testID}-${suffix}`;
125
257
  }
126
258
  //# sourceMappingURL=Calendar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAE1D,iFAAiF;AACjF,SAAS,aAAa,CAAC,EACrB,qBAAqB,EACrB,OAAO,GAAG,SAAS,EACnB,aAAa,GAAG,EAAE,EAClB,cAAc,EAAE,wBAAwB,EACxC,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,OAAO,EACP,OAAO,EACP,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,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AAK,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACpE,OAAO,CACL,CAAC,CAAC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC,CAAC,OAAO,IAAI,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CACrD,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,SAAS,cAAc,CAAC,IAAU,EAAE,KAAW;IAC7C,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,yDAAyD;AACzD,SAAS,gBAAgB,CAAC,KAAW,EAAE,MAA0B;IAC/D,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import type { GridRectItem } from '@ankhorage/grid-view';\nimport React from 'react';\n\nimport type { CalendarProps } from '../../../../types/calendar';\nimport { Button } from '../../../button/public';\nimport { GridView } from '../../../grid-view/public';\nimport { View } from '../../../layout/public';\nimport { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';\nimport { Text } from '../../../typography/public';\nimport { createCalendarMonth } from '../../application/createCalendarMonth';\nimport { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled';\n\nconst GRID_COLUMNS = 7;\nconst GRID_ROWS = 6;\n\n/*** Renders a locale-aware, accessible month calendar using canonical GridView geometry. */\nexport const Calendar = withZoraThemeScope(CalendarInner);\n\n/*** Connects controlled Calendar state to the shared month grid presentation. */\nfunction CalendarInner({\n defaultDisplayedMonth,\n density = 'regular',\n disabledDates = [],\n displayedMonth: controlledDisplayedMonth,\n interactionPolicy,\n isDateDisabled,\n locale,\n maxDate,\n minDate,\n onDisplayedMonthChange,\n onSelectedDateChange,\n selectedDate,\n testID,\n weekStartsOn = 0,\n}: CalendarProps) {\n const [uncontrolledDisplayedMonth, setUncontrolledDisplayedMonth] = React.useState(() =>\n startOfLocalMonth(defaultDisplayedMonth ?? selectedDate ?? minDate ?? new Date()),\n );\n const displayedMonth = startOfLocalMonth(controlledDisplayedMonth ?? uncontrolledDisplayedMonth);\n const cellSize = density === 'compact' ? 42 : 48;\n const gridWidth = cellSize * GRID_COLUMNS;\n const gridHeight = cellSize * GRID_ROWS;\n const cells = React.useMemo(\n () => createCalendarMonth(displayedMonth, weekStartsOn),\n [displayedMonth, weekStartsOn],\n );\n const gridItems = React.useMemo<readonly GridRectItem[]>(\n () =>\n cells.map((cell, index) => ({\n height: cellSize,\n id: cell.id,\n width: cellSize,\n x: (index % GRID_COLUMNS) * cellSize,\n y: Math.floor(index / GRID_COLUMNS) * cellSize,\n })),\n [cellSize, cells],\n );\n const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);\n const disabledDateIds = React.useMemo(\n () => new Set(disabledDates.map(formatCalendarDate)),\n [disabledDates],\n );\n const weekdays = React.useMemo(\n () => createWeekdayLabels(locale, weekStartsOn),\n [locale, weekStartsOn],\n );\n const setDisplayedMonth = React.useCallback(\n (month: Date) => {\n const nextMonth = startOfLocalMonth(month);\n if (controlledDisplayedMonth === undefined) setUncontrolledDisplayedMonth(nextMonth);\n onDisplayedMonthChange?.(nextMonth);\n },\n [controlledDisplayedMonth, onDisplayedMonthChange],\n );\n const previousMonth = addMonths(displayedMonth, -1);\n const nextMonth = addMonths(displayedMonth, 1);\n\n return (\n <View accessibilityLabel=\"Calendar\" gap={density === 'compact' ? 's' : 'm'} testID={testID}>\n <View align=\"center\" direction=\"row\" justify=\"space-between\">\n <Button\n disabled={!monthIntersectsRange(previousMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => setDisplayedMonth(previousMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Previous\n </Button>\n <Text accessibilityRole=\"header\" align=\"center\" variant=\"label\" weight=\"semiBold\">\n {formatMonthLabel(displayedMonth, locale)}\n </Text>\n <Button\n disabled={!monthIntersectsRange(nextMonth, minDate, maxDate)}\n interactionPolicy={interactionPolicy}\n onPress={() => setDisplayedMonth(nextMonth)}\n size=\"s\"\n variant=\"ghost\"\n >\n Next\n </Button>\n </View>\n <View direction=\"row\">\n {weekdays.map((weekday) => (\n <View key={weekday.id} width={cellSize}>\n <Text align=\"center\" emphasis=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {weekday.label}\n </Text>\n </View>\n ))}\n </View>\n <GridView\n contentHeight={gridHeight}\n contentWidth={gridWidth}\n height={gridHeight}\n interactionPolicy={interactionPolicy}\n items={gridItems}\n overscanPixels={0}\n renderItem={(item) => {\n const cell = cellsById.get(item.id);\n if (!cell) return null;\n const selected =\n selectedDate !== null &&\n selectedDate !== undefined &&\n isSameLocalDay(selectedDate, cell.date);\n const disabled = isCalendarDateDisabled({\n date: cell.date,\n disabledDateIds,\n isDateDisabled,\n maxDate,\n minDate,\n });\n const selectCell = () => {\n if (!cell.inDisplayedMonth) setDisplayedMonth(cell.date);\n onSelectedDateChange?.(cell.date);\n };\n return (\n <Button\n accessibilityState={{ disabled, selected }}\n color={selected ? 'primary' : 'neutral'}\n disabled={disabled}\n interactionPolicy={interactionPolicy}\n onPress={selectCell}\n size=\"s\"\n testID={testID ? `${testID}-day-${cell.id}` : undefined}\n variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}\n >\n {cell.date.getDate()}\n </Button>\n );\n }}\n testID={testID ? `${testID}-grid` : undefined}\n viewportInteraction=\"locked\"\n width={gridWidth}\n />\n </View>\n );\n}\n\n/*** Produces the ordered weekday labels for one local calendar week. */\nfunction createWeekdayLabels(locale: string | undefined, weekStartsOn: number) {\n const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' });\n const sunday = new Date(2023, 0, 1);\n return Array.from({ length: GRID_COLUMNS }, (_, index) => {\n const day = new Date(\n sunday.getFullYear(),\n sunday.getMonth(),\n sunday.getDate() + ((weekStartsOn + index) % GRID_COLUMNS),\n );\n return { id: String(index), label: formatter.format(day) };\n });\n}\n\n/*** Moves a local month without carrying a day-of-month overflow into the target month. */\nfunction addMonths(month: Date, count: number): Date {\n return new Date(month.getFullYear(), month.getMonth() + count, 1);\n}\n\n/*** Normalizes a value to the first local day of its month. */\nfunction startOfLocalMonth(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), 1);\n}\n\n/*** Formats a Date as a timezone-independent local calendar identifier. */\nfunction formatCalendarDate(value: Date): string {\n const year = String(value.getFullYear()).padStart(4, '0');\n const month = String(value.getMonth() + 1).padStart(2, '0');\n const day = String(value.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/*** Compares local calendar dates using their canonical date-only identifiers. */\nfunction compareLocalDates(left: Date, right: Date): number {\n return formatCalendarDate(left).localeCompare(formatCalendarDate(right));\n}\n\n/*** Reports whether a candidate month contains at least one date inside the configured range. */\nfunction monthIntersectsRange(\n month: Date,\n minDate: Date | undefined,\n maxDate: Date | undefined,\n): boolean {\n const first = startOfLocalMonth(month);\n const last = new Date(first.getFullYear(), first.getMonth() + 1, 0);\n return (\n (!minDate || compareLocalDates(last, minDate) >= 0) &&\n (!maxDate || compareLocalDates(first, maxDate) <= 0)\n );\n}\n\n/*** Reports whether two values identify the same local calendar day. */\nfunction isSameLocalDay(left: Date, right: Date): boolean {\n return formatCalendarDate(left) === formatCalendarDate(right);\n}\n\n/*** Formats a display month with the caller's locale. */\nfunction formatMonthLabel(value: Date, locale: string | undefined): string {\n return new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(value);\n}\n"]}
1
+ {"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../../src/features/calendar/adapters/inbound/Calendar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAAE,MAAM,EAAE,MAAM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CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAkB,CAAC;AACxK,CAAC;AACD,kFAAkF;AAClF,SAAS,cAAc,CAAC,IAAU,EAAE,KAAW;IAC7C,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AACD,0CAA0C;AAC1C,SAAS,eAAe,CAAC,KAAW,EAAE,MAA0B,EAAE,IAAkB;IAClF,OAAO,IAAI,IAAI,CAAC,cAAc,CAC5B,MAAM,EACN,IAAI,KAAK,OAAO;QACd,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CACxD,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClB,CAAC;AACD,4DAA4D;AAC5D,SAAS,cAAc,CAAC,KAAW,EAAE,MAA0B;IAC7D,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7F,CAAC;AACD,4EAA4E;AAC5E,SAAS,UAAU,CAAC,MAA0B,EAAE,MAAc;IAC5D,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAClE,CAAC","sourcesContent":["import type { GridRectItem } from '@ankhorage/grid-view';\nimport React from 'react';\n\nimport type { CalendarProps, CalendarView } from '../../../../types/calendar';\nimport type {\n TemporalDate,\n TemporalEvent,\n TemporalTimedEvent,\n TemporalTimeZone,\n} from '../../../../types/temporal';\nimport { Button } from '../../../button/public';\nimport { GridView } from '../../../grid-view/public';\nimport { View } from '../../../layout/public';\nimport { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope';\nimport { TimeGrid } from '../../../time-grid/public';\nimport { Text } from '../../../typography/public';\nimport { createCalendarMonth } from '../../application/createCalendarMonth';\nimport { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled';\n\nconst GRID_COLUMNS = 7;\nconst GRID_ROWS = 6;\nconst MINUTES_PER_DAY = 24 * 60;\n\n/*** Renders controlled month, week, and day Calendar views through GridView and TimeGrid. */\nexport const Calendar = withZoraThemeScope(CalendarInner);\n\n/*** Connects serializable manifest state and the DatePicker-compatible code API to Calendar views. */\nfunction CalendarInner(props: CalendarProps) {\n const {\n defaultDisplayedDate,\n defaultDisplayedMonth,\n defaultView = 'month',\n density = 'regular',\n displayedDate: controlledDisplayedDate,\n displayedMonth: controlledDisplayedMonth,\n events = [],\n locale,\n onDateChange,\n onDisplayedMonthChange,\n onEventActivate,\n onViewChange,\n timeZone,\n view: controlledView,\n weekStartsOn = 0,\n } = props;\n const [uncontrolledDate, setUncontrolledDate] = React.useState(\n () =>\n parseCalendarDate(defaultDisplayedDate) ??\n startOfLocalDay(defaultDisplayedMonth ?? props.selectedDate ?? props.minDate ?? new Date()),\n );\n const [uncontrolledView, setUncontrolledView] = React.useState<CalendarView>(defaultView);\n const displayedDate =\n parseCalendarDate(controlledDisplayedDate) ??\n startOfLocalDay(controlledDisplayedMonth ?? uncontrolledDate);\n const view = controlledView ?? uncontrolledView;\n const setDisplayedDate = React.useCallback(\n (value: Date) => {\n const next = startOfLocalDay(value);\n if (controlledDisplayedDate === undefined && controlledDisplayedMonth === undefined)\n setUncontrolledDate(next);\n onDisplayedMonthChange?.(startOfLocalMonth(next));\n onDateChange?.({ date: formatCalendarDate(next) });\n },\n [controlledDisplayedDate, controlledDisplayedMonth, onDateChange, onDisplayedMonthChange],\n );\n const setView = React.useCallback(\n (next: CalendarView) => {\n if (controlledView === undefined) setUncontrolledView(next);\n onViewChange?.({ view: next });\n },\n [controlledView, onViewChange],\n );\n const navigate = React.useCallback(\n (offset: number) =>\n setDisplayedDate(\n view === 'month'\n ? addMonths(displayedDate, offset)\n : addDays(displayedDate, offset * (view === 'week' ? 7 : 1)),\n ),\n [displayedDate, setDisplayedDate, view],\n );\n return (\n <View\n accessibilityLabel=\"Calendar\"\n gap={density === 'compact' ? 's' : 'm'}\n testID={props.testID}\n >\n <View align=\"center\" direction=\"row\" justify=\"space-between\">\n <Button\n interactionPolicy={props.interactionPolicy}\n onPress={() => navigate(-1)}\n size=\"s\"\n testID={withTestId(props.testID, 'previous')}\n variant=\"ghost\"\n >\n Previous\n </Button>\n <Text accessibilityRole=\"header\" align=\"center\" variant=\"label\" weight=\"semiBold\">\n {formatViewLabel(displayedDate, locale, view)}\n </Text>\n <Button\n interactionPolicy={props.interactionPolicy}\n onPress={() => navigate(1)}\n size=\"s\"\n testID={withTestId(props.testID, 'next')}\n variant=\"ghost\"\n >\n Next\n </Button>\n </View>\n <View direction=\"row\" justify=\"space-between\">\n {(['day', 'week', 'month'] as const).map((candidate) => (\n <Button\n key={candidate}\n interactionPolicy={props.interactionPolicy}\n onPress={() => setView(candidate)}\n size=\"s\"\n testID={withTestId(props.testID, `view-${candidate}`)}\n variant={view === candidate ? 'solid' : 'ghost'}\n >\n {candidate}\n </Button>\n ))}\n <Button\n interactionPolicy={props.interactionPolicy}\n onPress={() => setDisplayedDate(new Date())}\n size=\"s\"\n testID={withTestId(props.testID, 'today')}\n variant=\"ghost\"\n >\n Today\n </Button>\n </View>\n {view === 'month' ? (\n <CalendarMonth\n {...props}\n activateEvent={(id) => onEventActivate?.({ eventId: id })}\n cellSize={density === 'compact' ? 42 : 48}\n displayedDate={displayedDate}\n events={events}\n timeZone={timeZone}\n weekStartsOn={weekStartsOn}\n onSelectDate={(date) => {\n setDisplayedDate(date);\n props.onSelectedDateChange?.(date);\n }}\n />\n ) : (\n <CalendarTimeView\n activateEvent={(id) => onEventActivate?.({ eventId: id })}\n displayedDate={displayedDate}\n events={events}\n interactionPolicy={props.interactionPolicy}\n locale={locale}\n testID={props.testID}\n timeZone={timeZone}\n view={view}\n weekStartsOn={weekStartsOn}\n />\n )}\n </View>\n );\n}\n\n/*** Renders the canonical GridView month geometry with stable event activation. */\nfunction CalendarMonth({\n activateEvent,\n cellSize,\n displayedDate,\n events,\n onSelectDate,\n timeZone,\n weekStartsOn,\n ...props\n}: Omit<CalendarProps, 'displayedDate'> & {\n readonly activateEvent: (eventId: string) => void;\n readonly cellSize: number;\n readonly displayedDate: Date;\n readonly events: readonly TemporalEvent[];\n readonly onSelectDate: (date: Date) => void;\n readonly timeZone: TemporalTimeZone | undefined;\n readonly weekStartsOn: number;\n}) {\n const cells = React.useMemo(\n () => createCalendarMonth(displayedDate, weekStartsOn),\n [displayedDate, weekStartsOn],\n );\n const gridItems = React.useMemo<readonly GridRectItem[]>(\n () =>\n cells.map((cell, index) => ({\n height: cellSize,\n id: cell.id,\n width: cellSize,\n x: (index % GRID_COLUMNS) * cellSize,\n y: Math.floor(index / GRID_COLUMNS) * cellSize,\n })),\n [cellSize, cells],\n );\n const cellsById = React.useMemo(() => new Map(cells.map((cell) => [cell.id, cell])), [cells]);\n const disabledDateIds = React.useMemo(\n () => new Set((props.disabledDates ?? []).map(formatCalendarDate)),\n [props.disabledDates],\n );\n const eventsByDate = React.useMemo(\n () =>\n createEventsByDate(\n events,\n cells.map((cell) => cell.date),\n timeZone,\n ),\n [cells, events, timeZone],\n );\n return (\n <>\n <View direction=\"row\">\n {createWeekdayLabels(props.locale, weekStartsOn).map((weekday) => (\n <View key={weekday.id} width={cellSize}>\n <Text align=\"center\" emphasis=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {weekday.label}\n </Text>\n </View>\n ))}\n </View>\n <GridView\n contentHeight={cellSize * GRID_ROWS}\n contentWidth={cellSize * GRID_COLUMNS}\n height={cellSize * GRID_ROWS}\n interactionPolicy={props.interactionPolicy}\n items={gridItems}\n overscanPixels={0}\n renderItem={(item) => {\n const cell = cellsById.get(item.id);\n if (!cell) return null;\n const selected =\n props.selectedDate !== null &&\n props.selectedDate !== undefined &&\n isSameLocalDay(props.selectedDate, cell.date);\n const disabled = isCalendarDateDisabled({\n date: cell.date,\n disabledDateIds,\n isDateDisabled: props.isDateDisabled,\n maxDate: props.maxDate,\n minDate: props.minDate,\n });\n const event = eventsByDate.get(cell.id)?.[0];\n return (\n <View gap=\"xxs\">\n <Button\n accessibilityState={{ disabled, selected }}\n color={selected ? 'primary' : 'neutral'}\n disabled={disabled}\n interactionPolicy={props.interactionPolicy}\n onPress={() => onSelectDate(cell.date)}\n size=\"s\"\n testID={withTestId(props.testID, `day-${cell.id}`)}\n variant={selected ? 'solid' : cell.inDisplayedMonth ? 'ghost' : 'outline'}\n >\n {cell.date.getDate()}\n </Button>\n {props.density !== 'compact' && event ? (\n <Button\n interactionPolicy={props.interactionPolicy}\n onPress={() => activateEvent(event.id)}\n size=\"s\"\n testID={withTestId(props.testID, `event-${event.id}`)}\n variant=\"outline\"\n >\n {event.title}\n </Button>\n ) : null}\n </View>\n );\n }}\n testID={withTestId(props.testID, 'grid')}\n viewportInteraction=\"locked\"\n width={cellSize * GRID_COLUMNS}\n />\n </>\n );\n}\n\n/*** Renders day and week event lanes through the existing TimeGrid foundation. */\nfunction CalendarTimeView({\n activateEvent,\n displayedDate,\n events,\n interactionPolicy,\n locale,\n testID,\n timeZone,\n view,\n weekStartsOn,\n}: {\n readonly activateEvent: (eventId: string) => void;\n readonly displayedDate: Date;\n readonly events: readonly TemporalEvent[];\n readonly interactionPolicy: CalendarProps['interactionPolicy'];\n readonly locale: string | undefined;\n readonly testID: string | undefined;\n readonly timeZone: TemporalTimeZone | undefined;\n readonly view: Exclude<CalendarView, 'month'>;\n readonly weekStartsOn: number;\n}) {\n const dates = view === 'day' ? [displayedDate] : createWeek(displayedDate, weekStartsOn);\n const eventById = new Map(events.map((event) => [event.id, event]));\n return (\n <TimeGrid\n contentWidth={MINUTES_PER_DAY}\n height={Math.min(56 * dates.length, 336)}\n interactionPolicy={interactionPolicy}\n intervals={createTimeGridIntervals(events, dates, timeZone)}\n lanes={dates.map((date) => ({ height: 56, id: formatCalendarDate(date) }))}\n onIntervalPress={(interval) => activateEvent(interval.id)}\n overscanPixels={0}\n renderInterval={(interval) => (\n <Text variant=\"caption\">{eventById.get(interval.id)?.title}</Text>\n )}\n renderLaneLabel={(lane) => (\n <Text variant=\"caption\">\n {formatDayLabel(parseCalendarDate(lane.id) ?? displayedDate, locale)}\n </Text>\n )}\n testID={withTestId(testID, view)}\n width={320}\n />\n );\n}\n\n/*** Produces weekday labels for one local calendar week. */\nfunction createWeekdayLabels(locale: string | undefined, weekStartsOn: number) {\n const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' });\n return Array.from({ length: GRID_COLUMNS }, (_, index) => ({\n id: String(index),\n label: formatter.format(addDays(new Date(2023, 0, 1), (weekStartsOn + index) % GRID_COLUMNS)),\n }));\n}\n\n/*** Creates the visible local dates for a week view. */\nfunction createWeek(date: Date, weekStartsOn: number): readonly Date[] {\n const first = addDays(date, -((date.getDay() - weekStartsOn + GRID_COLUMNS) % GRID_COLUMNS));\n return Array.from({ length: GRID_COLUMNS }, (_, index) => addDays(first, index));\n}\n\n/*** Indexes events by each displayed local date they intersect in the Calendar timezone. */\nfunction createEventsByDate(\n events: readonly TemporalEvent[],\n dates: readonly Date[],\n timeZone: TemporalTimeZone | undefined,\n): ReadonlyMap<string, readonly TemporalEvent[]> {\n return new Map(\n dates.map((date) => [\n formatCalendarDate(date),\n events.filter((event) => eventIntersectsDate(event, formatCalendarDate(date), timeZone)),\n ]),\n );\n}\n\n/*** Maps timed events into TimeGrid lane-local minute coordinates. */\nfunction createTimeGridIntervals(\n events: readonly TemporalEvent[],\n dates: readonly Date[],\n timeZone: TemporalTimeZone | undefined,\n) {\n return dates.flatMap((date) =>\n events.flatMap((event) => {\n const dateId = formatCalendarDate(date);\n if (!isTemporalTimedEvent(event)) return [];\n if (!eventIntersectsDate(event, dateId, timeZone)) return [];\n const zone = timeZone ?? event.range.timeZone;\n const start = getZonedDateTimeParts(event.range.start, zone);\n const end = getZonedDateTimeParts(resolveTimedEnd(event), zone);\n const startMinute = start.date === dateId ? start.hour * 60 + start.minute : 0;\n const endMinute = end.date === dateId ? end.hour * 60 + end.minute : MINUTES_PER_DAY;\n return [\n {\n extent: Math.max(1, endMinute - startMinute),\n id: event.id,\n laneId: dateId,\n start: startMinute,\n },\n ];\n }),\n );\n}\n\n/*** Reports whether an event overlaps one local Calendar date. */\nfunction eventIntersectsDate(\n event: TemporalEvent,\n date: TemporalDate,\n timeZone: TemporalTimeZone | undefined,\n): boolean {\n if (!isTemporalTimedEvent(event))\n return (\n event.range.start <= date &&\n date < (event.range.end ?? addDaysToDate(event.range.start, event.range.duration))\n );\n const zone = timeZone ?? event.range.timeZone;\n return (\n getZonedDateTimeParts(event.range.start, zone).date <= date &&\n date <= getZonedDateTimeParts(resolveTimedEnd(event), zone).date\n );\n}\n\n/*** Narrows a serializable Calendar event to the instant-based timed variant. */\nfunction isTemporalTimedEvent(event: TemporalEvent): event is TemporalTimedEvent {\n return event.range.allDay === false;\n}\n\n/*** Resolves the exclusive timed end, including the existing duration alternative. */\nfunction resolveTimedEnd(event: TemporalTimedEvent): string {\n return (\n event.range.end ??\n new Date(\n Date.parse(event.range.start) + parseDurationMinutes(event.range.duration) * 60_000,\n ).toISOString()\n );\n}\n\n/*** Reads a UTC instant as a local date and wall-clock time in an IANA timezone. */\nfunction getZonedDateTimeParts(\n instant: string,\n timeZone: TemporalTimeZone,\n): { date: TemporalDate; hour: number; minute: number } {\n const parts = new Intl.DateTimeFormat('en-CA', {\n day: '2-digit',\n hour: '2-digit',\n hourCycle: 'h23',\n minute: '2-digit',\n month: '2-digit',\n timeZone,\n year: 'numeric',\n }).formatToParts(new Date(instant));\n const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));\n return {\n date: `${values.year}-${values.month}-${values.day}` as TemporalDate,\n hour: Number(values.hour),\n minute: Number(values.minute),\n };\n}\n\n/*** Parses the bounded hour-and-minute duration form used for Calendar placement. */\nfunction parseDurationMinutes(duration: string | undefined): number {\n const match = /^PT(?:(\\d+)H)?(?:(\\d+)M)?$/.exec(duration ?? 'PT60M');\n return match ? Number(match[1] ?? 0) * 60 + Number(match[2] ?? 0) : 60;\n}\n\n/*** Adds a date-only duration without introducing a timezone. */\nfunction addDaysToDate(start: TemporalDate, duration: string | undefined): TemporalDate {\n return formatCalendarDate(\n addDays(\n parseCalendarDate(start) ?? new Date(),\n Math.max(1, Math.ceil(parseDurationMinutes(duration) / MINUTES_PER_DAY)),\n ),\n );\n}\n\n/*** Parses a local YYYY-MM-DD date without UTC conversion. */\nfunction parseCalendarDate(value: string | undefined): Date | undefined {\n if (!value || !/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return undefined;\n const [year, month, day] = value.split('-').map(Number);\n return year === undefined || month === undefined || day === undefined\n ? undefined\n : new Date(year, month - 1, day);\n}\n\n/*** Moves a local calendar day. */\nfunction addDays(date: Date, count: number): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate() + count);\n}\n/*** Moves a local month without day overflow. */\nfunction addMonths(month: Date, count: number): Date {\n const year = month.getFullYear();\n const targetMonth = month.getMonth() + count;\n const lastDay = new Date(year, targetMonth + 1, 0).getDate();\n return new Date(year, targetMonth, Math.min(month.getDate(), lastDay));\n}\n/*** Normalizes a value to the first local day of its month. */\nfunction startOfLocalMonth(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), 1);\n}\n/*** Normalizes a value to its local calendar date. */\nfunction startOfLocalDay(value: Date): Date {\n return new Date(value.getFullYear(), value.getMonth(), value.getDate());\n}\n/*** Formats a Date as a timezone-independent local calendar identifier. */\nfunction formatCalendarDate(value: Date): TemporalDate {\n return `${String(value.getFullYear()).padStart(4, '0')}-${String(value.getMonth() + 1).padStart(2, '0')}-${String(value.getDate()).padStart(2, '0')}` as TemporalDate;\n}\n/*** Compares local calendar dates using their canonical date-only identifiers. */\nfunction isSameLocalDay(left: Date, right: Date): boolean {\n return formatCalendarDate(left) === formatCalendarDate(right);\n}\n/*** Formats the controlled view title. */\nfunction formatViewLabel(value: Date, locale: string | undefined, view: CalendarView): string {\n return new Intl.DateTimeFormat(\n locale,\n view === 'month'\n ? { month: 'long', year: 'numeric' }\n : { day: 'numeric', month: 'short', year: 'numeric' },\n ).format(value);\n}\n/*** Formats a compact lane label for day and week views. */\nfunction formatDayLabel(value: Date, locale: string | undefined): string {\n return new Intl.DateTimeFormat(locale, { day: 'numeric', weekday: 'short' }).format(value);\n}\n/*** Resolves a test identifier suffix only when a test root is provided. */\nfunction withTestId(testID: string | undefined, suffix: string): string | undefined {\n return testID === undefined ? undefined : `${testID}-${suffix}`;\n}\n"]}
@@ -1,10 +1,112 @@
1
1
  export declare const calendarMeta: {
2
2
  readonly name: "Calendar";
3
3
  readonly category: "component";
4
- readonly description: "Reusable local-date calendar with a month view backed by GridView geometry.";
5
- readonly directManifestNode: false;
6
- readonly note: "Uses Date values and executable change callbacks; available through the public code API.";
4
+ readonly description: "Serializable Calendar with GridView month and TimeGrid day/week views.";
5
+ readonly directManifestNode: true;
7
6
  readonly allowedChildren: readonly [];
8
- readonly props: {};
7
+ readonly blueprint: {
8
+ readonly label: "Calendar";
9
+ readonly defaultProps: {
10
+ readonly displayedDate: "2026-12-04";
11
+ readonly events: readonly [];
12
+ readonly view: "month";
13
+ };
14
+ };
15
+ readonly events: {
16
+ readonly dateChange: {
17
+ readonly label: "Date change";
18
+ readonly eventType: "calendar.dateChange";
19
+ readonly payloadFields: readonly [{
20
+ readonly path: "date";
21
+ readonly type: "string";
22
+ readonly label: "Date";
23
+ }];
24
+ };
25
+ readonly viewChange: {
26
+ readonly label: "View change";
27
+ readonly eventType: "calendar.viewChange";
28
+ readonly payloadFields: readonly [{
29
+ readonly path: "view";
30
+ readonly type: "string";
31
+ readonly label: "View";
32
+ }];
33
+ };
34
+ readonly eventActivate: {
35
+ readonly label: "Activate event";
36
+ readonly eventType: "calendar.eventActivate";
37
+ readonly payloadFields: readonly [{
38
+ readonly path: "eventId";
39
+ readonly type: "string";
40
+ readonly label: "Event ID";
41
+ }];
42
+ };
43
+ };
44
+ readonly bindings: {
45
+ readonly props: {
46
+ readonly displayedDate: {
47
+ readonly value: {
48
+ readonly type: "string";
49
+ };
50
+ readonly acceptsFallback: true;
51
+ readonly acceptsTransforms: true;
52
+ };
53
+ readonly events: {
54
+ readonly value: {
55
+ readonly type: "array";
56
+ readonly itemType: "object";
57
+ };
58
+ readonly acceptsFallback: true;
59
+ readonly acceptsTransforms: true;
60
+ };
61
+ readonly view: {
62
+ readonly value: {
63
+ readonly type: "string";
64
+ };
65
+ readonly acceptsFallback: true;
66
+ };
67
+ };
68
+ };
69
+ readonly props: {
70
+ readonly displayedDate: {
71
+ readonly type: "string";
72
+ readonly category: "State";
73
+ readonly label: "Displayed date";
74
+ };
75
+ readonly defaultDisplayedDate: {
76
+ readonly type: "string";
77
+ readonly category: "State";
78
+ readonly label: "Initial displayed date";
79
+ };
80
+ readonly view: {
81
+ readonly type: "enum";
82
+ readonly category: "State";
83
+ readonly enum: readonly ["day", "week", "month"];
84
+ };
85
+ readonly timeZone: {
86
+ readonly type: "string";
87
+ readonly category: "State";
88
+ readonly label: "Timezone";
89
+ };
90
+ readonly events: {
91
+ readonly type: "array";
92
+ readonly category: "Data";
93
+ readonly label: "Events";
94
+ };
95
+ readonly locale: {
96
+ readonly type: "string";
97
+ readonly category: "Content";
98
+ readonly label: "Locale";
99
+ };
100
+ readonly weekStartsOn: {
101
+ readonly type: "number";
102
+ readonly category: "Layout";
103
+ readonly label: "Week starts on";
104
+ };
105
+ readonly density: {
106
+ readonly type: "enum";
107
+ readonly category: "Layout";
108
+ readonly enum: readonly ["regular", "compact"];
109
+ };
110
+ };
9
111
  };
10
112
  //# sourceMappingURL=calendarMeta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendarMeta.d.ts","sourceRoot":"","sources":["../../../src/features/calendar/calendarMeta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;CAQa,CAAC"}
1
+ {"version":3,"file":"calendarMeta.d.ts","sourceRoot":"","sources":["../../../src/features/calendar/calendarMeta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDa,CAAC"}