@ankhorage/zora 27.6.1 → 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 (82) hide show
  1. package/CHANGELOG.md +7 -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/keyboard-avoiding-view/keyboardAvoidingViewMeta.d.ts +1 -1
  28. package/dist/features/layout/gridMeta.d.ts +1 -1
  29. package/dist/features/layout/screenMeta.d.ts +1 -1
  30. package/dist/features/layout/scrollViewMeta.d.ts +1 -1
  31. package/dist/features/layout/viewMeta.d.ts +1 -1
  32. package/dist/features/list/flatListMeta.d.ts +1 -1
  33. package/dist/features/list/sectionListMeta.d.ts +1 -1
  34. package/dist/features/reader/meta.d.ts +2 -2
  35. package/dist/features/registry/bindableComponentMeta.d.ts +42 -3
  36. package/dist/features/registry/bindableComponentMeta.d.ts.map +1 -1
  37. package/dist/features/registry/bindableComponentMeta.js +27 -10
  38. package/dist/features/registry/bindableComponentMeta.js.map +1 -1
  39. package/dist/features/scanner/meta.d.ts +2 -2
  40. package/dist/features/section/screenSectionMeta.d.ts +1 -1
  41. package/dist/features/surface/surfaceMeta.d.ts +1 -1
  42. package/dist/features/tabs/tabPanelMeta.d.ts +1 -1
  43. package/dist/features/timeline/meta.d.ts +79 -3
  44. package/dist/features/timeline/meta.d.ts.map +1 -1
  45. package/dist/features/timeline/meta.js +50 -3
  46. package/dist/features/timeline/meta.js.map +1 -1
  47. package/dist/features/timeline/public.d.ts +1 -1
  48. package/dist/features/timeline/public.d.ts.map +1 -1
  49. package/dist/features/timeline/public.js.map +1 -1
  50. package/dist/readerFree.d.ts +2 -2
  51. package/dist/readerFree.d.ts.map +1 -1
  52. package/dist/readerFree.js.map +1 -1
  53. package/dist/types/data-table.d.ts +37 -0
  54. package/dist/types/data-table.d.ts.map +1 -1
  55. package/dist/types/data-table.js.map +1 -1
  56. package/dist/types/timeline.d.ts +16 -0
  57. package/dist/types/timeline.d.ts.map +1 -1
  58. package/dist/types/timeline.js.map +1 -1
  59. package/package.json +50 -1
  60. package/src/constants/authoring.ts +2 -0
  61. package/src/features/data-table/adapters/inbound/DataTable.test.tsx +127 -6
  62. package/src/features/data-table/adapters/inbound/DataTable.tsx +149 -24
  63. package/src/features/data-table/dataTableMeta.test.ts +23 -0
  64. package/src/features/data-table/dataTableMeta.ts +42 -0
  65. package/src/features/data-table/public.ts +4 -0
  66. package/src/features/registry/bindableComponentMeta.ts +27 -10
  67. package/src/features/registry/componentMeta.test.ts +45 -0
  68. package/src/features/timeline/manifest.test.tsx +115 -0
  69. package/src/features/timeline/meta.ts +50 -3
  70. package/src/features/timeline/public.ts +6 -1
  71. package/src/readerFree.ts +10 -1
  72. package/src/types/data-table.ts +45 -0
  73. package/src/types/timeline.ts +18 -0
  74. package/web-dist/components/data-table/DataTable.d.ts +1 -1
  75. package/web-dist/components/data-table/DataTable.dependency-3.d.ts +1 -0
  76. package/web-dist/components/data-table/DataTable.js +128 -17
  77. package/web-dist/components/data-table/DataTable.types-0.d.ts +42 -0
  78. package/web-dist/components/data-table/index.d.ts +1 -1
  79. package/web-dist/components/timeline/Timeline.d.ts +1 -1
  80. package/web-dist/components/timeline/Timeline.types-0.d.ts +19 -0
  81. package/web-dist/components/timeline/index.d.ts +1 -1
  82. package/web-dist/manifest.json +1 -0
@@ -2,9 +2,34 @@ import type { ButtonIconSpec } from '@ankhorage/surface';
2
2
  import type React from 'react';
3
3
  import type { ZoraBaseProps } from './base';
4
4
  import type { PopoverMenuActionIntent } from './popover-menu';
5
+ import type { TextVariant } from './text';
5
6
  export type DataTableColumnAlign = 'start' | 'center' | 'end';
6
7
  export type DataTableDensity = 'comfortable' | 'compact';
7
8
  export type DataTableSortDirection = 'asc' | 'desc';
9
+ /** A portable reference to a string-valued row field used by a manifest cell. */
10
+ export type DataTableRowField<TRow extends object> = Extract<keyof TRow, string>;
11
+ /** Serializable rich presentations for a DataTable column. */
12
+ export type DataTableCellSpec<TRow extends object> = {
13
+ readonly kind: 'image';
14
+ readonly source: DataTableRowField<TRow>;
15
+ readonly alt?: DataTableRowField<TRow>;
16
+ } | {
17
+ readonly kind: 'text';
18
+ readonly value: DataTableRowField<TRow>;
19
+ readonly weight?: 'regular' | 'medium' | 'semiBold' | 'bold';
20
+ readonly variant?: TextVariant;
21
+ } | {
22
+ readonly kind: 'link';
23
+ readonly href: DataTableRowField<TRow>;
24
+ readonly label?: DataTableRowField<TRow>;
25
+ readonly variant?: TextVariant;
26
+ } | {
27
+ readonly kind: 'stack';
28
+ readonly direction: 'row' | 'column';
29
+ readonly align?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
30
+ readonly gap?: 'xxs' | 'xs' | 's' | 'm' | 'l';
31
+ readonly children: readonly DataTableCellSpec<TRow>[];
32
+ };
8
33
  export interface DataTableSortState {
9
34
  columnId: string;
10
35
  direction: DataTableSortDirection;
@@ -23,8 +48,16 @@ export interface DataTableColumn<TRow extends object> {
23
48
  width?: number;
24
49
  minWidth?: number;
25
50
  sortable?: boolean;
51
+ /** Portable manifest presentation. Takes precedence over the default accessor rendering. */
52
+ cell?: DataTableCellSpec<TRow>;
26
53
  renderCell?: (context: DataTableCellContext<TRow>) => React.ReactNode;
27
54
  }
55
+ export interface DataTableSelectionChangeEvent {
56
+ readonly selectedRowIds: readonly string[];
57
+ }
58
+ export interface DataTableRowActivateEvent {
59
+ readonly rowId: string;
60
+ }
28
61
  export interface DataTableRowAction<TRow extends object> {
29
62
  id: string;
30
63
  title: React.ReactNode;
@@ -43,6 +76,10 @@ export interface DataTableProps<TRow extends object> extends ZoraBaseProps {
43
76
  selectedRowIds?: readonly string[];
44
77
  /** Receives the next controlled selection after a row or visible-row toggle. */
45
78
  onSelectedRowIdsChange?: (selectedRowIds: readonly string[]) => void;
79
+ /** Emits the serializable controlled selection payload used by AppManifest events. */
80
+ onSelectionChange?: (event: DataTableSelectionChangeEvent) => void;
81
+ /** Emits a row activation independently of checkbox selection. */
82
+ onRowActivate?: (event: DataTableRowActivateEvent) => void;
46
83
  rowActions?: (row: TRow, index: number) => readonly DataTableRowAction<TRow>[];
47
84
  sort?: DataTableSortState;
48
85
  onSortChange?: (sort: DataTableSortState) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/types/data-table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,K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AAE,kBAAkB,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.js","sourceRoot":"","sources":["../../src/types/data-table.ts"],"names":[],"mappings":"","sourcesContent":["import type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\nimport type { PopoverMenuActionIntent } from './popover-menu';\n\nexport type DataTableColumnAlign = 'start' | 'center' | 'end';\nexport type DataTableDensity = 'comfortable' | 'compact';\nexport type DataTableSortDirection = 'asc' | 'desc';\n\nexport interface DataTableSortState {\n columnId: string;\n direction: DataTableSortDirection;\n}\n\nexport interface DataTableCellContext<TRow extends object> {\n row: TRow;\n rowIndex: number;\n column: DataTableColumn<TRow>;\n value: unknown;\n}\n\nexport interface DataTableColumn<TRow extends object> {\n id: string;\n header: React.ReactNode;\n accessor?: keyof TRow;\n align?: DataTableColumnAlign;\n width?: number;\n minWidth?: number;\n sortable?: boolean;\n renderCell?: (context: DataTableCellContext<TRow>) => React.ReactNode;\n}\n\nexport interface DataTableRowAction<TRow extends object> {\n id: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n icon?: ButtonIconSpec;\n intent?: PopoverMenuActionIntent;\n disabled?: boolean;\n onPress?: (row: TRow) => void;\n}\n\nexport interface DataTableProps<TRow extends object> extends ZoraBaseProps {\n columns: readonly DataTableColumn<TRow>[];\n rows: readonly TRow[];\n rowId?: (row: TRow, index: number) => string;\n rowKey?: keyof TRow;\n /** Controlled identifiers for rows selected with the optional checkbox column. */\n selectedRowIds?: readonly string[];\n /** Receives the next controlled selection after a row or visible-row toggle. */\n onSelectedRowIdsChange?: (selectedRowIds: readonly string[]) => void;\n rowActions?: (row: TRow, index: number) => readonly DataTableRowAction<TRow>[];\n sort?: DataTableSortState;\n onSortChange?: (sort: DataTableSortState) => void;\n loading?: boolean;\n loadingRows?: number;\n emptyTitle?: React.ReactNode;\n emptyDescription?: React.ReactNode;\n density?: DataTableDensity;\n testID?: string;\n}\n"]}
1
+ {"version":3,"file":"data-table.js","sourceRoot":"","sources":["../../src/types/data-table.ts"],"names":[],"mappings":"","sourcesContent":["import type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\nimport type { PopoverMenuActionIntent } from './popover-menu';\nimport type { TextVariant } from './text';\n\nexport type DataTableColumnAlign = 'start' | 'center' | 'end';\nexport type DataTableDensity = 'comfortable' | 'compact';\nexport type DataTableSortDirection = 'asc' | 'desc';\n\n/** A portable reference to a string-valued row field used by a manifest cell. */\nexport type DataTableRowField<TRow extends object> = Extract<keyof TRow, string>;\n\n/** Serializable rich presentations for a DataTable column. */\nexport type DataTableCellSpec<TRow extends object> =\n | {\n readonly kind: 'image';\n readonly source: DataTableRowField<TRow>;\n readonly alt?: DataTableRowField<TRow>;\n }\n | {\n readonly kind: 'text';\n readonly value: DataTableRowField<TRow>;\n readonly weight?: 'regular' | 'medium' | 'semiBold' | 'bold';\n readonly variant?: TextVariant;\n }\n | {\n readonly kind: 'link';\n readonly href: DataTableRowField<TRow>;\n readonly label?: DataTableRowField<TRow>;\n readonly variant?: TextVariant;\n }\n | {\n readonly kind: 'stack';\n readonly direction: 'row' | 'column';\n readonly align?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';\n readonly gap?: 'xxs' | 'xs' | 's' | 'm' | 'l';\n readonly children: readonly DataTableCellSpec<TRow>[];\n };\n\nexport interface DataTableSortState {\n columnId: string;\n direction: DataTableSortDirection;\n}\n\nexport interface DataTableCellContext<TRow extends object> {\n row: TRow;\n rowIndex: number;\n column: DataTableColumn<TRow>;\n value: unknown;\n}\n\nexport interface DataTableColumn<TRow extends object> {\n id: string;\n header: React.ReactNode;\n accessor?: keyof TRow;\n align?: DataTableColumnAlign;\n width?: number;\n minWidth?: number;\n sortable?: boolean;\n /** Portable manifest presentation. Takes precedence over the default accessor rendering. */\n cell?: DataTableCellSpec<TRow>;\n renderCell?: (context: DataTableCellContext<TRow>) => React.ReactNode;\n}\n\nexport interface DataTableSelectionChangeEvent {\n readonly selectedRowIds: readonly string[];\n}\n\nexport interface DataTableRowActivateEvent {\n readonly rowId: string;\n}\n\nexport interface DataTableRowAction<TRow extends object> {\n id: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n icon?: ButtonIconSpec;\n intent?: PopoverMenuActionIntent;\n disabled?: boolean;\n onPress?: (row: TRow) => void;\n}\n\nexport interface DataTableProps<TRow extends object> extends ZoraBaseProps {\n columns: readonly DataTableColumn<TRow>[];\n rows: readonly TRow[];\n rowId?: (row: TRow, index: number) => string;\n rowKey?: keyof TRow;\n /** Controlled identifiers for rows selected with the optional checkbox column. */\n selectedRowIds?: readonly string[];\n /** Receives the next controlled selection after a row or visible-row toggle. */\n onSelectedRowIdsChange?: (selectedRowIds: readonly string[]) => void;\n /** Emits the serializable controlled selection payload used by AppManifest events. */\n onSelectionChange?: (event: DataTableSelectionChangeEvent) => void;\n /** Emits a row activation independently of checkbox selection. */\n onRowActivate?: (event: DataTableRowActivateEvent) => void;\n rowActions?: (row: TRow, index: number) => readonly DataTableRowAction<TRow>[];\n sort?: DataTableSortState;\n onSortChange?: (sort: DataTableSortState) => void;\n loading?: boolean;\n loadingRows?: number;\n emptyTitle?: React.ReactNode;\n emptyDescription?: React.ReactNode;\n density?: DataTableDensity;\n testID?: string;\n}\n"]}
@@ -1,8 +1,24 @@
1
+ import type { MediaAssetReference } from '@ankhorage/contracts';
1
2
  import type { ButtonIconSpec } from '@ankhorage/surface';
2
3
  import type React from 'react';
3
4
  import type { ZoraBaseProps } from './base';
4
5
  import type { ImageProps } from './image';
5
6
  import type { ZoraColor } from './theme';
7
+ /** Portable Timeline item shape accepted by an AppManifest component node. */
8
+ export interface TimelineManifestItem {
9
+ readonly id: string;
10
+ readonly title: string;
11
+ readonly description?: string;
12
+ readonly meta?: string;
13
+ readonly status?: ZoraColor;
14
+ readonly marker?: MediaAssetReference;
15
+ readonly markerAlt?: string;
16
+ }
17
+ /** Portable Timeline props accepted by an AppManifest component node. */
18
+ export interface TimelineManifestProps {
19
+ readonly items: readonly TimelineManifestItem[];
20
+ readonly compact?: boolean;
21
+ }
6
22
  export interface TimelineItem {
7
23
  id: string;
8
24
  title: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/types/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC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AE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/types/timeline.ts"],"names":[],"mappings":"","sourcesContent":["import type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\nimport type { ImageProps } from './image';\nimport type { ZoraColor } from './theme';\n\nexport interface TimelineItem {\n id: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n meta?: React.ReactNode;\n status?: ZoraColor;\n icon?: ButtonIconSpec;\n marker?: ImageProps['source'];\n markerAlt?: string;\n testID?: string;\n}\n\nexport interface TimelineProps extends ZoraBaseProps {\n items: readonly TimelineItem[];\n compact?: boolean;\n}\n"]}
1
+ {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/types/timeline.ts"],"names":[],"mappings":"","sourcesContent":["import type { MediaAssetReference } from '@ankhorage/contracts';\nimport type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraBaseProps } from './base';\nimport type { ImageProps } from './image';\nimport type { ZoraColor } from './theme';\n\n/** Portable Timeline item shape accepted by an AppManifest component node. */\nexport interface TimelineManifestItem {\n readonly id: string;\n readonly title: string;\n readonly description?: string;\n readonly meta?: string;\n readonly status?: ZoraColor;\n readonly marker?: MediaAssetReference;\n readonly markerAlt?: string;\n}\n\n/** Portable Timeline props accepted by an AppManifest component node. */\nexport interface TimelineManifestProps {\n readonly items: readonly TimelineManifestItem[];\n readonly compact?: boolean;\n}\n\nexport interface TimelineItem {\n id: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n meta?: React.ReactNode;\n status?: ZoraColor;\n icon?: ButtonIconSpec;\n marker?: ImageProps['source'];\n markerAlt?: string;\n testID?: string;\n}\n\nexport interface TimelineProps extends ZoraBaseProps {\n items: readonly TimelineItem[];\n compact?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/zora",
3
3
  "type": "module",
4
- "version": "27.6.1",
4
+ "version": "27.7.0",
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": {
@@ -660,6 +660,55 @@
660
660
  }
661
661
  }
662
662
  },
663
+ {
664
+ "id": "dataTable.rowActivate",
665
+ "owner": "@ankhorage/zora",
666
+ "access": [
667
+ "emit"
668
+ ],
669
+ "binding": {
670
+ "kind": "event",
671
+ "bindableAs": [
672
+ "source"
673
+ ]
674
+ },
675
+ "label": "Activate row",
676
+ "output": {
677
+ "schema": {
678
+ "type": "object",
679
+ "properties": {
680
+ "rowId": {
681
+ "type": "string",
682
+ "title": "Row ID"
683
+ }
684
+ }
685
+ }
686
+ }
687
+ },
688
+ {
689
+ "id": "dataTable.selectionChange",
690
+ "owner": "@ankhorage/zora",
691
+ "access": [
692
+ "emit"
693
+ ],
694
+ "binding": {
695
+ "kind": "event",
696
+ "bindableAs": [
697
+ "source"
698
+ ]
699
+ },
700
+ "label": "Selection change",
701
+ "output": {
702
+ "schema": {
703
+ "type": "object",
704
+ "properties": {
705
+ "selectedRowIds": {
706
+ "title": "Selected row IDs"
707
+ }
708
+ }
709
+ }
710
+ }
711
+ },
663
712
  {
664
713
  "id": "dataTable.sortChange",
665
714
  "owner": "@ankhorage/zora",
@@ -47,6 +47,7 @@ export const FEATURE_MANIFEST_ELEMENTS = {
47
47
  toolbar: ['Toolbar'],
48
48
  typography: ['Heading', 'Text'],
49
49
  'time-picker': ['TimePicker'],
50
+ timeline: ['Timeline'],
50
51
  uploader: ['Uploader'],
51
52
  'bottom-sheet': ['BottomSheet'],
52
53
  chess: ['ChessBoard', 'OpeningBook'],
@@ -109,6 +110,7 @@ export const CONTAINER_ALLOWED_CHILDREN = [
109
110
  'ThemeModeToggle',
110
111
  'TextInput',
111
112
  'TimePicker',
113
+ 'Timeline',
112
114
  'Form',
113
115
  'Card',
114
116
  'EmptyState',
@@ -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
+ });