@dxos/react-ui-table 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/dist/lib/browser/{chunk-F7Y374KL.mjs → chunk-4KOQTPFC.mjs} +62 -111
- package/dist/lib/browser/chunk-4KOQTPFC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-62PYOJPY.mjs} +13 -16
- package/dist/lib/browser/chunk-62PYOJPY.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/index.mjs +57 -131
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +9 -8
- 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-SIRDIPHZ.mjs → chunk-7LMOZUTS.mjs} +13 -16
- package/dist/lib/node-esm/chunk-7LMOZUTS.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/{chunk-CCJ4LOVM.mjs → chunk-KOSV2J5N.mjs} +62 -111
- package/dist/lib/node-esm/chunk-KOSV2J5N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +57 -131
- 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 +9 -8
- 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 +2 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -20
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +87 -81
- 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 +2 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +88 -81
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +2 -1
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +1 -2
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +19 -19
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +7 -7
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -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 +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +19 -19
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +12 -6
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +6 -6
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts.map +1 -1
- 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.map +1 -1
- 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 +53 -63
- package/src/components/Table/ColumnActionsMenu.tsx +2 -1
- package/src/components/Table/ColumnSettings.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +9 -8
- package/src/components/Table/DynamicTable.tsx +11 -12
- package/src/components/Table/Relations.stories.tsx +46 -9
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +86 -33
- package/src/components/Table/TableContent.tsx +9 -4
- package/src/components/Table/TableToolbar.tsx +2 -2
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +8 -7
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +7 -4
- package/src/components/TableCellEditor/TableCellEditor.tsx +8 -6
- package/src/components/testing.ts +7 -12
- package/src/hooks/useProjectionModel.ts +5 -6
- package/src/hooks/useTableModel.ts +1 -1
- package/src/index.ts +0 -4
- package/src/model/table-model.test.ts +4 -9
- package/src/model/table-model.ts +43 -36
- package/src/model/table-presentation.test.ts +4 -9
- package/src/model/table-presentation.ts +15 -15
- package/src/testing/useTestTableModel.ts +6 -7
- package/src/types/Table.ts +16 -15
- package/src/util/dynamic-table.test.ts +13 -20
- package/src/util/dynamic-table.ts +19 -18
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.4-
|
|
3
|
+
"version": "0.8.4-staging.60fe92afc8",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -8,17 +8,14 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#translations": "./src/translations.ts"
|
|
17
|
+
},
|
|
15
18
|
"exports": {
|
|
16
|
-
"./deprecated": {
|
|
17
|
-
"source": "./src/deprecated/index.ts",
|
|
18
|
-
"types": "./dist/types/src/deprecated/index.d.ts",
|
|
19
|
-
"browser": "./dist/lib/browser/deprecated/index.mjs",
|
|
20
|
-
"node": "./dist/lib/node-esm/deprecated/index.mjs"
|
|
21
|
-
},
|
|
22
19
|
".": {
|
|
23
20
|
"source": "./src/index.ts",
|
|
24
21
|
"types": "./dist/types/src/index.d.ts",
|
|
@@ -31,6 +28,12 @@
|
|
|
31
28
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
32
29
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
33
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
|
+
},
|
|
34
37
|
"./types": {
|
|
35
38
|
"source": "./src/types/index.ts",
|
|
36
39
|
"types": "./dist/types/src/types/index.d.ts",
|
|
@@ -39,27 +42,14 @@
|
|
|
39
42
|
}
|
|
40
43
|
},
|
|
41
44
|
"types": "dist/types/src/index.d.ts",
|
|
42
|
-
"typesVersions": {
|
|
43
|
-
"*": {
|
|
44
|
-
"deprecated": [
|
|
45
|
-
"dist/types/src/deprecated/index.d.ts"
|
|
46
|
-
],
|
|
47
|
-
"testing": [
|
|
48
|
-
"dist/types/src/testing/index.d.ts"
|
|
49
|
-
],
|
|
50
|
-
"types": [
|
|
51
|
-
"dist/types/src/types/index.d.ts"
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
45
|
"files": [
|
|
56
46
|
"dist",
|
|
57
47
|
"src"
|
|
58
48
|
],
|
|
59
49
|
"dependencies": {
|
|
60
|
-
"@codemirror/autocomplete": "^6.
|
|
61
|
-
"@codemirror/state": "^6.
|
|
62
|
-
"@codemirror/view": "^6.
|
|
50
|
+
"@codemirror/autocomplete": "^6.20.2",
|
|
51
|
+
"@codemirror/state": "^6.6.0",
|
|
52
|
+
"@codemirror/view": "^6.43.0",
|
|
63
53
|
"@effect-atom/atom-react": "^0.5.0",
|
|
64
54
|
"@fluentui/react-tabster": "9.26.11",
|
|
65
55
|
"@radix-ui/react-context": "1.1.1",
|
|
@@ -68,58 +58,58 @@
|
|
|
68
58
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
69
59
|
"date-fns": "^3.6.0",
|
|
70
60
|
"lodash.orderby": "^4.6.0",
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/debug": "0.8.4-
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/react-
|
|
83
|
-
"@dxos/react-ui-
|
|
84
|
-
"@dxos/react-ui-components": "0.8.4-
|
|
85
|
-
"@dxos/react-ui-
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/react-ui-
|
|
88
|
-
"@dxos/react-ui-
|
|
89
|
-
"@dxos/react-ui-
|
|
90
|
-
"@dxos/react-ui-
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
61
|
+
"@dxos/async": "0.8.4-staging.60fe92afc8",
|
|
62
|
+
"@dxos/context": "0.8.4-staging.60fe92afc8",
|
|
63
|
+
"@dxos/echo": "0.8.4-staging.60fe92afc8",
|
|
64
|
+
"@dxos/debug": "0.8.4-staging.60fe92afc8",
|
|
65
|
+
"@dxos/invariant": "0.8.4-staging.60fe92afc8",
|
|
66
|
+
"@dxos/effect": "0.8.4-staging.60fe92afc8",
|
|
67
|
+
"@dxos/keys": "0.8.4-staging.60fe92afc8",
|
|
68
|
+
"@dxos/random": "0.8.4-staging.60fe92afc8",
|
|
69
|
+
"@dxos/react-client": "0.8.4-staging.60fe92afc8",
|
|
70
|
+
"@dxos/log": "0.8.4-staging.60fe92afc8",
|
|
71
|
+
"@dxos/react-ui-attention": "0.8.4-staging.60fe92afc8",
|
|
72
|
+
"@dxos/react-ui-editor": "0.8.4-staging.60fe92afc8",
|
|
73
|
+
"@dxos/react-ui-form": "0.8.4-staging.60fe92afc8",
|
|
74
|
+
"@dxos/react-ui-components": "0.8.4-staging.60fe92afc8",
|
|
75
|
+
"@dxos/react-ui-list": "0.8.4-staging.60fe92afc8",
|
|
76
|
+
"@dxos/lit-grid": "0.8.4-staging.60fe92afc8",
|
|
77
|
+
"@dxos/react-ui-grid": "0.8.4-staging.60fe92afc8",
|
|
78
|
+
"@dxos/react-ui-search": "0.8.4-staging.60fe92afc8",
|
|
79
|
+
"@dxos/react-ui-menu": "0.8.4-staging.60fe92afc8",
|
|
80
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-staging.60fe92afc8",
|
|
81
|
+
"@dxos/types": "0.8.4-staging.60fe92afc8",
|
|
82
|
+
"@dxos/schema": "0.8.4-staging.60fe92afc8",
|
|
83
|
+
"@dxos/ui-types": "0.8.4-staging.60fe92afc8",
|
|
84
|
+
"@dxos/util": "0.8.4-staging.60fe92afc8",
|
|
85
|
+
"@dxos/react-ui-stack": "0.8.4-staging.60fe92afc8"
|
|
96
86
|
},
|
|
97
87
|
"devDependencies": {
|
|
98
|
-
"@effect/platform": "0.
|
|
88
|
+
"@effect/platform": "0.96.1",
|
|
99
89
|
"@types/lodash.orderby": "^4.6.9",
|
|
100
90
|
"@types/react": "~19.2.7",
|
|
101
91
|
"@types/react-dom": "~19.2.3",
|
|
102
|
-
"effect": "3.
|
|
92
|
+
"effect": "3.21.3",
|
|
103
93
|
"fast-check": "^3.19.0",
|
|
104
94
|
"react": "~19.2.3",
|
|
105
95
|
"react-dom": "~19.2.3",
|
|
106
|
-
"vite": "^
|
|
107
|
-
"@dxos/lit-ui": "0.8.4-
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/
|
|
110
|
-
"@dxos/react-ui": "0.8.4-
|
|
111
|
-
"@dxos/storybook-utils": "0.8.4-
|
|
112
|
-
"@dxos/ui-theme": "0.8.4-
|
|
113
|
-
"@dxos/test-utils": "0.8.4-
|
|
96
|
+
"vite": "^8.0.16",
|
|
97
|
+
"@dxos/lit-ui": "0.8.4-staging.60fe92afc8",
|
|
98
|
+
"@dxos/random": "0.8.4-staging.60fe92afc8",
|
|
99
|
+
"@dxos/react-client": "0.8.4-staging.60fe92afc8",
|
|
100
|
+
"@dxos/react-ui": "0.8.4-staging.60fe92afc8",
|
|
101
|
+
"@dxos/storybook-utils": "0.8.4-staging.60fe92afc8",
|
|
102
|
+
"@dxos/ui-theme": "0.8.4-staging.60fe92afc8",
|
|
103
|
+
"@dxos/test-utils": "0.8.4-staging.60fe92afc8"
|
|
114
104
|
},
|
|
115
105
|
"peerDependencies": {
|
|
116
106
|
"@effect-atom/atom-react": "^0.5.0",
|
|
117
|
-
"@effect/platform": "0.
|
|
118
|
-
"effect": "3.
|
|
107
|
+
"@effect/platform": "0.96.1",
|
|
108
|
+
"effect": "3.21.3",
|
|
119
109
|
"react": "~19.2.3",
|
|
120
110
|
"react-dom": "~19.2.3",
|
|
121
|
-
"@dxos/react-ui": "0.8.4-
|
|
122
|
-
"@dxos/ui-theme": "0.8.4-
|
|
111
|
+
"@dxos/react-ui": "0.8.4-staging.60fe92afc8",
|
|
112
|
+
"@dxos/ui-theme": "0.8.4-staging.60fe92afc8"
|
|
123
113
|
},
|
|
124
114
|
"publishConfig": {
|
|
125
115
|
"access": "public"
|
|
@@ -7,8 +7,9 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { DropdownMenu, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
+
import { translationKey } from '#translations';
|
|
11
|
+
|
|
10
12
|
import { type ModalController, type TableModel } from '../../model';
|
|
11
|
-
import { translationKey } from '../../translations';
|
|
12
13
|
|
|
13
14
|
export type ColumnActionsMenuProps = {
|
|
14
15
|
model: TableModel;
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { useAtomValue } from '@effect-atom/atom-react';
|
|
6
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type Registry, type View } from '@dxos/echo';
|
|
9
9
|
import { Popover } from '@dxos/react-ui';
|
|
10
10
|
import { FieldEditor } from '@dxos/react-ui-form';
|
|
11
11
|
|
|
12
12
|
import { type ModalController, type TableModel } from '../../model';
|
|
13
13
|
|
|
14
14
|
type ColumnSettingsProps = {
|
|
15
|
-
registry?:
|
|
15
|
+
registry?: Registry.Registry;
|
|
16
16
|
model?: TableModel;
|
|
17
17
|
modals: ModalController;
|
|
18
18
|
onNewColumn: () => void;
|
|
@@ -6,18 +6,19 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import type * as Types from 'effect/Types';
|
|
7
7
|
import React, { useMemo, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import { type JsonSchema, Obj } from '@dxos/echo';
|
|
10
|
-
import { Format } from '@dxos/echo/
|
|
9
|
+
import { Filter, type JsonSchema, Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { Format } from '@dxos/echo/Format';
|
|
11
11
|
import { random } from '@dxos/random';
|
|
12
|
-
import {
|
|
12
|
+
import { useQuery, useType } from '@dxos/react-client/echo';
|
|
13
13
|
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
15
|
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
16
16
|
import { TestSchema } from '@dxos/schema/testing';
|
|
17
17
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
18
18
|
|
|
19
|
+
import { translations } from '#translations';
|
|
20
|
+
|
|
19
21
|
import { type TableFeatures } from '../../model';
|
|
20
|
-
import { translations } from '../../translations';
|
|
21
22
|
import { DynamicTable } from './DynamicTable';
|
|
22
23
|
|
|
23
24
|
random.seed(0);
|
|
@@ -131,13 +132,13 @@ export const WithJsonSchema: StoryObj = {
|
|
|
131
132
|
export const WithEchoSchema: StoryObj = {
|
|
132
133
|
render: () => {
|
|
133
134
|
const { space } = useClientStory();
|
|
134
|
-
const
|
|
135
|
-
const objects = useQuery(space?.db,
|
|
136
|
-
if (!
|
|
135
|
+
const type = useType(space?.db, Type.getURI(TestSchema.Person));
|
|
136
|
+
const objects = useQuery(space?.db, type ? Filter.type(type) : Filter.nothing());
|
|
137
|
+
if (!type) {
|
|
137
138
|
return <div>Loading schema...</div>;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
return <DynamicTable
|
|
141
|
+
return <DynamicTable type={type} rows={objects} />;
|
|
141
142
|
},
|
|
142
143
|
decorators: [
|
|
143
144
|
withClientProvider({
|
|
@@ -6,8 +6,7 @@ import { RegistryContext } from '@effect-atom/atom-react';
|
|
|
6
6
|
import type * as Types from 'effect/Types';
|
|
7
7
|
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import { type Type } from '@dxos/echo';
|
|
10
|
-
import { type JsonSchema } from '@dxos/echo';
|
|
9
|
+
import { type JsonSchema, type Type } from '@dxos/echo';
|
|
11
10
|
import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
|
|
12
11
|
import { type ProjectionModel } from '@dxos/schema';
|
|
13
12
|
import { mx } from '@dxos/ui-theme';
|
|
@@ -19,7 +18,7 @@ import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '.
|
|
|
19
18
|
import { Table, type TableController } from './Table';
|
|
20
19
|
|
|
21
20
|
export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = ThemedClassName<{
|
|
22
|
-
|
|
21
|
+
type?: T;
|
|
23
22
|
name?: string; // TODO(burdon): Remove?
|
|
24
23
|
rows: any[];
|
|
25
24
|
properties?: TablePropertyDefinition[];
|
|
@@ -37,8 +36,8 @@ export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = Theme
|
|
|
37
36
|
// TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
|
|
38
37
|
export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
|
|
39
38
|
classNames,
|
|
40
|
-
|
|
41
|
-
name = 'com.example.
|
|
39
|
+
type: typeProp,
|
|
40
|
+
name = 'com.example.dynamicTable', // Remove default or make random; this will lead to type collisions.
|
|
42
41
|
rows,
|
|
43
42
|
properties,
|
|
44
43
|
jsonSchema: jsonSchemaProp,
|
|
@@ -51,14 +50,14 @@ export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
|
|
|
51
50
|
const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
|
|
52
51
|
|
|
53
52
|
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
54
|
-
const {
|
|
55
|
-
() => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp,
|
|
56
|
-
[name, properties, jsonSchemaProp,
|
|
53
|
+
const { type } = useMemo(
|
|
54
|
+
() => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp, type: typeProp }),
|
|
55
|
+
[name, properties, jsonSchemaProp, typeProp],
|
|
57
56
|
);
|
|
58
57
|
|
|
59
58
|
useEffect(() => {
|
|
60
|
-
setDynamicTable(makeDynamicTable({ registry,
|
|
61
|
-
}, [registry,
|
|
59
|
+
setDynamicTable(makeDynamicTable({ registry, type, properties }));
|
|
60
|
+
}, [registry, type, properties]);
|
|
62
61
|
|
|
63
62
|
const tableRef = useRef<TableController>(null);
|
|
64
63
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
@@ -96,8 +95,8 @@ export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
|
|
|
96
95
|
}, [registry, model]);
|
|
97
96
|
|
|
98
97
|
return (
|
|
99
|
-
<div
|
|
100
|
-
<div
|
|
98
|
+
<div className={mx('dx-expander grid', classNames)}>
|
|
99
|
+
<div className='grid min-h-0 overflow-hidden'>
|
|
101
100
|
<Table.Root ref={tableRef}>
|
|
102
101
|
<Table.Content model={model} presentation={presentation} ignoreAttention onRowClick={onRowClick} />
|
|
103
102
|
</Table.Root>
|
|
@@ -7,14 +7,13 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
7
7
|
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
9
9
|
|
|
10
|
-
import { Obj, Type } from '@dxos/echo';
|
|
11
|
-
import { View } from '@dxos/echo';
|
|
10
|
+
import { Obj, Type, View } from '@dxos/echo';
|
|
12
11
|
import { invariant } from '@dxos/invariant';
|
|
13
12
|
import { type DxGrid } from '@dxos/lit-grid';
|
|
14
13
|
import { random } from '@dxos/random';
|
|
15
14
|
import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
16
15
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
17
|
-
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
16
|
+
import { translations as formTranslations } from '@dxos/react-ui-form/translations';
|
|
18
17
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
18
|
import { ViewModel } from '@dxos/schema';
|
|
20
19
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
@@ -22,9 +21,10 @@ import { withRegistry } from '@dxos/storybook-utils';
|
|
|
22
21
|
import { Organization, Person } from '@dxos/types';
|
|
23
22
|
import '@dxos/lit-ui/dx-tag-picker.pcss';
|
|
24
23
|
|
|
24
|
+
import { translations } from '#translations';
|
|
25
|
+
|
|
25
26
|
import { useProjectionModel, useTableModel } from '../../hooks';
|
|
26
27
|
import { type TableFeatures, TablePresentation, type TableRow } from '../../model';
|
|
27
|
-
import { translations } from '../../translations';
|
|
28
28
|
import { Table } from '../../types';
|
|
29
29
|
import { Table as TableComponent } from './Table';
|
|
30
30
|
|
|
@@ -66,7 +66,9 @@ const useTestModel = <S extends Type.AnyObj>(schema: S, count: number) => {
|
|
|
66
66
|
|
|
67
67
|
const objectGenerator = createAsyncGenerator(generator, schema, { db: space?.db, force: true });
|
|
68
68
|
void objectGenerator.createObjects(count).then((objects) => {
|
|
69
|
-
|
|
69
|
+
// TODO(wittjosiah): Remove cast. Type.InstanceType is now strict (no index signature),
|
|
70
|
+
// so it isn't assignable to TableRow (Record<JsonProp, any>); reconcile the row model type.
|
|
71
|
+
model.setRows(objects as unknown as TableRow[]);
|
|
70
72
|
});
|
|
71
73
|
}, [model, space]);
|
|
72
74
|
|
|
@@ -88,7 +90,7 @@ const DefaultStory = () => {
|
|
|
88
90
|
|
|
89
91
|
const handleCreate = useCallback(
|
|
90
92
|
(schema: Type.AnyEntity, values: any) => {
|
|
91
|
-
invariant(Type.
|
|
93
|
+
invariant(Type.isObject(schema));
|
|
92
94
|
invariant(space);
|
|
93
95
|
return space.db.add(Obj.make(schema, values));
|
|
94
96
|
},
|
|
@@ -147,6 +149,18 @@ export default meta;
|
|
|
147
149
|
type Story = StoryObj<typeof meta>;
|
|
148
150
|
|
|
149
151
|
export const Default: Story = {
|
|
152
|
+
// The play function exercises a deep timing race in dx-grid + React render
|
|
153
|
+
// pipeline (cell focus → keydown → `dispatchEditRequest` → `setEditing` →
|
|
154
|
+
// `FormCellEditor` `useEffect` → `Popover` mount). On chromium browser
|
|
155
|
+
// tests the combobox sometimes fails to render in time; local pass rate
|
|
156
|
+
// ~25%, which makes pure CI re-run lottery a poor fit. Excluding from
|
|
157
|
+
// automated test runs (the story still renders in Storybook for visual
|
|
158
|
+
// review and the production code path is covered by
|
|
159
|
+
// `playwright/smoke.spec.ts`). Re-enable once the underlying race is
|
|
160
|
+
// fixed — likely needs `dispatchEditRequest` to be synchronous from
|
|
161
|
+
// keydown and `FormCellEditor` to render the popover off `contextEditing`
|
|
162
|
+
// directly instead of mirroring it through local state.
|
|
163
|
+
tags: ['!test'],
|
|
150
164
|
play: async ({ canvasElement }) => {
|
|
151
165
|
const canvas = within(canvasElement);
|
|
152
166
|
const body = within(document.body);
|
|
@@ -158,19 +172,42 @@ export const Default: Story = {
|
|
|
158
172
|
// Focus on the second table (Person/contacts table)
|
|
159
173
|
await expect(secondGrid).toBeVisible();
|
|
160
174
|
|
|
175
|
+
// Wait for both grids' data generators to finish populating before
|
|
176
|
+
// interacting. `findByTestId` returns as soon as the cell DOM exists,
|
|
177
|
+
// but dx-grid's internal cell registry (used by `cellReadonly` and the
|
|
178
|
+
// edit-request dispatcher) is filled in lazily. If `keydown` lands
|
|
179
|
+
// before the registry has the row, `dispatchEditRequest` short-circuits
|
|
180
|
+
// and the combobox never opens — that's the "Unable to find combobox"
|
|
181
|
+
// flake. Wait for the first row of each grid to render non-empty
|
|
182
|
+
// content (a reliable proxy for "registry populated") BEFORE scrolling
|
|
183
|
+
// — once we scroll the second grid to column 4, dx-grid virtualizes
|
|
184
|
+
// columns 0-3 out of the DOM, so `grid.0.0` becomes unreachable.
|
|
185
|
+
await waitFor(
|
|
186
|
+
async () => {
|
|
187
|
+
const firstOrgCell = within(firstGrid).getByTestId('grid.0.0');
|
|
188
|
+
const orgText = (firstOrgCell.querySelector('.dx-grid__cell__content') as HTMLElement | null)?.textContent;
|
|
189
|
+
await expect(orgText).toBeTruthy();
|
|
190
|
+
const firstContactCell = within(secondGrid).getByTestId('grid.0.0');
|
|
191
|
+
const contactText = (firstContactCell.querySelector('.dx-grid__cell__content') as HTMLElement | null)
|
|
192
|
+
?.textContent;
|
|
193
|
+
await expect(contactText).toBeTruthy();
|
|
194
|
+
},
|
|
195
|
+
{ timeout: 10_000 },
|
|
196
|
+
);
|
|
197
|
+
|
|
161
198
|
// Scroll to the relations column (column 4) - this mimics the scrollToColumn call
|
|
162
199
|
(secondGrid.closest('dx-grid') as DxGrid).scrollToColumn(4);
|
|
163
200
|
|
|
164
|
-
// Find
|
|
201
|
+
// Find the target cell (first row, relations column).
|
|
165
202
|
const targetCell = await within(secondGrid).findByTestId('grid.4.0', undefined, { timeout: 10_000 });
|
|
166
203
|
await expect(targetCell).toBeVisible();
|
|
167
204
|
|
|
168
|
-
// Click to focus the cell
|
|
205
|
+
// Click to focus the cell.
|
|
169
206
|
await userEvent.click(targetCell as HTMLElement);
|
|
170
207
|
await expect(targetCell).toHaveFocus();
|
|
171
208
|
await userEvent.keyboard('{Enter}');
|
|
172
209
|
|
|
173
|
-
// Look for the combobox that should appear in edit mode
|
|
210
|
+
// Look for the combobox that should appear in edit mode.
|
|
174
211
|
const combobox = await body.findByRole('combobox', undefined, { timeout: 5000 });
|
|
175
212
|
await userEvent.click(combobox);
|
|
176
213
|
|
|
@@ -7,8 +7,9 @@ import React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { DropdownMenu, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
+
import { translationKey } from '#translations';
|
|
11
|
+
|
|
10
12
|
import { type ModalController, type TableModel } from '../../model';
|
|
11
|
-
import { translationKey } from '../../translations';
|
|
12
13
|
|
|
13
14
|
type RowActionsMenuProps = { model: TableModel; modals: ModalController };
|
|
14
15
|
|
|
@@ -47,7 +48,7 @@ export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
|
|
|
47
48
|
{/* Default actions */}
|
|
48
49
|
{model.features.dataEditable !== false && (
|
|
49
50
|
<DropdownMenu.Item data-testid='row-menu-delete' onClick={() => model.deleteRow(state.rowIndex)}>
|
|
50
|
-
{t(hasSelection ? 'bulk
|
|
51
|
+
{t(hasSelection ? 'bulk-delete-row.label' : 'delete-row.label')}
|
|
51
52
|
</DropdownMenu.Item>
|
|
52
53
|
)}
|
|
53
54
|
</DropdownMenu.Viewport>
|