@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
@@ -32,12 +32,34 @@ const View = ({
32
32
  </div>
33
33
  );
34
34
 
35
- await mock.module('react-native', () => ({ ScrollView: View }));
35
+ const openedUrls: string[] = [];
36
+
37
+ await mock.module('react-native', () => ({
38
+ Linking: { openURL: (url: string) => openedUrls.push(url) },
39
+ Pressable: ({
40
+ accessibilityLabel,
41
+ accessibilityRole,
42
+ children,
43
+ onPress,
44
+ }: {
45
+ accessibilityLabel?: string;
46
+ accessibilityRole?: string;
47
+ children?: React.ReactNode;
48
+ onPress?: () => void;
49
+ }) => (
50
+ <button aria-label={accessibilityLabel} onClick={onPress} role={accessibilityRole}>
51
+ {children}
52
+ </button>
53
+ ),
54
+ ScrollView: View,
55
+ }));
36
56
  await mock.module('../../../button/public', () => ({
37
57
  Button: ({ children, onPress }: { children?: React.ReactNode; onPress?: () => void }) => (
38
58
  <button onClick={onPress}>{children}</button>
39
59
  ),
40
- IconButton: ({ onPress }: { onPress?: () => void }) => <button onClick={onPress} />,
60
+ IconButton: ({ label, onPress }: { label?: string; onPress?: () => void }) => (
61
+ <button aria-label={label} onClick={onPress} />
62
+ ),
41
63
  }));
42
64
  await mock.module('../../../card/public', () => ({
43
65
  Card: ({
@@ -78,6 +100,9 @@ await mock.module('../../../form/checkbox/public', () => ({
78
100
  />
79
101
  ),
80
102
  }));
103
+ await mock.module('../../../image/public', () => ({
104
+ Image: ({ alt, source }: { alt?: string; source?: string }) => <img alt={alt} src={source} />,
105
+ }));
81
106
  await mock.module('../../../layout/public', () => ({ View }));
82
107
  await mock.module('../../../popover-menu/public', () => ({ PopoverMenu: View }));
83
108
  await mock.module('../../../skeleton/public', () => ({ SkeletonList: View }));
@@ -85,7 +110,9 @@ await mock.module('../../../theme/adapters/inbound/withZoraThemeScope', () => ({
85
110
  withZoraThemeScope: <P,>(Component: React.ComponentType<P>) => Component,
86
111
  }));
87
112
  await mock.module('../../../typography/public', () => ({
88
- Text: ({ children }: { children?: React.ReactNode }) => <span>{children}</span>,
113
+ Text: ({ children, weight }: { children?: React.ReactNode; weight?: string }) => (
114
+ <span data-weight={weight}>{children}</span>
115
+ ),
89
116
  }));
90
117
  await mock.module('@ankhorage/surface', () => ({
91
118
  Show: ({ children, fallback }: { children?: React.ReactNode; fallback?: React.ReactNode }) => (
@@ -119,6 +146,7 @@ function mount() {
119
146
  test('uses stable row identities for controlled checkbox and all-visible selection', async () => {
120
147
  const mounted = mount();
121
148
  const changes: string[][] = [];
149
+ const activations: { rowId: string }[] = [];
122
150
  const onSelectedRowIdsChange = (selectedRowIds: readonly string[]) =>
123
151
  changes.push([...selectedRowIds]);
124
152
 
@@ -127,6 +155,7 @@ test('uses stable row identities for controlled checkbox and all-visible selecti
127
155
  <DataTable
128
156
  columns={[{ accessor: 'name', header: 'Company', id: 'company' }]}
129
157
  onSelectedRowIdsChange={onSelectedRowIdsChange}
158
+ onRowActivate={(event) => activations.push(event)}
130
159
  rowKey="id"
131
160
  rows={[
132
161
  { id: 'acme', name: 'Acme' },
@@ -150,6 +179,8 @@ test('uses stable row identities for controlled checkbox and all-visible selecti
150
179
  ['acme', 'zora'],
151
180
  ['acme', 'zora'],
152
181
  ]);
182
+ mounted.host.querySelector<HTMLButtonElement>('[aria-label="Activate row acme"]')?.click();
183
+ expect(activations).toEqual([{ rowId: 'acme' }]);
153
184
 
154
185
  await mounted.render(
155
186
  <DataTable
@@ -205,19 +236,56 @@ test('uses desktop stable row ids and the controlled callback in mobile cards',
205
236
  mobilePresentation = true;
206
237
  const mounted = mount();
207
238
  const changes: string[][] = [];
239
+ const selectionEvents: { selectedRowIds: readonly string[] }[] = [];
240
+ const activationEvents: { rowId: string }[] = [];
208
241
 
209
242
  try {
210
243
  await mounted.render(
211
244
  <DataTable
212
245
  columns={[
213
- { accessor: 'name', header: 'Company', id: 'company' },
246
+ {
247
+ cell: {
248
+ align: 'center',
249
+ children: [
250
+ { alt: 'name', kind: 'image', source: 'logo' },
251
+ {
252
+ children: [
253
+ { kind: 'text', value: 'name', weight: 'bold' },
254
+ { href: 'website', kind: 'link', variant: 'caption' },
255
+ ],
256
+ direction: 'column',
257
+ gap: 'xxs',
258
+ kind: 'stack',
259
+ },
260
+ ],
261
+ direction: 'row',
262
+ gap: 's',
263
+ kind: 'stack',
264
+ },
265
+ header: 'Company',
266
+ id: 'company',
267
+ },
214
268
  { accessor: 'location', header: 'Location', id: 'location' },
215
269
  ]}
216
270
  onSelectedRowIdsChange={(selectedRowIds) => changes.push([...selectedRowIds])}
271
+ onRowActivate={(event) => activationEvents.push(event)}
272
+ onSelectionChange={(event) => selectionEvents.push(event)}
217
273
  rowId={(row) => `company-${row.id}`}
218
274
  rows={[
219
- { id: 'acme', location: 'Zurich', name: 'Acme' },
220
- { id: 'zora', location: 'Bern', name: 'ZORA' },
275
+ {
276
+ id: 'acme',
277
+ location: 'Zurich',
278
+ logo: 'https://example.test/acme.png',
279
+ name: 'Acme',
280
+ website: 'https://acme.test',
281
+ },
282
+ {
283
+ id: 'zora',
284
+ location: 'Bern',
285
+ logo: 'https://example.test/zora.png',
286
+ name: 'ZORA',
287
+ website: 'https://zora.test',
288
+ },
221
289
  ]}
222
290
  selectedRowIds={['company-acme']}
223
291
  />,
@@ -234,9 +302,62 @@ test('uses desktop stable row ids and the controlled callback in mobile cards',
234
302
 
235
303
  unselected?.click();
236
304
  expect(changes).toEqual([['company-acme', 'company-zora']]);
305
+ expect(selectionEvents).toEqual([{ selectedRowIds: ['company-acme', 'company-zora'] }]);
306
+ expect(JSON.stringify(selectionEvents[0])).toBe(
307
+ '{"selectedRowIds":["company-acme","company-zora"]}',
308
+ );
309
+
310
+ const activation = mounted.host.querySelector<HTMLButtonElement>(
311
+ '[aria-label="Activate row company-acme"]',
312
+ );
313
+ activation?.click();
314
+ expect(activationEvents).toEqual([{ rowId: 'company-acme' }]);
315
+ expect(mounted.host.querySelector('img')?.getAttribute('src')).toBe(
316
+ 'https://example.test/acme.png',
317
+ );
318
+ expect(mounted.host.querySelector('[data-weight="bold"]')?.textContent).toBe('Acme');
319
+ const companyLink = mounted.host.querySelector<HTMLButtonElement>('[role="link"]');
320
+ companyLink?.click();
321
+ expect(openedUrls).toEqual(['https://acme.test']);
237
322
  } finally {
238
323
  mobilePresentation = false;
239
324
  await mounted.unmount();
240
325
  mounted.host.remove();
241
326
  }
242
327
  });
328
+
329
+ test('navigates only valid HTTP and HTTPS portable links', async () => {
330
+ const mounted = mount();
331
+ openedUrls.splice(0, openedUrls.length);
332
+
333
+ try {
334
+ await mounted.render(
335
+ <DataTable
336
+ columns={[
337
+ {
338
+ cell: { href: 'website', kind: 'link', label: 'name' },
339
+ header: 'Website',
340
+ id: 'website',
341
+ },
342
+ ]}
343
+ rowKey="id"
344
+ rows={[
345
+ { id: 'http', name: 'HTTP', website: 'http://example.test' },
346
+ { id: 'https', name: 'HTTPS', website: 'https://example.test/path' },
347
+ { id: 'javascript', name: 'JavaScript', website: 'javascript:alert(1)' },
348
+ { id: 'data', name: 'Data', website: 'data:text/html,unsafe' },
349
+ { id: 'custom', name: 'Custom', website: 'acme://unsafe' },
350
+ { id: 'malformed', name: 'Malformed', website: 'https://' },
351
+ ]}
352
+ />,
353
+ );
354
+
355
+ const links = [...mounted.host.querySelectorAll<HTMLButtonElement>('[role="link"]')];
356
+ expect(links.map((link) => link.textContent)).toEqual(['HTTP', 'HTTPS']);
357
+ links.forEach((link) => link.click());
358
+ expect(openedUrls).toEqual(['http://example.test', 'https://example.test/path']);
359
+ } finally {
360
+ await mounted.unmount();
361
+ mounted.host.remove();
362
+ }
363
+ });
@@ -1,10 +1,11 @@
1
1
  import type { InteractionPolicy } from '@ankhorage/surface';
2
2
  import { Show } from '@ankhorage/surface';
3
3
  import React from 'react';
4
- import { ScrollView, type ViewStyle } from 'react-native';
4
+ import { Linking, Pressable, ScrollView, type ViewStyle } from 'react-native';
5
5
 
6
6
  import type {
7
7
  DataTableCellContext,
8
+ DataTableCellSpec,
8
9
  DataTableColumn,
9
10
  DataTableColumnAlign,
10
11
  DataTableDensity,
@@ -12,11 +13,11 @@ import type {
12
13
  DataTableRowAction,
13
14
  DataTableSortDirection,
14
15
  } from '../../../../types/data-table';
15
- import { Button } from '../../../button/public';
16
- import { IconButton } from '../../../button/public';
16
+ import { Button, IconButton } from '../../../button/public';
17
17
  import { Card } from '../../../card/public';
18
18
  import { EmptyState } from '../../../empty-state/public';
19
19
  import { Checkbox } from '../../../form/checkbox/public';
20
+ import { Image } from '../../../image/public';
20
21
  import { View } from '../../../layout/public';
21
22
  import { PopoverMenu, type PopoverMenuAction } from '../../../popover-menu/public';
22
23
  import { SkeletonList } from '../../../skeleton/public';
@@ -101,6 +102,76 @@ function renderDefaultCell(value: unknown): React.ReactNode {
101
102
  return '—';
102
103
  }
103
104
 
105
+ /** Reads a manifest cell field without accepting executable accessor behavior. */
106
+ function resolveCellField<TRow extends object>(row: TRow, field: keyof TRow): unknown {
107
+ return Object.getOwnPropertyDescriptor(row, field)?.value;
108
+ }
109
+
110
+ /** Resolves a row value into a string suitable for portable text and URL presentation. */
111
+ function resolveCellString(value: unknown): string | undefined {
112
+ return typeof value === 'string' || typeof value === 'number' ? String(value) : undefined;
113
+ }
114
+
115
+ /*** Resolves an untrusted row value to the HTTP(S) URL accepted by the platform navigation boundary. */
116
+ function resolveExternalWebsiteUrl(url: string): string | undefined {
117
+ try {
118
+ const parsedUrl = new URL(url);
119
+ return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:' ? url : undefined;
120
+ } catch {
121
+ return undefined;
122
+ }
123
+ }
124
+
125
+ /** Opens a validated portable website cell through React Native's platform URL boundary. */
126
+ function openExternalUrl(url: string): void {
127
+ const externalUrl = resolveExternalWebsiteUrl(url);
128
+ if (externalUrl) {
129
+ void Linking.openURL(externalUrl);
130
+ }
131
+ }
132
+
133
+ /** Renders one serializable manifest cell specification with canonical ZORA primitives. */
134
+ function renderPortableCell<TRow extends object>(
135
+ cell: DataTableCellSpec<TRow>,
136
+ row: TRow,
137
+ ): React.ReactNode {
138
+ switch (cell.kind) {
139
+ case 'image': {
140
+ const source = resolveCellString(resolveCellField(row, cell.source));
141
+ const alt = resolveCellString(resolveCellField(row, cell.alt ?? cell.source));
142
+ return <Image alt={alt} height={32} radius="s" source={source} width={32} />;
143
+ }
144
+ case 'text':
145
+ return (
146
+ <Text variant={cell.variant ?? 'bodySmall'} weight={cell.weight}>
147
+ {renderDefaultCell(resolveCellField(row, cell.value))}
148
+ </Text>
149
+ );
150
+ case 'link': {
151
+ const href = resolveCellString(resolveCellField(row, cell.href));
152
+ const label = resolveCellString(resolveCellField(row, cell.label ?? cell.href)) ?? href;
153
+ const externalUrl = href ? resolveExternalWebsiteUrl(href) : undefined;
154
+ return externalUrl ? (
155
+ <Pressable accessibilityRole="link" onPress={() => openExternalUrl(externalUrl)}>
156
+ <Text color="primary" variant={cell.variant ?? 'bodySmall'} weight="medium">
157
+ {label}
158
+ </Text>
159
+ </Pressable>
160
+ ) : (
161
+ <Text variant="bodySmall">—</Text>
162
+ );
163
+ }
164
+ case 'stack':
165
+ return (
166
+ <View align={cell.align} direction={cell.direction} gap={cell.gap}>
167
+ {cell.children.map((child, index) => (
168
+ <React.Fragment key={`cell-${index}`}>{renderPortableCell(child, row)}</React.Fragment>
169
+ ))}
170
+ </View>
171
+ );
172
+ }
173
+ }
174
+
104
175
  function createCellContext<TRow extends object>(
105
176
  column: DataTableColumn<TRow>,
106
177
  row: TRow,
@@ -120,7 +191,9 @@ function renderCell<TRow extends object>(
120
191
  rowIndex: number,
121
192
  ) {
122
193
  const context = createCellContext(column, row, rowIndex);
123
- return column.renderCell ? column.renderCell(context) : renderDefaultCell(context.value);
194
+ if (column.renderCell) return column.renderCell(context);
195
+ if (column.cell) return renderPortableCell(column.cell, row);
196
+ return renderDefaultCell(context.value);
124
197
  }
125
198
 
126
199
  function renderTableCell<TRow extends object>(
@@ -128,9 +201,8 @@ function renderTableCell<TRow extends object>(
128
201
  row: TRow,
129
202
  rowIndex: number,
130
203
  ) {
131
- if (column.renderCell) {
132
- return column.renderCell(createCellContext(column, row, rowIndex));
133
- }
204
+ if (column.renderCell) return column.renderCell(createCellContext(column, row, rowIndex));
205
+ if (column.cell) return renderPortableCell(column.cell, row);
134
206
 
135
207
  return (
136
208
  <Text align={resolveTextAlign(column.align)} variant="bodySmall">
@@ -168,6 +240,16 @@ function resolveNextVisibleSelection(
168
240
  : selectedRowIds.filter((selectedRowId) => !visibleRowIdSet.has(selectedRowId));
169
241
  }
170
242
 
243
+ /** Emits both the established controlled callback and its portable manifest event counterpart. */
244
+ function emitSelectionChange<TRow extends object>(
245
+ selectedRowIds: readonly string[],
246
+ onSelectedRowIdsChange: DataTableProps<TRow>['onSelectedRowIdsChange'],
247
+ onSelectionChange: DataTableProps<TRow>['onSelectionChange'],
248
+ ): void {
249
+ onSelectedRowIdsChange?.(selectedRowIds);
250
+ onSelectionChange?.({ selectedRowIds });
251
+ }
252
+
171
253
  /*** Maps row-scoped DataTable actions into the shared PopoverMenu action contract. */
172
254
  function mapRowActions<TRow extends object>(
173
255
  row: TRow,
@@ -316,6 +398,8 @@ function DataTableDesktop<TRow extends object>({
316
398
  rowKey,
317
399
  selectedRowIds,
318
400
  onSelectedRowIdsChange,
401
+ onSelectionChange,
402
+ onRowActivate,
319
403
  sort,
320
404
  onSortChange,
321
405
  density,
@@ -327,7 +411,9 @@ function DataTableDesktop<TRow extends object>({
327
411
  const controlledSelectedRowIds = selectedRowIds ?? [];
328
412
  const selectedRowIdSet = new Set(controlledSelectedRowIds);
329
413
  const selectionEnabled = selectedRowIds !== undefined;
330
- const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
414
+ const selectionDisabled =
415
+ interactionPolicy === 'passive' ||
416
+ (onSelectedRowIdsChange === undefined && onSelectionChange === undefined);
331
417
  const hasRowActions = rows.some((row, rowIndex) => (rowActions?.(row, rowIndex).length ?? 0) > 0);
332
418
  const selection = selectionEnabled
333
419
  ? {
@@ -335,8 +421,10 @@ function DataTableDesktop<TRow extends object>({
335
421
  disabled: selectionDisabled,
336
422
  onAllVisibleSelectedChange: (selected: boolean) => {
337
423
  if (selectionDisabled) return;
338
- onSelectedRowIdsChange(
424
+ emitSelectionChange(
339
425
  resolveNextVisibleSelection(controlledSelectedRowIds, rowIds, selected),
426
+ onSelectedRowIdsChange,
427
+ onSelectionChange,
340
428
  );
341
429
  },
342
430
  }
@@ -379,27 +467,41 @@ function DataTableDesktop<TRow extends object>({
379
467
  interactionPolicy={interactionPolicy}
380
468
  onCheckedChange={(nextSelected) => {
381
469
  if (selectionDisabled) return;
382
- onSelectedRowIdsChange(
470
+ emitSelectionChange(
383
471
  resolveNextSelectedRowIds(
384
472
  controlledSelectedRowIds,
385
473
  currentRowId,
386
474
  nextSelected,
387
475
  ),
476
+ onSelectedRowIdsChange,
477
+ onSelectionChange,
388
478
  );
389
479
  }}
390
480
  />
391
481
  </View>
392
482
  ) : null}
393
- {columns.map((column) => (
394
- <View
395
- key={column.id}
396
- px={padding.px}
397
- py={padding.py}
398
- style={resolveCellStyle(column)}
399
- >
400
- {renderTableCell(column, row, rowIndex)}
401
- </View>
402
- ))}
483
+ <View direction="row" style={{ flexGrow: 1, flexShrink: 1 }}>
484
+ {columns.map((column) => (
485
+ <View
486
+ key={column.id}
487
+ px={padding.px}
488
+ py={padding.py}
489
+ style={resolveCellStyle(column)}
490
+ >
491
+ {renderTableCell(column, row, rowIndex)}
492
+ </View>
493
+ ))}
494
+ </View>
495
+ {onRowActivate ? (
496
+ <IconButton
497
+ icon={{ name: 'arrow-forward' }}
498
+ interactionPolicy={interactionPolicy}
499
+ label={`Activate row ${currentRowId}`}
500
+ onPress={() => onRowActivate({ rowId: currentRowId })}
501
+ size="s"
502
+ variant="ghost"
503
+ />
504
+ ) : null}
403
505
  {hasRowActions ? (
404
506
  <View
405
507
  px={padding.px}
@@ -428,6 +530,8 @@ function DataTableMobile<TRow extends object>({
428
530
  rowKey,
429
531
  selectedRowIds,
430
532
  onSelectedRowIdsChange,
533
+ onSelectionChange,
534
+ onRowActivate,
431
535
  testID,
432
536
  interactionPolicy,
433
537
  }: DataTableProps<TRow>) {
@@ -435,7 +539,9 @@ function DataTableMobile<TRow extends object>({
435
539
  const controlledSelectedRowIds = selectedRowIds ?? [];
436
540
  const selectedRowIdSet = new Set(controlledSelectedRowIds);
437
541
  const selectionEnabled = selectedRowIds !== undefined;
438
- const selectionDisabled = interactionPolicy === 'passive' || onSelectedRowIdsChange === undefined;
542
+ const selectionDisabled =
543
+ interactionPolicy === 'passive' ||
544
+ (onSelectedRowIdsChange === undefined && onSelectionChange === undefined);
439
545
 
440
546
  return (
441
547
  <View gap="s">
@@ -445,10 +551,27 @@ function DataTableMobile<TRow extends object>({
445
551
  ? renderCell(primaryColumn, row, rowIndex)
446
552
  : `Row ${rowIndex + 1}`;
447
553
  const actions = renderRowActions({ row, rowActions, rowIndex, testID, interactionPolicy });
554
+ const rowActivation = onRowActivate ? (
555
+ <IconButton
556
+ icon={{ name: 'arrow-forward' }}
557
+ interactionPolicy={interactionPolicy}
558
+ label={`Activate row ${currentRowId}`}
559
+ onPress={() => onRowActivate({ rowId: currentRowId })}
560
+ size="s"
561
+ variant="ghost"
562
+ />
563
+ ) : null;
448
564
 
449
565
  return (
450
566
  <Card
451
- actions={actions}
567
+ actions={
568
+ rowActivation || actions ? (
569
+ <View direction="row" gap="xs">
570
+ {rowActivation}
571
+ {actions}
572
+ </View>
573
+ ) : null
574
+ }
452
575
  compact
453
576
  interactionPolicy={interactionPolicy}
454
577
  key={currentRowId}
@@ -464,12 +587,14 @@ function DataTableMobile<TRow extends object>({
464
587
  interactionPolicy={interactionPolicy}
465
588
  onCheckedChange={(nextSelected) => {
466
589
  if (selectionDisabled) return;
467
- onSelectedRowIdsChange(
590
+ emitSelectionChange(
468
591
  resolveNextSelectedRowIds(
469
592
  controlledSelectedRowIds,
470
593
  currentRowId,
471
594
  nextSelected,
472
595
  ),
596
+ onSelectedRowIdsChange,
597
+ onSelectionChange,
473
598
  );
474
599
  }}
475
600
  />
@@ -479,7 +604,7 @@ function DataTableMobile<TRow extends object>({
479
604
  <Text emphasis="muted" variant="caption" weight="semiBold">
480
605
  {column.header}
481
606
  </Text>
482
- {column.renderCell ? (
607
+ {column.renderCell || column.cell ? (
483
608
  renderCell(column, row, rowIndex)
484
609
  ) : (
485
610
  <Text variant="bodySmall">
@@ -0,0 +1,23 @@
1
+ import { expect, test } from 'bun:test';
2
+
3
+ import { dataTableMeta } from './dataTableMeta';
4
+
5
+ test('describes serializable controlled selection and row activation manifest events', () => {
6
+ expect(JSON.parse(JSON.stringify(dataTableMeta))).toMatchObject({
7
+ bindings: {
8
+ events: {
9
+ rowActivate: { payload: { eventType: 'dataTable.rowActivate' } },
10
+ selectionChange: { payload: { eventType: 'dataTable.selectionChange' } },
11
+ },
12
+ props: { selectedRowIds: { value: { type: 'array' } } },
13
+ },
14
+ events: {
15
+ rowActivate: { payloadFields: [{ path: 'rowId', type: 'string' }] },
16
+ selectionChange: { payloadFields: [{ path: 'selectedRowIds', type: 'unknown' }] },
17
+ },
18
+ });
19
+ expect(dataTableMeta.props.columns.itemSchema.find(({ key }) => key === 'cell')).toEqual({
20
+ key: 'cell',
21
+ schema: { category: 'Content', label: 'Portable cell presentation', type: 'object' },
22
+ });
23
+ });
@@ -15,6 +15,16 @@ export const dataTableMeta = {
15
15
  { path: 'direction', type: 'string' },
16
16
  ],
17
17
  },
18
+ selectionChange: {
19
+ label: 'Selection change',
20
+ eventType: 'dataTable.selectionChange',
21
+ payloadFields: [{ path: 'selectedRowIds', type: 'unknown', label: 'Selected row IDs' }],
22
+ },
23
+ rowActivate: {
24
+ label: 'Activate row',
25
+ eventType: 'dataTable.rowActivate',
26
+ payloadFields: [{ path: 'rowId', type: 'string', label: 'Row ID' }],
27
+ },
18
28
  },
19
29
  bindings: {
20
30
  props: {
@@ -28,6 +38,29 @@ export const dataTableMeta = {
28
38
  },
29
39
  acceptsFallback: true,
30
40
  },
41
+ selectedRowIds: {
42
+ label: 'Selected row IDs',
43
+ description: 'Controlled stable row identities selected with the checkbox column.',
44
+ value: { type: 'array' },
45
+ acceptsFallback: true,
46
+ acceptsTransforms: true,
47
+ },
48
+ },
49
+ events: {
50
+ selectionChange: {
51
+ label: 'Selection change',
52
+ payload: {
53
+ eventType: 'dataTable.selectionChange',
54
+ fields: [{ path: 'selectedRowIds', type: 'unknown', label: 'Selected row IDs' }],
55
+ },
56
+ },
57
+ rowActivate: {
58
+ label: 'Activate row',
59
+ payload: {
60
+ eventType: 'dataTable.rowActivate',
61
+ fields: [{ path: 'rowId', type: 'string', label: 'Row ID' }],
62
+ },
63
+ },
31
64
  },
32
65
  },
33
66
  props: {
@@ -47,8 +80,17 @@ export const dataTableMeta = {
47
80
  { key: 'width', schema: { type: 'number', category: 'Layout' } },
48
81
  { key: 'minWidth', schema: { type: 'number', category: 'Layout' } },
49
82
  { key: 'sortable', schema: { type: 'boolean', category: 'Behavior' } },
83
+ {
84
+ key: 'cell',
85
+ schema: {
86
+ type: 'object',
87
+ category: 'Content',
88
+ label: 'Portable cell presentation',
89
+ },
90
+ },
50
91
  ],
51
92
  },
93
+ selectedRowIds: { type: 'array', category: 'Selection', label: 'Selected row IDs' },
52
94
  loading: { type: 'boolean', category: 'State' },
53
95
  loadingRows: { type: 'number', category: 'State' },
54
96
  emptyTitle: { type: 'string', category: 'Content' },
@@ -1,10 +1,14 @@
1
1
  export type {
2
2
  DataTableCellContext,
3
+ DataTableCellSpec,
3
4
  DataTableColumn,
4
5
  DataTableColumnAlign,
5
6
  DataTableDensity,
6
7
  DataTableProps,
7
8
  DataTableRowAction,
9
+ DataTableRowActivateEvent,
10
+ DataTableRowField,
11
+ DataTableSelectionChangeEvent,
8
12
  DataTableSortDirection,
9
13
  DataTableSortState,
10
14
  } from '../../types/data-table';
@@ -194,12 +194,19 @@ function measureRenderedNodes(cy: Core, nodeIds: readonly string[]): GraphViewMe
194
194
  const nodes = [...new Set(nodeIds)].flatMap((id) => {
195
195
  const node = cy.getElementById(id);
196
196
  if (!node.isNode()) return [];
197
+ const bounds = node.isParent() ? node.renderedBoundingBox() : null;
197
198
 
198
199
  return [
199
200
  {
200
201
  id,
201
- position: node.renderedPosition(),
202
- size: { width: node.renderedOuterWidth(), height: node.renderedOuterHeight() },
202
+ position:
203
+ bounds === null
204
+ ? node.renderedPosition()
205
+ : { x: bounds.x1 + bounds.w / 2, y: bounds.y1 + bounds.h / 2 },
206
+ size:
207
+ bounds === null
208
+ ? { width: node.renderedOuterWidth(), height: node.renderedOuterHeight() }
209
+ : { width: bounds.w, height: bounds.h },
203
210
  },
204
211
  ];
205
212
  });