@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.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/capabilities/index.js +94 -5
- package/dist/capabilities/index.js.map +5 -5
- package/dist/constants/authoring.d.ts +4 -3
- package/dist/constants/authoring.d.ts.map +1 -1
- package/dist/constants/authoring.js +2 -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/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/data-table/adapters/inbound/DataTable.d.ts.map +1 -1
- package/dist/features/data-table/adapters/inbound/DataTable.js +90 -18
- package/dist/features/data-table/adapters/inbound/DataTable.js.map +1 -1
- package/dist/features/data-table/dataTableMeta.d.ts +63 -0
- package/dist/features/data-table/dataTableMeta.d.ts.map +1 -1
- package/dist/features/data-table/dataTableMeta.js +42 -0
- package/dist/features/data-table/dataTableMeta.js.map +1 -1
- package/dist/features/data-table/public.d.ts +1 -1
- package/dist/features/data-table/public.d.ts.map +1 -1
- package/dist/features/data-table/public.js.map +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/reader/meta.d.ts +2 -2
- package/dist/features/registry/bindableComponentMeta.d.ts +42 -3
- package/dist/features/registry/bindableComponentMeta.d.ts.map +1 -1
- package/dist/features/registry/bindableComponentMeta.js +27 -10
- package/dist/features/registry/bindableComponentMeta.js.map +1 -1
- 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/timeline/meta.d.ts +79 -3
- package/dist/features/timeline/meta.d.ts.map +1 -1
- package/dist/features/timeline/meta.js +50 -3
- package/dist/features/timeline/meta.js.map +1 -1
- package/dist/features/timeline/public.d.ts +1 -1
- package/dist/features/timeline/public.d.ts.map +1 -1
- package/dist/features/timeline/public.js.map +1 -1
- package/dist/readerFree.d.ts +2 -2
- package/dist/readerFree.d.ts.map +1 -1
- package/dist/readerFree.js.map +1 -1
- package/dist/types/data-table.d.ts +37 -0
- package/dist/types/data-table.d.ts.map +1 -1
- package/dist/types/data-table.js.map +1 -1
- package/dist/types/timeline.d.ts +16 -0
- package/dist/types/timeline.d.ts.map +1 -1
- package/dist/types/timeline.js.map +1 -1
- package/package.json +50 -1
- package/src/constants/authoring.ts +2 -0
- package/src/features/data-table/adapters/inbound/DataTable.test.tsx +127 -6
- package/src/features/data-table/adapters/inbound/DataTable.tsx +149 -24
- package/src/features/data-table/dataTableMeta.test.ts +23 -0
- package/src/features/data-table/dataTableMeta.ts +42 -0
- package/src/features/data-table/public.ts +4 -0
- package/src/features/registry/bindableComponentMeta.ts +27 -10
- package/src/features/registry/componentMeta.test.ts +45 -0
- package/src/features/timeline/manifest.test.tsx +115 -0
- package/src/features/timeline/meta.ts +50 -3
- package/src/features/timeline/public.ts +6 -1
- package/src/readerFree.ts +10 -1
- package/src/types/data-table.ts +45 -0
- package/src/types/timeline.ts +18 -0
- package/web-dist/components/data-table/DataTable.d.ts +1 -1
- package/web-dist/components/data-table/DataTable.dependency-3.d.ts +1 -0
- package/web-dist/components/data-table/DataTable.js +128 -17
- package/web-dist/components/data-table/DataTable.types-0.d.ts +42 -0
- package/web-dist/components/data-table/index.d.ts +1 -1
- package/web-dist/components/timeline/Timeline.d.ts +1 -1
- package/web-dist/components/timeline/Timeline.types-0.d.ts +19 -0
- package/web-dist/components/timeline/index.d.ts +1 -1
- package/web-dist/manifest.json +1 -0
|
@@ -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
|
-
|
|
7
|
+
description: 'Displays an ordered sequence of dated events with accessible image markers.',
|
|
8
|
+
directManifestNode: true,
|
|
7
9
|
allowedChildren: [],
|
|
8
|
-
|
|
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;
|
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 {
|
|
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,
|
package/src/types/data-table.ts
CHANGED
|
@@ -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;
|
package/src/types/timeline.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MediaAssetReference } from '@ankhorage/contracts';
|
|
1
2
|
import type { ButtonIconSpec } from '@ankhorage/surface';
|
|
2
3
|
import type React from 'react';
|
|
3
4
|
|
|
@@ -5,6 +6,23 @@ import type { ZoraBaseProps } from './base';
|
|
|
5
6
|
import type { ImageProps } from './image';
|
|
6
7
|
import type { ZoraColor } from './theme';
|
|
7
8
|
|
|
9
|
+
/** Portable Timeline item shape accepted by an AppManifest component node. */
|
|
10
|
+
export interface TimelineManifestItem {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly meta?: string;
|
|
15
|
+
readonly status?: ZoraColor;
|
|
16
|
+
readonly marker?: MediaAssetReference;
|
|
17
|
+
readonly markerAlt?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Portable Timeline props accepted by an AppManifest component node. */
|
|
21
|
+
export interface TimelineManifestProps {
|
|
22
|
+
readonly items: readonly TimelineManifestItem[];
|
|
23
|
+
readonly compact?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
export interface TimelineItem {
|
|
9
27
|
id: string;
|
|
10
28
|
title: React.ReactNode;
|
|
@@ -6,4 +6,4 @@ import type { DataTableProps } from './DataTable.types-0';
|
|
|
6
6
|
* Displays structured tabular data with responsive columns and optional controlled row selection.
|
|
7
7
|
*/
|
|
8
8
|
export declare const DataTable: <TRow extends object>(props: DataTableProps<TRow>) => React.ReactElement | null;
|
|
9
|
-
export type { DataTableCellContext, DataTableColumn, DataTableColumnAlign, DataTableDensity, DataTableProps, DataTableRowAction, DataTableSortDirection, DataTableSortState } from './DataTable.types-0';
|
|
9
|
+
export type { DataTableCellContext, DataTableCellSpec, DataTableColumn, DataTableColumnAlign, DataTableDensity, DataTableProps, DataTableRowAction, DataTableRowActivateEvent, DataTableRowField, DataTableSelectionChangeEvent, DataTableSortDirection, DataTableSortState } from './DataTable.types-0';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TextVariant = 'body' | 'lead' | 'bodySmall' | 'caption' | 'label' | 'eyebrow' | 'code';
|
|
@@ -29,7 +29,9 @@ import {
|
|
|
29
29
|
import"../../chunks/Accordion-ms1y70gq.js";
|
|
30
30
|
import"../../chunks/Accordion-9hcbf56f.js";
|
|
31
31
|
import"../../chunks/Accordion-260pyaxy.js";
|
|
32
|
-
import
|
|
32
|
+
import {
|
|
33
|
+
Image2
|
|
34
|
+
} from "../../chunks/Accordion-kcca65d8.js";
|
|
33
35
|
import {
|
|
34
36
|
EmptyState2
|
|
35
37
|
} from "../../chunks/Accordion-tnt1txfq.js";
|
|
@@ -74,6 +76,7 @@ function Show({ when, children, fallback = null }) {
|
|
|
74
76
|
|
|
75
77
|
// src/features/data-table/adapters/inbound/DataTable.tsx
|
|
76
78
|
var import_react_native = __toESM(require_cjs(), 1);
|
|
79
|
+
import React from "react";
|
|
77
80
|
|
|
78
81
|
// src/features/data-table/utils/resolveDataTableRowKey.ts
|
|
79
82
|
function resolveDataTableRowKey(row, index, rowKey, rowId) {
|
|
@@ -146,6 +149,74 @@ function renderDefaultCell(value) {
|
|
|
146
149
|
}
|
|
147
150
|
return "—";
|
|
148
151
|
}
|
|
152
|
+
function resolveCellField(row, field) {
|
|
153
|
+
return Object.getOwnPropertyDescriptor(row, field)?.value;
|
|
154
|
+
}
|
|
155
|
+
function resolveCellString(value) {
|
|
156
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : undefined;
|
|
157
|
+
}
|
|
158
|
+
function resolveExternalWebsiteUrl(url) {
|
|
159
|
+
try {
|
|
160
|
+
const parsedUrl = new URL(url);
|
|
161
|
+
return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? url : undefined;
|
|
162
|
+
} catch {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function openExternalUrl(url) {
|
|
167
|
+
const externalUrl = resolveExternalWebsiteUrl(url);
|
|
168
|
+
if (externalUrl) {
|
|
169
|
+
import_react_native.Linking.openURL(externalUrl);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function renderPortableCell(cell, row) {
|
|
173
|
+
switch (cell.kind) {
|
|
174
|
+
case "image": {
|
|
175
|
+
const source = resolveCellString(resolveCellField(row, cell.source));
|
|
176
|
+
const alt = resolveCellString(resolveCellField(row, cell.alt ?? cell.source));
|
|
177
|
+
return /* @__PURE__ */ jsx2(Image2, {
|
|
178
|
+
alt,
|
|
179
|
+
height: 32,
|
|
180
|
+
radius: "s",
|
|
181
|
+
source,
|
|
182
|
+
width: 32
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
case "text":
|
|
186
|
+
return /* @__PURE__ */ jsx2(Text3, {
|
|
187
|
+
variant: cell.variant ?? "bodySmall",
|
|
188
|
+
weight: cell.weight,
|
|
189
|
+
children: renderDefaultCell(resolveCellField(row, cell.value))
|
|
190
|
+
});
|
|
191
|
+
case "link": {
|
|
192
|
+
const href = resolveCellString(resolveCellField(row, cell.href));
|
|
193
|
+
const label = resolveCellString(resolveCellField(row, cell.label ?? cell.href)) ?? href;
|
|
194
|
+
const externalUrl = href ? resolveExternalWebsiteUrl(href) : undefined;
|
|
195
|
+
return externalUrl ? /* @__PURE__ */ jsx2(import_react_native.Pressable, {
|
|
196
|
+
accessibilityRole: "link",
|
|
197
|
+
onPress: () => openExternalUrl(externalUrl),
|
|
198
|
+
children: /* @__PURE__ */ jsx2(Text3, {
|
|
199
|
+
color: "primary",
|
|
200
|
+
variant: cell.variant ?? "bodySmall",
|
|
201
|
+
weight: "medium",
|
|
202
|
+
children: label
|
|
203
|
+
})
|
|
204
|
+
}) : /* @__PURE__ */ jsx2(Text3, {
|
|
205
|
+
variant: "bodySmall",
|
|
206
|
+
children: "—"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
case "stack":
|
|
210
|
+
return /* @__PURE__ */ jsx2(View2, {
|
|
211
|
+
align: cell.align,
|
|
212
|
+
direction: cell.direction,
|
|
213
|
+
gap: cell.gap,
|
|
214
|
+
children: cell.children.map((child, index) => /* @__PURE__ */ jsx2(React.Fragment, {
|
|
215
|
+
children: renderPortableCell(child, row)
|
|
216
|
+
}, `cell-${index}`))
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
149
220
|
function createCellContext(column, row, rowIndex) {
|
|
150
221
|
return {
|
|
151
222
|
column,
|
|
@@ -156,12 +227,17 @@ function createCellContext(column, row, rowIndex) {
|
|
|
156
227
|
}
|
|
157
228
|
function renderCell(column, row, rowIndex) {
|
|
158
229
|
const context = createCellContext(column, row, rowIndex);
|
|
159
|
-
|
|
230
|
+
if (column.renderCell)
|
|
231
|
+
return column.renderCell(context);
|
|
232
|
+
if (column.cell)
|
|
233
|
+
return renderPortableCell(column.cell, row);
|
|
234
|
+
return renderDefaultCell(context.value);
|
|
160
235
|
}
|
|
161
236
|
function renderTableCell(column, row, rowIndex) {
|
|
162
|
-
if (column.renderCell)
|
|
237
|
+
if (column.renderCell)
|
|
163
238
|
return column.renderCell(createCellContext(column, row, rowIndex));
|
|
164
|
-
|
|
239
|
+
if (column.cell)
|
|
240
|
+
return renderPortableCell(column.cell, row);
|
|
165
241
|
return /* @__PURE__ */ jsx2(Text3, {
|
|
166
242
|
align: resolveTextAlign(column.align),
|
|
167
243
|
variant: "bodySmall",
|
|
@@ -178,6 +254,10 @@ function resolveNextVisibleSelection(selectedRowIds, visibleRowIds, selected) {
|
|
|
178
254
|
const visibleRowIdSet = new Set(visibleRowIds);
|
|
179
255
|
return selected ? [...new Set([...selectedRowIds, ...visibleRowIds])] : selectedRowIds.filter((selectedRowId) => !visibleRowIdSet.has(selectedRowId));
|
|
180
256
|
}
|
|
257
|
+
function emitSelectionChange(selectedRowIds, onSelectedRowIdsChange, onSelectionChange) {
|
|
258
|
+
onSelectedRowIdsChange?.(selectedRowIds);
|
|
259
|
+
onSelectionChange?.({ selectedRowIds });
|
|
260
|
+
}
|
|
181
261
|
function mapRowActions(row, actions) {
|
|
182
262
|
return actions.map((action) => ({
|
|
183
263
|
description: action.description,
|
|
@@ -304,6 +384,8 @@ function DataTableDesktop({
|
|
|
304
384
|
rowKey,
|
|
305
385
|
selectedRowIds,
|
|
306
386
|
onSelectedRowIdsChange,
|
|
387
|
+
onSelectionChange,
|
|
388
|
+
onRowActivate,
|
|
307
389
|
sort,
|
|
308
390
|
onSortChange,
|
|
309
391
|
density,
|
|
@@ -315,7 +397,7 @@ function DataTableDesktop({
|
|
|
315
397
|
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
316
398
|
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
317
399
|
const selectionEnabled = selectedRowIds !== undefined;
|
|
318
|
-
const selectionDisabled = interactionPolicy === "passive" || onSelectedRowIdsChange === undefined;
|
|
400
|
+
const selectionDisabled = interactionPolicy === "passive" || onSelectedRowIdsChange === undefined && onSelectionChange === undefined;
|
|
319
401
|
const hasRowActions = rows.some((row, rowIndex) => (rowActions?.(row, rowIndex).length ?? 0) > 0);
|
|
320
402
|
const selection = selectionEnabled ? {
|
|
321
403
|
allVisibleSelected: rowIds.every((currentRowId) => selectedRowIdSet.has(currentRowId)),
|
|
@@ -323,7 +405,7 @@ function DataTableDesktop({
|
|
|
323
405
|
onAllVisibleSelectedChange: (selected) => {
|
|
324
406
|
if (selectionDisabled)
|
|
325
407
|
return;
|
|
326
|
-
|
|
408
|
+
emitSelectionChange(resolveNextVisibleSelection(controlledSelectedRowIds, rowIds, selected), onSelectedRowIdsChange, onSelectionChange);
|
|
327
409
|
}
|
|
328
410
|
} : undefined;
|
|
329
411
|
return /* @__PURE__ */ jsx2(import_react_native.ScrollView, {
|
|
@@ -370,16 +452,28 @@ function DataTableDesktop({
|
|
|
370
452
|
onCheckedChange: (nextSelected) => {
|
|
371
453
|
if (selectionDisabled)
|
|
372
454
|
return;
|
|
373
|
-
|
|
455
|
+
emitSelectionChange(resolveNextSelectedRowIds(controlledSelectedRowIds, currentRowId, nextSelected), onSelectedRowIdsChange, onSelectionChange);
|
|
374
456
|
}
|
|
375
457
|
})
|
|
376
458
|
}) : null,
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
459
|
+
/* @__PURE__ */ jsx2(View2, {
|
|
460
|
+
direction: "row",
|
|
461
|
+
style: { flexGrow: 1, flexShrink: 1 },
|
|
462
|
+
children: columns.map((column) => /* @__PURE__ */ jsx2(View2, {
|
|
463
|
+
px: padding.px,
|
|
464
|
+
py: padding.py,
|
|
465
|
+
style: resolveCellStyle(column),
|
|
466
|
+
children: renderTableCell(column, row, rowIndex)
|
|
467
|
+
}, column.id))
|
|
468
|
+
}),
|
|
469
|
+
onRowActivate ? /* @__PURE__ */ jsx2(IconButton2, {
|
|
470
|
+
icon: { name: "arrow-forward" },
|
|
471
|
+
interactionPolicy,
|
|
472
|
+
label: `Activate row ${currentRowId}`,
|
|
473
|
+
onPress: () => onRowActivate({ rowId: currentRowId }),
|
|
474
|
+
size: "s",
|
|
475
|
+
variant: "ghost"
|
|
476
|
+
}) : null,
|
|
383
477
|
hasRowActions ? /* @__PURE__ */ jsx2(View2, {
|
|
384
478
|
px: padding.px,
|
|
385
479
|
py: padding.py,
|
|
@@ -404,6 +498,8 @@ function DataTableMobile({
|
|
|
404
498
|
rowKey,
|
|
405
499
|
selectedRowIds,
|
|
406
500
|
onSelectedRowIdsChange,
|
|
501
|
+
onSelectionChange,
|
|
502
|
+
onRowActivate,
|
|
407
503
|
testID,
|
|
408
504
|
interactionPolicy
|
|
409
505
|
}) {
|
|
@@ -411,15 +507,30 @@ function DataTableMobile({
|
|
|
411
507
|
const controlledSelectedRowIds = selectedRowIds ?? [];
|
|
412
508
|
const selectedRowIdSet = new Set(controlledSelectedRowIds);
|
|
413
509
|
const selectionEnabled = selectedRowIds !== undefined;
|
|
414
|
-
const selectionDisabled = interactionPolicy === "passive" || onSelectedRowIdsChange === undefined;
|
|
510
|
+
const selectionDisabled = interactionPolicy === "passive" || onSelectedRowIdsChange === undefined && onSelectionChange === undefined;
|
|
415
511
|
return /* @__PURE__ */ jsx2(View2, {
|
|
416
512
|
gap: "s",
|
|
417
513
|
children: rows.map((row, rowIndex) => {
|
|
418
514
|
const currentRowId = resolveDataTableRowKey(row, rowIndex, rowKey, rowId);
|
|
419
515
|
const title = primaryColumn ? renderCell(primaryColumn, row, rowIndex) : `Row ${rowIndex + 1}`;
|
|
420
516
|
const actions = renderRowActions({ row, rowActions, rowIndex, testID, interactionPolicy });
|
|
517
|
+
const rowActivation = onRowActivate ? /* @__PURE__ */ jsx2(IconButton2, {
|
|
518
|
+
icon: { name: "arrow-forward" },
|
|
519
|
+
interactionPolicy,
|
|
520
|
+
label: `Activate row ${currentRowId}`,
|
|
521
|
+
onPress: () => onRowActivate({ rowId: currentRowId }),
|
|
522
|
+
size: "s",
|
|
523
|
+
variant: "ghost"
|
|
524
|
+
}) : null;
|
|
421
525
|
return /* @__PURE__ */ jsx2(Card2, {
|
|
422
|
-
actions,
|
|
526
|
+
actions: rowActivation || actions ? /* @__PURE__ */ jsxs(View2, {
|
|
527
|
+
direction: "row",
|
|
528
|
+
gap: "xs",
|
|
529
|
+
children: [
|
|
530
|
+
rowActivation,
|
|
531
|
+
actions
|
|
532
|
+
]
|
|
533
|
+
}) : null,
|
|
423
534
|
compact: true,
|
|
424
535
|
interactionPolicy,
|
|
425
536
|
testID: testID ? `${testID}-card-${rowIndex}` : undefined,
|
|
@@ -435,7 +546,7 @@ function DataTableMobile({
|
|
|
435
546
|
onCheckedChange: (nextSelected) => {
|
|
436
547
|
if (selectionDisabled)
|
|
437
548
|
return;
|
|
438
|
-
|
|
549
|
+
emitSelectionChange(resolveNextSelectedRowIds(controlledSelectedRowIds, currentRowId, nextSelected), onSelectedRowIdsChange, onSelectionChange);
|
|
439
550
|
}
|
|
440
551
|
}) : null,
|
|
441
552
|
detailColumns.map((column) => /* @__PURE__ */ jsxs(View2, {
|
|
@@ -447,7 +558,7 @@ function DataTableMobile({
|
|
|
447
558
|
weight: "semiBold",
|
|
448
559
|
children: column.header
|
|
449
560
|
}),
|
|
450
|
-
column.renderCell ? renderCell(column, row, rowIndex) : /* @__PURE__ */ jsx2(Text3, {
|
|
561
|
+
column.renderCell || column.cell ? renderCell(column, row, rowIndex) : /* @__PURE__ */ jsx2(Text3, {
|
|
451
562
|
variant: "bodySmall",
|
|
452
563
|
children: renderDefaultCell(resolveAccessorValue(row, column))
|
|
453
564
|
})
|
|
@@ -6,12 +6,40 @@ import type { ZoraBaseProps } from './DataTable.dependency-0';
|
|
|
6
6
|
|
|
7
7
|
import type { PopoverMenuActionIntent } from './DataTable.dependency-2';
|
|
8
8
|
|
|
9
|
+
import type { TextVariant } from './DataTable.dependency-3';
|
|
10
|
+
|
|
9
11
|
export type DataTableColumnAlign = 'start' | 'center' | 'end';
|
|
10
12
|
|
|
11
13
|
export type DataTableDensity = 'comfortable' | 'compact';
|
|
12
14
|
|
|
13
15
|
export type DataTableSortDirection = 'asc' | 'desc';
|
|
14
16
|
|
|
17
|
+
/** A portable reference to a string-valued row field used by a manifest cell. */
|
|
18
|
+
export type DataTableRowField<TRow extends object> = Extract<keyof TRow, string>;
|
|
19
|
+
|
|
20
|
+
/** Serializable rich presentations for a DataTable column. */
|
|
21
|
+
export type DataTableCellSpec<TRow extends object> = {
|
|
22
|
+
readonly kind: 'image';
|
|
23
|
+
readonly source: DataTableRowField<TRow>;
|
|
24
|
+
readonly alt?: DataTableRowField<TRow>;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'text';
|
|
27
|
+
readonly value: DataTableRowField<TRow>;
|
|
28
|
+
readonly weight?: 'regular' | 'medium' | 'semiBold' | 'bold';
|
|
29
|
+
readonly variant?: TextVariant;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: 'link';
|
|
32
|
+
readonly href: DataTableRowField<TRow>;
|
|
33
|
+
readonly label?: DataTableRowField<TRow>;
|
|
34
|
+
readonly variant?: TextVariant;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'stack';
|
|
37
|
+
readonly direction: 'row' | 'column';
|
|
38
|
+
readonly align?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
|
|
39
|
+
readonly gap?: 'xxs' | 'xs' | 's' | 'm' | 'l';
|
|
40
|
+
readonly children: readonly DataTableCellSpec<TRow>[];
|
|
41
|
+
};
|
|
42
|
+
|
|
15
43
|
export interface DataTableSortState {
|
|
16
44
|
columnId: string;
|
|
17
45
|
direction: DataTableSortDirection;
|
|
@@ -32,9 +60,19 @@ export interface DataTableColumn<TRow extends object> {
|
|
|
32
60
|
width?: number;
|
|
33
61
|
minWidth?: number;
|
|
34
62
|
sortable?: boolean;
|
|
63
|
+
/** Portable manifest presentation. Takes precedence over the default accessor rendering. */
|
|
64
|
+
cell?: DataTableCellSpec<TRow>;
|
|
35
65
|
renderCell?: (context: DataTableCellContext<TRow>) => React.ReactNode;
|
|
36
66
|
}
|
|
37
67
|
|
|
68
|
+
export interface DataTableSelectionChangeEvent {
|
|
69
|
+
readonly selectedRowIds: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DataTableRowActivateEvent {
|
|
73
|
+
readonly rowId: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
38
76
|
export interface DataTableRowAction<TRow extends object> {
|
|
39
77
|
id: string;
|
|
40
78
|
title: React.ReactNode;
|
|
@@ -54,6 +92,10 @@ export interface DataTableProps<TRow extends object> extends ZoraBaseProps {
|
|
|
54
92
|
selectedRowIds?: readonly string[];
|
|
55
93
|
/** Receives the next controlled selection after a row or visible-row toggle. */
|
|
56
94
|
onSelectedRowIdsChange?: (selectedRowIds: readonly string[]) => void;
|
|
95
|
+
/** Emits the serializable controlled selection payload used by AppManifest events. */
|
|
96
|
+
onSelectionChange?: (event: DataTableSelectionChangeEvent) => void;
|
|
97
|
+
/** Emits a row activation independently of checkbox selection. */
|
|
98
|
+
onRowActivate?: (event: DataTableRowActivateEvent) => void;
|
|
57
99
|
rowActions?: (row: TRow, index: number) => readonly DataTableRowAction<TRow>[];
|
|
58
100
|
sort?: DataTableSortState;
|
|
59
101
|
onSortChange?: (sort: DataTableSortState) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { DataTable } from './DataTable';
|
|
2
|
-
export type { DataTableCellContext, DataTableColumn, DataTableColumnAlign, DataTableDensity, DataTableProps, DataTableRowAction, DataTableSortDirection, DataTableSortState } from './DataTable';
|
|
2
|
+
export type { DataTableCellContext, DataTableCellSpec, DataTableColumn, DataTableColumnAlign, DataTableDensity, DataTableProps, DataTableRowAction, DataTableRowActivateEvent, DataTableRowField, DataTableSelectionChangeEvent, DataTableSortDirection, DataTableSortState } from './DataTable';
|
|
@@ -8,4 +8,4 @@ import type { TimelineProps } from './Timeline.types-0';
|
|
|
8
8
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const Timeline: (props: TimelineProps) => React.ReactElement | null;
|
|
11
|
-
export type { TimelineItem, TimelineProps } from './Timeline.types-0';
|
|
11
|
+
export type { TimelineItem, TimelineManifestItem, TimelineManifestProps, TimelineProps } from './Timeline.types-0';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { MediaAssetReference } from '@ankhorage/contracts';
|
|
2
|
+
|
|
1
3
|
import type { ButtonIconSpec } from '@ankhorage/surface';
|
|
2
4
|
|
|
3
5
|
import type React from 'react';
|
|
@@ -8,6 +10,23 @@ import type { ImageProps } from './Timeline.dependency-2';
|
|
|
8
10
|
|
|
9
11
|
import type { ZoraColor } from './Timeline.dependency-4';
|
|
10
12
|
|
|
13
|
+
/** Portable Timeline item shape accepted by an AppManifest component node. */
|
|
14
|
+
export interface TimelineManifestItem {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly description?: string;
|
|
18
|
+
readonly meta?: string;
|
|
19
|
+
readonly status?: ZoraColor;
|
|
20
|
+
readonly marker?: MediaAssetReference;
|
|
21
|
+
readonly markerAlt?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Portable Timeline props accepted by an AppManifest component node. */
|
|
25
|
+
export interface TimelineManifestProps {
|
|
26
|
+
readonly items: readonly TimelineManifestItem[];
|
|
27
|
+
readonly compact?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
11
30
|
export interface TimelineItem {
|
|
12
31
|
id: string;
|
|
13
32
|
title: React.ReactNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Timeline } from './Timeline';
|
|
2
|
-
export type { TimelineItem, TimelineProps } from './Timeline';
|
|
2
|
+
export type { TimelineItem, TimelineManifestItem, TimelineManifestProps, TimelineProps } from './Timeline';
|
package/web-dist/manifest.json
CHANGED
|
@@ -1290,6 +1290,7 @@
|
|
|
1290
1290
|
"components/data-table/DataTable.dependency-0.d.ts",
|
|
1291
1291
|
"components/data-table/DataTable.dependency-1.d.ts",
|
|
1292
1292
|
"components/data-table/DataTable.dependency-2.d.ts",
|
|
1293
|
+
"components/data-table/DataTable.dependency-3.d.ts",
|
|
1293
1294
|
"components/data-table/DataTable.types-0.d.ts",
|
|
1294
1295
|
"components/data-table/index.js",
|
|
1295
1296
|
"components/data-table/index.d.ts",
|