@dxos/react-ui-table 0.8.1-staging.5be625a → 0.8.1-staging.9eaf14f
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/dist/lib/browser/{chunk-5MKYB7NF.mjs → chunk-YWNRUF4J.mjs} +7 -3
- package/dist/lib/browser/{chunk-5MKYB7NF.mjs.map → chunk-YWNRUF4J.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +295 -97
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-NRFKBRPV.cjs → chunk-TGG6OZ54.cjs} +10 -6
- package/dist/lib/node/{chunk-NRFKBRPV.cjs.map → chunk-TGG6OZ54.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +293 -93
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-SU4D55KI.mjs → chunk-KKLP54L3.mjs} +7 -3
- package/dist/lib/node-esm/{chunk-SU4D55KI.mjs.map → chunk-KKLP54L3.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +295 -97
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +15 -10
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +10 -0
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +2 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts +9 -0
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +6 -10
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +6 -3
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +13 -14
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +4 -4
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +2 -2
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -1
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +21 -30
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +2 -2
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/components/Table/DynamicTable.stories.tsx +155 -0
- package/src/components/Table/DynamicTable.tsx +46 -28
- package/src/components/Table/Table.stories.tsx +129 -125
- package/src/components/Table/Table.tsx +51 -26
- package/src/components/Table/relations.stories.tsx +113 -0
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +8 -3
- package/src/components/TableCellEditor/TableCellEditor.tsx +102 -4
- package/src/components/testing.ts +0 -1
- package/src/hooks/useTableModel.ts +11 -11
- package/src/model/index.ts +1 -0
- package/src/model/selection-model.ts +12 -2
- package/src/model/table-model.test.ts +1 -1
- package/src/model/table-model.ts +27 -18
- package/src/model/table-presentation.test.ts +1 -1
- package/src/model/table-presentation.ts +65 -11
- package/src/model/table-sorting.ts +2 -2
- package/src/playwright/smoke.spec.ts +2 -3
- package/src/types/table.ts +6 -5
- package/src/util/dynamic-table.ts +57 -25
- package/src/util/table-controls.ts +4 -4
- package/src/util/table.ts +2 -1
- package/dist/lib/browser/deprecated/index.mjs +0 -1483
- package/dist/lib/browser/deprecated/index.mjs.map +0 -7
- package/dist/lib/node/deprecated/index.cjs +0 -1511
- package/dist/lib/node/deprecated/index.cjs.map +0 -7
- package/dist/lib/node-esm/deprecated/index.mjs +0 -1485
- package/dist/lib/node-esm/deprecated/index.mjs.map +0 -7
- package/dist/types/src/deprecated/components/Cell/Cell.d.ts +0 -12
- package/dist/types/src/deprecated/components/Cell/Cell.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Cell/CellCombobox.d.ts +0 -13
- package/dist/types/src/deprecated/components/Cell/CellCombobox.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Cell/index.d.ts +0 -2
- package/dist/types/src/deprecated/components/Cell/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.d.ts +0 -23
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts +0 -36
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.d.ts +0 -15
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts +0 -84
- package/dist/types/src/deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/ColumnMenu/index.d.ts +0 -3
- package/dist/types/src/deprecated/components/ColumnMenu/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/Table.d.ts +0 -20
- package/dist/types/src/deprecated/components/Table/Table.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/Table.stories.d.ts +0 -116
- package/dist/types/src/deprecated/components/Table/Table.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableBody.d.ts +0 -12
- package/dist/types/src/deprecated/components/Table/TableBody.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableContext.d.ts +0 -13
- package/dist/types/src/deprecated/components/Table/TableContext.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableHead.d.ts +0 -9
- package/dist/types/src/deprecated/components/Table/TableHead.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/TableRootContext.d.ts +0 -17
- package/dist/types/src/deprecated/components/Table/TableRootContext.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/index.d.ts +0 -5
- package/dist/types/src/deprecated/components/Table/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/Table/props.d.ts +0 -42
- package/dist/types/src/deprecated/components/Table/props.d.ts.map +0 -1
- package/dist/types/src/deprecated/components/index.d.ts +0 -4
- package/dist/types/src/deprecated/components/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/helpers.d.ts +0 -91
- package/dist/types/src/deprecated/helpers.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/index.d.ts +0 -5
- package/dist/types/src/deprecated/hooks/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useColumnSizing.d.ts +0 -12
- package/dist/types/src/deprecated/hooks/useColumnSizing.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useColumnSorting.d.ts +0 -15
- package/dist/types/src/deprecated/hooks/useColumnSorting.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/usePinLastRow.d.ts +0 -3
- package/dist/types/src/deprecated/hooks/usePinLastRow.d.ts.map +0 -1
- package/dist/types/src/deprecated/hooks/useRowSelection.d.ts +0 -7
- package/dist/types/src/deprecated/hooks/useRowSelection.d.ts.map +0 -1
- package/dist/types/src/deprecated/index.d.ts +0 -8
- package/dist/types/src/deprecated/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/Schema.stories.d.ts +0 -11
- package/dist/types/src/deprecated/schema/Schema.stories.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/column-utils.d.ts +0 -7
- package/dist/types/src/deprecated/schema/column-utils.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/index.d.ts +0 -3
- package/dist/types/src/deprecated/schema/index.d.ts.map +0 -1
- package/dist/types/src/deprecated/schema/types.d.ts +0 -27
- package/dist/types/src/deprecated/schema/types.d.ts.map +0 -1
- package/dist/types/src/deprecated/theme.d.ts +0 -29
- package/dist/types/src/deprecated/theme.d.ts.map +0 -1
- package/dist/types/src/deprecated/translations.d.ts +0 -21
- package/dist/types/src/deprecated/translations.d.ts.map +0 -1
- package/dist/types/src/deprecated/types.d.ts +0 -26
- package/dist/types/src/deprecated/types.d.ts.map +0 -1
- package/src/deprecated/components/Cell/Cell.tsx +0 -88
- package/src/deprecated/components/Cell/CellCombobox.tsx +0 -103
- package/src/deprecated/components/Cell/index.ts +0 -5
- package/src/deprecated/components/ColumnMenu/ColumnMenu.stories.tsx +0 -129
- package/src/deprecated/components/ColumnMenu/ColumnMenu.tsx +0 -182
- package/src/deprecated/components/ColumnMenu/ColumnSettings.stories.tsx +0 -108
- package/src/deprecated/components/ColumnMenu/ColumnSettings.tsx +0 -207
- package/src/deprecated/components/ColumnMenu/index.ts +0 -6
- package/src/deprecated/components/Table/Table.stories.tsx +0 -508
- package/src/deprecated/components/Table/Table.tsx +0 -301
- package/src/deprecated/components/Table/TableBody.tsx +0 -82
- package/src/deprecated/components/Table/TableContext.tsx +0 -34
- package/src/deprecated/components/Table/TableHead.tsx +0 -78
- package/src/deprecated/components/Table/TableRootContext.ts +0 -39
- package/src/deprecated/components/Table/index.ts +0 -8
- package/src/deprecated/components/Table/props.ts +0 -60
- package/src/deprecated/components/index.ts +0 -7
- package/src/deprecated/helpers.tsx +0 -526
- package/src/deprecated/hooks/index.ts +0 -8
- package/src/deprecated/hooks/useColumnSizing.ts +0 -46
- package/src/deprecated/hooks/useColumnSorting.ts +0 -64
- package/src/deprecated/hooks/usePinLastRow.ts +0 -47
- package/src/deprecated/hooks/useRowSelection.ts +0 -40
- package/src/deprecated/index.ts +0 -12
- package/src/deprecated/schema/Schema.stories.tsx +0 -59
- package/src/deprecated/schema/column-utils.ts +0 -54
- package/src/deprecated/schema/index.ts +0 -6
- package/src/deprecated/schema/types.ts +0 -40
- package/src/deprecated/theme.ts +0 -82
- package/src/deprecated/translations.ts +0 -26
- package/src/deprecated/types.ts +0 -38
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type DxGridPlane, type DxGridPlaneCells, type DxGridPlaneRange } from '@dxos/react-ui-grid';
|
|
2
|
-
import { type
|
|
2
|
+
import { type SelectionMode } from './selection-model';
|
|
3
|
+
import { type TableRow, type TableModel } from './table-model';
|
|
3
4
|
/**
|
|
4
5
|
* Presentation layer for a table component, handling cell rendering and grid display logic.
|
|
5
6
|
* Manages rendering of table cells, headers, selection columns, and action columns across
|
|
6
7
|
* different grid planes.
|
|
7
8
|
*/
|
|
8
|
-
export declare class TablePresentation<T extends
|
|
9
|
-
id: string;
|
|
10
|
-
}> {
|
|
9
|
+
export declare class TablePresentation<T extends TableRow = TableRow> {
|
|
11
10
|
private readonly model;
|
|
12
11
|
private readonly _visibleRange;
|
|
13
12
|
constructor(model: TableModel<T>, _visibleRange?: import("@preact/signals-core").Signal<DxGridPlaneRange>);
|
|
@@ -19,4 +18,5 @@ export declare class TablePresentation<T extends BaseTableRow = {
|
|
|
19
18
|
private getSelectAllCell;
|
|
20
19
|
private getNewColumnCell;
|
|
21
20
|
}
|
|
21
|
+
export declare const cellClassesForRowSelection: (selected: boolean, selectionMode: SelectionMode) => string[] | undefined;
|
|
22
22
|
//# sourceMappingURL=table-presentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-presentation.d.ts","sourceRoot":"","sources":["../../../../src/model/table-presentation.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"table-presentation.d.ts","sourceRoot":"","sources":["../../../../src/model/table-presentation.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAGtB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAG/D;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAExD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EACpB,aAAa,0DAG5B;IAGG,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB;IAoC9E,OAAO,CAAC,gBAAgB;IAyHxB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,uBAAuB;IAgB/B,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,gBAAgB;CAczB;AAED,eAAO,MAAM,0BAA0B,aAAc,OAAO,iBAAiB,aAAa,yBAgBzF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Signal, type ReadonlySignal } from '@preact/signals-core';
|
|
2
2
|
import { type SortDirectionType, type FieldSortType } from '@dxos/echo-schema';
|
|
3
3
|
import type { ViewProjection, ViewType } from '@dxos/schema';
|
|
4
|
-
import { type
|
|
4
|
+
import { type TableRow } from './table-model';
|
|
5
5
|
/**
|
|
6
6
|
* Manages table sorting functionality through display and data index mapping.
|
|
7
7
|
*
|
|
@@ -23,7 +23,7 @@ import { type BaseTableRow } from './table-model';
|
|
|
23
23
|
* │ 2: "Cherry" │ => │ 2: "Cherry" │ => │ 2 => 2 │
|
|
24
24
|
* └──────────────┘ └──────────────┘ └────────┘
|
|
25
25
|
*/
|
|
26
|
-
export declare class TableSorting<T extends
|
|
26
|
+
export declare class TableSorting<T extends TableRow> {
|
|
27
27
|
private readonly _view;
|
|
28
28
|
private readonly _projection;
|
|
29
29
|
private readonly _displayToDataIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-sorting.d.ts","sourceRoot":"","sources":["../../../../src/model/table-sorting.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG1F,OAAO,EAAkC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/G,OAAO,KAAK,EAA2B,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtF,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"table-sorting.d.ts","sourceRoot":"","sources":["../../../../src/model/table-sorting.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG1F,OAAO,EAAkC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE/G,OAAO,KAAK,EAA2B,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAU9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,QAAQ;IASxC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAT9B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA6B;IACjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IACnD,SAAgB,UAAU,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;gBAG9C,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EACA,KAAK,EAAE,QAAQ,GAAG,SAAS,EAC3B,WAAW,EAAE,cAAc;IAoB9C;;;OAGG;IACH,IAAW,OAAO,IAAI,aAAa,GAAG,SAAS,CAU9C;IAED;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEM,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAI1C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAO5D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAiBjC,SAAS,IAAI,IAAI;IAIjB,IAAI,IAAI,IAAI;IAenB,OAAO,CAAC,oBAAoB;IAkC5B,OAAO,CAAC,YAAY;CAsCrB"}
|
|
@@ -49,5 +49,6 @@ export declare const TableType: import("@dxos/echo-schema").EchoObjectSchema<S.S
|
|
|
49
49
|
}, import("@dxos/echo-schema").TypedObjectOptions>>>;
|
|
50
50
|
threads: S.optional<S.Array$<import("@dxos/echo-schema").Ref$<Expando>>>;
|
|
51
51
|
}>>;
|
|
52
|
-
export
|
|
52
|
+
export interface TableType extends S.Schema.Type<typeof TableType> {
|
|
53
|
+
}
|
|
53
54
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/types/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,OAAO,EAAoC,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAI7F,eAAO,MAAM,WAAW;;;;
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/types/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,OAAO,EAAoC,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAI7F,eAAO,MAAM,WAAW;;;;cAYc,EAAG,WAAW;eAC8K,EAAG,MAAM;gBAAmI,EAAG,QAAQ,CAAC,EAAE,MAAM;gBAAgJ,EAAG,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;uBAAqB,EAAG,MAAM;kBAAe,EAAG,MAAM;qBAA6C,EAAG,QAAQ,QAAO,EAAG,OAAO;kBAAgB,EAAG,QAAQ,QAAO,EAAG,MAAM;2BAAyB,EAAG,QAAQ,CAAC,EAAE,MAAM;;sBAAyQ,EAAG,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;uBAAqB,EAAG,MAAM;kBAAe,EAAG,MAAM;qBAA6C,EAAG,QAAQ,QAAO,EAAG,OAAO;kBAAgB,EAAG,QAAQ,QAAO,EAAG,MAAM;2BAAyB,EAAG,QAAQ,CAAC,EAAE,MAAM;;kBAAgH,EAAG,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,QAAO,EAAG,MAAM,SAAQ,EAAG,GAAG;;;EAJ38C,CAAC;AAEH,eAAO,MAAM,SAAS;;;;cACgB,EAAG,WAAW;eAC8K,EAAG,MAAM;gBAAmI,EAAG,QAAQ,CAAC,EAAE,MAAM;gBAAgJ,EAAG,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;uBAAqB,EAAG,MAAM;kBAAe,EAAG,MAAM;qBAA6C,EAAG,QAAQ,QAAO,EAAG,OAAO;kBAAgB,EAAG,QAAQ,QAAO,EAAG,MAAM;2BAAyB,EAAG,QAAQ,CAAC,EAAE,MAAM;;sBAAyQ,EAAG,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;uBAAqB,EAAG,MAAM;kBAAe,EAAG,MAAM;qBAA6C,EAAG,QAAQ,QAAO,EAAG,OAAO;kBAAgB,EAAG,QAAQ,QAAO,EAAG,MAAM;2BAAyB,EAAG,QAAQ,CAAC,EAAE,MAAM;;kBAAgH,EAAG,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,QAAO,EAAG,MAAM,SAAQ,EAAG,GAAG;;;GAFj2C,CAAC;AAC7G,MAAM,WAAW,SAAU,SAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC;CAAG"}
|
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BaseSchema, JsonSchemaType, SortDirectionType } from '@dxos/echo-schema';
|
|
2
2
|
import { ViewProjection, type SchemaPropertyDefinition } from '@dxos/schema';
|
|
3
|
+
import { TableType } from '../types';
|
|
3
4
|
type PropertyDisplayProps = {
|
|
4
5
|
size: number;
|
|
5
6
|
title: string;
|
|
6
7
|
sort: SortDirectionType;
|
|
7
8
|
};
|
|
8
9
|
export type TablePropertyDefinition = SchemaPropertyDefinition & Partial<PropertyDisplayProps>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
size: import("effect/Schema").optional<typeof import("effect/Schema").Number>;
|
|
29
|
-
referencePath: import("effect/Schema").optional<import("effect/Schema").Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>>;
|
|
30
|
-
}>>>>>;
|
|
31
|
-
metadata: import("effect/Schema").optional<import("effect/Schema").mutable<import("effect/Schema").Record$<typeof import("effect/Schema").String, typeof import("effect/Schema").Any>>>;
|
|
32
|
-
}, import("@dxos/echo-schema").TypedObjectOptions>> | undefined;
|
|
33
|
-
threads?: readonly import("@dxos/echo-schema").Ref<import("@dxos/echo-schema").Expando>[] | undefined;
|
|
34
|
-
}>;
|
|
35
|
-
schema: import("@dxos/echo-schema").EchoSchema;
|
|
36
|
-
view: import("@dxos/live-object").ReactiveObject<import("@dxos/schema").ViewType>;
|
|
37
|
-
viewProjection: ViewProjection;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
export declare const getBaseSchems: ({ typename, properties, jsonSchema, schema, }: {
|
|
14
|
+
typename?: string;
|
|
15
|
+
properties?: TablePropertyDefinition[];
|
|
16
|
+
jsonSchema?: JsonSchemaType;
|
|
17
|
+
schema?: BaseSchema;
|
|
18
|
+
}) => {
|
|
19
|
+
typename: string;
|
|
20
|
+
jsonSchema: JsonSchemaType;
|
|
21
|
+
};
|
|
22
|
+
export declare const makeDynamicTable: ({ typename, jsonSchema, properties, }: {
|
|
23
|
+
typename: string;
|
|
24
|
+
jsonSchema: JsonSchemaType;
|
|
25
|
+
properties?: TablePropertyDefinition[];
|
|
26
|
+
}) => {
|
|
27
|
+
table: TableType;
|
|
28
|
+
projection: ViewProjection;
|
|
38
29
|
};
|
|
39
30
|
export {};
|
|
40
31
|
//# sourceMappingURL=dynamic-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-table.d.ts","sourceRoot":"","sources":["../../../../src/util/dynamic-table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dynamic-table.d.ts","sourceRoot":"","sources":["../../../../src/util/dynamic-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAGL,cAAc,EAEd,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAE/F;;GAEG;AAEH,eAAO,MAAM,aAAa,kDAKvB;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,CAAA;CAWjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,0CAI1B;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;IAC3B,UAAU,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACxC,KAAG;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,cAAc,CAAA;CAkBjD,CAAC"}
|
|
@@ -22,8 +22,8 @@ export declare const CONTROL_IDENTIFIERS: {
|
|
|
22
22
|
readonly checkbox: "data-table-checkbox";
|
|
23
23
|
readonly switch: "data-table-switch";
|
|
24
24
|
};
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
25
|
+
export declare const CheckboxStory: ({ rowIndex, header, checked, disabled, }: RenderCheckboxProps) => string;
|
|
26
|
+
export declare const SwitchStory: ({ colIndex, rowIndex, checked, disabled }: RenderSwitchProps) => string;
|
|
27
27
|
export declare const tableControls: {
|
|
28
28
|
readonly checkbox: {
|
|
29
29
|
readonly attr: "data-table-checkbox";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-controls.d.ts","sourceRoot":"","sources":["../../../../src/util/table-controls.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/G,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE3G,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAwBX,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"table-controls.d.ts","sourceRoot":"","sources":["../../../../src/util/table-controls.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/G,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE3G,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAwBX,eAAO,MAAM,aAAa,6CAKvB,mBAAmB,KAAG,MAQxB,CAAC;AAEF,eAAO,MAAM,WAAW,8CAA+D,iBAAiB,KAAG,MAQ1G,CAAC;AAEF,eAAO,MAAM,aAAa;;;oEApBvB,mBAAmB,KAAG,MAAM;+BAwBb,WAAW,KAAG,OAAO,CAAC,WAAW,EAAE;YAAE,IAAI,EAAE,UAAU,CAAA;SAAE,CAAC;;;;qEAda,iBAAiB,KAAG,MAAM;+BAuB/F,WAAW,KAAG,OAAO,CAAC,WAAW,EAAE;YAAE,IAAI,EAAE,QAAQ,CAAA;SAAE,CAAC;;CAM9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/util/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAOL,CAAC,EAGF,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/util/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAOL,CAAC,EAGF,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGtE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,oDAMzB,oBAAoB,KAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CA8CtD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.1-staging.
|
|
3
|
+
"version": "0.8.1-staging.9eaf14f",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -50,31 +50,32 @@
|
|
|
50
50
|
"@radix-ui/react-primitive": "2.0.2",
|
|
51
51
|
"@radix-ui/react-slot": "1.1.2",
|
|
52
52
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
53
|
-
"@tanstack/react-table": "^8.13.2",
|
|
54
|
-
"@tanstack/react-virtual": "^3.9.0",
|
|
55
53
|
"date-fns": "^3.3.1",
|
|
56
54
|
"lodash.orderby": "^4.6.0",
|
|
57
|
-
"@dxos/context": "0.8.1-staging.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/log": "0.8.1-staging.
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/react-
|
|
69
|
-
"@dxos/react-ui-
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/react-ui-
|
|
55
|
+
"@dxos/context": "0.8.1-staging.9eaf14f",
|
|
56
|
+
"@dxos/echo-schema": "0.8.1-staging.9eaf14f",
|
|
57
|
+
"@dxos/debug": "0.8.1-staging.9eaf14f",
|
|
58
|
+
"@dxos/invariant": "0.8.1-staging.9eaf14f",
|
|
59
|
+
"@dxos/effect": "0.8.1-staging.9eaf14f",
|
|
60
|
+
"@dxos/keys": "0.8.1-staging.9eaf14f",
|
|
61
|
+
"@dxos/log": "0.8.1-staging.9eaf14f",
|
|
62
|
+
"@dxos/lit-grid": "0.8.1-staging.9eaf14f",
|
|
63
|
+
"@dxos/plugin-space": "0.8.1-staging.9eaf14f",
|
|
64
|
+
"@dxos/live-object": "0.8.1-staging.9eaf14f",
|
|
65
|
+
"@dxos/plugin-search": "0.8.1-staging.9eaf14f",
|
|
66
|
+
"@dxos/react-client": "0.8.1-staging.9eaf14f",
|
|
67
|
+
"@dxos/react-ui-attention": "0.8.1-staging.9eaf14f",
|
|
68
|
+
"@dxos/react-ui-editor": "0.8.1-staging.9eaf14f",
|
|
69
|
+
"@dxos/react-ui-form": "0.8.1-staging.9eaf14f",
|
|
70
|
+
"@dxos/react-ui-menu": "0.8.1-staging.9eaf14f",
|
|
71
|
+
"@dxos/react-ui-searchlist": "0.8.1-staging.9eaf14f",
|
|
72
|
+
"@dxos/react-ui-grid": "0.8.1-staging.9eaf14f",
|
|
73
|
+
"@dxos/react-ui-stack": "0.8.1-staging.9eaf14f",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.1-staging.9eaf14f",
|
|
75
|
+
"@dxos/react-ui-tag-picker": "0.8.1-staging.9eaf14f",
|
|
76
|
+
"@dxos/react-ui-types": "0.8.1-staging.9eaf14f",
|
|
77
|
+
"@dxos/schema": "0.8.1-staging.9eaf14f",
|
|
78
|
+
"@dxos/util": "0.8.1-staging.9eaf14f"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -85,19 +86,19 @@
|
|
|
85
86
|
"react": "~18.2.0",
|
|
86
87
|
"react-dom": "~18.2.0",
|
|
87
88
|
"vite": "5.4.7",
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/
|
|
90
|
-
"@dxos/react-ui": "0.8.1-staging.
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
89
|
+
"@dxos/echo-signals": "0.8.1-staging.9eaf14f",
|
|
90
|
+
"@dxos/random": "0.8.1-staging.9eaf14f",
|
|
91
|
+
"@dxos/react-ui-theme": "0.8.1-staging.9eaf14f",
|
|
92
|
+
"@dxos/react-ui": "0.8.1-staging.9eaf14f",
|
|
93
|
+
"@dxos/storybook-utils": "0.8.1-staging.9eaf14f",
|
|
94
|
+
"@dxos/test-utils": "0.8.1-staging.9eaf14f"
|
|
94
95
|
},
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"@phosphor-icons/react": "^2.1.5",
|
|
97
98
|
"react": "~18.2.0",
|
|
98
99
|
"react-dom": "~18.2.0",
|
|
99
|
-
"@dxos/react-ui": "0.8.1-staging.
|
|
100
|
-
"@dxos/react-ui-theme": "0.8.1-staging.
|
|
100
|
+
"@dxos/react-ui": "0.8.1-staging.9eaf14f",
|
|
101
|
+
"@dxos/react-ui-theme": "0.8.1-staging.9eaf14f"
|
|
101
102
|
},
|
|
102
103
|
"publishConfig": {
|
|
103
104
|
"access": "public"
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useMemo, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { FormatEnum, type JsonSchemaType } from '@dxos/echo-schema';
|
|
11
|
+
import { faker } from '@dxos/random';
|
|
12
|
+
import { useClient } from '@dxos/react-client';
|
|
13
|
+
import { Filter, useQuery, useSchema, create } from '@dxos/react-client/echo';
|
|
14
|
+
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
15
|
+
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
16
|
+
import { Testing } from '@dxos/schema/testing';
|
|
17
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
|
+
|
|
19
|
+
import { DynamicTable } from './DynamicTable';
|
|
20
|
+
import { type TableFeatures } from '../../model';
|
|
21
|
+
import translations from '../../translations';
|
|
22
|
+
|
|
23
|
+
faker.seed(0);
|
|
24
|
+
|
|
25
|
+
const useTestPropertiesAndObjects = () => {
|
|
26
|
+
const properties = useMemo<SchemaPropertyDefinition[]>(
|
|
27
|
+
() => [
|
|
28
|
+
{ name: 'name', format: FormatEnum.String },
|
|
29
|
+
{ name: 'age', format: FormatEnum.Number },
|
|
30
|
+
],
|
|
31
|
+
[],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const [rows] = useState<any[]>(
|
|
35
|
+
Array.from({ length: 10 }, () => ({
|
|
36
|
+
id: faker.string.uuid(),
|
|
37
|
+
name: faker.person.fullName(),
|
|
38
|
+
age: faker.number.int({ min: 18, max: 80 }),
|
|
39
|
+
})),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return { properties, rows };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//
|
|
46
|
+
// Story components.
|
|
47
|
+
//
|
|
48
|
+
|
|
49
|
+
const DynamicTableStory = () => {
|
|
50
|
+
const { properties, rows } = useTestPropertiesAndObjects();
|
|
51
|
+
return <DynamicTable properties={properties} rows={rows} />;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
// Story definitions.
|
|
56
|
+
//
|
|
57
|
+
|
|
58
|
+
const meta: Meta = {
|
|
59
|
+
title: 'ui/react-ui-table/DynamicTable',
|
|
60
|
+
component: DynamicTable,
|
|
61
|
+
parameters: { translations },
|
|
62
|
+
decorators: [withTheme, withLayout({ fullscreen: true, tooltips: true })],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default meta;
|
|
66
|
+
|
|
67
|
+
export const Default: StoryObj = {
|
|
68
|
+
render: DynamicTableStory,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const WithRowClicks: StoryObj = {
|
|
72
|
+
render: () => {
|
|
73
|
+
const { properties, rows } = useTestPropertiesAndObjects();
|
|
74
|
+
|
|
75
|
+
const handleRowClicked = (row: any) => {
|
|
76
|
+
console.log('Row clicked:', row);
|
|
77
|
+
alert(`Row clicked: ${row.name}, age: ${row.age}`);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return <DynamicTable properties={properties} rows={rows} onRowClick={handleRowClicked} />;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const WithClickToSelect: StoryObj = {
|
|
85
|
+
render: () => {
|
|
86
|
+
const { properties, rows } = useTestPropertiesAndObjects();
|
|
87
|
+
|
|
88
|
+
const features = useMemo<Partial<TableFeatures>>(
|
|
89
|
+
() => ({ selection: { enabled: true, mode: 'single' as const }, dataEditable: false }),
|
|
90
|
+
[],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return <DynamicTable properties={properties} rows={rows} features={features} />;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const WithJsonSchema: StoryObj = {
|
|
98
|
+
render: () => {
|
|
99
|
+
const schema = useMemo<JsonSchemaType>(
|
|
100
|
+
() => ({
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
name: { type: 'string', title: 'Full Name' },
|
|
104
|
+
age: { type: 'number', title: 'Age (Years)' },
|
|
105
|
+
email: { type: 'string', format: 'email', title: 'Email Address' },
|
|
106
|
+
active: { type: 'boolean', title: 'Active Status' },
|
|
107
|
+
},
|
|
108
|
+
required: ['name', 'email'],
|
|
109
|
+
}),
|
|
110
|
+
[],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const [rows] = useState<any[]>(
|
|
114
|
+
Array.from({ length: 15 }, () => ({
|
|
115
|
+
name: faker.person.fullName(),
|
|
116
|
+
age: faker.number.int({ min: 18, max: 80 }),
|
|
117
|
+
email: faker.internet.email(),
|
|
118
|
+
active: faker.datatype.boolean(),
|
|
119
|
+
})),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
return <DynamicTable jsonSchema={schema} rows={rows} />;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const WithEchoSchema: StoryObj = {
|
|
127
|
+
render: () => {
|
|
128
|
+
const client = useClient();
|
|
129
|
+
const { space } = useClientProvider();
|
|
130
|
+
const schema = useSchema(client, space, Testing.Contact.typename);
|
|
131
|
+
const objects = useQuery(space, schema ? Filter.schema(schema) : Filter.nothing());
|
|
132
|
+
if (!schema) {
|
|
133
|
+
return <div>Loading schema...</div>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return <DynamicTable schema={schema} rows={objects} />;
|
|
137
|
+
},
|
|
138
|
+
decorators: [
|
|
139
|
+
withClientProvider({
|
|
140
|
+
types: [Testing.Contact],
|
|
141
|
+
createIdentity: true,
|
|
142
|
+
createSpace: true,
|
|
143
|
+
onSpaceCreated: async ({ space }) => {
|
|
144
|
+
Array.from({ length: 10 }).forEach(() => {
|
|
145
|
+
space.db.add(
|
|
146
|
+
create(Testing.Contact, {
|
|
147
|
+
name: faker.person.fullName(),
|
|
148
|
+
email: faker.internet.email(),
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
154
|
+
],
|
|
155
|
+
};
|
|
@@ -4,61 +4,78 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useRef, useMemo, useCallback } from 'react';
|
|
6
6
|
|
|
7
|
+
import { type BaseSchema, type JsonSchemaType } from '@dxos/echo-schema';
|
|
8
|
+
import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
|
|
7
9
|
import { mx } from '@dxos/react-ui-theme';
|
|
8
10
|
|
|
9
11
|
import { Table, type TableController } from './Table';
|
|
10
12
|
import { useTableModel } from '../../hooks';
|
|
11
|
-
import { TablePresentation, type TableRowAction } from '../../model';
|
|
12
|
-
import { makeDynamicTable, type TablePropertyDefinition } from '../../util';
|
|
13
|
+
import { type TableFeatures, TablePresentation, type TableRowAction } from '../../model';
|
|
14
|
+
import { getBaseSchems as getBaseSchema, makeDynamicTable, type TablePropertyDefinition } from '../../util';
|
|
13
15
|
|
|
14
|
-
type DynamicTableProps = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
type DynamicTableProps = ThemedClassName<{
|
|
17
|
+
name?: string; // TODO(burdon): Remove?
|
|
18
|
+
rows: any[];
|
|
19
|
+
properties?: TablePropertyDefinition[];
|
|
20
|
+
jsonSchema?: JsonSchemaType;
|
|
21
|
+
schema?: BaseSchema;
|
|
22
|
+
features?: Partial<TableFeatures>;
|
|
20
23
|
rowActions?: TableRowAction[];
|
|
24
|
+
onRowClick?: (row: any) => void;
|
|
21
25
|
onRowAction?: (actionId: string, datum: any) => void;
|
|
22
|
-
}
|
|
26
|
+
}>;
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
|
-
* A dynamic table component that renders data using the specified properties.
|
|
26
29
|
* Properties define both the schema and display characteristics of the table columns.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated Use Table.
|
|
27
32
|
*/
|
|
33
|
+
// TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
|
|
34
|
+
// TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
|
|
28
35
|
export const DynamicTable = ({
|
|
29
|
-
data,
|
|
30
|
-
properties,
|
|
31
36
|
classNames,
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
name = 'example.com/dynamic-table', // Rmove default or make random; this will lead to type collisions.
|
|
38
|
+
rows,
|
|
39
|
+
properties,
|
|
40
|
+
jsonSchema,
|
|
41
|
+
schema,
|
|
34
42
|
rowActions,
|
|
43
|
+
onRowClick,
|
|
35
44
|
onRowAction,
|
|
45
|
+
...props
|
|
36
46
|
}: DynamicTableProps) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return makeDynamicTable(
|
|
41
|
-
}, [
|
|
47
|
+
const { table, projection } = useMemo(() => {
|
|
48
|
+
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
49
|
+
const props = getBaseSchema({ typename: name, properties, jsonSchema, schema });
|
|
50
|
+
return makeDynamicTable({ ...props, properties });
|
|
51
|
+
}, [name, properties, schema, jsonSchema]);
|
|
42
52
|
|
|
43
53
|
const tableRef = useRef<TableController>(null);
|
|
44
54
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
45
55
|
tableRef.current?.update?.(cell);
|
|
46
56
|
}, []);
|
|
47
57
|
|
|
48
|
-
const
|
|
58
|
+
const handleRowOrderChange = useCallback(() => {
|
|
49
59
|
tableRef.current?.update?.();
|
|
50
60
|
}, []);
|
|
51
61
|
|
|
52
|
-
const features =
|
|
62
|
+
const features = useDefaultValue(
|
|
63
|
+
props.features,
|
|
64
|
+
() =>
|
|
65
|
+
({
|
|
66
|
+
selection: { enabled: false },
|
|
67
|
+
dataEditable: false,
|
|
68
|
+
}) as const,
|
|
69
|
+
);
|
|
53
70
|
|
|
54
71
|
const model = useTableModel({
|
|
55
72
|
table,
|
|
56
|
-
|
|
57
|
-
projection
|
|
73
|
+
rows,
|
|
74
|
+
projection,
|
|
58
75
|
features,
|
|
59
|
-
onCellUpdate: handleCellUpdate,
|
|
60
|
-
onRowOrderChanged: handleRowOrderChanged,
|
|
61
76
|
rowActions,
|
|
77
|
+
onCellUpdate: handleCellUpdate,
|
|
78
|
+
onRowOrderChange: handleRowOrderChange,
|
|
62
79
|
onRowAction,
|
|
63
80
|
});
|
|
64
81
|
|
|
@@ -68,16 +85,17 @@ export const DynamicTable = ({
|
|
|
68
85
|
}
|
|
69
86
|
}, [model]);
|
|
70
87
|
|
|
88
|
+
// TODO(burdon): Do we need the outer divs?
|
|
71
89
|
return (
|
|
72
|
-
<div className={mx('is-full bs-full grow grid', classNames)}>
|
|
73
|
-
<div className='grid min-bs-0 overflow-hidden'>
|
|
90
|
+
<div role='none' className={mx('is-full bs-full grow grid', classNames)}>
|
|
91
|
+
<div role='none' className='grid min-bs-0 overflow-hidden'>
|
|
74
92
|
<Table.Root>
|
|
75
93
|
<Table.Main
|
|
76
94
|
ref={tableRef}
|
|
77
95
|
model={model}
|
|
78
96
|
presentation={presentation}
|
|
79
|
-
onRowClicked={onRowClicked}
|
|
80
97
|
ignoreAttention
|
|
98
|
+
onRowClick={onRowClick}
|
|
81
99
|
/>
|
|
82
100
|
</Table.Root>
|
|
83
101
|
</div>
|