@dxos/react-ui-table 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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-BF54SSNL.mjs +70 -0
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/chunk-F7Y374KL.mjs +1751 -0
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1195 -2846
- 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-CCJ4LOVM.mjs +1753 -0
- package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs +71 -0
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1195 -2846
- 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 +35 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +110 -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 +21 -18
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +109 -6
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +17 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -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 +38 -5
- 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/index.d.ts +0 -1
- package/dist/types/src/components/index.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 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +6 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- 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 +0 -1
- 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 +116 -34
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +5 -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/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 +21 -23
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +26 -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.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 +70 -55
- package/src/components/Table/ColumnActionsMenu.tsx +16 -12
- package/src/components/Table/ColumnSettings.tsx +18 -15
- package/src/components/Table/DynamicTable.stories.tsx +38 -35
- package/src/components/Table/DynamicTable.tsx +38 -34
- package/src/components/Table/Relations.stories.tsx +245 -0
- package/src/components/Table/RowActionsMenu.tsx +26 -17
- package/src/components/Table/Table.stories.tsx +196 -218
- package/src/components/Table/Table.tsx +47 -376
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/Table/TableToolbar.tsx +111 -0
- package/src/components/TableCellEditor/CellValidationMessage.tsx +6 -6
- package/src/components/TableCellEditor/FormCellEditor.tsx +152 -49
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +37 -77
- package/src/components/TableCellEditor/TableCellEditor.tsx +104 -233
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +46 -37
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +14 -14
- package/src/hooks/useProjectionModel.ts +39 -0
- package/src/hooks/useTableModel.ts +41 -35
- package/src/index.ts +0 -1
- package/src/model/modal-controller.ts +24 -41
- package/src/model/selection-model.ts +75 -41
- package/src/model/table-model.test.ts +91 -56
- package/src/model/table-model.ts +468 -187
- package/src/model/table-presentation.test.ts +69 -59
- package/src/model/table-presentation.ts +112 -66
- package/src/playwright/TableManager.ts +13 -6
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +180 -43
- package/src/testing/index.ts +5 -0
- package/src/testing/useTestTableModel.ts +133 -0
- package/src/translations.ts +20 -22
- package/src/types/Table.ts +79 -0
- package/src/types/index.ts +2 -2
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +51 -36
- package/src/util/index.ts +2 -1
- package/src/util/query-ast.ts +22 -0
- package/src/util/schema.ts +4 -4
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +4 -3
- package/src/util/table-controls.ts +6 -3
- package/dist/lib/browser/chunk-Q5QQXJUO.mjs +0 -27
- package/dist/lib/browser/chunk-Q5QQXJUO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZNOU6LHG.mjs +0 -29
- package/dist/lib/node-esm/chunk-ZNOU6LHG.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/components/TableToolbar/TableToolbar.d.ts +0 -21
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
- package/dist/types/src/components/TableToolbar/index.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 -123
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/components/TableToolbar/TableToolbar.tsx +0 -102
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -216
- 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.4-main.
|
|
3
|
+
"version": "0.8.4-main.fcfe5033a5",
|
|
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,70 +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
|
-
"date-fns": "^3.
|
|
69
|
+
"date-fns": "^3.6.0",
|
|
55
70
|
"lodash.orderby": "^4.6.0",
|
|
56
|
-
"@dxos/context": "0.8.4-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/log": "0.8.4-main.
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/react-
|
|
69
|
-
"@dxos/react-ui-
|
|
70
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
71
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/react-ui-
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/react-ui-
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/util": "0.8.4-main.
|
|
71
|
+
"@dxos/context": "0.8.4-main.fcfe5033a5",
|
|
72
|
+
"@dxos/effect": "0.8.4-main.fcfe5033a5",
|
|
73
|
+
"@dxos/async": "0.8.4-main.fcfe5033a5",
|
|
74
|
+
"@dxos/debug": "0.8.4-main.fcfe5033a5",
|
|
75
|
+
"@dxos/echo-atom": "0.8.4-main.fcfe5033a5",
|
|
76
|
+
"@dxos/keys": "0.8.4-main.fcfe5033a5",
|
|
77
|
+
"@dxos/lit-grid": "0.8.4-main.fcfe5033a5",
|
|
78
|
+
"@dxos/invariant": "0.8.4-main.fcfe5033a5",
|
|
79
|
+
"@dxos/log": "0.8.4-main.fcfe5033a5",
|
|
80
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
81
|
+
"@dxos/echo": "0.8.4-main.fcfe5033a5",
|
|
82
|
+
"@dxos/react-client": "0.8.4-main.fcfe5033a5",
|
|
83
|
+
"@dxos/react-ui-attention": "0.8.4-main.fcfe5033a5",
|
|
84
|
+
"@dxos/react-ui-components": "0.8.4-main.fcfe5033a5",
|
|
85
|
+
"@dxos/react-ui-editor": "0.8.4-main.fcfe5033a5",
|
|
86
|
+
"@dxos/react-ui-form": "0.8.4-main.fcfe5033a5",
|
|
87
|
+
"@dxos/react-ui-search": "0.8.4-main.fcfe5033a5",
|
|
88
|
+
"@dxos/react-ui-grid": "0.8.4-main.fcfe5033a5",
|
|
89
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
|
|
90
|
+
"@dxos/react-ui-menu": "0.8.4-main.fcfe5033a5",
|
|
91
|
+
"@dxos/schema": "0.8.4-main.fcfe5033a5",
|
|
92
|
+
"@dxos/types": "0.8.4-main.fcfe5033a5",
|
|
93
|
+
"@dxos/react-ui-stack": "0.8.4-main.fcfe5033a5",
|
|
94
|
+
"@dxos/ui-types": "0.8.4-main.fcfe5033a5",
|
|
95
|
+
"@dxos/util": "0.8.4-main.fcfe5033a5"
|
|
81
96
|
},
|
|
82
97
|
"devDependencies": {
|
|
83
|
-
"@effect
|
|
84
|
-
"@effect/platform": "0.88.0",
|
|
98
|
+
"@effect/platform": "0.94.4",
|
|
85
99
|
"@types/lodash.orderby": "^4.6.9",
|
|
86
|
-
"@types/react": "~
|
|
87
|
-
"@types/react-dom": "~
|
|
88
|
-
"effect": "3.
|
|
100
|
+
"@types/react": "~19.2.7",
|
|
101
|
+
"@types/react-dom": "~19.2.3",
|
|
102
|
+
"effect": "3.20.0",
|
|
89
103
|
"fast-check": "^3.19.0",
|
|
90
|
-
"react": "~
|
|
91
|
-
"react-dom": "~
|
|
92
|
-
"vite": "
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/react-ui
|
|
97
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
98
|
-
"@dxos/
|
|
104
|
+
"react": "~19.2.3",
|
|
105
|
+
"react-dom": "~19.2.3",
|
|
106
|
+
"vite": "^7.1.11",
|
|
107
|
+
"@dxos/lit-ui": "0.8.4-main.fcfe5033a5",
|
|
108
|
+
"@dxos/react-client": "0.8.4-main.fcfe5033a5",
|
|
109
|
+
"@dxos/random": "0.8.4-main.fcfe5033a5",
|
|
110
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
111
|
+
"@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
|
|
112
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5",
|
|
113
|
+
"@dxos/test-utils": "0.8.4-main.fcfe5033a5"
|
|
99
114
|
},
|
|
100
115
|
"peerDependencies": {
|
|
101
|
-
"@effect-
|
|
102
|
-
"@effect/platform": "
|
|
103
|
-
"effect": "
|
|
104
|
-
"react": "~
|
|
105
|
-
"react-dom": "~
|
|
106
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
107
|
-
"@dxos/
|
|
116
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
117
|
+
"@effect/platform": "0.94.4",
|
|
118
|
+
"effect": "3.20.0",
|
|
119
|
+
"react": "~19.2.3",
|
|
120
|
+
"react-dom": "~19.2.3",
|
|
121
|
+
"@dxos/react-ui": "0.8.4-main.fcfe5033a5",
|
|
122
|
+
"@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
|
|
108
123
|
},
|
|
109
124
|
"publishConfig": {
|
|
110
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,32 +34,32 @@ 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
|
-
{t('column
|
|
39
|
+
{t('column-action-sort-descending.menu')}
|
|
36
40
|
</DropdownMenu.Item>
|
|
37
41
|
)}
|
|
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
|
-
{t('column
|
|
47
|
+
{t('column-action-sort-ascending.menu')}
|
|
44
48
|
</DropdownMenu.Item>
|
|
45
49
|
)}
|
|
46
50
|
{isCurrentColumnSorted && (
|
|
47
|
-
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.
|
|
48
|
-
{t('column
|
|
51
|
+
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.clearSort()}>
|
|
52
|
+
{t('column-action-clear-sorting.menu')}
|
|
49
53
|
</DropdownMenu.Item>
|
|
50
54
|
)}
|
|
51
55
|
{model.getColumnCount() > 1 && model.features.schemaEditable && (
|
|
52
56
|
<DropdownMenu.Item data-testid='column-delete' onClick={() => model.deleteColumn(state.fieldId)}>
|
|
53
|
-
{t('column
|
|
57
|
+
{t('column-action-delete.menu')}
|
|
54
58
|
</DropdownMenu.Item>
|
|
55
59
|
)}
|
|
56
60
|
{model.features.schemaEditable && (
|
|
57
61
|
<DropdownMenu.Item data-testid='column-settings' onClick={() => modals.openColumnSettings()}>
|
|
58
|
-
{t('column
|
|
62
|
+
{t('column-action-settings.menu')}
|
|
59
63
|
</DropdownMenu.Item>
|
|
60
64
|
)}
|
|
61
65
|
</DropdownMenu.Viewport>
|
|
@@ -2,21 +2,25 @@
|
|
|
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, type View } from '@dxos/echo';
|
|
7
9
|
import { Popover } from '@dxos/react-ui';
|
|
8
10
|
import { FieldEditor } from '@dxos/react-ui-form';
|
|
9
|
-
import { type FieldType } from '@dxos/schema';
|
|
10
11
|
|
|
11
|
-
import { type
|
|
12
|
+
import { type ModalController, type TableModel } from '../../model';
|
|
12
13
|
|
|
13
|
-
type ColumnSettingsProps = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
type ColumnSettingsProps = {
|
|
15
|
+
registry?: SchemaRegistry.SchemaRegistry;
|
|
16
|
+
model?: TableModel;
|
|
17
|
+
modals: ModalController;
|
|
18
|
+
onNewColumn: () => void;
|
|
19
|
+
};
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnSettingsProps) => {
|
|
22
|
+
const [newField, setNewField] = useState<View.FieldType>();
|
|
23
|
+
const state = useAtomValue(modals.state);
|
|
20
24
|
|
|
21
25
|
useEffect(() => {
|
|
22
26
|
if (state?.type === 'columnSettings' && state.mode.type === 'create' && model?.projection) {
|
|
@@ -33,11 +37,11 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
33
37
|
if (state?.type === 'columnSettings') {
|
|
34
38
|
const { mode } = state;
|
|
35
39
|
if (mode.type === 'edit') {
|
|
36
|
-
return model?.
|
|
40
|
+
return model?.projection?.getFields().find((f) => f.id === mode.fieldId);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
return undefined;
|
|
40
|
-
}, [model?.
|
|
44
|
+
}, [model?.projection, state]);
|
|
41
45
|
|
|
42
46
|
const field = existingField ?? newField;
|
|
43
47
|
|
|
@@ -47,11 +51,11 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
47
51
|
|
|
48
52
|
const handleCancel = useCallback(() => {
|
|
49
53
|
if (state?.type === 'columnSettings' && state.mode.type === 'create' && newField) {
|
|
50
|
-
model?.projection
|
|
54
|
+
model?.projection.deleteFieldProjection(newField.id);
|
|
51
55
|
}
|
|
52
56
|
}, [model?.projection, state, newField]);
|
|
53
57
|
|
|
54
|
-
if (!model?.
|
|
58
|
+
if (!model?.projection || !field) {
|
|
55
59
|
return null;
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -59,13 +63,12 @@ export const ColumnSettings = ({ model, modals, onNewColumn }: ColumnSettingsPro
|
|
|
59
63
|
<Popover.Root modal={false} open={state?.type === 'columnSettings'}>
|
|
60
64
|
<Popover.VirtualTrigger virtualRef={modals.trigger} />
|
|
61
65
|
<Popover.Portal>
|
|
62
|
-
<Popover.Content classNames='md:
|
|
66
|
+
<Popover.Content classNames='md:w-64'>
|
|
63
67
|
<Popover.Viewport>
|
|
64
68
|
<FieldEditor
|
|
65
|
-
view={model.view!}
|
|
66
69
|
projection={model.projection}
|
|
67
70
|
field={field}
|
|
68
|
-
registry={
|
|
71
|
+
registry={registry}
|
|
69
72
|
onSave={handleSave}
|
|
70
73
|
onCancel={handleCancel}
|
|
71
74
|
/>
|
|
@@ -2,41 +2,40 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
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 {
|
|
12
|
-
import {
|
|
13
|
-
import { useClient } from '@dxos/react-client';
|
|
9
|
+
import { type JsonSchema, Obj } from '@dxos/echo';
|
|
10
|
+
import { Format } from '@dxos/echo/internal';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
14
12
|
import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
|
|
15
|
-
import {
|
|
13
|
+
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { withLayout, 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
20
|
import { translations } from '../../translations';
|
|
21
|
+
import { DynamicTable } from './DynamicTable';
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
random.seed(0);
|
|
25
24
|
|
|
26
25
|
const useTestPropertiesAndObjects = () => {
|
|
27
26
|
const properties = useMemo<SchemaPropertyDefinition[]>(
|
|
28
27
|
() => [
|
|
29
|
-
{ name: 'name', format:
|
|
30
|
-
{ name: 'age', format:
|
|
28
|
+
{ name: 'name', format: Format.TypeFormat.String },
|
|
29
|
+
{ name: 'age', format: Format.TypeFormat.Number },
|
|
31
30
|
],
|
|
32
31
|
[],
|
|
33
32
|
);
|
|
34
33
|
|
|
35
34
|
const [rows] = useState<any[]>(
|
|
36
35
|
Array.from({ length: 10 }, () => ({
|
|
37
|
-
id:
|
|
38
|
-
name:
|
|
39
|
-
age:
|
|
36
|
+
id: random.string.uuid(),
|
|
37
|
+
name: random.person.fullName(),
|
|
38
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
40
39
|
})),
|
|
41
40
|
);
|
|
42
41
|
|
|
@@ -56,15 +55,20 @@ const DynamicTableStory = () => {
|
|
|
56
55
|
// Story definitions.
|
|
57
56
|
//
|
|
58
57
|
|
|
59
|
-
const meta
|
|
58
|
+
const meta = {
|
|
60
59
|
title: 'ui/react-ui-table/DynamicTable',
|
|
61
60
|
component: DynamicTable,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
|
|
62
|
+
parameters: {
|
|
63
|
+
layout: 'fullscreen',
|
|
64
|
+
translations,
|
|
65
|
+
},
|
|
66
|
+
} satisfies Meta<typeof DynamicTable>;
|
|
65
67
|
|
|
66
68
|
export default meta;
|
|
67
69
|
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
71
|
+
|
|
68
72
|
export const Default: StoryObj = {
|
|
69
73
|
render: DynamicTableStory,
|
|
70
74
|
};
|
|
@@ -97,7 +101,7 @@ export const WithClickToSelect: StoryObj = {
|
|
|
97
101
|
|
|
98
102
|
export const WithJsonSchema: StoryObj = {
|
|
99
103
|
render: () => {
|
|
100
|
-
const schema = useMemo<
|
|
104
|
+
const schema = useMemo<Types.DeepMutable<JsonSchema.JsonSchema>>(
|
|
101
105
|
() => ({
|
|
102
106
|
type: 'object',
|
|
103
107
|
properties: {
|
|
@@ -113,10 +117,10 @@ export const WithJsonSchema: StoryObj = {
|
|
|
113
117
|
|
|
114
118
|
const [rows] = useState<any[]>(
|
|
115
119
|
Array.from({ length: 15 }, () => ({
|
|
116
|
-
name:
|
|
117
|
-
age:
|
|
118
|
-
email:
|
|
119
|
-
active:
|
|
120
|
+
name: random.person.fullName(),
|
|
121
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
122
|
+
email: random.internet.email(),
|
|
123
|
+
active: random.datatype.boolean(),
|
|
120
124
|
})),
|
|
121
125
|
);
|
|
122
126
|
|
|
@@ -126,10 +130,9 @@ export const WithJsonSchema: StoryObj = {
|
|
|
126
130
|
|
|
127
131
|
export const WithEchoSchema: StoryObj = {
|
|
128
132
|
render: () => {
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
|
|
133
|
+
const { space } = useClientStory();
|
|
134
|
+
const schema = useSchema(space?.db, TestSchema.Person.typename);
|
|
135
|
+
const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
|
|
133
136
|
if (!schema) {
|
|
134
137
|
return <div>Loading schema...</div>;
|
|
135
138
|
}
|
|
@@ -138,15 +141,15 @@ export const WithEchoSchema: StoryObj = {
|
|
|
138
141
|
},
|
|
139
142
|
decorators: [
|
|
140
143
|
withClientProvider({
|
|
141
|
-
types: [
|
|
144
|
+
types: [TestSchema.Person],
|
|
142
145
|
createIdentity: true,
|
|
143
146
|
createSpace: true,
|
|
144
|
-
|
|
147
|
+
onCreateSpace: async ({ space }) => {
|
|
145
148
|
Array.from({ length: 10 }).forEach(() => {
|
|
146
149
|
space.db.add(
|
|
147
|
-
Obj.make(
|
|
148
|
-
name:
|
|
149
|
-
email:
|
|
150
|
+
Obj.make(TestSchema.Person, {
|
|
151
|
+
name: random.person.fullName(),
|
|
152
|
+
email: random.internet.email(),
|
|
150
153
|
}),
|
|
151
154
|
);
|
|
152
155
|
});
|
|
@@ -2,24 +2,28 @@
|
|
|
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
|
+
import { Table, type TableController } from './Table';
|
|
16
20
|
|
|
17
|
-
type DynamicTableProps = ThemedClassName<{
|
|
21
|
+
export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = ThemedClassName<{
|
|
22
|
+
schema?: T;
|
|
18
23
|
name?: string; // TODO(burdon): Remove?
|
|
19
24
|
rows: any[];
|
|
20
25
|
properties?: TablePropertyDefinition[];
|
|
21
|
-
jsonSchema?:
|
|
22
|
-
schema?: Schema.Schema.AnyNoContext;
|
|
26
|
+
jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
|
|
23
27
|
features?: Partial<TableFeatures>;
|
|
24
28
|
rowActions?: TableRowAction[];
|
|
25
29
|
onRowClick?: (row: any) => void;
|
|
@@ -31,23 +35,30 @@ type DynamicTableProps = ThemedClassName<{
|
|
|
31
35
|
*/
|
|
32
36
|
// TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
|
|
33
37
|
// TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
|
|
34
|
-
export const DynamicTable = ({
|
|
38
|
+
export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
|
|
35
39
|
classNames,
|
|
36
|
-
|
|
40
|
+
schema,
|
|
41
|
+
name = 'com.example.dynamic-table', // Remove default or make random; this will lead to type collisions.
|
|
37
42
|
rows,
|
|
38
43
|
properties,
|
|
39
|
-
jsonSchema,
|
|
40
|
-
schema,
|
|
44
|
+
jsonSchema: jsonSchemaProp,
|
|
41
45
|
rowActions,
|
|
42
46
|
onRowClick,
|
|
43
47
|
onRowAction,
|
|
44
48
|
...props
|
|
45
|
-
}: DynamicTableProps) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
}: DynamicTableProps<T>) => {
|
|
50
|
+
const registry = useContext(RegistryContext);
|
|
51
|
+
const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
|
|
52
|
+
|
|
53
|
+
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
54
|
+
const { jsonSchema } = useMemo(
|
|
55
|
+
() => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp, schema }),
|
|
56
|
+
[name, properties, jsonSchemaProp, schema],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
|
|
61
|
+
}, [registry, jsonSchema, properties]);
|
|
51
62
|
|
|
52
63
|
const tableRef = useRef<TableController>(null);
|
|
53
64
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
@@ -68,9 +79,9 @@ export const DynamicTable = ({
|
|
|
68
79
|
);
|
|
69
80
|
|
|
70
81
|
const model = useTableModel({
|
|
71
|
-
table,
|
|
72
82
|
rows,
|
|
73
|
-
|
|
83
|
+
object: dynamicTable?.object,
|
|
84
|
+
projection: dynamicTable?.projection,
|
|
74
85
|
features,
|
|
75
86
|
rowActions,
|
|
76
87
|
onCellUpdate: handleCellUpdate,
|
|
@@ -80,22 +91,15 @@ export const DynamicTable = ({
|
|
|
80
91
|
|
|
81
92
|
const presentation = useMemo(() => {
|
|
82
93
|
if (model) {
|
|
83
|
-
return new TablePresentation(model);
|
|
94
|
+
return new TablePresentation(registry, model);
|
|
84
95
|
}
|
|
85
|
-
}, [model]);
|
|
96
|
+
}, [registry, model]);
|
|
86
97
|
|
|
87
|
-
// TODO(burdon): Do we need the outer divs?
|
|
88
98
|
return (
|
|
89
|
-
<div role='none' className={mx('
|
|
90
|
-
<div role='none' className='grid min-
|
|
91
|
-
<Table.Root>
|
|
92
|
-
<Table.
|
|
93
|
-
ref={tableRef}
|
|
94
|
-
model={model}
|
|
95
|
-
presentation={presentation}
|
|
96
|
-
ignoreAttention
|
|
97
|
-
onRowClick={onRowClick}
|
|
98
|
-
/>
|
|
99
|
+
<div role='none' className={mx('dx-expander grid', classNames)}>
|
|
100
|
+
<div role='none' className='grid min-h-0 overflow-hidden'>
|
|
101
|
+
<Table.Root ref={tableRef}>
|
|
102
|
+
<Table.Content model={model} presentation={presentation} ignoreAttention onRowClick={onRowClick} />
|
|
99
103
|
</Table.Root>
|
|
100
104
|
</div>
|
|
101
105
|
</div>
|