@dxos/react-ui-table 0.8.3 → 0.8.4-main.1068cf700f
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-GTGYBRJA.mjs +1748 -0
- package/dist/lib/browser/chunk-GTGYBRJA.mjs.map +7 -0
- package/dist/lib/browser/chunk-OZBLY7XM.mjs +76 -0
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1156 -2508
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +114 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/node-esm/chunk-DPNSZHU5.mjs +1750 -0
- package/dist/lib/node-esm/chunk-DPNSZHU5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs +77 -0
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1156 -2508
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +115 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -5
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +2 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +4 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +7 -7
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +37 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +111 -0
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +13 -9
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +108 -4
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +2 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +14 -9
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +12 -18
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -4
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +4 -4
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +26 -56
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +13 -0
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +11 -10
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -8
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +17 -7
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +149 -32
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +13 -2
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/playwright/TableManager.d.ts +2 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/useTestTableModel.d.ts +25 -0
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +31 -0
- package/dist/types/src/types/Table.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +15 -14
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
- package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts +7 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -0
- package/dist/types/src/util/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/src/util/table-buttons.d.ts +15 -1
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +69 -56
- package/src/components/Table/ColumnActionsMenu.tsx +11 -7
- package/src/components/Table/ColumnSettings.tsx +16 -12
- package/src/components/Table/DynamicTable.stories.tsx +29 -25
- package/src/components/Table/DynamicTable.tsx +34 -22
- package/src/components/Table/Relations.stories.tsx +237 -0
- package/src/components/Table/RowActionsMenu.tsx +26 -17
- package/src/components/Table/Table.stories.tsx +171 -194
- package/src/components/Table/Table.tsx +364 -286
- package/src/components/TableCellEditor/CellValidationMessage.tsx +8 -3
- package/src/components/TableCellEditor/FormCellEditor.tsx +146 -49
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +36 -76
- package/src/components/TableCellEditor/TableCellEditor.tsx +106 -198
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +49 -33
- package/src/components/testing.ts +41 -32
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAddRow.ts +36 -0
- package/src/hooks/useProjectionModel.ts +39 -0
- package/src/hooks/useTableModel.ts +41 -35
- package/src/index.ts +1 -2
- package/src/model/modal-controller.ts +24 -41
- package/src/model/selection-model.ts +75 -41
- package/src/model/table-model.test.ts +92 -56
- package/src/model/table-model.ts +628 -162
- package/src/model/table-presentation.test.ts +70 -59
- package/src/model/table-presentation.ts +278 -149
- package/src/playwright/TableManager.ts +13 -6
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +180 -41
- package/src/testing/index.ts +5 -0
- package/src/testing/useTestTableModel.ts +133 -0
- package/src/translations.ts +7 -5
- package/src/types/Table.ts +90 -0
- package/src/types/index.ts +2 -2
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +50 -36
- package/src/util/index.ts +2 -1
- package/src/util/query-ast.ts +19 -0
- package/src/util/schema.ts +4 -4
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +28 -4
- package/src/util/table-controls.ts +4 -1
- package/dist/lib/browser/chunk-TL7CKQQV.mjs +0 -27
- package/dist/lib/browser/chunk-TL7CKQQV.mjs.map +0 -7
- package/dist/lib/node/chunk-O2VPBNS5.cjs +0 -50
- package/dist/lib/node/chunk-O2VPBNS5.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -2739
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/types/index.cjs +0 -31
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs +0 -29
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs.map +0 -7
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
- package/dist/types/src/components/Table/relations.stories.d.ts +0 -9
- package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/model/table-sorting.d.ts +0 -53
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/dist/types/src/types/table.d.ts +0 -56
- package/dist/types/src/types/table.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -14
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -84
- package/src/components/Table/relations.stories.tsx +0 -124
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/model/table-sorting.ts +0 -216
- package/src/playwright/playwright.config.cts +0 -18
- package/src/types/table.ts +0 -27
- package/src/util/table.ts +0 -127
package/package.json
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.1068cf700f",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
"./deprecated": {
|
|
17
|
+
"source": "./src/deprecated/index.ts",
|
|
13
18
|
"types": "./dist/types/src/deprecated/index.d.ts",
|
|
14
19
|
"browser": "./dist/lib/browser/deprecated/index.mjs",
|
|
15
20
|
"node": "./dist/lib/node-esm/deprecated/index.mjs"
|
|
16
21
|
},
|
|
17
22
|
".": {
|
|
23
|
+
"source": "./src/index.ts",
|
|
18
24
|
"types": "./dist/types/src/index.d.ts",
|
|
19
25
|
"browser": "./dist/lib/browser/index.mjs",
|
|
20
26
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
21
27
|
},
|
|
28
|
+
"./testing": {
|
|
29
|
+
"source": "./src/testing/index.ts",
|
|
30
|
+
"types": "./dist/types/src/testing/index.d.ts",
|
|
31
|
+
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
32
|
+
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
33
|
+
},
|
|
22
34
|
"./types": {
|
|
35
|
+
"source": "./src/types/index.ts",
|
|
23
36
|
"types": "./dist/types/src/types/index.d.ts",
|
|
24
37
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
25
38
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -31,6 +44,9 @@
|
|
|
31
44
|
"deprecated": [
|
|
32
45
|
"dist/types/src/deprecated/index.d.ts"
|
|
33
46
|
],
|
|
47
|
+
"testing": [
|
|
48
|
+
"dist/types/src/testing/index.d.ts"
|
|
49
|
+
],
|
|
34
50
|
"types": [
|
|
35
51
|
"dist/types/src/types/index.d.ts"
|
|
36
52
|
]
|
|
@@ -41,72 +57,69 @@
|
|
|
41
57
|
"src"
|
|
42
58
|
],
|
|
43
59
|
"dependencies": {
|
|
44
|
-
"@codemirror/autocomplete": "^6.
|
|
45
|
-
"@codemirror/state": "^6.
|
|
46
|
-
"@codemirror/view": "^6.
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@preact/signals-core": "^1.9.0",
|
|
60
|
+
"@codemirror/autocomplete": "^6.19.0",
|
|
61
|
+
"@codemirror/state": "^6.5.2",
|
|
62
|
+
"@codemirror/view": "^6.38.4",
|
|
63
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
64
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
50
65
|
"@radix-ui/react-context": "1.1.1",
|
|
51
66
|
"@radix-ui/react-primitive": "2.0.2",
|
|
52
67
|
"@radix-ui/react-slot": "1.1.2",
|
|
53
68
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
54
69
|
"date-fns": "^3.3.1",
|
|
55
70
|
"lodash.orderby": "^4.6.0",
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/echo": "0.8.
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/effect": "0.8.
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/log": "0.8.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/react-
|
|
68
|
-
"@dxos/react-
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-ui-editor": "0.8.
|
|
71
|
-
"@dxos/react-ui-form": "0.8.
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.
|
|
76
|
-
"@dxos/react-ui-
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
71
|
+
"@dxos/async": "0.8.4-main.1068cf700f",
|
|
72
|
+
"@dxos/context": "0.8.4-main.1068cf700f",
|
|
73
|
+
"@dxos/echo-atom": "0.8.4-main.1068cf700f",
|
|
74
|
+
"@dxos/debug": "0.8.4-main.1068cf700f",
|
|
75
|
+
"@dxos/echo": "0.8.4-main.1068cf700f",
|
|
76
|
+
"@dxos/effect": "0.8.4-main.1068cf700f",
|
|
77
|
+
"@dxos/invariant": "0.8.4-main.1068cf700f",
|
|
78
|
+
"@dxos/keys": "0.8.4-main.1068cf700f",
|
|
79
|
+
"@dxos/lit-grid": "0.8.4-main.1068cf700f",
|
|
80
|
+
"@dxos/log": "0.8.4-main.1068cf700f",
|
|
81
|
+
"@dxos/random": "0.8.4-main.1068cf700f",
|
|
82
|
+
"@dxos/react-ui-attention": "0.8.4-main.1068cf700f",
|
|
83
|
+
"@dxos/react-client": "0.8.4-main.1068cf700f",
|
|
84
|
+
"@dxos/react-ui-components": "0.8.4-main.1068cf700f",
|
|
85
|
+
"@dxos/react-ui-editor": "0.8.4-main.1068cf700f",
|
|
86
|
+
"@dxos/react-ui-form": "0.8.4-main.1068cf700f",
|
|
87
|
+
"@dxos/react-ui-menu": "0.8.4-main.1068cf700f",
|
|
88
|
+
"@dxos/react-ui-grid": "0.8.4-main.1068cf700f",
|
|
89
|
+
"@dxos/react-ui-stack": "0.8.4-main.1068cf700f",
|
|
90
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.1068cf700f",
|
|
91
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.1068cf700f",
|
|
92
|
+
"@dxos/types": "0.8.4-main.1068cf700f",
|
|
93
|
+
"@dxos/schema": "0.8.4-main.1068cf700f",
|
|
94
|
+
"@dxos/ui-types": "0.8.4-main.1068cf700f",
|
|
95
|
+
"@dxos/util": "0.8.4-main.1068cf700f"
|
|
81
96
|
},
|
|
82
97
|
"devDependencies": {
|
|
83
|
-
"@effect
|
|
84
|
-
"@effect/platform": "0.80.12",
|
|
85
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
98
|
+
"@effect/platform": "0.94.4",
|
|
86
99
|
"@types/lodash.orderby": "^4.6.9",
|
|
87
|
-
"@types/react": "~
|
|
88
|
-
"@types/react-dom": "~
|
|
89
|
-
"effect": "3.
|
|
100
|
+
"@types/react": "~19.2.7",
|
|
101
|
+
"@types/react-dom": "~19.2.3",
|
|
102
|
+
"effect": "3.19.16",
|
|
90
103
|
"fast-check": "^3.19.0",
|
|
91
|
-
"react": "~
|
|
92
|
-
"react-dom": "~
|
|
93
|
-
"vite": "
|
|
94
|
-
"@dxos/random": "0.8.
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/storybook-utils": "0.8.
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/
|
|
104
|
+
"react": "~19.2.3",
|
|
105
|
+
"react-dom": "~19.2.3",
|
|
106
|
+
"vite": "7.1.9",
|
|
107
|
+
"@dxos/random": "0.8.4-main.1068cf700f",
|
|
108
|
+
"@dxos/react-ui": "0.8.4-main.1068cf700f",
|
|
109
|
+
"@dxos/storybook-utils": "0.8.4-main.1068cf700f",
|
|
110
|
+
"@dxos/lit-ui": "0.8.4-main.1068cf700f",
|
|
111
|
+
"@dxos/test-utils": "0.8.4-main.1068cf700f",
|
|
112
|
+
"@dxos/ui-theme": "0.8.4-main.1068cf700f",
|
|
113
|
+
"@dxos/react-client": "0.8.4-main.1068cf700f"
|
|
100
114
|
},
|
|
101
115
|
"peerDependencies": {
|
|
102
|
-
"@effect-
|
|
103
|
-
"@effect/platform": "0.
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"react": "~
|
|
107
|
-
"react-
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/react-ui-theme": "0.8.3"
|
|
116
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
117
|
+
"@effect/platform": "0.94.4",
|
|
118
|
+
"effect": "3.19.16",
|
|
119
|
+
"react": "~19.2.3",
|
|
120
|
+
"react-dom": "~19.2.3",
|
|
121
|
+
"@dxos/react-ui": "0.8.4-main.1068cf700f",
|
|
122
|
+
"@dxos/ui-theme": "0.8.4-main.1068cf700f"
|
|
110
123
|
},
|
|
111
124
|
"publishConfig": {
|
|
112
125
|
"access": "public"
|
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import { DropdownMenu, useTranslation } from '@dxos/react-ui';
|
|
8
9
|
|
|
9
|
-
import { type
|
|
10
|
+
import { type ModalController, type TableModel } from '../../model';
|
|
10
11
|
import { translationKey } from '../../translations';
|
|
11
12
|
|
|
12
|
-
type ColumnActionsMenuProps = {
|
|
13
|
+
export type ColumnActionsMenuProps = {
|
|
14
|
+
model: TableModel;
|
|
15
|
+
modals: ModalController;
|
|
16
|
+
};
|
|
13
17
|
|
|
14
18
|
export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) => {
|
|
15
19
|
const { t } = useTranslation(translationKey);
|
|
16
|
-
const state = modals.state
|
|
20
|
+
const state = useAtomValue(modals.state);
|
|
17
21
|
if (state?.type !== 'column') {
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const currentSort = model.
|
|
25
|
+
const currentSort = model.getSorting();
|
|
22
26
|
const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
|
|
23
27
|
|
|
24
28
|
return (
|
|
@@ -30,7 +34,7 @@ export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) =>
|
|
|
30
34
|
{(!isCurrentColumnSorted || currentSort?.direction === 'asc') && (
|
|
31
35
|
<DropdownMenu.Item
|
|
32
36
|
data-testid='column-sort-descending'
|
|
33
|
-
onClick={() => model.
|
|
37
|
+
onClick={() => model.setSort(state.fieldId, 'desc')}
|
|
34
38
|
>
|
|
35
39
|
{t('column action sort descending')}
|
|
36
40
|
</DropdownMenu.Item>
|
|
@@ -38,13 +42,13 @@ export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) =>
|
|
|
38
42
|
{(!isCurrentColumnSorted || currentSort?.direction === 'desc') && (
|
|
39
43
|
<DropdownMenu.Item
|
|
40
44
|
data-testid='column-sort-ascending'
|
|
41
|
-
onClick={() => model.
|
|
45
|
+
onClick={() => model.setSort(state.fieldId, 'asc')}
|
|
42
46
|
>
|
|
43
47
|
{t('column action sort ascending')}
|
|
44
48
|
</DropdownMenu.Item>
|
|
45
49
|
)}
|
|
46
50
|
{isCurrentColumnSorted && (
|
|
47
|
-
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.
|
|
51
|
+
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.clearSort()}>
|
|
48
52
|
{t('column action clear sorting')}
|
|
49
53
|
</DropdownMenu.Item>
|
|
50
54
|
)}
|
|
@@ -2,21 +2,26 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
5
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
7
|
|
|
8
|
+
import { type SchemaRegistry } from '@dxos/echo';
|
|
7
9
|
import { Popover } from '@dxos/react-ui';
|
|
8
10
|
import { FieldEditor } from '@dxos/react-ui-form';
|
|
9
11
|
import { type FieldType } from '@dxos/schema';
|
|
10
12
|
|
|
11
|
-
import { type
|
|
13
|
+
import { type ModalController, type TableModel } from '../../model';
|
|
12
14
|
|
|
13
|
-
type ColumnSettingsProps = {
|
|
15
|
+
type ColumnSettingsProps = {
|
|
16
|
+
registry?: SchemaRegistry.SchemaRegistry;
|
|
17
|
+
model?: TableModel;
|
|
18
|
+
modals: ModalController;
|
|
19
|
+
onNewColumn: () => void;
|
|
20
|
+
};
|
|
14
21
|
|
|
15
|
-
export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsProps) => {
|
|
22
|
+
export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnSettingsProps) => {
|
|
16
23
|
const [newField, setNewField] = useState<FieldType>();
|
|
17
|
-
const state = modals.state
|
|
18
|
-
|
|
19
|
-
const space = model?.space;
|
|
24
|
+
const state = useAtomValue(modals.state);
|
|
20
25
|
|
|
21
26
|
useEffect(() => {
|
|
22
27
|
if (state?.type === 'columnSettings' && state.mode.type === 'create' && model?.projection) {
|
|
@@ -33,11 +38,11 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
33
38
|
if (state?.type === 'columnSettings') {
|
|
34
39
|
const { mode } = state;
|
|
35
40
|
if (mode.type === 'edit') {
|
|
36
|
-
return model?.
|
|
41
|
+
return model?.projection?.getFields().find((f) => f.id === mode.fieldId);
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
return undefined;
|
|
40
|
-
}, [model?.
|
|
45
|
+
}, [model?.projection, state]);
|
|
41
46
|
|
|
42
47
|
const field = existingField ?? newField;
|
|
43
48
|
|
|
@@ -47,11 +52,11 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
47
52
|
|
|
48
53
|
const handleCancel = useCallback(() => {
|
|
49
54
|
if (state?.type === 'columnSettings' && state.mode.type === 'create' && newField) {
|
|
50
|
-
model?.projection
|
|
55
|
+
model?.projection.deleteFieldProjection(newField.id);
|
|
51
56
|
}
|
|
52
57
|
}, [model?.projection, state, newField]);
|
|
53
58
|
|
|
54
|
-
if (!model?.
|
|
59
|
+
if (!model?.projection || !field) {
|
|
55
60
|
return null;
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -62,10 +67,9 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
62
67
|
<Popover.Content classNames='md:is-64'>
|
|
63
68
|
<Popover.Viewport>
|
|
64
69
|
<FieldEditor
|
|
65
|
-
view={model.view!}
|
|
66
70
|
projection={model.projection}
|
|
67
71
|
field={field}
|
|
68
|
-
registry={
|
|
72
|
+
registry={registry}
|
|
69
73
|
onSave={handleSave}
|
|
70
74
|
onCancel={handleCancel}
|
|
71
75
|
/>
|
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import type * as Types from 'effect/Types';
|
|
8
7
|
import React, { useMemo, useState } from 'react';
|
|
9
8
|
|
|
10
|
-
import { Obj } from '@dxos/echo';
|
|
11
|
-
import {
|
|
9
|
+
import { type JsonSchema, Obj } from '@dxos/echo';
|
|
10
|
+
import { Format } from '@dxos/echo/internal';
|
|
12
11
|
import { faker } from '@dxos/random';
|
|
13
|
-
import { useClient } from '@dxos/react-client';
|
|
14
12
|
import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
|
|
15
|
-
import {
|
|
13
|
+
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
15
|
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
16
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
17
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
19
18
|
|
|
20
|
-
import { DynamicTable } from './DynamicTable';
|
|
21
19
|
import { type TableFeatures } from '../../model';
|
|
22
|
-
import translations from '../../translations';
|
|
20
|
+
import { translations } from '../../translations';
|
|
21
|
+
|
|
22
|
+
import { DynamicTable } from './DynamicTable';
|
|
23
23
|
|
|
24
24
|
faker.seed(0);
|
|
25
25
|
|
|
26
26
|
const useTestPropertiesAndObjects = () => {
|
|
27
27
|
const properties = useMemo<SchemaPropertyDefinition[]>(
|
|
28
28
|
() => [
|
|
29
|
-
{ name: 'name', format:
|
|
30
|
-
{ name: 'age', format:
|
|
29
|
+
{ name: 'name', format: Format.TypeFormat.String },
|
|
30
|
+
{ name: 'age', format: Format.TypeFormat.Number },
|
|
31
31
|
],
|
|
32
32
|
[],
|
|
33
33
|
);
|
|
@@ -56,15 +56,20 @@ const DynamicTableStory = () => {
|
|
|
56
56
|
// Story definitions.
|
|
57
57
|
//
|
|
58
58
|
|
|
59
|
-
const meta
|
|
59
|
+
const meta = {
|
|
60
60
|
title: 'ui/react-ui-table/DynamicTable',
|
|
61
61
|
component: DynamicTable,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
decorators: [withTheme(), withRegistry],
|
|
63
|
+
parameters: {
|
|
64
|
+
layout: 'fullscreen',
|
|
65
|
+
translations,
|
|
66
|
+
},
|
|
67
|
+
} satisfies Meta<typeof DynamicTable>;
|
|
65
68
|
|
|
66
69
|
export default meta;
|
|
67
70
|
|
|
71
|
+
type Story = StoryObj<typeof meta>;
|
|
72
|
+
|
|
68
73
|
export const Default: StoryObj = {
|
|
69
74
|
render: DynamicTableStory,
|
|
70
75
|
};
|
|
@@ -97,7 +102,7 @@ export const WithClickToSelect: StoryObj = {
|
|
|
97
102
|
|
|
98
103
|
export const WithJsonSchema: StoryObj = {
|
|
99
104
|
render: () => {
|
|
100
|
-
const schema = useMemo<
|
|
105
|
+
const schema = useMemo<Types.DeepMutable<JsonSchema.JsonSchema>>(
|
|
101
106
|
() => ({
|
|
102
107
|
type: 'object',
|
|
103
108
|
properties: {
|
|
@@ -126,10 +131,9 @@ export const WithJsonSchema: StoryObj = {
|
|
|
126
131
|
|
|
127
132
|
export const WithEchoSchema: StoryObj = {
|
|
128
133
|
render: () => {
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
|
|
134
|
+
const { space } = useClientStory();
|
|
135
|
+
const schema = useSchema(space?.db, TestSchema.Person.typename);
|
|
136
|
+
const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
|
|
133
137
|
if (!schema) {
|
|
134
138
|
return <div>Loading schema...</div>;
|
|
135
139
|
}
|
|
@@ -138,13 +142,13 @@ export const WithEchoSchema: StoryObj = {
|
|
|
138
142
|
},
|
|
139
143
|
decorators: [
|
|
140
144
|
withClientProvider({
|
|
141
|
-
types: [
|
|
145
|
+
types: [TestSchema.Person],
|
|
142
146
|
createIdentity: true,
|
|
143
147
|
createSpace: true,
|
|
144
|
-
|
|
148
|
+
onCreateSpace: async ({ space }) => {
|
|
145
149
|
Array.from({ length: 10 }).forEach(() => {
|
|
146
150
|
space.db.add(
|
|
147
|
-
Obj.make(
|
|
151
|
+
Obj.make(TestSchema.Person, {
|
|
148
152
|
name: faker.person.fullName(),
|
|
149
153
|
email: faker.internet.email(),
|
|
150
154
|
}),
|
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
+
import type * as Types from 'effect/Types';
|
|
7
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
8
|
|
|
8
|
-
import { type
|
|
9
|
+
import { type Type } from '@dxos/echo';
|
|
10
|
+
import { type JsonSchema } from '@dxos/echo';
|
|
9
11
|
import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
12
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { mx } from '@dxos/ui-theme';
|
|
11
14
|
|
|
12
|
-
import { Table, type TableController } from './Table';
|
|
13
15
|
import { useTableModel } from '../../hooks';
|
|
14
16
|
import { type TableFeatures, TablePresentation, type TableRowAction } from '../../model';
|
|
15
|
-
import {
|
|
17
|
+
import { type Table as TableType } from '../../types';
|
|
18
|
+
import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '../../util';
|
|
19
|
+
|
|
20
|
+
import { Table, type TableController } from './Table';
|
|
16
21
|
|
|
17
|
-
type DynamicTableProps = ThemedClassName<{
|
|
22
|
+
export type DynamicTableProps<T extends Type.Entity.Any = Type.Entity.Any> = ThemedClassName<{
|
|
23
|
+
schema?: T;
|
|
18
24
|
name?: string; // TODO(burdon): Remove?
|
|
19
25
|
rows: any[];
|
|
20
26
|
properties?: TablePropertyDefinition[];
|
|
21
|
-
jsonSchema?:
|
|
22
|
-
schema?: Schema.Schema.AnyNoContext;
|
|
27
|
+
jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
|
|
23
28
|
features?: Partial<TableFeatures>;
|
|
24
29
|
rowActions?: TableRowAction[];
|
|
25
30
|
onRowClick?: (row: any) => void;
|
|
@@ -31,23 +36,30 @@ type DynamicTableProps = ThemedClassName<{
|
|
|
31
36
|
*/
|
|
32
37
|
// TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
|
|
33
38
|
// TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
|
|
34
|
-
export const DynamicTable = ({
|
|
39
|
+
export const DynamicTable = <T extends Type.Entity.Any = Type.Entity.Any>({
|
|
35
40
|
classNames,
|
|
41
|
+
schema,
|
|
36
42
|
name = 'example.com/dynamic-table', // Rmove default or make random; this will lead to type collisions.
|
|
37
43
|
rows,
|
|
38
44
|
properties,
|
|
39
|
-
jsonSchema,
|
|
40
|
-
schema,
|
|
45
|
+
jsonSchema: _jsonSchema,
|
|
41
46
|
rowActions,
|
|
42
47
|
onRowClick,
|
|
43
48
|
onRowAction,
|
|
44
49
|
...props
|
|
45
|
-
}: DynamicTableProps) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
}: DynamicTableProps<T>) => {
|
|
51
|
+
const registry = useContext(RegistryContext);
|
|
52
|
+
const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
|
|
53
|
+
|
|
54
|
+
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
55
|
+
const { jsonSchema } = useMemo(
|
|
56
|
+
() => getBaseSchema({ typename: name, properties, jsonSchema: _jsonSchema, schema }),
|
|
57
|
+
[name, properties, _jsonSchema, schema],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
|
|
62
|
+
}, [registry, jsonSchema, properties]);
|
|
51
63
|
|
|
52
64
|
const tableRef = useRef<TableController>(null);
|
|
53
65
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
@@ -68,9 +80,9 @@ export const DynamicTable = ({
|
|
|
68
80
|
);
|
|
69
81
|
|
|
70
82
|
const model = useTableModel({
|
|
71
|
-
table,
|
|
72
83
|
rows,
|
|
73
|
-
|
|
84
|
+
object: dynamicTable?.object,
|
|
85
|
+
projection: dynamicTable?.projection,
|
|
74
86
|
features,
|
|
75
87
|
rowActions,
|
|
76
88
|
onCellUpdate: handleCellUpdate,
|
|
@@ -80,9 +92,9 @@ export const DynamicTable = ({
|
|
|
80
92
|
|
|
81
93
|
const presentation = useMemo(() => {
|
|
82
94
|
if (model) {
|
|
83
|
-
return new TablePresentation(model);
|
|
95
|
+
return new TablePresentation(registry, model);
|
|
84
96
|
}
|
|
85
|
-
}, [model]);
|
|
97
|
+
}, [registry, model]);
|
|
86
98
|
|
|
87
99
|
// TODO(burdon): Do we need the outer divs?
|
|
88
100
|
return (
|