@ankhorage/zora 28.11.0 → 28.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +2 -1
- package/dist/capabilities/index.js.map +3 -3
- package/dist/constants/authoring.d.ts +3 -3
- package/dist/constants/authoring.d.ts.map +1 -1
- package/dist/constants/authoring.js +1 -0
- package/dist/constants/authoring.js.map +1 -1
- package/dist/features/accordion/accordionItemMeta.d.ts +1 -1
- package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
- package/dist/features/calendar/adapters/inbound/Calendar.d.ts.map +1 -1
- package/dist/features/calendar/adapters/inbound/Calendar.js +91 -7
- package/dist/features/calendar/adapters/inbound/Calendar.js.map +1 -1
- package/dist/features/card/cardMeta.d.ts +1 -1
- package/dist/features/card/mediaCardMeta.d.ts +1 -1
- package/dist/features/card/postCardMeta.d.ts +1 -1
- package/dist/features/chat/messageBubbleMeta.d.ts +1 -1
- package/dist/features/dialog/dialogMeta.d.ts +2 -2
- package/dist/features/gradient/gradientMeta.d.ts +1 -1
- package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
- package/dist/features/layout/gridMeta.d.ts +1 -1
- package/dist/features/layout/screenMeta.d.ts +1 -1
- package/dist/features/layout/scrollViewMeta.d.ts +1 -1
- package/dist/features/layout/viewMeta.d.ts +1 -1
- package/dist/features/list/flatListMeta.d.ts +1 -1
- package/dist/features/list/sectionListMeta.d.ts +1 -1
- package/dist/features/master-detail/masterDetailMeta.d.ts +1 -1
- package/dist/features/popover/popoverMeta.d.ts +1 -1
- package/dist/features/reader/meta.d.ts +2 -2
- package/dist/features/registry/bindableComponentMeta.d.ts +2 -2
- package/dist/features/scanner/meta.d.ts +2 -2
- package/dist/features/section/screenSectionMeta.d.ts +1 -1
- package/dist/features/surface/surfaceMeta.d.ts +1 -1
- package/dist/features/tabs/tabPanelMeta.d.ts +1 -1
- package/dist/features/time-grid/adapters/inbound/TimeGrid.d.ts +1 -1
- package/dist/features/time-grid/adapters/inbound/TimeGrid.d.ts.map +1 -1
- package/dist/features/time-grid/adapters/inbound/TimeGrid.js +45 -22
- package/dist/features/time-grid/adapters/inbound/TimeGrid.js.map +1 -1
- package/dist/types/color.d.ts +3 -3
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/color.js.map +1 -1
- package/dist/types/time-grid.d.ts +9 -0
- package/dist/types/time-grid.d.ts.map +1 -1
- package/dist/types/time-grid.js.map +1 -1
- package/package.json +4 -4
- package/src/constants/authoring.ts +1 -0
- package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +65 -4
- package/src/features/calendar/adapters/inbound/Calendar.tsx +172 -22
- package/src/features/time-grid/adapters/inbound/TimeGrid.tsx +64 -21
- package/src/types/color.ts +3 -3
- package/src/types/time-grid.ts +9 -0
- package/web-dist/chunks/{Accordion-j3esnt3f.js → Accordion-95003ycq.js} +139 -22
- package/web-dist/chunks/{Accordion-91qf4q27.js → Accordion-gb3mfjmx.js} +42 -19
- package/web-dist/components/calendar/Calendar.js +2 -2
- package/web-dist/components/color-picker/ColorPicker.types-0.d.ts +3 -3
- package/web-dist/components/color-tone/ColorTone.types-0.d.ts +3 -3
- package/web-dist/components/color-wheel/ColorWheel.types-0.d.ts +1 -1
- package/web-dist/components/date-picker/DatePicker.js +2 -2
- package/web-dist/components/time-grid/TimeGrid.d.ts +1 -1
- package/web-dist/components/time-grid/TimeGrid.dependency-2.d.ts +13 -0
- package/web-dist/components/time-grid/TimeGrid.js +1 -1
- package/web-dist/components/time-grid/TimeGrid.types-0.d.ts +10 -0
- package/web-dist/manifest.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-grid.d.ts","sourceRoot":"","sources":["../../src/types/time-grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"time-grid.d.ts","sourceRoot":"","sources":["../../src/types/time-grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;AAEpC,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACjD,mGAAmG;IACnG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAChE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IACvE,QAAQ,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IAC5F,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IACnE,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-grid.js","sourceRoot":"","sources":["../../src/types/time-grid.ts"],"names":[],"mappings":"","sourcesContent":["import type { GridLane, GridLaneInterval, GridViewport } from '@ankhorage/grid-view';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\n\n/** An ordered, variable-height track rendered by the generic TimeGrid. */\nexport type TimeGridLane = GridLane;\n\n/** A stable world-space interval rendered by the generic TimeGrid. */\nexport type TimeGridInterval = GridLaneInterval;\n\n/**\n * Code API for virtualized interval lanes. Domain adapters map dates, PPQ ticks, and other units\n * to numeric world coordinates before reaching this boundary.\n */\nexport interface TimeGridProps extends ZoraBaseProps {\n readonly lanes: readonly TimeGridLane[];\n readonly intervals: readonly TimeGridInterval[];\n readonly contentWidth: number;\n readonly width: number;\n readonly height: number;\n readonly zoom?: number;\n readonly overscanPixels?: number;\n readonly focusedIntervalId?: string;\n readonly onFocusedIntervalIdChange?: (id: string) => void;\n readonly revealPaddingPixels?: number;\n readonly selectedIntervalIds?: readonly string[];\n readonly onIntervalPress?: (interval: TimeGridInterval) => void;\n readonly onViewportChange?: (viewport: GridViewport) => void;\n readonly onVisibleIntervalIdsChange?: (ids: readonly string[]) => void;\n readonly renderInterval: (interval: TimeGridInterval, selected: boolean) => React.ReactNode;\n readonly renderLaneLabel?: (lane: TimeGridLane) => React.ReactNode;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"time-grid.js","sourceRoot":"","sources":["../../src/types/time-grid.ts"],"names":[],"mappings":"","sourcesContent":["import type { GridLane, GridLaneInterval, GridViewport } from '@ankhorage/grid-view';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\nimport type { GridWorldLayerContext } from './grid-view';\n\n/** An ordered, variable-height track rendered by the generic TimeGrid. */\nexport type TimeGridLane = GridLane;\n\n/** A stable world-space interval rendered by the generic TimeGrid. */\nexport type TimeGridInterval = GridLaneInterval;\n\n/**\n * Code API for virtualized interval lanes. Domain adapters map dates, PPQ ticks, and other units\n * to numeric world coordinates before reaching this boundary.\n */\nexport interface TimeGridProps extends ZoraBaseProps {\n readonly lanes: readonly TimeGridLane[];\n readonly intervals: readonly TimeGridInterval[];\n readonly contentWidth: number;\n /** Required for vertical time progression, where intervals extend down the grid. */\n readonly contentHeight?: number;\n readonly width: number;\n readonly height: number;\n /** Selects whether lane intervals progress across or down the shared GridView world. */\n readonly orientation?: 'horizontal' | 'vertical';\n /** Controls the shared viewport affordances for compositions that provide their own navigation. */\n readonly viewportControls?: 'hidden' | 'visible';\n readonly zoom?: number;\n readonly overscanPixels?: number;\n readonly focusedIntervalId?: string;\n readonly onFocusedIntervalIdChange?: (id: string) => void;\n readonly revealPaddingPixels?: number;\n readonly selectedIntervalIds?: readonly string[];\n readonly onIntervalPress?: (interval: TimeGridInterval) => void;\n readonly onViewportChange?: (viewport: GridViewport) => void;\n readonly onVisibleIntervalIdsChange?: (ids: readonly string[]) => void;\n readonly renderInterval: (interval: TimeGridInterval, selected: boolean) => React.ReactNode;\n readonly renderLaneLabel?: (lane: TimeGridLane) => React.ReactNode;\n /** Draws owner-defined geometry behind virtualized intervals without duplicating GridView. */\n readonly renderWorldLayer?: (layer: GridWorldLayerContext) => React.ReactNode;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/zora",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "28.11.
|
|
4
|
+
"version": "28.11.1",
|
|
5
5
|
"description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
|
|
6
6
|
"homepage": "https://github.com/ankhorage/zora#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ankhorage/capability": "^0.2.3",
|
|
46
|
-
"@ankhorage/color-theory": "^0.
|
|
47
|
-
"@ankhorage/contracts": "^28.1.
|
|
46
|
+
"@ankhorage/color-theory": "^0.4.0",
|
|
47
|
+
"@ankhorage/contracts": "^28.1.1",
|
|
48
48
|
"@ankhorage/game": "^0.1.4",
|
|
49
49
|
"@ankhorage/graph": "^0.5.0",
|
|
50
50
|
"@ankhorage/grid-view": "^0.5.0",
|
|
51
51
|
"@ankhorage/reader": "^0.1.4",
|
|
52
52
|
"@ankhorage/runtime": "^5.8.4",
|
|
53
|
-
"@ankhorage/surface": "^9.8.
|
|
53
|
+
"@ankhorage/surface": "^9.8.14",
|
|
54
54
|
"@ankhorage/utility": "^1.11.0",
|
|
55
55
|
"expo-asset": "~57.0.21",
|
|
56
56
|
"expo-audio": "~57.0.5",
|
|
@@ -81,6 +81,62 @@ test('selects adjacent days through the locked GridView in regular and compact c
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
test('renders responsive day columns, a time axis, and activatable event cards in a direct week Calendar', async () => {
|
|
85
|
+
const [{ Calendar }, { ZoraProvider }] = (await Promise.all([
|
|
86
|
+
import(pathToFileURL(join(webDistRoot, 'components', 'calendar', 'index.js')).href),
|
|
87
|
+
import(pathToFileURL(join(webDistRoot, 'runtime/ZoraProvider.js')).href),
|
|
88
|
+
])) as [{ Calendar: typeof CalendarComponent }, { ZoraProvider: typeof ZoraProviderComponent }];
|
|
89
|
+
|
|
90
|
+
await withBrowserAsync(async (host) => {
|
|
91
|
+
const activations: string[] = [];
|
|
92
|
+
const root = createRoot(host);
|
|
93
|
+
try {
|
|
94
|
+
await interactAsync(() =>
|
|
95
|
+
root.render(
|
|
96
|
+
<ZoraProvider mode="light">
|
|
97
|
+
<Calendar
|
|
98
|
+
defaultDisplayedDate="2026-12-04"
|
|
99
|
+
defaultView="week"
|
|
100
|
+
events={[
|
|
101
|
+
{
|
|
102
|
+
id: 'planning',
|
|
103
|
+
range: {
|
|
104
|
+
allDay: false,
|
|
105
|
+
end: '2026-11-30T01:00:00Z',
|
|
106
|
+
start: '2026-11-30T00:00:00Z',
|
|
107
|
+
timeZone: 'Europe/Zurich',
|
|
108
|
+
},
|
|
109
|
+
title: 'Planning',
|
|
110
|
+
},
|
|
111
|
+
]}
|
|
112
|
+
onEventActivate={({ eventId }) => activations.push(eventId)}
|
|
113
|
+
testID="direct-week-calendar"
|
|
114
|
+
timeZone="Europe/Zurich"
|
|
115
|
+
weekStartsOn={1}
|
|
116
|
+
/>
|
|
117
|
+
</ZoraProvider>,
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const grid = host.querySelector<HTMLElement>(
|
|
122
|
+
'[data-testid="direct-week-calendar-week-grid-viewport"]',
|
|
123
|
+
);
|
|
124
|
+
const event = host.querySelector<HTMLButtonElement>(
|
|
125
|
+
'[data-testid="direct-week-calendar-week-grid-interval-2026-11-30:planning"]',
|
|
126
|
+
);
|
|
127
|
+
if (!grid || !event) throw new Error('Missing responsive week Calendar grid or event card');
|
|
128
|
+
|
|
129
|
+
expect(host.textContent).toContain('30 Mon');
|
|
130
|
+
expect(host.textContent).toContain('Planning');
|
|
131
|
+
expect(grid.getAttribute('style')).not.toContain('width: 320px');
|
|
132
|
+
await interactAsync(() => event.click());
|
|
133
|
+
expect(activations).toEqual(['planning']);
|
|
134
|
+
} finally {
|
|
135
|
+
await interactAsync(() => root.unmount());
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
84
140
|
test('renders a Calendar manifest and reactively updates its controlled date and events', async () => {
|
|
85
141
|
const [{ Calendar }, { ZoraProvider }] = (await Promise.all([
|
|
86
142
|
import(pathToFileURL(join(webDistRoot, 'components', 'calendar', 'index.js')).href),
|
|
@@ -89,7 +145,7 @@ test('renders a Calendar manifest and reactively updates its controlled date and
|
|
|
89
145
|
const node = {
|
|
90
146
|
id: 'calendar',
|
|
91
147
|
type: 'Calendar',
|
|
92
|
-
props: { testID: 'manifest-calendar', view: '
|
|
148
|
+
props: { testID: 'manifest-calendar', view: 'week' },
|
|
93
149
|
} as const satisfies UiNode;
|
|
94
150
|
const bindings = {
|
|
95
151
|
calendar: {
|
|
@@ -125,8 +181,8 @@ test('renders a Calendar manifest and reactively updates its controlled date and
|
|
|
125
181
|
title: 'Zurich',
|
|
126
182
|
range: {
|
|
127
183
|
allDay: false,
|
|
128
|
-
start: '2026-12-
|
|
129
|
-
end: '2026-12-
|
|
184
|
+
start: '2026-12-04T00:00:00Z',
|
|
185
|
+
end: '2026-12-04T01:00:00Z',
|
|
130
186
|
timeZone: 'Europe/Zurich',
|
|
131
187
|
},
|
|
132
188
|
},
|
|
@@ -156,11 +212,15 @@ test('renders a Calendar manifest and reactively updates its controlled date and
|
|
|
156
212
|
try {
|
|
157
213
|
await interactAsync(render);
|
|
158
214
|
expect(host.textContent).toContain('Zurich');
|
|
215
|
+
expect(host.textContent).toContain('4 Fri');
|
|
216
|
+
expect(
|
|
217
|
+
host.querySelector('[data-testid="manifest-calendar-week-grid-viewport"]'),
|
|
218
|
+
).not.toBeNull();
|
|
159
219
|
const next = host.querySelector<HTMLButtonElement>('[data-testid="manifest-calendar-next"]');
|
|
160
220
|
if (!next) throw new Error('Missing manifest Calendar next navigation');
|
|
161
221
|
await interactAsync(() => next.click());
|
|
162
222
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
163
|
-
expect(stateAdapter.get<string>('calendar.date')).toEqual({ data: '
|
|
223
|
+
expect(stateAdapter.get<string>('calendar.date')).toEqual({ data: '2026-12-11', ok: true });
|
|
164
224
|
stateAdapter.set('calendar.events', []);
|
|
165
225
|
await interactAsync(render);
|
|
166
226
|
expect(host.textContent).not.toContain('Zurich');
|
|
@@ -185,6 +245,7 @@ function formatDate(value: Date): string {
|
|
|
185
245
|
/*** Mounts an isolated browser surface and restores global DOM bindings after a test. */
|
|
186
246
|
async function withBrowserAsync(testBrowser: (host: HTMLElement) => Promise<void>): Promise<void> {
|
|
187
247
|
const browserWindow = new Window();
|
|
248
|
+
Object.defineProperty(browserWindow, 'innerWidth', { configurable: true, value: 1024 });
|
|
188
249
|
const keys = ['window', 'document', 'Node', 'navigator', 'IS_REACT_ACT_ENVIRONMENT'] as const;
|
|
189
250
|
const previous = keys.map(
|
|
190
251
|
(key) => [key, Object.getOwnPropertyDescriptor(globalThis, key)] as const,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GridRectItem } from '@ankhorage/grid-view';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useWindowDimensions, View as NativeView } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import type { CalendarProps, CalendarView } from '../../../../types/calendar';
|
|
5
6
|
import type {
|
|
@@ -20,6 +21,11 @@ import { isCalendarDateDisabled } from '../../application/isCalendarDateDisabled
|
|
|
20
21
|
const GRID_COLUMNS = 7;
|
|
21
22
|
const GRID_ROWS = 6;
|
|
22
23
|
const MINUTES_PER_DAY = 24 * 60;
|
|
24
|
+
const TIME_AXIS_WIDTH = 56;
|
|
25
|
+
const TIME_GRID_HEADER_HEIGHT = 36;
|
|
26
|
+
const MINIMUM_DAY_WIDTH = 96;
|
|
27
|
+
const MINIMUM_TIME_GRID_HEIGHT = 360;
|
|
28
|
+
const MAXIMUM_TIME_GRID_HEIGHT = 720;
|
|
23
29
|
|
|
24
30
|
/*** Renders controlled month, week, and day Calendar views through GridView and TimeGrid. */
|
|
25
31
|
export const Calendar = withZoraThemeScope(CalendarInner);
|
|
@@ -301,28 +307,163 @@ function CalendarTimeView({
|
|
|
301
307
|
readonly view: Exclude<CalendarView, 'month'>;
|
|
302
308
|
readonly weekStartsOn: number;
|
|
303
309
|
}) {
|
|
304
|
-
const
|
|
305
|
-
const
|
|
310
|
+
const { height: windowHeight, width: windowWidth } = useWindowDimensions();
|
|
311
|
+
const [measuredWidth, setMeasuredWidth] = React.useState(0);
|
|
312
|
+
const dates = React.useMemo(
|
|
313
|
+
() => (view === 'day' ? [displayedDate] : createWeek(displayedDate, weekStartsOn)),
|
|
314
|
+
[displayedDate, view, weekStartsOn],
|
|
315
|
+
);
|
|
316
|
+
const width = measuredWidth || windowWidth || getBrowserViewportWidth();
|
|
317
|
+
const contentWidth = Math.max(width, TIME_AXIS_WIDTH + dates.length * MINIMUM_DAY_WIDTH);
|
|
318
|
+
const dayWidth = (contentWidth - TIME_AXIS_WIDTH) / dates.length;
|
|
319
|
+
const height = Math.max(
|
|
320
|
+
MINIMUM_TIME_GRID_HEIGHT,
|
|
321
|
+
Math.min(MAXIMUM_TIME_GRID_HEIGHT, windowHeight - 180),
|
|
322
|
+
);
|
|
323
|
+
const intervals = React.useMemo(
|
|
324
|
+
() => createTimeGridIntervals(events, dates, timeZone),
|
|
325
|
+
[dates, events, timeZone],
|
|
326
|
+
);
|
|
327
|
+
const eventByIntervalId = React.useMemo(
|
|
328
|
+
() =>
|
|
329
|
+
new Map(
|
|
330
|
+
intervals.flatMap((interval) => {
|
|
331
|
+
const event = events.find((candidate) => interval.id.endsWith(`:${candidate.id}`));
|
|
332
|
+
return event ? [[interval.id, event] as const] : [];
|
|
333
|
+
}),
|
|
334
|
+
),
|
|
335
|
+
[events, intervals],
|
|
336
|
+
);
|
|
306
337
|
return (
|
|
307
|
-
<
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
interactionPolicy={interactionPolicy}
|
|
311
|
-
intervals={createTimeGridIntervals(events, dates, timeZone)}
|
|
312
|
-
lanes={dates.map((date) => ({ height: 56, id: formatCalendarDate(date) }))}
|
|
313
|
-
onIntervalPress={(interval) => activateEvent(interval.id)}
|
|
314
|
-
overscanPixels={0}
|
|
315
|
-
renderInterval={(interval) => (
|
|
316
|
-
<Text variant="caption">{eventById.get(interval.id)?.title}</Text>
|
|
317
|
-
)}
|
|
318
|
-
renderLaneLabel={(lane) => (
|
|
319
|
-
<Text variant="caption">
|
|
320
|
-
{formatDayLabel(parseCalendarDate(lane.id) ?? displayedDate, locale)}
|
|
321
|
-
</Text>
|
|
322
|
-
)}
|
|
338
|
+
<NativeView
|
|
339
|
+
onLayout={(event) => setMeasuredWidth(event.nativeEvent.layout.width)}
|
|
340
|
+
style={{ height, width: '100%' }}
|
|
323
341
|
testID={withTestId(testID, view)}
|
|
324
|
-
|
|
325
|
-
|
|
342
|
+
>
|
|
343
|
+
{width > 0 ? (
|
|
344
|
+
<TimeGrid
|
|
345
|
+
contentHeight={TIME_GRID_HEADER_HEIGHT + MINUTES_PER_DAY}
|
|
346
|
+
contentWidth={contentWidth}
|
|
347
|
+
height={height}
|
|
348
|
+
interactionPolicy={interactionPolicy}
|
|
349
|
+
intervals={intervals}
|
|
350
|
+
lanes={[
|
|
351
|
+
{ height: TIME_AXIS_WIDTH, id: 'time-axis' },
|
|
352
|
+
...dates.map((date) => ({ height: dayWidth, id: formatCalendarDate(date) })),
|
|
353
|
+
]}
|
|
354
|
+
onIntervalPress={(interval) => {
|
|
355
|
+
const event = eventByIntervalId.get(interval.id);
|
|
356
|
+
if (event) activateEvent(event.id);
|
|
357
|
+
}}
|
|
358
|
+
orientation="vertical"
|
|
359
|
+
overscanPixels={0}
|
|
360
|
+
renderInterval={(interval) => (
|
|
361
|
+
<View bg="subtle" borderColor="primary" borderWidth={1} gap="xxs" p="xs" radius="s">
|
|
362
|
+
<Text numberOfLines={1} variant="caption" weight="semiBold">
|
|
363
|
+
{eventByIntervalId.get(interval.id)?.title}
|
|
364
|
+
</Text>
|
|
365
|
+
</View>
|
|
366
|
+
)}
|
|
367
|
+
renderWorldLayer={(layer) => (
|
|
368
|
+
<CalendarTimeGridGeometry
|
|
369
|
+
dates={dates}
|
|
370
|
+
dayWidth={dayWidth}
|
|
371
|
+
layer={layer}
|
|
372
|
+
locale={locale}
|
|
373
|
+
/>
|
|
374
|
+
)}
|
|
375
|
+
testID={withTestId(testID, `${view}-grid`)}
|
|
376
|
+
viewportControls="hidden"
|
|
377
|
+
width={width}
|
|
378
|
+
/>
|
|
379
|
+
) : null}
|
|
380
|
+
</NativeView>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/*** Draws the fixed Calendar time axis, weekday headers, and hourly world geometry. */
|
|
385
|
+
function CalendarTimeGridGeometry({
|
|
386
|
+
dates,
|
|
387
|
+
dayWidth,
|
|
388
|
+
layer,
|
|
389
|
+
locale,
|
|
390
|
+
}: {
|
|
391
|
+
readonly dates: readonly Date[];
|
|
392
|
+
readonly dayWidth: number;
|
|
393
|
+
readonly layer: {
|
|
394
|
+
readonly origin: { readonly x: number; readonly y: number };
|
|
395
|
+
readonly pixelsPerUnitX: number;
|
|
396
|
+
readonly pixelsPerUnitY: number;
|
|
397
|
+
readonly width: number;
|
|
398
|
+
readonly height: number;
|
|
399
|
+
};
|
|
400
|
+
readonly locale: string | undefined;
|
|
401
|
+
}) {
|
|
402
|
+
const hourFormatter = new Intl.DateTimeFormat(locale, { hour: 'numeric' });
|
|
403
|
+
return (
|
|
404
|
+
<NativeView pointerEvents="none" style={{ height: layer.height, width: layer.width }}>
|
|
405
|
+
{dates.map((date, index) => (
|
|
406
|
+
<React.Fragment key={formatCalendarDate(date)}>
|
|
407
|
+
<NativeView
|
|
408
|
+
style={{
|
|
409
|
+
borderLeftWidth: 1,
|
|
410
|
+
height: layer.height - layer.origin.y,
|
|
411
|
+
left: layer.origin.x + (TIME_AXIS_WIDTH + index * dayWidth) * layer.pixelsPerUnitX,
|
|
412
|
+
position: 'absolute',
|
|
413
|
+
top: layer.origin.y,
|
|
414
|
+
width: dayWidth * layer.pixelsPerUnitX,
|
|
415
|
+
}}
|
|
416
|
+
>
|
|
417
|
+
<Text align="center" variant="caption" weight="semiBold">
|
|
418
|
+
{formatDayLabel(date, locale)}
|
|
419
|
+
</Text>
|
|
420
|
+
</NativeView>
|
|
421
|
+
{index === dates.length - 1 ? (
|
|
422
|
+
<NativeView
|
|
423
|
+
style={{
|
|
424
|
+
borderLeftWidth: 1,
|
|
425
|
+
height: layer.height - layer.origin.y,
|
|
426
|
+
left:
|
|
427
|
+
layer.origin.x +
|
|
428
|
+
(TIME_AXIS_WIDTH + (index + 1) * dayWidth) * layer.pixelsPerUnitX,
|
|
429
|
+
position: 'absolute',
|
|
430
|
+
top: layer.origin.y,
|
|
431
|
+
}}
|
|
432
|
+
/>
|
|
433
|
+
) : null}
|
|
434
|
+
</React.Fragment>
|
|
435
|
+
))}
|
|
436
|
+
{Array.from({ length: 25 }, (_, hour) => {
|
|
437
|
+
const top = layer.origin.y + (TIME_GRID_HEADER_HEIGHT + hour * 60) * layer.pixelsPerUnitY;
|
|
438
|
+
return (
|
|
439
|
+
<React.Fragment key={hour}>
|
|
440
|
+
<NativeView
|
|
441
|
+
style={{
|
|
442
|
+
borderTopWidth: 1,
|
|
443
|
+
left: layer.origin.x + TIME_AXIS_WIDTH * layer.pixelsPerUnitX,
|
|
444
|
+
position: 'absolute',
|
|
445
|
+
top,
|
|
446
|
+
width: layer.width - TIME_AXIS_WIDTH * layer.pixelsPerUnitX,
|
|
447
|
+
}}
|
|
448
|
+
/>
|
|
449
|
+
{hour < 24 ? (
|
|
450
|
+
<Text
|
|
451
|
+
align="right"
|
|
452
|
+
style={{
|
|
453
|
+
left: layer.origin.x,
|
|
454
|
+
position: 'absolute',
|
|
455
|
+
top,
|
|
456
|
+
width: TIME_AXIS_WIDTH * layer.pixelsPerUnitX - 6,
|
|
457
|
+
}}
|
|
458
|
+
variant="caption"
|
|
459
|
+
>
|
|
460
|
+
{hourFormatter.format(new Date(2023, 0, 1, hour))}
|
|
461
|
+
</Text>
|
|
462
|
+
) : null}
|
|
463
|
+
</React.Fragment>
|
|
464
|
+
);
|
|
465
|
+
})}
|
|
466
|
+
</NativeView>
|
|
326
467
|
);
|
|
327
468
|
}
|
|
328
469
|
|
|
@@ -374,9 +515,9 @@ function createTimeGridIntervals(
|
|
|
374
515
|
return [
|
|
375
516
|
{
|
|
376
517
|
extent: Math.max(1, endMinute - startMinute),
|
|
377
|
-
id: event.id
|
|
518
|
+
id: `${dateId}:${event.id}`,
|
|
378
519
|
laneId: dateId,
|
|
379
|
-
start: startMinute,
|
|
520
|
+
start: TIME_GRID_HEADER_HEIGHT + startMinute,
|
|
380
521
|
},
|
|
381
522
|
];
|
|
382
523
|
}),
|
|
@@ -503,6 +644,15 @@ function formatViewLabel(value: Date, locale: string | undefined, view: Calendar
|
|
|
503
644
|
function formatDayLabel(value: Date, locale: string | undefined): string {
|
|
504
645
|
return new Intl.DateTimeFormat(locale, { day: 'numeric', weekday: 'short' }).format(value);
|
|
505
646
|
}
|
|
647
|
+
/*** Reads the browser viewport only when native layout measurement is not yet available. */
|
|
648
|
+
function getBrowserViewportWidth(): number {
|
|
649
|
+
const browserWindow = Reflect.get(globalThis, 'window');
|
|
650
|
+
return typeof browserWindow === 'object' &&
|
|
651
|
+
'innerWidth' in browserWindow &&
|
|
652
|
+
typeof browserWindow.innerWidth === 'number'
|
|
653
|
+
? Math.max(0, browserWindow.innerWidth)
|
|
654
|
+
: 0;
|
|
655
|
+
}
|
|
506
656
|
/*** Resolves a test identifier suffix only when a test root is provided. */
|
|
507
657
|
function withTestId(testID: string | undefined, suffix: string): string | undefined {
|
|
508
658
|
return testID === undefined ? undefined : `${testID}-${suffix}`;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getLaneIntervalPlacement,
|
|
3
|
+
getVisibleGridItems,
|
|
4
|
+
type GridLaneIntervalPlacement,
|
|
5
|
+
type GridViewport,
|
|
6
|
+
} from '@ankhorage/grid-view';
|
|
2
7
|
import React from 'react';
|
|
3
8
|
import { Pressable, View } from 'react-native';
|
|
4
9
|
|
|
@@ -10,6 +15,7 @@ import { TimeGridKeyboardProxy } from './TimeGridKeyboardProxy';
|
|
|
10
15
|
|
|
11
16
|
/*** Presents virtualized variable-height interval lanes through ZORA's shared GridView renderer. */
|
|
12
17
|
export function TimeGrid({
|
|
18
|
+
contentHeight: requestedContentHeight,
|
|
13
19
|
contentWidth,
|
|
14
20
|
focusedIntervalId,
|
|
15
21
|
height,
|
|
@@ -20,12 +26,15 @@ export function TimeGrid({
|
|
|
20
26
|
onIntervalPress,
|
|
21
27
|
onViewportChange,
|
|
22
28
|
onVisibleIntervalIdsChange,
|
|
29
|
+
orientation = 'horizontal',
|
|
23
30
|
overscanPixels,
|
|
24
31
|
renderInterval,
|
|
25
32
|
renderLaneLabel,
|
|
33
|
+
renderWorldLayer,
|
|
26
34
|
revealPaddingPixels,
|
|
27
35
|
selectedIntervalIds = [],
|
|
28
36
|
testID,
|
|
37
|
+
viewportControls,
|
|
29
38
|
width,
|
|
30
39
|
zoom,
|
|
31
40
|
}: TimeGridProps) {
|
|
@@ -49,18 +58,29 @@ export function TimeGrid({
|
|
|
49
58
|
[intervals],
|
|
50
59
|
);
|
|
51
60
|
const selectedIds = React.useMemo(() => new Set(selectedIntervalIds), [selectedIntervalIds]);
|
|
52
|
-
const
|
|
61
|
+
const laneExtent = React.useMemo(
|
|
53
62
|
() => lanes.reduce((total, lane) => total + lane.height, 0),
|
|
54
63
|
[lanes],
|
|
55
64
|
);
|
|
65
|
+
const contentHeight = orientation === 'vertical' ? (requestedContentHeight ?? 0) : laneExtent;
|
|
66
|
+
const resolvedContentWidth = orientation === 'vertical' ? laneExtent : contentWidth;
|
|
67
|
+
const placements = React.useMemo(
|
|
68
|
+
() =>
|
|
69
|
+
orientation === 'vertical'
|
|
70
|
+
? createVerticalPlacements(lanes, intervals)
|
|
71
|
+
: intervals.map((interval) => getLaneIntervalPlacement(lanes, interval)),
|
|
72
|
+
[intervals, lanes, orientation],
|
|
73
|
+
);
|
|
56
74
|
const visibleIntervals = React.useMemo(
|
|
57
|
-
() =>
|
|
58
|
-
|
|
75
|
+
() =>
|
|
76
|
+
orientation === 'vertical'
|
|
77
|
+
? getVisibleGridItems(placements, viewport, overscanPixels)
|
|
78
|
+
: resolveTimeGridVisibleIntervals(lanes, intervals, viewport, overscanPixels),
|
|
79
|
+
[intervals, lanes, orientation, overscanPixels, placements, viewport],
|
|
59
80
|
);
|
|
60
81
|
const focusedPlacement = React.useMemo(() => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [focusedIntervalId, intervals, lanes]);
|
|
82
|
+
return placements.find((interval) => interval.id === focusedIntervalId);
|
|
83
|
+
}, [focusedIntervalId, placements]);
|
|
64
84
|
const gridItems = React.useMemo(
|
|
65
85
|
() =>
|
|
66
86
|
focusedPlacement && !visibleIntervals.some((interval) => interval.id === focusedPlacement.id)
|
|
@@ -71,12 +91,12 @@ export function TimeGrid({
|
|
|
71
91
|
const labelIntervals = React.useMemo(
|
|
72
92
|
() =>
|
|
73
93
|
lanes.map((lane) => ({
|
|
74
|
-
extent:
|
|
94
|
+
extent: resolvedContentWidth,
|
|
75
95
|
id: `lane-label-${lane.id}`,
|
|
76
96
|
laneId: lane.id,
|
|
77
97
|
start: 0,
|
|
78
98
|
})),
|
|
79
|
-
[
|
|
99
|
+
[lanes, resolvedContentWidth],
|
|
80
100
|
);
|
|
81
101
|
const visibleLabels = React.useMemo(
|
|
82
102
|
() => resolveTimeGridVisibleIntervals(lanes, labelIntervals, viewport, overscanPixels),
|
|
@@ -97,22 +117,14 @@ export function TimeGrid({
|
|
|
97
117
|
|
|
98
118
|
const resolveNextFocusId = React.useCallback(
|
|
99
119
|
(intervalId: string, direction: 'down' | 'left' | 'right' | 'up') => {
|
|
100
|
-
|
|
101
|
-
height: contentHeight,
|
|
102
|
-
offsetX: 0,
|
|
103
|
-
offsetY: 0,
|
|
104
|
-
pixelsPerUnitX: 1,
|
|
105
|
-
pixelsPerUnitY: 1,
|
|
106
|
-
width: contentWidth,
|
|
107
|
-
});
|
|
108
|
-
return resolveTimeGridNextFocusId(allIntervals, intervalId, direction);
|
|
120
|
+
return resolveTimeGridNextFocusId(placements, intervalId, direction);
|
|
109
121
|
},
|
|
110
|
-
[
|
|
122
|
+
[placements],
|
|
111
123
|
);
|
|
112
124
|
|
|
113
125
|
return (
|
|
114
126
|
<View style={{ flexDirection: 'row', height, width }} testID={testID}>
|
|
115
|
-
{renderLaneLabel ? (
|
|
127
|
+
{orientation === 'horizontal' && renderLaneLabel ? (
|
|
116
128
|
<View
|
|
117
129
|
accessibilityElementsHidden
|
|
118
130
|
pointerEvents="none"
|
|
@@ -139,7 +151,7 @@ export function TimeGrid({
|
|
|
139
151
|
) : null}
|
|
140
152
|
<GridView
|
|
141
153
|
contentHeight={contentHeight}
|
|
142
|
-
contentWidth={
|
|
154
|
+
contentWidth={resolvedContentWidth}
|
|
143
155
|
focusedItemId={focusedIntervalId}
|
|
144
156
|
height={height}
|
|
145
157
|
interactionPolicy={interactionPolicy}
|
|
@@ -179,7 +191,9 @@ export function TimeGrid({
|
|
|
179
191
|
);
|
|
180
192
|
}}
|
|
181
193
|
revealPaddingPixels={revealPaddingPixels}
|
|
194
|
+
renderWorldLayer={renderWorldLayer}
|
|
182
195
|
testID={testID === undefined ? undefined : `${testID}-viewport`}
|
|
196
|
+
viewportControls={viewportControls}
|
|
183
197
|
width={width}
|
|
184
198
|
zoom={zoom}
|
|
185
199
|
/>
|
|
@@ -187,6 +201,35 @@ export function TimeGrid({
|
|
|
187
201
|
);
|
|
188
202
|
}
|
|
189
203
|
|
|
204
|
+
/*** Maps date lanes and time intervals into a conventional vertical-time world. */
|
|
205
|
+
function createVerticalPlacements(
|
|
206
|
+
lanes: TimeGridProps['lanes'],
|
|
207
|
+
intervals: TimeGridProps['intervals'],
|
|
208
|
+
): readonly GridLaneIntervalPlacement[] {
|
|
209
|
+
const offsets = new Map<string, number>();
|
|
210
|
+
lanes.reduce((offset, lane) => {
|
|
211
|
+
offsets.set(lane.id, offset);
|
|
212
|
+
return offset + lane.height;
|
|
213
|
+
}, 0);
|
|
214
|
+
return intervals.flatMap((interval) => {
|
|
215
|
+
const x = offsets.get(interval.laneId);
|
|
216
|
+
const laneIndex = lanes.findIndex((candidate) => candidate.id === interval.laneId);
|
|
217
|
+
const lane = lanes.find((candidate) => candidate.id === interval.laneId);
|
|
218
|
+
return x === undefined || lane === undefined || laneIndex < 0
|
|
219
|
+
? []
|
|
220
|
+
: [
|
|
221
|
+
{
|
|
222
|
+
...interval,
|
|
223
|
+
height: interval.extent,
|
|
224
|
+
laneIndex,
|
|
225
|
+
width: lane.height,
|
|
226
|
+
x,
|
|
227
|
+
y: interval.start,
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
190
233
|
/*** Maps desktop arrow keys to the platform-neutral interval navigation directions. */
|
|
191
234
|
function resolveKeyboardDirection(key: string): 'down' | 'left' | 'right' | 'up' | undefined {
|
|
192
235
|
if (key === 'ArrowDown') return 'down';
|
package/src/types/color.ts
CHANGED
|
@@ -4,15 +4,15 @@ import type { ZoraBaseProps } from './base';
|
|
|
4
4
|
|
|
5
5
|
export type ColorPickerTab = 'grid' | 'wheel';
|
|
6
6
|
|
|
7
|
-
/** A consumer-owned OKLCH target from
|
|
7
|
+
/** A consumer-owned OKLCH target from a tone catalog. */
|
|
8
8
|
export interface ColorToneTarget {
|
|
9
9
|
readonly lightness: number;
|
|
10
10
|
readonly chroma: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Structural boundary for a
|
|
15
|
-
* neither the catalog nor its classifications.
|
|
14
|
+
* Structural boundary for a consumer-owned tone-pair entry. ZORA intentionally
|
|
15
|
+
* owns neither the catalog nor its classifications.
|
|
16
16
|
*/
|
|
17
17
|
export interface ColorToneDefinition {
|
|
18
18
|
readonly id: string;
|
package/src/types/time-grid.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { GridLane, GridLaneInterval, GridViewport } from '@ankhorage/grid-v
|
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ZoraBaseProps } from './base';
|
|
5
|
+
import type { GridWorldLayerContext } from './grid-view';
|
|
5
6
|
|
|
6
7
|
/** An ordered, variable-height track rendered by the generic TimeGrid. */
|
|
7
8
|
export type TimeGridLane = GridLane;
|
|
@@ -17,8 +18,14 @@ export interface TimeGridProps extends ZoraBaseProps {
|
|
|
17
18
|
readonly lanes: readonly TimeGridLane[];
|
|
18
19
|
readonly intervals: readonly TimeGridInterval[];
|
|
19
20
|
readonly contentWidth: number;
|
|
21
|
+
/** Required for vertical time progression, where intervals extend down the grid. */
|
|
22
|
+
readonly contentHeight?: number;
|
|
20
23
|
readonly width: number;
|
|
21
24
|
readonly height: number;
|
|
25
|
+
/** Selects whether lane intervals progress across or down the shared GridView world. */
|
|
26
|
+
readonly orientation?: 'horizontal' | 'vertical';
|
|
27
|
+
/** Controls the shared viewport affordances for compositions that provide their own navigation. */
|
|
28
|
+
readonly viewportControls?: 'hidden' | 'visible';
|
|
22
29
|
readonly zoom?: number;
|
|
23
30
|
readonly overscanPixels?: number;
|
|
24
31
|
readonly focusedIntervalId?: string;
|
|
@@ -30,4 +37,6 @@ export interface TimeGridProps extends ZoraBaseProps {
|
|
|
30
37
|
readonly onVisibleIntervalIdsChange?: (ids: readonly string[]) => void;
|
|
31
38
|
readonly renderInterval: (interval: TimeGridInterval, selected: boolean) => React.ReactNode;
|
|
32
39
|
readonly renderLaneLabel?: (lane: TimeGridLane) => React.ReactNode;
|
|
40
|
+
/** Draws owner-defined geometry behind virtualized intervals without duplicating GridView. */
|
|
41
|
+
readonly renderWorldLayer?: (layer: GridWorldLayerContext) => React.ReactNode;
|
|
33
42
|
}
|