@dxos/react-ui-table 0.8.4-main.3c1ae3b → 0.8.4-main.3fbcb4aa9b
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-CJQ6T4LL.mjs → chunk-FBURZBPH.mjs} +19 -26
- package/dist/lib/browser/chunk-FBURZBPH.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-V7A7ZA5E.mjs → chunk-YGC7LZJN.mjs} +611 -699
- package/dist/lib/browser/chunk-YGC7LZJN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1105 -1032
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +23 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +36 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -1
- package/dist/lib/node-esm/{chunk-T6PXZQ6W.mjs → chunk-DKKMSVKP.mjs} +19 -26
- package/dist/lib/node-esm/chunk-DKKMSVKP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-P73ALX3N.mjs → chunk-GKIWDEZ7.mjs} +611 -698
- package/dist/lib/node-esm/chunk-GKIWDEZ7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1105 -1032
- 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 +23 -18
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +37 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +5 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -23
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +84 -84
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +20 -21
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +86 -86
- 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.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -4
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +23 -25
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.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 +22 -13
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +5 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +2 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +6 -5
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +18 -9
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +100 -18
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +3 -1
- 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.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +4 -5
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- 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 +13 -15
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +11 -8
- 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 -0
- 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.map +1 -1
- package/dist/types/src/util/signals.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 +20 -20
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +4 -4
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/tag.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -76
- package/src/components/Table/ColumnActionsMenu.tsx +13 -11
- package/src/components/Table/ColumnSettings.tsx +7 -7
- package/src/components/Table/DynamicTable.stories.tsx +24 -22
- package/src/components/Table/DynamicTable.tsx +28 -36
- package/src/components/Table/Relations.stories.tsx +95 -47
- package/src/components/Table/RowActionsMenu.tsx +6 -4
- package/src/components/Table/Table.stories.tsx +87 -64
- package/src/components/Table/Table.tsx +42 -419
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +44 -45
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -5
- package/src/components/TableCellEditor/FormCellEditor.tsx +61 -70
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +14 -13
- package/src/components/TableCellEditor/TableCellEditor.tsx +14 -12
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +42 -16
- package/src/hooks/useAddRow.ts +8 -10
- package/src/hooks/useProjectionModel.ts +29 -9
- package/src/hooks/useTableModel.ts +27 -23
- package/src/index.ts +0 -4
- package/src/model/modal-controller.ts +23 -12
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +81 -54
- package/src/model/table-model.ts +411 -139
- package/src/model/table-presentation.test.ts +58 -49
- package/src/model/table-presentation.ts +34 -29
- package/src/playwright/TableManager.ts +10 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +51 -7
- package/src/testing/useTestTableModel.ts +25 -22
- package/src/translations.ts +20 -22
- package/src/types/Table.ts +19 -30
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +36 -17
- package/src/util/index.ts +2 -0
- package/src/util/query-ast.ts +22 -0
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-CJQ6T4LL.mjs.map +0 -7
- package/dist/lib/browser/chunk-V7A7ZA5E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-P73ALX3N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T6PXZQ6W.mjs.map +0 -7
- 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 -56
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -234
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.3fbcb4aa9b",
|
|
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",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#translations": "./src/translations.ts"
|
|
17
|
+
},
|
|
11
18
|
"exports": {
|
|
12
|
-
"./deprecated": {
|
|
13
|
-
"source": "./src/deprecated/index.ts",
|
|
14
|
-
"types": "./dist/types/src/deprecated/index.d.ts",
|
|
15
|
-
"browser": "./dist/lib/browser/deprecated/index.mjs",
|
|
16
|
-
"node": "./dist/lib/node-esm/deprecated/index.mjs"
|
|
17
|
-
},
|
|
18
19
|
".": {
|
|
19
20
|
"source": "./src/index.ts",
|
|
20
21
|
"types": "./dist/types/src/index.d.ts",
|
|
@@ -27,6 +28,12 @@
|
|
|
27
28
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
28
29
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
29
30
|
},
|
|
31
|
+
"./translations": {
|
|
32
|
+
"source": "./src/translations.ts",
|
|
33
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
34
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
35
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
36
|
+
},
|
|
30
37
|
"./types": {
|
|
31
38
|
"source": "./src/types/index.ts",
|
|
32
39
|
"types": "./dist/types/src/types/index.d.ts",
|
|
@@ -35,19 +42,6 @@
|
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
44
|
"types": "dist/types/src/index.d.ts",
|
|
38
|
-
"typesVersions": {
|
|
39
|
-
"*": {
|
|
40
|
-
"deprecated": [
|
|
41
|
-
"dist/types/src/deprecated/index.d.ts"
|
|
42
|
-
],
|
|
43
|
-
"testing": [
|
|
44
|
-
"dist/types/src/testing/index.d.ts"
|
|
45
|
-
],
|
|
46
|
-
"types": [
|
|
47
|
-
"dist/types/src/types/index.d.ts"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
45
|
"files": [
|
|
52
46
|
"dist",
|
|
53
47
|
"src"
|
|
@@ -55,72 +49,68 @@
|
|
|
55
49
|
"dependencies": {
|
|
56
50
|
"@codemirror/autocomplete": "^6.19.0",
|
|
57
51
|
"@codemirror/state": "^6.5.2",
|
|
58
|
-
"@codemirror/view": "^6.38.
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@preact/signals-core": "^1.12.1",
|
|
52
|
+
"@codemirror/view": "^6.38.5",
|
|
53
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
54
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
62
55
|
"@radix-ui/react-context": "1.1.1",
|
|
63
56
|
"@radix-ui/react-primitive": "2.0.2",
|
|
64
57
|
"@radix-ui/react-slot": "1.1.2",
|
|
65
58
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
66
|
-
"date-fns": "^3.
|
|
59
|
+
"date-fns": "^3.6.0",
|
|
67
60
|
"lodash.orderby": "^4.6.0",
|
|
68
|
-
"@dxos/async": "0.8.4-main.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/debug": "0.8.4-main.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/echo
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/keys": "0.8.4-main.
|
|
76
|
-
"@dxos/lit-grid": "0.8.4-main.
|
|
77
|
-
"@dxos/log": "0.8.4-main.
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/react-
|
|
82
|
-
"@dxos/react-ui-
|
|
83
|
-
"@dxos/react-ui-
|
|
84
|
-
"@dxos/react-ui-
|
|
85
|
-
"@dxos/react-ui-
|
|
86
|
-
"@dxos/react-ui-
|
|
87
|
-
"@dxos/react-ui-
|
|
88
|
-
"@dxos/react-ui-
|
|
89
|
-
"@dxos/react-ui-
|
|
90
|
-
"@dxos/
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/types": "0.8.4-main.
|
|
94
|
-
"@dxos/util": "0.8.4-main.3c1ae3b"
|
|
61
|
+
"@dxos/async": "0.8.4-main.3fbcb4aa9b",
|
|
62
|
+
"@dxos/effect": "0.8.4-main.3fbcb4aa9b",
|
|
63
|
+
"@dxos/debug": "0.8.4-main.3fbcb4aa9b",
|
|
64
|
+
"@dxos/invariant": "0.8.4-main.3fbcb4aa9b",
|
|
65
|
+
"@dxos/echo": "0.8.4-main.3fbcb4aa9b",
|
|
66
|
+
"@dxos/echo-atom": "0.8.4-main.3fbcb4aa9b",
|
|
67
|
+
"@dxos/context": "0.8.4-main.3fbcb4aa9b",
|
|
68
|
+
"@dxos/keys": "0.8.4-main.3fbcb4aa9b",
|
|
69
|
+
"@dxos/lit-grid": "0.8.4-main.3fbcb4aa9b",
|
|
70
|
+
"@dxos/log": "0.8.4-main.3fbcb4aa9b",
|
|
71
|
+
"@dxos/random": "0.8.4-main.3fbcb4aa9b",
|
|
72
|
+
"@dxos/react-client": "0.8.4-main.3fbcb4aa9b",
|
|
73
|
+
"@dxos/react-ui-attention": "0.8.4-main.3fbcb4aa9b",
|
|
74
|
+
"@dxos/react-ui-components": "0.8.4-main.3fbcb4aa9b",
|
|
75
|
+
"@dxos/react-ui-editor": "0.8.4-main.3fbcb4aa9b",
|
|
76
|
+
"@dxos/react-ui-form": "0.8.4-main.3fbcb4aa9b",
|
|
77
|
+
"@dxos/react-ui-grid": "0.8.4-main.3fbcb4aa9b",
|
|
78
|
+
"@dxos/react-ui-list": "0.8.4-main.3fbcb4aa9b",
|
|
79
|
+
"@dxos/react-ui-stack": "0.8.4-main.3fbcb4aa9b",
|
|
80
|
+
"@dxos/react-ui-search": "0.8.4-main.3fbcb4aa9b",
|
|
81
|
+
"@dxos/react-ui-menu": "0.8.4-main.3fbcb4aa9b",
|
|
82
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.3fbcb4aa9b",
|
|
83
|
+
"@dxos/schema": "0.8.4-main.3fbcb4aa9b",
|
|
84
|
+
"@dxos/types": "0.8.4-main.3fbcb4aa9b",
|
|
85
|
+
"@dxos/util": "0.8.4-main.3fbcb4aa9b",
|
|
86
|
+
"@dxos/ui-types": "0.8.4-main.3fbcb4aa9b"
|
|
95
87
|
},
|
|
96
88
|
"devDependencies": {
|
|
97
|
-
"@effect
|
|
98
|
-
"@effect/platform": "0.92.1",
|
|
89
|
+
"@effect/platform": "0.94.4",
|
|
99
90
|
"@types/lodash.orderby": "^4.6.9",
|
|
100
|
-
"@types/react": "~19.2.
|
|
101
|
-
"@types/react-dom": "~19.2.
|
|
102
|
-
"effect": "3.
|
|
91
|
+
"@types/react": "~19.2.7",
|
|
92
|
+
"@types/react-dom": "~19.2.3",
|
|
93
|
+
"effect": "3.20.0",
|
|
103
94
|
"fast-check": "^3.19.0",
|
|
104
|
-
"react": "~19.2.
|
|
105
|
-
"react-dom": "~19.2.
|
|
106
|
-
"vite": "
|
|
107
|
-
"@dxos/
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/
|
|
110
|
-
"@dxos/
|
|
111
|
-
"@dxos/
|
|
112
|
-
"@dxos/
|
|
113
|
-
"@dxos/
|
|
114
|
-
"@dxos/test-utils": "0.8.4-main.3c1ae3b"
|
|
95
|
+
"react": "~19.2.3",
|
|
96
|
+
"react-dom": "~19.2.3",
|
|
97
|
+
"vite": "^8.0.10",
|
|
98
|
+
"@dxos/random": "0.8.4-main.3fbcb4aa9b",
|
|
99
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
100
|
+
"@dxos/react-client": "0.8.4-main.3fbcb4aa9b",
|
|
101
|
+
"@dxos/storybook-utils": "0.8.4-main.3fbcb4aa9b",
|
|
102
|
+
"@dxos/test-utils": "0.8.4-main.3fbcb4aa9b",
|
|
103
|
+
"@dxos/lit-ui": "0.8.4-main.3fbcb4aa9b",
|
|
104
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
|
|
115
105
|
},
|
|
116
106
|
"peerDependencies": {
|
|
117
|
-
"@effect-atom/atom-react": "^0.
|
|
118
|
-
"@effect/platform": "
|
|
119
|
-
"effect": "
|
|
120
|
-
"react": "
|
|
121
|
-
"react-dom": "
|
|
122
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
123
|
-
"@dxos/
|
|
107
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
108
|
+
"@effect/platform": "0.94.4",
|
|
109
|
+
"effect": "3.20.0",
|
|
110
|
+
"react": "~19.2.3",
|
|
111
|
+
"react-dom": "~19.2.3",
|
|
112
|
+
"@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
|
|
113
|
+
"@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
|
|
124
114
|
},
|
|
125
115
|
"publishConfig": {
|
|
126
116
|
"access": "public"
|
|
@@ -2,12 +2,14 @@
|
|
|
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
|
|
|
10
|
+
import { translationKey } from '#translations';
|
|
11
|
+
|
|
9
12
|
import { type ModalController, type TableModel } from '../../model';
|
|
10
|
-
import { translationKey } from '../../translations';
|
|
11
13
|
|
|
12
14
|
export type ColumnActionsMenuProps = {
|
|
13
15
|
model: TableModel;
|
|
@@ -16,12 +18,12 @@ export type ColumnActionsMenuProps = {
|
|
|
16
18
|
|
|
17
19
|
export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) => {
|
|
18
20
|
const { t } = useTranslation(translationKey);
|
|
19
|
-
const state = modals.state
|
|
21
|
+
const state = useAtomValue(modals.state);
|
|
20
22
|
if (state?.type !== 'column') {
|
|
21
23
|
return null;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
const currentSort = model.
|
|
26
|
+
const currentSort = model.getSorting();
|
|
25
27
|
const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
|
|
26
28
|
|
|
27
29
|
return (
|
|
@@ -33,32 +35,32 @@ export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) =>
|
|
|
33
35
|
{(!isCurrentColumnSorted || currentSort?.direction === 'asc') && (
|
|
34
36
|
<DropdownMenu.Item
|
|
35
37
|
data-testid='column-sort-descending'
|
|
36
|
-
onClick={() => model.
|
|
38
|
+
onClick={() => model.setSort(state.fieldId, 'desc')}
|
|
37
39
|
>
|
|
38
|
-
{t('column
|
|
40
|
+
{t('column-action-sort-descending.menu')}
|
|
39
41
|
</DropdownMenu.Item>
|
|
40
42
|
)}
|
|
41
43
|
{(!isCurrentColumnSorted || currentSort?.direction === 'desc') && (
|
|
42
44
|
<DropdownMenu.Item
|
|
43
45
|
data-testid='column-sort-ascending'
|
|
44
|
-
onClick={() => model.
|
|
46
|
+
onClick={() => model.setSort(state.fieldId, 'asc')}
|
|
45
47
|
>
|
|
46
|
-
{t('column
|
|
48
|
+
{t('column-action-sort-ascending.menu')}
|
|
47
49
|
</DropdownMenu.Item>
|
|
48
50
|
)}
|
|
49
51
|
{isCurrentColumnSorted && (
|
|
50
|
-
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.
|
|
51
|
-
{t('column
|
|
52
|
+
<DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.clearSort()}>
|
|
53
|
+
{t('column-action-clear-sorting.menu')}
|
|
52
54
|
</DropdownMenu.Item>
|
|
53
55
|
)}
|
|
54
56
|
{model.getColumnCount() > 1 && model.features.schemaEditable && (
|
|
55
57
|
<DropdownMenu.Item data-testid='column-delete' onClick={() => model.deleteColumn(state.fieldId)}>
|
|
56
|
-
{t('column
|
|
58
|
+
{t('column-action-delete.menu')}
|
|
57
59
|
</DropdownMenu.Item>
|
|
58
60
|
)}
|
|
59
61
|
{model.features.schemaEditable && (
|
|
60
62
|
<DropdownMenu.Item data-testid='column-settings' onClick={() => modals.openColumnSettings()}>
|
|
61
|
-
{t('column
|
|
63
|
+
{t('column-action-settings.menu')}
|
|
62
64
|
</DropdownMenu.Item>
|
|
63
65
|
)}
|
|
64
66
|
</DropdownMenu.Viewport>
|
|
@@ -2,12 +2,12 @@
|
|
|
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
|
|
|
7
|
-
import { type SchemaRegistry } from '@dxos/echo';
|
|
8
|
+
import { type SchemaRegistry, type View } from '@dxos/echo';
|
|
8
9
|
import { Popover } from '@dxos/react-ui';
|
|
9
10
|
import { FieldEditor } from '@dxos/react-ui-form';
|
|
10
|
-
import { type FieldType } from '@dxos/schema';
|
|
11
11
|
|
|
12
12
|
import { type ModalController, type TableModel } from '../../model';
|
|
13
13
|
|
|
@@ -19,8 +19,8 @@ type ColumnSettingsProps = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnSettingsProps) => {
|
|
22
|
-
const [newField, setNewField] = useState<FieldType>();
|
|
23
|
-
const state = modals.state
|
|
22
|
+
const [newField, setNewField] = useState<View.FieldType>();
|
|
23
|
+
const state = useAtomValue(modals.state);
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
if (state?.type === 'columnSettings' && state.mode.type === 'create' && model?.projection) {
|
|
@@ -37,11 +37,11 @@ export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnS
|
|
|
37
37
|
if (state?.type === 'columnSettings') {
|
|
38
38
|
const { mode } = state;
|
|
39
39
|
if (mode.type === 'edit') {
|
|
40
|
-
return model?.projection?.
|
|
40
|
+
return model?.projection?.getFields().find((f) => f.id === mode.fieldId);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return undefined;
|
|
44
|
-
}, [model?.projection
|
|
44
|
+
}, [model?.projection, state]);
|
|
45
45
|
|
|
46
46
|
const field = existingField ?? newField;
|
|
47
47
|
|
|
@@ -63,7 +63,7 @@ export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnS
|
|
|
63
63
|
<Popover.Root modal={false} open={state?.type === 'columnSettings'}>
|
|
64
64
|
<Popover.VirtualTrigger virtualRef={modals.trigger} />
|
|
65
65
|
<Popover.Portal>
|
|
66
|
-
<Popover.Content classNames='md:
|
|
66
|
+
<Popover.Content classNames='md:w-64'>
|
|
67
67
|
<Popover.Viewport>
|
|
68
68
|
<FieldEditor
|
|
69
69
|
projection={model.projection}
|
|
@@ -3,23 +3,25 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import type * as Types from 'effect/Types';
|
|
6
7
|
import React, { useMemo, useState } from 'react';
|
|
7
8
|
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { Format
|
|
10
|
-
import {
|
|
9
|
+
import { type JsonSchema, Obj } from '@dxos/echo';
|
|
10
|
+
import { Format } from '@dxos/echo/internal';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
11
12
|
import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
|
|
12
|
-
import {
|
|
13
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
14
15
|
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
15
16
|
import { TestSchema } from '@dxos/schema/testing';
|
|
17
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
16
18
|
|
|
17
|
-
import {
|
|
18
|
-
import { translations } from '../../translations';
|
|
19
|
+
import { translations } from '#translations';
|
|
19
20
|
|
|
21
|
+
import { type TableFeatures } from '../../model';
|
|
20
22
|
import { DynamicTable } from './DynamicTable';
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
random.seed(0);
|
|
23
25
|
|
|
24
26
|
const useTestPropertiesAndObjects = () => {
|
|
25
27
|
const properties = useMemo<SchemaPropertyDefinition[]>(
|
|
@@ -32,9 +34,9 @@ const useTestPropertiesAndObjects = () => {
|
|
|
32
34
|
|
|
33
35
|
const [rows] = useState<any[]>(
|
|
34
36
|
Array.from({ length: 10 }, () => ({
|
|
35
|
-
id:
|
|
36
|
-
name:
|
|
37
|
-
age:
|
|
37
|
+
id: random.string.uuid(),
|
|
38
|
+
name: random.person.fullName(),
|
|
39
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
38
40
|
})),
|
|
39
41
|
);
|
|
40
42
|
|
|
@@ -57,7 +59,7 @@ const DynamicTableStory = () => {
|
|
|
57
59
|
const meta = {
|
|
58
60
|
title: 'ui/react-ui-table/DynamicTable',
|
|
59
61
|
component: DynamicTable,
|
|
60
|
-
decorators: [withTheme],
|
|
62
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
|
|
61
63
|
parameters: {
|
|
62
64
|
layout: 'fullscreen',
|
|
63
65
|
translations,
|
|
@@ -100,7 +102,7 @@ export const WithClickToSelect: StoryObj = {
|
|
|
100
102
|
|
|
101
103
|
export const WithJsonSchema: StoryObj = {
|
|
102
104
|
render: () => {
|
|
103
|
-
const schema = useMemo<
|
|
105
|
+
const schema = useMemo<Types.DeepMutable<JsonSchema.JsonSchema>>(
|
|
104
106
|
() => ({
|
|
105
107
|
type: 'object',
|
|
106
108
|
properties: {
|
|
@@ -116,10 +118,10 @@ export const WithJsonSchema: StoryObj = {
|
|
|
116
118
|
|
|
117
119
|
const [rows] = useState<any[]>(
|
|
118
120
|
Array.from({ length: 15 }, () => ({
|
|
119
|
-
name:
|
|
120
|
-
age:
|
|
121
|
-
email:
|
|
122
|
-
active:
|
|
121
|
+
name: random.person.fullName(),
|
|
122
|
+
age: random.number.int({ min: 18, max: 80 }),
|
|
123
|
+
email: random.internet.email(),
|
|
124
|
+
active: random.datatype.boolean(),
|
|
123
125
|
})),
|
|
124
126
|
);
|
|
125
127
|
|
|
@@ -129,9 +131,9 @@ export const WithJsonSchema: StoryObj = {
|
|
|
129
131
|
|
|
130
132
|
export const WithEchoSchema: StoryObj = {
|
|
131
133
|
render: () => {
|
|
132
|
-
const { space } =
|
|
133
|
-
const schema = useSchema(space, TestSchema.Person.typename);
|
|
134
|
-
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());
|
|
135
137
|
if (!schema) {
|
|
136
138
|
return <div>Loading schema...</div>;
|
|
137
139
|
}
|
|
@@ -147,8 +149,8 @@ export const WithEchoSchema: StoryObj = {
|
|
|
147
149
|
Array.from({ length: 10 }).forEach(() => {
|
|
148
150
|
space.db.add(
|
|
149
151
|
Obj.make(TestSchema.Person, {
|
|
150
|
-
name:
|
|
151
|
-
email:
|
|
152
|
+
name: random.person.fullName(),
|
|
153
|
+
email: random.internet.email(),
|
|
152
154
|
}),
|
|
153
155
|
);
|
|
154
156
|
});
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
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';
|
|
6
8
|
|
|
7
9
|
import { type Type } from '@dxos/echo';
|
|
8
|
-
import { type
|
|
10
|
+
import { type JsonSchema } from '@dxos/echo';
|
|
9
11
|
import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
13
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
14
|
|
|
13
15
|
import { useTableModel } from '../../hooks';
|
|
14
16
|
import { type TableFeatures, TablePresentation, type TableRowAction } from '../../model';
|
|
17
|
+
import { type Table as TableType } from '../../types';
|
|
15
18
|
import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '../../util';
|
|
16
|
-
|
|
17
19
|
import { Table, type TableController } from './Table';
|
|
18
20
|
|
|
19
|
-
export type DynamicTableProps<T extends Type.
|
|
21
|
+
export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = ThemedClassName<{
|
|
20
22
|
schema?: T;
|
|
21
23
|
name?: string; // TODO(burdon): Remove?
|
|
22
24
|
rows: any[];
|
|
23
25
|
properties?: TablePropertyDefinition[];
|
|
24
|
-
jsonSchema?:
|
|
26
|
+
jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
|
|
25
27
|
features?: Partial<TableFeatures>;
|
|
26
28
|
rowActions?: TableRowAction[];
|
|
27
29
|
onRowClick?: (row: any) => void;
|
|
@@ -33,25 +35,30 @@ export type DynamicTableProps<T extends Type.Entity.Any = Type.Entity.Any> = The
|
|
|
33
35
|
*/
|
|
34
36
|
// TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
|
|
35
37
|
// TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
|
|
36
|
-
export const DynamicTable = <T extends Type.
|
|
38
|
+
export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
|
|
37
39
|
classNames,
|
|
38
40
|
schema,
|
|
39
|
-
name = 'example.
|
|
41
|
+
name = 'com.example.dynamicTable', // Remove default or make random; this will lead to type collisions.
|
|
40
42
|
rows,
|
|
41
43
|
properties,
|
|
42
|
-
jsonSchema:
|
|
44
|
+
jsonSchema: jsonSchemaProp,
|
|
43
45
|
rowActions,
|
|
44
46
|
onRowClick,
|
|
45
47
|
onRowAction,
|
|
46
48
|
...props
|
|
47
49
|
}: DynamicTableProps<T>) => {
|
|
50
|
+
const registry = useContext(RegistryContext);
|
|
51
|
+
const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
|
|
52
|
+
|
|
48
53
|
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
49
54
|
const { jsonSchema } = useMemo(
|
|
50
|
-
() => getBaseSchema({ typename: name, properties, jsonSchema:
|
|
51
|
-
[name, properties,
|
|
55
|
+
() => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp, schema }),
|
|
56
|
+
[name, properties, jsonSchemaProp, schema],
|
|
52
57
|
);
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
|
|
61
|
+
}, [registry, jsonSchema, properties]);
|
|
55
62
|
|
|
56
63
|
const tableRef = useRef<TableController>(null);
|
|
57
64
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
@@ -71,18 +78,10 @@ export const DynamicTable = <T extends Type.Entity.Any = Type.Entity.Any>({
|
|
|
71
78
|
}) as const,
|
|
72
79
|
);
|
|
73
80
|
|
|
74
|
-
const projectionModel = useMemo(() => {
|
|
75
|
-
if (jsonSchema && projection) {
|
|
76
|
-
const model = new ProjectionModel(jsonSchema, projection);
|
|
77
|
-
model.normalizeView();
|
|
78
|
-
return model;
|
|
79
|
-
}
|
|
80
|
-
}, [jsonSchema, projection]);
|
|
81
|
-
|
|
82
81
|
const model = useTableModel({
|
|
83
82
|
rows,
|
|
84
|
-
object,
|
|
85
|
-
projection:
|
|
83
|
+
object: dynamicTable?.object,
|
|
84
|
+
projection: dynamicTable?.projection,
|
|
86
85
|
features,
|
|
87
86
|
rowActions,
|
|
88
87
|
onCellUpdate: handleCellUpdate,
|
|
@@ -92,22 +91,15 @@ export const DynamicTable = <T extends Type.Entity.Any = Type.Entity.Any>({
|
|
|
92
91
|
|
|
93
92
|
const presentation = useMemo(() => {
|
|
94
93
|
if (model) {
|
|
95
|
-
return new TablePresentation(model);
|
|
94
|
+
return new TablePresentation(registry, model);
|
|
96
95
|
}
|
|
97
|
-
}, [model]);
|
|
96
|
+
}, [registry, model]);
|
|
98
97
|
|
|
99
|
-
// TODO(burdon): Do we need the outer divs?
|
|
100
98
|
return (
|
|
101
|
-
<div
|
|
102
|
-
<div
|
|
103
|
-
<Table.Root>
|
|
104
|
-
<Table.
|
|
105
|
-
ref={tableRef}
|
|
106
|
-
model={model}
|
|
107
|
-
presentation={presentation}
|
|
108
|
-
ignoreAttention
|
|
109
|
-
onRowClick={onRowClick}
|
|
110
|
-
/>
|
|
99
|
+
<div className={mx('dx-expander grid', classNames)}>
|
|
100
|
+
<div className='grid min-h-0 overflow-hidden'>
|
|
101
|
+
<Table.Root ref={tableRef}>
|
|
102
|
+
<Table.Content model={model} presentation={presentation} ignoreAttention onRowClick={onRowClick} />
|
|
111
103
|
</Table.Root>
|
|
112
104
|
</div>
|
|
113
105
|
</div>
|