@dxos/react-ui-table 0.7.5-main.9d2a38b → 0.7.5-main.c41020f
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-T7CTRLHA.mjs → chunk-3FR6NHPD.mjs} +6 -4
- package/dist/lib/browser/chunk-3FR6NHPD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +57 -8
- 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-XQRKYO7Q.cjs → chunk-NB3SFHGA.cjs} +8 -6
- package/dist/lib/node/chunk-NB3SFHGA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +59 -10
- 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-6HE6MLBK.mjs → chunk-RLVVOZW5.mjs} +6 -4
- package/dist/lib/node-esm/chunk-RLVVOZW5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +57 -8
- 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/_deprecated/components/Cell/Cell.d.ts +2 -2
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts +2 -3
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts +6 -7
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts +1 -2
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts +6 -7
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/Table.d.ts +5 -5
- package/dist/types/src/_deprecated/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts +8 -9
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts +1 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts +1 -2
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts +2 -3
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +1 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +1 -2
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +1 -2
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -2
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +1 -4
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +1 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +1 -2
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +12 -35
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +21 -90
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +36 -35
- package/src/_deprecated/schema/Schema.stories.tsx +1 -1
- package/src/components/Table/Table.stories.tsx +23 -24
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +1 -1
- package/src/hooks/useTableModel.ts +21 -0
- package/src/model/table-model.ts +1 -1
- package/src/model/table-presentation.ts +13 -1
- package/src/model/table-sorting.ts +14 -0
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/types/table.ts +3 -3
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/src/util/table.ts +9 -2
- package/dist/lib/browser/chunk-T7CTRLHA.mjs.map +0 -7
- package/dist/lib/node/chunk-XQRKYO7Q.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-6HE6MLBK.mjs.map +0 -7
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- /package/src/playwright/{playwright.config.ts → playwright.config.cts} +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.7.5-main.
|
|
3
|
+
"version": "0.7.5-main.c41020f",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
9
|
"sideEffects": true,
|
|
10
|
+
"type": "module",
|
|
10
11
|
"exports": {
|
|
11
12
|
"./deprecated": {
|
|
12
13
|
"types": "./dist/types/src/_deprecated/index.d.ts",
|
|
@@ -43,37 +44,37 @@
|
|
|
43
44
|
"@codemirror/autocomplete": "^6.18.1",
|
|
44
45
|
"@codemirror/state": "^6.4.1",
|
|
45
46
|
"@codemirror/view": "^6.34.1",
|
|
46
|
-
"@fluentui/react-tabster": "
|
|
47
|
+
"@fluentui/react-tabster": "9.23.3",
|
|
47
48
|
"@preact/signals-core": "^1.6.0",
|
|
48
|
-
"@radix-ui/react-context": "
|
|
49
|
-
"@radix-ui/react-primitive": "
|
|
50
|
-
"@radix-ui/react-slot": "
|
|
51
|
-
"@radix-ui/react-use-controllable-state": "
|
|
49
|
+
"@radix-ui/react-context": "1.1.1",
|
|
50
|
+
"@radix-ui/react-primitive": "2.0.2",
|
|
51
|
+
"@radix-ui/react-slot": "1.1.2",
|
|
52
|
+
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
52
53
|
"@tanstack/react-table": "^8.13.2",
|
|
53
54
|
"@tanstack/react-virtual": "^3.9.0",
|
|
54
55
|
"date-fns": "^3.3.1",
|
|
55
56
|
"lodash.orderby": "^4.6.0",
|
|
56
|
-
"@dxos/context": "0.7.5-main.
|
|
57
|
-
"@dxos/debug": "0.7.5-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/keys": "0.7.5-main.
|
|
61
|
-
"@dxos/lit-grid": "0.7.5-main.
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/plugin-
|
|
65
|
-
"@dxos/react-client": "0.7.5-main.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/react-ui-
|
|
68
|
-
"@dxos/react-ui-
|
|
69
|
-
"@dxos/react-ui-
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
57
|
+
"@dxos/context": "0.7.5-main.c41020f",
|
|
58
|
+
"@dxos/debug": "0.7.5-main.c41020f",
|
|
59
|
+
"@dxos/invariant": "0.7.5-main.c41020f",
|
|
60
|
+
"@dxos/echo-schema": "0.7.5-main.c41020f",
|
|
61
|
+
"@dxos/keys": "0.7.5-main.c41020f",
|
|
62
|
+
"@dxos/lit-grid": "0.7.5-main.c41020f",
|
|
63
|
+
"@dxos/log": "0.7.5-main.c41020f",
|
|
64
|
+
"@dxos/live-object": "0.7.5-main.c41020f",
|
|
65
|
+
"@dxos/plugin-search": "0.7.5-main.c41020f",
|
|
66
|
+
"@dxos/react-client": "0.7.5-main.c41020f",
|
|
67
|
+
"@dxos/plugin-space": "0.7.5-main.c41020f",
|
|
68
|
+
"@dxos/react-ui-grid": "0.7.5-main.c41020f",
|
|
69
|
+
"@dxos/react-ui-menu": "0.7.5-main.c41020f",
|
|
70
|
+
"@dxos/react-ui-attention": "0.7.5-main.c41020f",
|
|
71
|
+
"@dxos/react-ui-form": "0.7.5-main.c41020f",
|
|
72
|
+
"@dxos/react-ui-searchlist": "0.7.5-main.c41020f",
|
|
73
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.5-main.c41020f",
|
|
74
|
+
"@dxos/react-ui-stack": "0.7.5-main.c41020f",
|
|
75
|
+
"@dxos/react-ui-types": "0.7.5-main.c41020f",
|
|
76
|
+
"@dxos/schema": "0.7.5-main.c41020f",
|
|
77
|
+
"@dxos/util": "0.7.5-main.c41020f"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
80
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -84,19 +85,19 @@
|
|
|
84
85
|
"react": "~18.2.0",
|
|
85
86
|
"react-dom": "~18.2.0",
|
|
86
87
|
"vite": "5.4.7",
|
|
87
|
-
"@dxos/echo-signals": "0.7.5-main.
|
|
88
|
-
"@dxos/random": "0.7.5-main.
|
|
89
|
-
"@dxos/react-ui
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
88
|
+
"@dxos/echo-signals": "0.7.5-main.c41020f",
|
|
89
|
+
"@dxos/random": "0.7.5-main.c41020f",
|
|
90
|
+
"@dxos/react-ui": "0.7.5-main.c41020f",
|
|
91
|
+
"@dxos/react-ui-theme": "0.7.5-main.c41020f",
|
|
92
|
+
"@dxos/storybook-utils": "0.7.5-main.c41020f",
|
|
93
|
+
"@dxos/test-utils": "0.7.5-main.c41020f"
|
|
93
94
|
},
|
|
94
95
|
"peerDependencies": {
|
|
95
96
|
"@phosphor-icons/react": "^2.1.5",
|
|
96
97
|
"react": "~18.2.0",
|
|
97
98
|
"react-dom": "~18.2.0",
|
|
98
|
-
"@dxos/react-ui": "0.7.5-main.
|
|
99
|
-
"@dxos/react-ui-theme": "0.7.5-main.
|
|
99
|
+
"@dxos/react-ui": "0.7.5-main.c41020f",
|
|
100
|
+
"@dxos/react-ui-theme": "0.7.5-main.c41020f"
|
|
100
101
|
},
|
|
101
102
|
"publishConfig": {
|
|
102
103
|
"access": "public"
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { type EchoSchema } from '@dxos/echo-schema';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
13
12
|
import { faker } from '@dxos/random';
|
|
14
|
-
import { Filter, useQuery, create } from '@dxos/react-client/echo';
|
|
13
|
+
import { Filter, useQuery, useSchema, create } from '@dxos/react-client/echo';
|
|
15
14
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
16
15
|
import { useDefaultValue } from '@dxos/react-ui';
|
|
17
16
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
@@ -41,13 +40,13 @@ const DefaultStory = () => {
|
|
|
41
40
|
|
|
42
41
|
const tables = useQuery(space, Filter.schema(TableType));
|
|
43
42
|
const [table, setTable] = useState<TableType>();
|
|
44
|
-
const
|
|
43
|
+
const schema = useSchema(space, table?.view?.target?.query.type);
|
|
44
|
+
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
if (space && tables.length && !table) {
|
|
47
47
|
const table = tables[0];
|
|
48
48
|
invariant(table.view);
|
|
49
49
|
setTable(table);
|
|
50
|
-
setSchema(space.db.schemaRegistry.getSchema(table.view.target!.query.type));
|
|
51
50
|
}
|
|
52
51
|
}, [space, tables]);
|
|
53
52
|
|
|
@@ -175,7 +174,7 @@ type StoryProps = {
|
|
|
175
174
|
rows?: number;
|
|
176
175
|
} & Pick<SimulatorProps, 'insertInterval' | 'updateInterval'>;
|
|
177
176
|
|
|
178
|
-
const
|
|
177
|
+
const _TablePerformanceStory = (props: StoryProps) => {
|
|
179
178
|
const getDefaultRows = useCallback(() => 10, []);
|
|
180
179
|
const rows = useDefaultValue(props.rows, getDefaultRows);
|
|
181
180
|
const table = useMemo(() => createTable(), []);
|
|
@@ -248,22 +247,22 @@ const meta: Meta<StoryProps> = {
|
|
|
248
247
|
|
|
249
248
|
export default meta;
|
|
250
249
|
|
|
251
|
-
type Story = StoryObj<StoryProps>;
|
|
252
|
-
|
|
253
250
|
export const Default = {};
|
|
254
251
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
252
|
+
// TODO(ZaymonFC): Restore the performance stories.
|
|
253
|
+
// type Story = StoryObj<StoryProps>;
|
|
254
|
+
// export const Mutations: Story = {
|
|
255
|
+
// render: TablePerformanceStory,
|
|
256
|
+
// args: {
|
|
257
|
+
// rows: 1000,
|
|
258
|
+
// updateInterval: 1,
|
|
259
|
+
// },
|
|
260
|
+
// };
|
|
261
|
+
|
|
262
|
+
// export const RapidInsertions: Story = {
|
|
263
|
+
// render: TablePerformanceStory,
|
|
264
|
+
// args: {
|
|
265
|
+
// rows: 0,
|
|
266
|
+
// insertInterval: 100,
|
|
267
|
+
// },
|
|
268
|
+
// };
|
|
@@ -38,7 +38,7 @@ const DefaultStory = ({ editing }: StoryProps) => {
|
|
|
38
38
|
const table = tables[0];
|
|
39
39
|
invariant(table.view);
|
|
40
40
|
setTable(table);
|
|
41
|
-
setSchema(space.db.schemaRegistry.getSchema(table.view.target!.query.type));
|
|
41
|
+
setSchema(space.db.schemaRegistry.getSchema(table.view.target!.query.type!));
|
|
42
42
|
}
|
|
43
43
|
}, [space, tables]);
|
|
44
44
|
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { effect } from '@preact/signals-core';
|
|
5
6
|
import { useEffect, useState } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type ReactiveObject } from '@dxos/react-client/echo';
|
|
9
|
+
import { useSelectionActions } from '@dxos/react-ui-attention';
|
|
8
10
|
import { type ViewProjection } from '@dxos/schema';
|
|
11
|
+
import { isNonNullable } from '@dxos/util';
|
|
9
12
|
|
|
10
13
|
import { type BaseTableRow, TableModel, type TableModelProps } from '../model';
|
|
11
14
|
import { type TableType } from '../types';
|
|
@@ -48,5 +51,23 @@ export const useTableModel = <T extends BaseTableRow = { id: string }>({
|
|
|
48
51
|
}
|
|
49
52
|
}, [model, objects]);
|
|
50
53
|
|
|
54
|
+
const { select, clear } = useSelectionActions([table?.id, table?.view?.target?.query.type].filter(isNonNullable));
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!model) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const unsubscribe = effect(() => {
|
|
62
|
+
select([...model.selection.selection.value]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Maybe clear the selection here?
|
|
66
|
+
return () => {
|
|
67
|
+
clear();
|
|
68
|
+
unsubscribe();
|
|
69
|
+
};
|
|
70
|
+
}, [model]);
|
|
71
|
+
|
|
51
72
|
return model;
|
|
52
73
|
};
|
package/src/model/table-model.ts
CHANGED
|
@@ -68,7 +68,8 @@ export class TablePresentation<T extends BaseTableRow = { id: string }> {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
switch (props.format) {
|
|
71
|
-
case FormatEnum.Boolean:
|
|
71
|
+
case FormatEnum.Boolean:
|
|
72
|
+
case FormatEnum.SingleSelect: {
|
|
72
73
|
return '';
|
|
73
74
|
}
|
|
74
75
|
case FormatEnum.Ref: {
|
|
@@ -119,6 +120,17 @@ export class TablePresentation<T extends BaseTableRow = { id: string }> {
|
|
|
119
120
|
cell.readonly = true;
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
if (props.format === FormatEnum.SingleSelect) {
|
|
124
|
+
const value = getValue(obj, field.path);
|
|
125
|
+
const options = this.model.projection.getFieldProjection(field.id).props.options;
|
|
126
|
+
if (options) {
|
|
127
|
+
const option = options.find((o) => o.id === value);
|
|
128
|
+
if (option) {
|
|
129
|
+
cell.accessoryHtml = `<span class="dx-tag" data-hue="${option.color}">${option.title}</span>`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
122
134
|
const idx = toPlaneCellIndex({ col: colIndex, row: displayIndex });
|
|
123
135
|
cells[idx] = cell;
|
|
124
136
|
};
|
|
@@ -188,6 +188,20 @@ export class TableSorting<T extends BaseTableRow> {
|
|
|
188
188
|
return value;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* For single select fields, the sort value is determined by the index of the option in the
|
|
193
|
+
* options array. This ensures sort order matches the configured option order.
|
|
194
|
+
*/
|
|
195
|
+
if (format === FormatEnum.SingleSelect) {
|
|
196
|
+
const options = props.options;
|
|
197
|
+
if (!options) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const option = options.find((option) => option.id === value);
|
|
202
|
+
return option ? options.indexOf(option) : undefined;
|
|
203
|
+
}
|
|
204
|
+
|
|
191
205
|
// TODO(ZaymonFC): Should we format this returned value for display based on the referenced prop format?
|
|
192
206
|
// Right now we're going to be sorting based on the raw values.
|
|
193
207
|
// Maybe we need to recurse this function with the referenced prop format and field?
|
|
@@ -145,7 +145,7 @@ test.describe('Table', () => {
|
|
|
145
145
|
await page.getByRole('option', { name: 'Anita Mayer' }).click();
|
|
146
146
|
|
|
147
147
|
// Assert that the value is shown in the cell.
|
|
148
|
-
await expect(page.getByRole('gridcell', { name: 'Anita Mayer' })).toBeVisible();
|
|
148
|
+
await expect(page.getByRole('gridcell', { name: 'Anita Mayer' }).first()).toBeVisible();
|
|
149
149
|
|
|
150
150
|
// Create new object.
|
|
151
151
|
await table.grid.cell(4, 1, 'grid').click();
|
|
@@ -157,7 +157,7 @@ test.describe('Table', () => {
|
|
|
157
157
|
await page.getByTestId('save-button').click();
|
|
158
158
|
|
|
159
159
|
// Scroll to the left.
|
|
160
|
-
await page.getByRole('gridcell', { name: 'test' }).click();
|
|
160
|
+
await page.getByRole('gridcell', { name: 'test' }).first().click();
|
|
161
161
|
|
|
162
162
|
await page.close();
|
|
163
163
|
});
|
|
@@ -173,7 +173,7 @@ test.describe('Table', () => {
|
|
|
173
173
|
await page.getByTestId('table-switch').nth(7).click();
|
|
174
174
|
|
|
175
175
|
// Test that checks are durable in the data model by sorting.
|
|
176
|
-
await table.sortColumn(
|
|
176
|
+
await table.sortColumn(3, 'descending');
|
|
177
177
|
|
|
178
178
|
// Assert the first two switch checkboxes are checked.
|
|
179
179
|
await expect(page.getByTestId('table-switch').first()).toBeChecked();
|
package/src/types/table.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Ref, ObjectId, S, TypedObject } from '@dxos/echo-schema';
|
|
6
|
-
import { ThreadType } from '@dxos/plugin-space/types';
|
|
5
|
+
import { Ref, ObjectId, S, TypedObject, Expando } from '@dxos/echo-schema';
|
|
6
|
+
// import { ThreadType } from '@dxos/plugin-space/types';
|
|
7
7
|
import { ViewType } from '@dxos/schema';
|
|
8
8
|
|
|
9
9
|
export const TableSchema = S.Struct({
|
|
@@ -11,7 +11,7 @@ export const TableSchema = S.Struct({
|
|
|
11
11
|
name: S.optional(S.String),
|
|
12
12
|
view: S.optional(Ref(ViewType)),
|
|
13
13
|
// TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.
|
|
14
|
-
threads: S.optional(S.Array(Ref(ThreadType))),
|
|
14
|
+
threads: S.optional(S.Array(Ref(Expando /* ThreadType */))), // TODO(dmaretskyi): Breaks edge because plugin-space depends on react-client.
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
// type TableType = S.Schema.Type<typeof TableSchema>;
|
|
@@ -39,7 +39,7 @@ const createButton = ({
|
|
|
39
39
|
.join(' ');
|
|
40
40
|
|
|
41
41
|
const positionClass = type === 'primary' ? 'inline-end-2' : 'inline-end-9';
|
|
42
|
-
return `<button ${attr} data-testid="${testId}" class="
|
|
42
|
+
return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? 'disabled' : ''}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const addColumnButton = {
|
|
@@ -23,8 +23,8 @@ export const CONTROL_IDENTIFIERS = {
|
|
|
23
23
|
} as const;
|
|
24
24
|
|
|
25
25
|
const BASE_CLASSES = {
|
|
26
|
-
checkbox: 'absolute inset-block-[.375rem] inline-end-[.375rem]
|
|
27
|
-
switch: 'absolute inset-block-[.25rem] inline-end-[.25rem]
|
|
26
|
+
checkbox: 'absolute inset-block-[.375rem] inline-end-[.375rem] dx-checkbox',
|
|
27
|
+
switch: 'absolute inset-block-[.25rem] inline-end-[.25rem] dx-checkbox--switch',
|
|
28
28
|
} as const;
|
|
29
29
|
|
|
30
30
|
const renderAttributes = (data: Record<string, string>) => {
|
package/src/util/table.ts
CHANGED
|
@@ -46,7 +46,7 @@ export const initializeTable = async ({
|
|
|
46
46
|
// We need to get the schema properties here. For now, only simple types and refs, not compound types
|
|
47
47
|
// are going to be supported.
|
|
48
48
|
const fields = getSchemaProperties(schema.ast)
|
|
49
|
-
.filter((prop) => prop.
|
|
49
|
+
.filter((prop) => prop.format !== FormatEnum.Ref)
|
|
50
50
|
.map((prop) => prop.name);
|
|
51
51
|
|
|
52
52
|
table.view = makeRef(
|
|
@@ -82,7 +82,7 @@ export const initializeTable = async ({
|
|
|
82
82
|
name: 'View',
|
|
83
83
|
typename: contactSchema.typename,
|
|
84
84
|
jsonSchema: contactSchema.jsonSchema,
|
|
85
|
-
fields: ['name', '
|
|
85
|
+
fields: ['name', 'email', 'salary', 'active'],
|
|
86
86
|
}),
|
|
87
87
|
);
|
|
88
88
|
|
|
@@ -94,6 +94,13 @@ export const initializeTable = async ({
|
|
|
94
94
|
size: 150,
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
|
+
projection.setFieldProjection({
|
|
98
|
+
field: {
|
|
99
|
+
id: table.view.target!.fields.find((f) => f.path === 'active')!.id,
|
|
100
|
+
path: 'active' as JsonPath,
|
|
101
|
+
size: 100,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
97
104
|
|
|
98
105
|
projection.setFieldProjection({
|
|
99
106
|
field: {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/table.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Ref, ObjectId, S, TypedObject } from '@dxos/echo-schema';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId, // TODO(burdon): Where should this be?\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.\n threads: S.optional(S.Array(Ref(ThreadType))),\n});\n\n// type TableType = S.Schema.Type<typeof TableSchema>;\n\nexport class TableType extends TypedObject({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n})(TableSchema.fields) {}\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,KAAKC,UAAUC,GAAGC,mBAAmB;AAC9C,SAASC,kBAAkB;AAC3B,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,EAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;EACzBC,MAAMP,EAAEK,SAASG,IAAIC,QAAAA,CAAAA;;EAErBC,SAASV,EAAEK,SAASL,EAAEW,MAAMH,IAAII,UAAAA,CAAAA,CAAAA;AAClC,CAAA;AAIO,IAAMC,YAAN,cAAwBC,YAAY;EACzCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGjB,YAAYkB,MAAM,EAAA;AAAG;",
|
|
6
|
-
"names": ["Ref", "ObjectId", "S", "TypedObject", "ThreadType", "ViewType", "TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "ThreadType", "TableType", "TypedObject", "typename", "version", "fields"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/table.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Ref, ObjectId, S, TypedObject } from '@dxos/echo-schema';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId, // TODO(burdon): Where should this be?\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.\n threads: S.optional(S.Array(Ref(ThreadType))),\n});\n\n// type TableType = S.Schema.Type<typeof TableSchema>;\n\nexport class TableType extends TypedObject({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n})(TableSchema.fields) {}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAA8C;AAC9C,mBAA2B;AAC3B,oBAAyB;AAElB,IAAMA,cAAcC,qBAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,qBAAEK,SAASL,qBAAEM,MAAM;EACzBC,MAAMP,qBAAEK,aAASG,wBAAIC,sBAAAA,CAAAA;;EAErBC,SAASV,qBAAEK,SAASL,qBAAEW,UAAMH,wBAAII,uBAAAA,CAAAA,CAAAA;AAClC,CAAA;AAIO,IAAMC,YAAN,kBAAwBC,gCAAY;EACzCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGjB,YAAYkB,MAAM,EAAA;AAAG;",
|
|
6
|
-
"names": ["TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "ThreadType", "TableType", "TypedObject", "typename", "version", "fields"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/table.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Ref, ObjectId, S, TypedObject } from '@dxos/echo-schema';\nimport { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId, // TODO(burdon): Where should this be?\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Should not import from plugin. Either factor out type or use reverse deps when supported.\n threads: S.optional(S.Array(Ref(ThreadType))),\n});\n\n// type TableType = S.Schema.Type<typeof TableSchema>;\n\nexport class TableType extends TypedObject({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n})(TableSchema.fields) {}\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,KAAKC,UAAUC,GAAGC,mBAAmB;AAC9C,SAASC,kBAAkB;AAC3B,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,EAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;EACzBC,MAAMP,EAAEK,SAASG,IAAIC,QAAAA,CAAAA;;EAErBC,SAASV,EAAEK,SAASL,EAAEW,MAAMH,IAAII,UAAAA,CAAAA,CAAAA;AAClC,CAAA;AAIO,IAAMC,YAAN,cAAwBC,YAAY;EACzCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGjB,YAAYkB,MAAM,EAAA;AAAG;",
|
|
6
|
-
"names": ["Ref", "ObjectId", "S", "TypedObject", "ThreadType", "ViewType", "TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "ThreadType", "TableType", "TypedObject", "typename", "version", "fields"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.config.d.ts","sourceRoot":"","sources":["../../../../src/playwright/playwright.config.ts"],"names":[],"mappings":";AASA,wBAQG"}
|
|
File without changes
|