@ankhorage/zora 27.6.0 → 27.7.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 (96) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/dist/capabilities/index.js +94 -5
  4. package/dist/capabilities/index.js.map +5 -5
  5. package/dist/constants/authoring.d.ts +4 -3
  6. package/dist/constants/authoring.d.ts.map +1 -1
  7. package/dist/constants/authoring.js +2 -0
  8. package/dist/constants/authoring.js.map +1 -1
  9. package/dist/features/accordion/accordionItemMeta.d.ts +1 -1
  10. package/dist/features/bottom-sheet/bottomSheetMeta.d.ts +1 -1
  11. package/dist/features/card/cardMeta.d.ts +1 -1
  12. package/dist/features/card/mediaCardMeta.d.ts +1 -1
  13. package/dist/features/card/postCardMeta.d.ts +1 -1
  14. package/dist/features/chat/messageBubbleMeta.d.ts +1 -1
  15. package/dist/features/data-table/adapters/inbound/DataTable.d.ts.map +1 -1
  16. package/dist/features/data-table/adapters/inbound/DataTable.js +90 -18
  17. package/dist/features/data-table/adapters/inbound/DataTable.js.map +1 -1
  18. package/dist/features/data-table/dataTableMeta.d.ts +63 -0
  19. package/dist/features/data-table/dataTableMeta.d.ts.map +1 -1
  20. package/dist/features/data-table/dataTableMeta.js +42 -0
  21. package/dist/features/data-table/dataTableMeta.js.map +1 -1
  22. package/dist/features/data-table/public.d.ts +1 -1
  23. package/dist/features/data-table/public.d.ts.map +1 -1
  24. package/dist/features/data-table/public.js.map +1 -1
  25. package/dist/features/dialog/dialogMeta.d.ts +2 -2
  26. package/dist/features/gradient/gradientMeta.d.ts +1 -1
  27. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js +7 -2
  28. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js.map +1 -1
  29. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
  30. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +8 -4
  31. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
  32. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.d.ts.map +1 -1
  33. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js +18 -6
  34. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js.map +1 -1
  35. package/dist/features/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
  36. package/dist/features/layout/gridMeta.d.ts +1 -1
  37. package/dist/features/layout/screenMeta.d.ts +1 -1
  38. package/dist/features/layout/scrollViewMeta.d.ts +1 -1
  39. package/dist/features/layout/viewMeta.d.ts +1 -1
  40. package/dist/features/list/flatListMeta.d.ts +1 -1
  41. package/dist/features/list/sectionListMeta.d.ts +1 -1
  42. package/dist/features/reader/meta.d.ts +2 -2
  43. package/dist/features/registry/bindableComponentMeta.d.ts +42 -3
  44. package/dist/features/registry/bindableComponentMeta.d.ts.map +1 -1
  45. package/dist/features/registry/bindableComponentMeta.js +27 -10
  46. package/dist/features/registry/bindableComponentMeta.js.map +1 -1
  47. package/dist/features/scanner/meta.d.ts +2 -2
  48. package/dist/features/section/screenSectionMeta.d.ts +1 -1
  49. package/dist/features/surface/surfaceMeta.d.ts +1 -1
  50. package/dist/features/tabs/tabPanelMeta.d.ts +1 -1
  51. package/dist/features/timeline/meta.d.ts +79 -3
  52. package/dist/features/timeline/meta.d.ts.map +1 -1
  53. package/dist/features/timeline/meta.js +50 -3
  54. package/dist/features/timeline/meta.js.map +1 -1
  55. package/dist/features/timeline/public.d.ts +1 -1
  56. package/dist/features/timeline/public.d.ts.map +1 -1
  57. package/dist/features/timeline/public.js.map +1 -1
  58. package/dist/readerFree.d.ts +2 -2
  59. package/dist/readerFree.d.ts.map +1 -1
  60. package/dist/readerFree.js.map +1 -1
  61. package/dist/types/data-table.d.ts +37 -0
  62. package/dist/types/data-table.d.ts.map +1 -1
  63. package/dist/types/data-table.js.map +1 -1
  64. package/dist/types/timeline.d.ts +16 -0
  65. package/dist/types/timeline.d.ts.map +1 -1
  66. package/dist/types/timeline.js.map +1 -1
  67. package/package.json +51 -2
  68. package/src/constants/authoring.ts +2 -0
  69. package/src/features/data-table/adapters/inbound/DataTable.test.tsx +127 -6
  70. package/src/features/data-table/adapters/inbound/DataTable.tsx +149 -24
  71. package/src/features/data-table/dataTableMeta.test.ts +23 -0
  72. package/src/features/data-table/dataTableMeta.ts +42 -0
  73. package/src/features/data-table/public.ts +4 -0
  74. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphController.ts +9 -2
  75. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +108 -1
  76. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +11 -3
  77. package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.test.ts +33 -0
  78. package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.ts +19 -5
  79. package/src/features/registry/bindableComponentMeta.ts +27 -10
  80. package/src/features/registry/componentMeta.test.ts +45 -0
  81. package/src/features/timeline/manifest.test.tsx +115 -0
  82. package/src/features/timeline/meta.ts +50 -3
  83. package/src/features/timeline/public.ts +6 -1
  84. package/src/readerFree.ts +10 -1
  85. package/src/types/data-table.ts +45 -0
  86. package/src/types/timeline.ts +18 -0
  87. package/web-dist/components/data-table/DataTable.d.ts +1 -1
  88. package/web-dist/components/data-table/DataTable.dependency-3.d.ts +1 -0
  89. package/web-dist/components/data-table/DataTable.js +128 -17
  90. package/web-dist/components/data-table/DataTable.types-0.d.ts +42 -0
  91. package/web-dist/components/data-table/index.d.ts +1 -1
  92. package/web-dist/components/graph-view/GraphView.js +21 -11
  93. package/web-dist/components/timeline/Timeline.d.ts +1 -1
  94. package/web-dist/components/timeline/Timeline.types-0.d.ts +19 -0
  95. package/web-dist/components/timeline/index.d.ts +1 -1
  96. package/web-dist/manifest.json +1 -0
@@ -159,7 +159,9 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
159
159
  runtime.setNodeSize('repository-0', { height: 24, width: 48 });
160
160
  await new Promise((resolve) => setTimeout(resolve, 0));
161
161
 
162
- expect(controller.measureNodes?.(retainedIds)).toEqual(before);
162
+ expect(
163
+ controller.measureNodes?.(retainedIds)?.nodes.map(({ id, position }) => ({ id, position })),
164
+ ).toEqual(before?.nodes.map(({ id, position }) => ({ id, position })));
163
165
  expect(controller.getViewport()).toEqual(viewport);
164
166
  expect(calls.ready).toBe(1);
165
167
  expect(calls.complete).toBe(1);
@@ -169,6 +171,66 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
169
171
  }
170
172
  });
171
173
 
174
+ test('keeps added compound targets inside a preserved user viewport without relayout', async () => {
175
+ await withGraphViewportAsync(async () => {
176
+ const ready = Promise.withResolvers<GraphViewController>();
177
+ const calls = { ready: 0, sort: 0 };
178
+ const controllers: GraphViewController[] = [];
179
+ const runtime = createGraphRuntime(undefined, {
180
+ current: {
181
+ onReady: (controller) => {
182
+ calls.ready += 1;
183
+ controllers.push(controller);
184
+ ready.resolve(controller);
185
+ },
186
+ },
187
+ });
188
+ const input = {
189
+ nodes: [{ id: 'README' }, { id: 'src' }],
190
+ edges: [],
191
+ layout: 'grid' as const,
192
+ layoutOptions: {
193
+ sort: () => {
194
+ calls.sort += 1;
195
+ return 0;
196
+ },
197
+ },
198
+ richNodeRendering: false,
199
+ topologyUpdatePolicy: 'preserve-positions' as const,
200
+ };
201
+ try {
202
+ runtime.update(input);
203
+ const controller = await ready.promise;
204
+ controller.fit();
205
+ controller.setZoom(0.8);
206
+ controller.setPan({ x: -40, y: -30 });
207
+ const viewport = controller.getViewport();
208
+ const retainedPosition = controller.measureNodes?.(['README']);
209
+ const sortCount = calls.sort;
210
+
211
+ runtime.update({
212
+ ...input,
213
+ nodes: [
214
+ { id: 'README' },
215
+ { id: 'src' },
216
+ { id: 'src.features', parentId: 'src' },
217
+ { id: 'src.features.nested', parentId: 'src.features' },
218
+ ],
219
+ });
220
+
221
+ expect(controller.getViewport()).toEqual(viewport);
222
+ expect(viewport).toEqual({ zoom: 0.8, pan: { x: -40, y: -30 } });
223
+ expect(controller.measureNodes?.(['README'])).toEqual(retainedPosition);
224
+ expect(calls.ready).toBe(1);
225
+ expect(controllers).toEqual([controller]);
226
+ expect(calls.sort).toBe(sortCount);
227
+ expectCompoundMeasurementsToFitViewport(controller, ['src.features', 'src.features.nested']);
228
+ } finally {
229
+ runtime.destroy();
230
+ }
231
+ });
232
+ });
233
+
172
234
  test('lays out a late initial rich-node measurement without a topology change', async () => {
173
235
  const ready = Promise.withResolvers<GraphViewController>();
174
236
  const completed = Promise.withResolvers<void>();
@@ -296,6 +358,51 @@ function expectMeasuredNodesToFit(controller: GraphViewController, nodeIds: read
296
358
  }
297
359
  }
298
360
 
361
+ function expectCompoundMeasurementsToFitViewport(
362
+ controller: GraphViewController,
363
+ nodeIds: readonly string[],
364
+ ) {
365
+ const measurement = controller.measureNodes?.(nodeIds);
366
+ expect(measurement).not.toBeNull();
367
+ if (measurement === null) return;
368
+ expect(measurement.viewport).toEqual({ width: 992, height: 440 });
369
+ expect(measurement.nodes).toHaveLength(2);
370
+ expect(measurement.nodes.map((node) => node.id)).toEqual(nodeIds);
371
+ for (const node of measurement.nodes) {
372
+ expect(Number.isFinite(node.position.x)).toBe(true);
373
+ expect(Number.isFinite(node.position.y)).toBe(true);
374
+ expect(node.size.width).toBeGreaterThan(0);
375
+ expect(node.size.height).toBeGreaterThan(0);
376
+ const left = node.position.x - node.size.width / 2;
377
+ const right = node.position.x + node.size.width / 2;
378
+ const top = node.position.y - node.size.height / 2;
379
+ const bottom = node.position.y + node.size.height / 2;
380
+ expect(left).toBeGreaterThanOrEqual(0);
381
+ expect(right).toBeLessThanOrEqual(measurement.viewport.width);
382
+ expect(top).toBeGreaterThanOrEqual(0);
383
+ expect(bottom).toBeLessThanOrEqual(measurement.viewport.height);
384
+ expect(node.position.x).toBeGreaterThanOrEqual(left);
385
+ expect(node.position.x).toBeLessThanOrEqual(right);
386
+ expect(node.position.y).toBeGreaterThanOrEqual(top);
387
+ expect(node.position.y).toBeLessThanOrEqual(bottom);
388
+ }
389
+ }
390
+
391
+ async function withGraphViewportAsync(run: () => Promise<void>) {
392
+ const probe = cytoscape({ headless: true });
393
+ const core = Object.getPrototypeOf(probe) as { height: () => number; width: () => number };
394
+ probe.destroy();
395
+ const { height, width } = core;
396
+ core.height = () => 440;
397
+ core.width = () => 992;
398
+ try {
399
+ await run();
400
+ } finally {
401
+ core.height = height;
402
+ core.width = width;
403
+ }
404
+ }
405
+
299
406
  test('preserves selection and positions through hover presentation updates without relayout', async () => {
300
407
  const ready = Promise.withResolvers<GraphViewController>();
301
408
  const events: GraphViewElementEvent[] = [];
@@ -84,6 +84,7 @@ export function createGraphRuntime(
84
84
  minZoom: 0.05,
85
85
  maxZoom: 2,
86
86
  selectionType: 'additive',
87
+ styleEnabled: true,
87
88
  userPanningEnabled: true,
88
89
  });
89
90
  const state = createRuntimeState(cy, container, callbacksRef, readLatestPointerDown);
@@ -191,7 +192,6 @@ function updateRuntime(state: GraphRuntimeState, input: GraphRuntimeUpdate) {
191
192
  state.cy.batch(() => {
192
193
  if (previous?.nodes !== input.nodes || previous.edges !== input.edges) {
193
194
  syncGraphElements(state.cy, input.nodes, input.edges);
194
- if (preservesTopology) placeAddedGraphNodes(state.cy, previous?.nodes ?? [], input.nodes);
195
195
  }
196
196
  if (
197
197
  previous?.styleRules !== input.styleRules ||
@@ -201,6 +201,7 @@ function updateRuntime(state: GraphRuntimeState, input: GraphRuntimeUpdate) {
201
201
  applyGraphStyles(state.cy, input.styleRules, input.richNodeRendering);
202
202
  }
203
203
  });
204
+ if (preservesTopology) placeAddedGraphNodes(state.cy, previous?.nodes ?? [], input.nodes);
204
205
  sizeGraphNodesToLabels(
205
206
  state.cy,
206
207
  state.labelSizedNodeIds,
@@ -272,7 +273,7 @@ function beginPreservedTopologyMeasurementWindow(
272
273
  });
273
274
  }
274
275
 
275
- /*** Limit stable-update geometry checks to nodes that existed before reconciliation. */
276
+ /*** Limit stable-update geometry checks to retained leaves with independently stable positions. */
276
277
  function getRetainedNodeIds(
277
278
  previous: GraphRuntimeUpdate | null,
278
279
  input: GraphRuntimeUpdate,
@@ -280,7 +281,14 @@ function getRetainedNodeIds(
280
281
  ): ReadonlySet<string> | null {
281
282
  if (!preservesTopology || previous === null) return null;
282
283
  const nextNodeIds = new Set(input.nodes.map((node) => node.id));
283
- return new Set(previous.nodes.map((node) => node.id).filter((id) => nextNodeIds.has(id)));
284
+ const nextParentIds = new Set(
285
+ input.nodes.flatMap((node) => (node.parentId === undefined ? [] : [node.parentId])),
286
+ );
287
+ return new Set(
288
+ previous.nodes
289
+ .map((node) => node.id)
290
+ .filter((id) => nextNodeIds.has(id) && !nextParentIds.has(id)),
291
+ );
284
292
  }
285
293
 
286
294
  /*** Start a generation-safe layout whose completion is the only normal automatic fit trigger. */
@@ -0,0 +1,33 @@
1
+ import { expect, test } from 'bun:test';
2
+ import cytoscape from 'cytoscape';
3
+
4
+ import { placeAddedGraphNodes } from './placeAddedGraphNodes';
5
+
6
+ test('positions added compound descendants at the visible viewport when no retained leaf remains', () => {
7
+ const cy = cytoscape({
8
+ headless: true,
9
+ elements: [
10
+ { data: { id: 'src' } },
11
+ { data: { id: 'src.features', parent: 'src' } },
12
+ { data: { id: 'src.features.nested', parent: 'src.features' } },
13
+ ],
14
+ });
15
+ try {
16
+ cy.extent = () => ({ x1: 100, x2: 300, y1: 40, y2: 200, w: 200, h: 160 });
17
+
18
+ placeAddedGraphNodes(
19
+ cy,
20
+ [{ id: 'src' }],
21
+ [
22
+ { id: 'src' },
23
+ { id: 'src.features', parentId: 'src' },
24
+ { id: 'src.features.nested', parentId: 'src.features' },
25
+ ],
26
+ );
27
+
28
+ expect(cy.getElementById('src.features').isParent()).toBe(true);
29
+ expect(cy.getElementById('src.features.nested').position()).toEqual({ x: 200, y: 120 });
30
+ } finally {
31
+ cy.destroy();
32
+ }
33
+ });
@@ -20,18 +20,32 @@ export function placeAddedGraphNodes(
20
20
  .sort((left, right) => left.id.localeCompare(right.id));
21
21
  if (addedNodes.length === 0) return;
22
22
 
23
+ const addedLeaves = addedNodes
24
+ .map((node) => cy.getElementById(node.id))
25
+ .filter((node) => !node.empty() && !node.isParent());
26
+ if (addedLeaves.length === 0) return;
27
+
23
28
  const retainedNodes = cy
24
29
  .nodes()
25
30
  .filter((node) => previousNodeIds.has(node.id()) && !node.isParent());
26
31
  const bounds = retainedNodes.boundingBox({ includeEdges: false, includeLabels: true });
27
- const origin = retainedNodes.empty() ? { x: 0, y: 0 } : { x: bounds.x2 + GRID_GAP, y: bounds.y1 };
28
- const columns = Math.ceil(Math.sqrt(addedNodes.length));
29
- addedNodes.forEach((node, index) => {
30
- const graphNode = cy.getElementById(node.id);
31
- if (graphNode.empty() || graphNode.isParent()) return;
32
+ const origin = retainedNodes.empty()
33
+ ? getVisibleViewportCenter(cy)
34
+ : { x: bounds.x2 + GRID_GAP, y: bounds.y1 };
35
+ const columns = Math.ceil(Math.sqrt(addedLeaves.length));
36
+ addedLeaves.forEach((graphNode, index) => {
32
37
  graphNode.position({
33
38
  x: origin.x + (index % columns) * GRID_GAP,
34
39
  y: origin.y + Math.floor(index / columns) * GRID_GAP,
35
40
  });
36
41
  });
37
42
  }
43
+
44
+ /*** Return the model point at the center of the unchanged visible viewport. */
45
+ function getVisibleViewportCenter(cy: Core) {
46
+ const extent = cy.extent();
47
+ return {
48
+ x: (extent.x1 + extent.x2) / 2,
49
+ y: (extent.y1 + extent.y2) / 2,
50
+ };
51
+ }
@@ -330,7 +330,7 @@ export const ZORA_BINDABLE_COMPONENT_META = {
330
330
  DataTable: {
331
331
  name: 'DataTable',
332
332
  category: 'component',
333
- description: 'Renders tabular records.',
333
+ description: 'Renders tabular records with portable selection and activation events.',
334
334
  directManifestNode: true,
335
335
  allowedChildren: [],
336
336
  bindings: {
@@ -338,22 +338,39 @@ export const ZORA_BINDABLE_COMPONENT_META = {
338
338
  rows: {
339
339
  label: 'Rows',
340
340
  description: 'Rows rendered by the table.',
341
- value: {
342
- type: 'array',
343
- itemType: 'record',
344
- },
341
+ value: { type: 'array', itemType: 'record' },
342
+ acceptsFallback: true,
343
+ acceptsTransforms: true,
344
+ },
345
+ selectedRowIds: {
346
+ label: 'Selected row IDs',
347
+ description: 'Controlled stable row identities selected with the checkbox column.',
348
+ value: { type: 'array', itemType: 'string' },
345
349
  acceptsFallback: true,
346
350
  acceptsTransforms: true,
347
351
  },
348
352
  },
353
+ events: {
354
+ selectionChange: {
355
+ label: 'Selection change',
356
+ payload: {
357
+ eventType: 'dataTable.selectionChange',
358
+ fields: [{ path: 'selectedRowIds', type: 'unknown', label: 'Selected row IDs' }],
359
+ },
360
+ },
361
+ rowActivate: {
362
+ label: 'Activate row',
363
+ payload: {
364
+ eventType: 'dataTable.rowActivate',
365
+ fields: [{ path: 'rowId', type: 'string', label: 'Row ID' }],
366
+ },
367
+ },
368
+ },
349
369
  },
350
370
  props: {
351
371
  inverted: INVERTED_POLARITY_PROP,
352
- rows: {
353
- type: 'array',
354
- category: 'Data',
355
- label: 'Rows',
356
- },
372
+ rows: { type: 'array', category: 'Data', label: 'Rows' },
373
+ selectedRowIds: { type: 'array', category: 'Selection', label: 'Selected row IDs' },
357
374
  },
358
375
  },
359
376
  Reader: {
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from 'bun:test';
2
2
 
3
+ import { ZORA_COLORS } from '../theme/colorModel';
3
4
  import type { BarcodeScannerViewProps, ZoraComponentEventPayloadKind } from '.';
4
5
  import { ZORA_COMPONENT_META } from '.';
5
6
 
@@ -285,6 +286,7 @@ describe('ZORA_COMPONENT_META invariants', () => {
285
286
  'TimePicker',
286
287
  'TabletopTable',
287
288
  'PokerTrainingTable',
289
+ 'Timeline',
288
290
  ]);
289
291
 
290
292
  const expectedContainerNodes = new Set([
@@ -466,6 +468,49 @@ describe('ZORA_COMPONENT_META invariants', () => {
466
468
  expect(ZORA_COMPONENT_META.ThemeModeToggle.blueprint?.defaultProps).toEqual({ size: 'm' });
467
469
  });
468
470
 
471
+ test('Timeline is a direct manifest leaf with portable dated marker items', () => {
472
+ const timeline = ZORA_COMPONENT_META.Timeline;
473
+
474
+ expect(timeline.directManifestNode).toBe(true);
475
+ expect(timeline.allowedChildren).toEqual([]);
476
+ expect(timeline.blueprint?.defaultProps).toEqual({ items: [] });
477
+ expect(timeline.props.items?.itemSchema).toEqual([
478
+ { key: 'id', schema: { type: 'string', category: 'Identity', label: 'Event ID' } },
479
+ { key: 'title', schema: { type: 'string', category: 'Content', label: 'Title' } },
480
+ {
481
+ key: 'description',
482
+ schema: { type: 'string', category: 'Content', label: 'Description' },
483
+ },
484
+ { key: 'meta', schema: { type: 'string', category: 'Content', label: 'Date and time' } },
485
+ {
486
+ key: 'status',
487
+ schema: {
488
+ type: 'enum',
489
+ category: 'State',
490
+ label: 'Status',
491
+ enum: ZORA_COLORS,
492
+ },
493
+ },
494
+ {
495
+ key: 'marker',
496
+ schema: {
497
+ type: 'media',
498
+ category: 'Content',
499
+ label: 'SVG or image marker',
500
+ mediaKinds: ['image'],
501
+ },
502
+ },
503
+ {
504
+ key: 'markerAlt',
505
+ schema: {
506
+ type: 'string',
507
+ category: 'Accessibility',
508
+ label: 'Marker alternative text',
509
+ },
510
+ },
511
+ ]);
512
+ });
513
+
469
514
  test('KeyboardAvoidingView is a direct manifest container with native behavior props', () => {
470
515
  const keyboardAvoidingView = ZORA_COMPONENT_META.KeyboardAvoidingView;
471
516
 
@@ -0,0 +1,115 @@
1
+ import { join } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+
4
+ import { isSerializableValue, type MediaAssetRegistry, type UiNode } from '@ankhorage/contracts';
5
+ import { expect, mock, test } from 'bun:test';
6
+ import { Window } from 'happy-dom';
7
+ import React from 'react';
8
+ import { renderToStaticMarkup } from 'react-dom/server';
9
+
10
+ import type { TimelineManifestProps } from '../../types/timeline';
11
+ import type { ZoraProvider as ZoraProviderComponent } from '../theme/runtime';
12
+ import type { Timeline as TimelineComponent } from './adapters/inbound/Timeline';
13
+
14
+ const webDistRoot = join(import.meta.dir, '../../../web-dist');
15
+
16
+ const timelineRuntimePromise = Promise.all([
17
+ import(pathToFileURL(join(webDistRoot, 'components/timeline/index.js')).href) as Promise<{
18
+ Timeline: typeof TimelineComponent;
19
+ }>,
20
+ import(pathToFileURL(join(webDistRoot, 'runtime/ZoraProvider.js')).href) as Promise<{
21
+ ZoraProvider: typeof ZoraProviderComponent;
22
+ }>,
23
+ ]);
24
+
25
+ await mock.module('react-native', () => ({
26
+ StyleSheet: { create: <T,>(styles: T) => styles },
27
+ Text: ({ children }: { children?: React.ReactNode }) => <span>{children}</span>,
28
+ View: ({ children }: { children?: React.ReactNode }) => <div>{children}</div>,
29
+ }));
30
+
31
+ const { RuntimeRenderer } = await import('@ankhorage/runtime');
32
+
33
+ async function loadTimelineRuntime() {
34
+ const [timelineModule, themeModule] = await timelineRuntimePromise;
35
+ return { Timeline: timelineModule.Timeline, ZoraProvider: themeModule.ZoraProvider };
36
+ }
37
+
38
+ const manifestTimelineProps = {
39
+ items: [
40
+ {
41
+ id: 'acquired',
42
+ title: 'Company acquired',
43
+ description:
44
+ 'A deliberately long event description that wraps across lines while its connector flexes to the next event.',
45
+ meta: '2026-11-22T09:00:00Z',
46
+ status: 'success',
47
+ marker: { mediaId: 'acquisition-mark' },
48
+ markerAlt: 'Acquisition marker',
49
+ },
50
+ {
51
+ id: 'integrated',
52
+ title: 'Company integrated',
53
+ meta: '2026-11-23T09:00:00Z',
54
+ status: 'primary',
55
+ },
56
+ ],
57
+ } as const satisfies TimelineManifestProps;
58
+
59
+ const timelineNode = {
60
+ id: 'acquisition-history',
61
+ type: 'Timeline',
62
+ props: manifestTimelineProps,
63
+ } satisfies UiNode;
64
+
65
+ const mediaAssets = {
66
+ 'acquisition-mark': {
67
+ id: 'acquisition-mark',
68
+ name: 'Acquisition marker',
69
+ kind: 'image',
70
+ source: { kind: 'url', url: 'https://example.test/acquisition.svg' },
71
+ },
72
+ } as const satisfies MediaAssetRegistry;
73
+
74
+ test('keeps Timeline manifest items serializable and rejects executable values', () => {
75
+ expect(isSerializableValue(manifestTimelineProps)).toBe(true);
76
+ expect(
77
+ isSerializableValue({
78
+ ...manifestTimelineProps,
79
+ items: [{ ...manifestTimelineProps.items[0], markerAlt: () => 'not serializable' }],
80
+ }),
81
+ ).toBe(false);
82
+ });
83
+
84
+ test('maps serializable Timeline markers through the runtime while preserving item order and connector height', async () => {
85
+ const { Timeline, ZoraProvider } = await loadTimelineRuntime();
86
+ const browser = new Window();
87
+
88
+ try {
89
+ browser.document.body.innerHTML = renderToStaticMarkup(
90
+ <ZoraProvider mode="light">
91
+ <RuntimeRenderer
92
+ isRoot
93
+ mediaAssets={mediaAssets}
94
+ node={timelineNode}
95
+ registry={{ Timeline }}
96
+ />
97
+ </ZoraProvider>,
98
+ );
99
+
100
+ const timeline = browser.document.querySelector('[data-testid="acquisition-history"]');
101
+ const firstItem = timeline?.children.item(0);
102
+ const marker = firstItem?.querySelector('[role="img"]');
103
+ const connector = firstItem?.querySelector('[style*="width:2px"]');
104
+ const content = firstItem?.lastElementChild;
105
+ const text = timeline?.textContent ?? '';
106
+
107
+ expect(marker?.getAttribute('aria-label')).toBe('Acquisition marker');
108
+ expect(text.indexOf('Company acquired')).toBeLessThan(text.indexOf('Company integrated'));
109
+ expect(connector?.getAttribute('style')).toContain('flex:1');
110
+ expect(connector?.getAttribute('style')).not.toContain('height:36px');
111
+ expect(content?.getAttribute('style')).toContain('padding-bottom:24px');
112
+ } finally {
113
+ browser.close();
114
+ }
115
+ });
@@ -1,10 +1,57 @@
1
1
  import type { ZoraComponentMeta } from '../../types/authoring';
2
+ import { ZORA_COLORS } from '../theme/colorModel';
2
3
 
3
4
  export const timelineMeta = {
4
5
  name: 'Timeline',
5
6
  category: 'pattern',
6
- directManifestNode: false,
7
+ description: 'Displays an ordered sequence of dated events with accessible image markers.',
8
+ directManifestNode: true,
7
9
  allowedChildren: [],
8
- note: 'Timeline pattern component; not represented as a manifest node in v1.',
9
- props: {},
10
+ blueprint: { label: 'Timeline', defaultProps: { items: [] } },
11
+ props: {
12
+ items: {
13
+ type: 'array',
14
+ category: 'Content',
15
+ label: 'Events',
16
+ itemSchema: [
17
+ { key: 'id', schema: { type: 'string', category: 'Identity', label: 'Event ID' } },
18
+ { key: 'title', schema: { type: 'string', category: 'Content', label: 'Title' } },
19
+ {
20
+ key: 'description',
21
+ schema: { type: 'string', category: 'Content', label: 'Description' },
22
+ },
23
+ { key: 'meta', schema: { type: 'string', category: 'Content', label: 'Date and time' } },
24
+ {
25
+ key: 'status',
26
+ schema: {
27
+ type: 'enum',
28
+ category: 'State',
29
+ label: 'Status',
30
+ enum: ZORA_COLORS,
31
+ },
32
+ },
33
+ {
34
+ key: 'marker',
35
+ schema: {
36
+ type: 'media',
37
+ category: 'Content',
38
+ label: 'SVG or image marker',
39
+ mediaKinds: ['image'],
40
+ },
41
+ },
42
+ {
43
+ key: 'markerAlt',
44
+ schema: { type: 'string', category: 'Accessibility', label: 'Marker alternative text' },
45
+ },
46
+ ],
47
+ authoring: { authority: 'instance' },
48
+ },
49
+ compact: {
50
+ type: 'boolean',
51
+ category: 'Layout',
52
+ label: 'Compact',
53
+ default: false,
54
+ authoring: { authority: 'instance' },
55
+ },
56
+ },
10
57
  } as const satisfies ZoraComponentMeta;
@@ -1,2 +1,7 @@
1
- export type { TimelineItem, TimelineProps } from '../../types/timeline';
1
+ export type {
2
+ TimelineItem,
3
+ TimelineManifestItem,
4
+ TimelineManifestProps,
5
+ TimelineProps,
6
+ } from '../../types/timeline';
2
7
  export { Timeline } from './adapters/inbound/Timeline';
package/src/readerFree.ts CHANGED
@@ -166,11 +166,15 @@ export type {
166
166
  export { ContentRail } from './features/content-rail/public';
167
167
  export type {
168
168
  DataTableCellContext,
169
+ DataTableCellSpec,
169
170
  DataTableColumn,
170
171
  DataTableColumnAlign,
171
172
  DataTableDensity,
172
173
  DataTableProps,
173
174
  DataTableRowAction,
175
+ DataTableRowActivateEvent,
176
+ DataTableRowField,
177
+ DataTableSelectionChangeEvent,
174
178
  DataTableSortDirection,
175
179
  DataTableSortState,
176
180
  } from './features/data-table/public';
@@ -510,7 +514,12 @@ export {
510
514
  type TimePickerProps,
511
515
  type TimePickerValue,
512
516
  } from './features/time-picker/public';
513
- export type { TimelineItem, TimelineProps } from './features/timeline/public';
517
+ export type {
518
+ TimelineItem,
519
+ TimelineManifestItem,
520
+ TimelineManifestProps,
521
+ TimelineProps,
522
+ } from './features/timeline/public';
514
523
  export { Timeline } from './features/timeline/public';
515
524
  export type {
516
525
  ToastController,
@@ -3,11 +3,42 @@ import type React from 'react';
3
3
 
4
4
  import type { ZoraBaseProps } from './base';
5
5
  import type { PopoverMenuActionIntent } from './popover-menu';
6
+ import type { TextVariant } from './text';
6
7
 
7
8
  export type DataTableColumnAlign = 'start' | 'center' | 'end';
8
9
  export type DataTableDensity = 'comfortable' | 'compact';
9
10
  export type DataTableSortDirection = 'asc' | 'desc';
10
11
 
12
+ /** A portable reference to a string-valued row field used by a manifest cell. */
13
+ export type DataTableRowField<TRow extends object> = Extract<keyof TRow, string>;
14
+
15
+ /** Serializable rich presentations for a DataTable column. */
16
+ export type DataTableCellSpec<TRow extends object> =
17
+ | {
18
+ readonly kind: 'image';
19
+ readonly source: DataTableRowField<TRow>;
20
+ readonly alt?: DataTableRowField<TRow>;
21
+ }
22
+ | {
23
+ readonly kind: 'text';
24
+ readonly value: DataTableRowField<TRow>;
25
+ readonly weight?: 'regular' | 'medium' | 'semiBold' | 'bold';
26
+ readonly variant?: TextVariant;
27
+ }
28
+ | {
29
+ readonly kind: 'link';
30
+ readonly href: DataTableRowField<TRow>;
31
+ readonly label?: DataTableRowField<TRow>;
32
+ readonly variant?: TextVariant;
33
+ }
34
+ | {
35
+ readonly kind: 'stack';
36
+ readonly direction: 'row' | 'column';
37
+ readonly align?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
38
+ readonly gap?: 'xxs' | 'xs' | 's' | 'm' | 'l';
39
+ readonly children: readonly DataTableCellSpec<TRow>[];
40
+ };
41
+
11
42
  export interface DataTableSortState {
12
43
  columnId: string;
13
44
  direction: DataTableSortDirection;
@@ -28,9 +59,19 @@ export interface DataTableColumn<TRow extends object> {
28
59
  width?: number;
29
60
  minWidth?: number;
30
61
  sortable?: boolean;
62
+ /** Portable manifest presentation. Takes precedence over the default accessor rendering. */
63
+ cell?: DataTableCellSpec<TRow>;
31
64
  renderCell?: (context: DataTableCellContext<TRow>) => React.ReactNode;
32
65
  }
33
66
 
67
+ export interface DataTableSelectionChangeEvent {
68
+ readonly selectedRowIds: readonly string[];
69
+ }
70
+
71
+ export interface DataTableRowActivateEvent {
72
+ readonly rowId: string;
73
+ }
74
+
34
75
  export interface DataTableRowAction<TRow extends object> {
35
76
  id: string;
36
77
  title: React.ReactNode;
@@ -50,6 +91,10 @@ export interface DataTableProps<TRow extends object> extends ZoraBaseProps {
50
91
  selectedRowIds?: readonly string[];
51
92
  /** Receives the next controlled selection after a row or visible-row toggle. */
52
93
  onSelectedRowIdsChange?: (selectedRowIds: readonly string[]) => void;
94
+ /** Emits the serializable controlled selection payload used by AppManifest events. */
95
+ onSelectionChange?: (event: DataTableSelectionChangeEvent) => void;
96
+ /** Emits a row activation independently of checkbox selection. */
97
+ onRowActivate?: (event: DataTableRowActivateEvent) => void;
53
98
  rowActions?: (row: TRow, index: number) => readonly DataTableRowAction<TRow>[];
54
99
  sort?: DataTableSortState;
55
100
  onSortChange?: (sort: DataTableSortState) => void;