@dxos/react-ui-table 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-4K7JPALT.mjs +66 -0
- package/dist/lib/browser/chunk-4K7JPALT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZAOSIG3L.mjs → chunk-OZTXLZGM.mjs} +526 -536
- package/dist/lib/browser/chunk-OZTXLZGM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +373 -481
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -8
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs +67 -0
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZOFFI3JJ.mjs → chunk-S56Z4V4X.mjs} +526 -536
- package/dist/lib/node-esm/chunk-S56Z4V4X.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +373 -481
- 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 +11 -8
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +3 -3
- package/dist/types/src/components/Table/DynamicTable.d.ts +2 -2
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +51 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +104 -5
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +8 -5
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +41 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +12 -6
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +8 -13
- 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/testing.d.ts +3 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +3 -2
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +0 -7
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +7 -6
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +1 -2
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +3 -22
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- 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/types/schema.d.ts +25 -5
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +4 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- 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/table-buttons.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -50
- package/src/components/Table/DynamicTable.stories.tsx +12 -9
- package/src/components/Table/DynamicTable.tsx +4 -7
- package/src/components/Table/Relations.stories.tsx +162 -38
- package/src/components/Table/Table.stories.tsx +59 -52
- package/src/components/Table/Table.tsx +109 -90
- package/src/components/TableCellEditor/FormCellEditor.tsx +153 -42
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +22 -63
- package/src/components/TableCellEditor/TableCellEditor.tsx +62 -208
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/testing.ts +2 -2
- package/src/hooks/useAddRow.ts +7 -5
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/modal-controller.ts +0 -28
- package/src/model/table-model.test.ts +18 -10
- package/src/model/table-model.ts +26 -17
- package/src/model/table-presentation.test.ts +21 -20
- package/src/model/table-presentation.ts +58 -39
- package/src/model/table-sorting.ts +15 -6
- package/src/playwright/smoke.spec.ts +46 -46
- package/src/testing/useTestTableModel.ts +9 -6
- package/src/types/index.ts +1 -1
- package/src/types/schema.ts +63 -6
- package/src/util/dynamic-table.ts +11 -11
- package/src/util/index.ts +0 -1
- package/src/util/schema.ts +4 -4
- package/src/util/table-buttons.ts +3 -3
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZAOSIG3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZOFFI3JJ.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/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -12
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/util/table.ts +0 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.406dc2a",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -53,72 +53,73 @@
|
|
|
53
53
|
"src"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@codemirror/autocomplete": "^6.
|
|
57
|
-
"@codemirror/state": "^6.
|
|
58
|
-
"@codemirror/view": "^6.
|
|
56
|
+
"@codemirror/autocomplete": "^6.19.0",
|
|
57
|
+
"@codemirror/state": "^6.5.2",
|
|
58
|
+
"@codemirror/view": "^6.38.4",
|
|
59
59
|
"@fluentui/react-tabster": "^9.24.2",
|
|
60
60
|
"@preact-signals/safe-react": "^0.9.0",
|
|
61
|
-
"@preact/signals-core": "^1.
|
|
61
|
+
"@preact/signals-core": "^1.12.1",
|
|
62
62
|
"@radix-ui/react-context": "1.1.1",
|
|
63
63
|
"@radix-ui/react-primitive": "2.0.2",
|
|
64
64
|
"@radix-ui/react-slot": "1.1.2",
|
|
65
65
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
66
66
|
"date-fns": "^3.3.1",
|
|
67
67
|
"lodash.orderby": "^4.6.0",
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/debug": "0.8.4-main.
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/echo
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/keys": "0.8.4-main.
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/log": "0.8.4-main.
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/react-
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/react-ui-
|
|
84
|
-
"@dxos/react-ui-
|
|
85
|
-
"@dxos/react-ui-grid": "0.8.4-main.
|
|
86
|
-
"@dxos/react-ui-menu": "0.8.4-main.
|
|
87
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
88
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
89
|
-
"@dxos/react-
|
|
90
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/
|
|
93
|
-
"@dxos/
|
|
68
|
+
"@dxos/async": "0.8.4-main.406dc2a",
|
|
69
|
+
"@dxos/debug": "0.8.4-main.406dc2a",
|
|
70
|
+
"@dxos/context": "0.8.4-main.406dc2a",
|
|
71
|
+
"@dxos/echo": "0.8.4-main.406dc2a",
|
|
72
|
+
"@dxos/effect": "0.8.4-main.406dc2a",
|
|
73
|
+
"@dxos/echo-db": "0.8.4-main.406dc2a",
|
|
74
|
+
"@dxos/keys": "0.8.4-main.406dc2a",
|
|
75
|
+
"@dxos/invariant": "0.8.4-main.406dc2a",
|
|
76
|
+
"@dxos/lit-grid": "0.8.4-main.406dc2a",
|
|
77
|
+
"@dxos/log": "0.8.4-main.406dc2a",
|
|
78
|
+
"@dxos/plugin-search": "0.8.4-main.406dc2a",
|
|
79
|
+
"@dxos/random": "0.8.4-main.406dc2a",
|
|
80
|
+
"@dxos/react-ui-attention": "0.8.4-main.406dc2a",
|
|
81
|
+
"@dxos/live-object": "0.8.4-main.406dc2a",
|
|
82
|
+
"@dxos/react-ui-editor": "0.8.4-main.406dc2a",
|
|
83
|
+
"@dxos/react-ui-components": "0.8.4-main.406dc2a",
|
|
84
|
+
"@dxos/react-ui-form": "0.8.4-main.406dc2a",
|
|
85
|
+
"@dxos/react-ui-grid": "0.8.4-main.406dc2a",
|
|
86
|
+
"@dxos/react-ui-menu": "0.8.4-main.406dc2a",
|
|
87
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.406dc2a",
|
|
88
|
+
"@dxos/react-ui-stack": "0.8.4-main.406dc2a",
|
|
89
|
+
"@dxos/react-client": "0.8.4-main.406dc2a",
|
|
90
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.406dc2a",
|
|
91
|
+
"@dxos/react-ui-types": "0.8.4-main.406dc2a",
|
|
92
|
+
"@dxos/schema": "0.8.4-main.406dc2a",
|
|
93
|
+
"@dxos/util": "0.8.4-main.406dc2a"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@effect-rx/rx-react": "0.
|
|
97
|
-
"@effect/platform": "0.
|
|
96
|
+
"@effect-rx/rx-react": "0.42.4",
|
|
97
|
+
"@effect/platform": "0.92.1",
|
|
98
98
|
"@types/lodash.orderby": "^4.6.9",
|
|
99
|
-
"@types/react": "~
|
|
100
|
-
"@types/react-dom": "~
|
|
101
|
-
"effect": "3.
|
|
99
|
+
"@types/react": "~19.2.2",
|
|
100
|
+
"@types/react-dom": "~19.2.1",
|
|
101
|
+
"effect": "3.18.3",
|
|
102
102
|
"fast-check": "^3.19.0",
|
|
103
|
-
"react": "~
|
|
104
|
-
"react-dom": "~
|
|
105
|
-
"vite": "
|
|
106
|
-
"@dxos/echo-signals": "0.8.4-main.
|
|
107
|
-
"@dxos/plugin-search": "0.8.4-main.
|
|
108
|
-
"@dxos/react-ui
|
|
109
|
-
"@dxos/
|
|
110
|
-
"@dxos/
|
|
111
|
-
"@dxos/
|
|
112
|
-
"@dxos/
|
|
103
|
+
"react": "~19.2.0",
|
|
104
|
+
"react-dom": "~19.2.0",
|
|
105
|
+
"vite": "7.1.9",
|
|
106
|
+
"@dxos/echo-signals": "0.8.4-main.406dc2a",
|
|
107
|
+
"@dxos/plugin-search": "0.8.4-main.406dc2a",
|
|
108
|
+
"@dxos/react-ui": "0.8.4-main.406dc2a",
|
|
109
|
+
"@dxos/react-ui-theme": "0.8.4-main.406dc2a",
|
|
110
|
+
"@dxos/lit-ui": "0.8.4-main.406dc2a",
|
|
111
|
+
"@dxos/random": "0.8.4-main.406dc2a",
|
|
112
|
+
"@dxos/storybook-utils": "0.8.4-main.406dc2a",
|
|
113
|
+
"@dxos/test-utils": "0.8.4-main.406dc2a"
|
|
113
114
|
},
|
|
114
115
|
"peerDependencies": {
|
|
115
116
|
"@effect-rx/rx-react": "^0.34.1",
|
|
116
117
|
"@effect/platform": "^0.80.12",
|
|
117
118
|
"effect": "^3.13.3",
|
|
118
|
-
"react": "
|
|
119
|
-
"react-dom": "
|
|
120
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
121
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
119
|
+
"react": "^19.0.0",
|
|
120
|
+
"react-dom": "^19.0.0",
|
|
121
|
+
"@dxos/react-ui": "0.8.4-main.406dc2a",
|
|
122
|
+
"@dxos/react-ui-theme": "0.8.4-main.406dc2a"
|
|
122
123
|
},
|
|
123
124
|
"publishConfig": {
|
|
124
125
|
"access": "public"
|
|
@@ -2,20 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useMemo, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { FormatEnum, type JsonSchemaType } from '@dxos/echo
|
|
9
|
+
import { FormatEnum, type JsonSchemaType } from '@dxos/echo/internal';
|
|
12
10
|
import { faker } from '@dxos/random';
|
|
13
11
|
import { useClient } from '@dxos/react-client';
|
|
14
12
|
import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
|
|
15
13
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
15
|
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
17
16
|
import { Testing } from '@dxos/schema/testing';
|
|
18
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
19
17
|
|
|
20
18
|
import { type TableFeatures } from '../../model';
|
|
21
19
|
import { translations } from '../../translations';
|
|
@@ -57,15 +55,20 @@ const DynamicTableStory = () => {
|
|
|
57
55
|
// Story definitions.
|
|
58
56
|
//
|
|
59
57
|
|
|
60
|
-
const meta
|
|
58
|
+
const meta = {
|
|
61
59
|
title: 'ui/react-ui-table/DynamicTable',
|
|
62
60
|
component: DynamicTable,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
decorators: [withTheme],
|
|
62
|
+
parameters: {
|
|
63
|
+
layout: 'fullscreen',
|
|
64
|
+
translations,
|
|
65
|
+
},
|
|
66
|
+
} satisfies Meta<typeof DynamicTable>;
|
|
66
67
|
|
|
67
68
|
export default meta;
|
|
68
69
|
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
71
|
+
|
|
69
72
|
export const Default: StoryObj = {
|
|
70
73
|
render: DynamicTableStory,
|
|
71
74
|
};
|
|
@@ -142,7 +145,7 @@ export const WithEchoSchema: StoryObj = {
|
|
|
142
145
|
types: [Testing.Contact],
|
|
143
146
|
createIdentity: true,
|
|
144
147
|
createSpace: true,
|
|
145
|
-
|
|
148
|
+
onCreateSpace: async ({ space }) => {
|
|
146
149
|
Array.from({ length: 10 }).forEach(() => {
|
|
147
150
|
space.db.add(
|
|
148
151
|
Obj.make(Testing.Contact, {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type JsonSchemaType } from '@dxos/echo
|
|
8
|
+
import { type JsonSchemaType } from '@dxos/echo/internal';
|
|
9
9
|
import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
|
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
@@ -45,15 +45,12 @@ export const DynamicTable = ({
|
|
|
45
45
|
...props
|
|
46
46
|
}: DynamicTableProps) => {
|
|
47
47
|
// TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
|
|
48
|
-
const {
|
|
48
|
+
const { jsonSchema } = useMemo(
|
|
49
49
|
() => getBaseSchema({ typename: name, properties, jsonSchema: _jsonSchema, schema }),
|
|
50
50
|
[name, properties, _jsonSchema, schema],
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
const { projection, view } = useMemo(
|
|
54
|
-
() => makeDynamicTable({ typename, jsonSchema, properties }),
|
|
55
|
-
[typename, jsonSchema, properties],
|
|
56
|
-
);
|
|
53
|
+
const { projection, view } = useMemo(() => makeDynamicTable({ jsonSchema, properties }), [jsonSchema, properties]);
|
|
57
54
|
|
|
58
55
|
const tableRef = useRef<TableController>(null);
|
|
59
56
|
const handleCellUpdate = useCallback((cell: any) => {
|
|
@@ -2,27 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
6
|
+
import type * as Schema from 'effect/Schema';
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
9
|
+
|
|
10
|
+
import { Obj, Type } from '@dxos/echo';
|
|
11
|
+
import { type JsonSchemaType } from '@dxos/echo/internal';
|
|
12
|
+
import { type DxGrid } from '@dxos/lit-grid';
|
|
13
|
+
import '@dxos/lit-ui/dx-tag-picker.pcss';
|
|
12
14
|
import { faker } from '@dxos/random';
|
|
13
15
|
import { useClient } from '@dxos/react-client';
|
|
14
16
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
17
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
18
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
19
|
+
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
15
20
|
import { DataType } from '@dxos/schema';
|
|
16
21
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
17
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
22
|
|
|
19
23
|
import { useTableModel } from '../../hooks';
|
|
20
24
|
import { type TableFeatures, TablePresentation, type TableRow } from '../../model';
|
|
21
25
|
import { translations } from '../../translations';
|
|
22
|
-
import {
|
|
23
|
-
import { createTable } from '../../util';
|
|
26
|
+
import { Table } from '../../types';
|
|
24
27
|
|
|
25
|
-
import { Table } from './Table';
|
|
28
|
+
import { Table as TableComponent } from './Table';
|
|
26
29
|
|
|
27
30
|
faker.seed(1);
|
|
28
31
|
const generator: ValueGenerator = faker as any;
|
|
@@ -42,23 +45,20 @@ const useTestModel = <S extends Type.Obj.Any>(schema: S, count: number) => {
|
|
|
42
45
|
[],
|
|
43
46
|
);
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
useAsyncEffect(async () => {
|
|
46
49
|
if (!space) {
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await space.db.schemaRegistry.register([effectSchema]);
|
|
60
|
-
});
|
|
61
|
-
return () => clearTimeout(timeout);
|
|
53
|
+
const {
|
|
54
|
+
jsonSchema,
|
|
55
|
+
schema: effectSchema,
|
|
56
|
+
view,
|
|
57
|
+
} = await Table.makeView({ client, space, typename: Type.getTypename(schema) });
|
|
58
|
+
setJsonSchema(jsonSchema);
|
|
59
|
+
setView(view);
|
|
60
|
+
space.db.add(view);
|
|
61
|
+
await space.db.schemaRegistry.register([effectSchema]);
|
|
62
62
|
}, [client, space, schema]);
|
|
63
63
|
|
|
64
64
|
const model = useTableModel<TableRow>({ view, schema: jsonSchema, rows: [], features });
|
|
@@ -89,36 +89,160 @@ const DefaultStory = () => {
|
|
|
89
89
|
const client = useClient();
|
|
90
90
|
const { model: orgModel, presentation: orgPresentation } = useTestModel(DataType.Organization, 50);
|
|
91
91
|
const { model: contactModel, presentation: contactPresentation } = useTestModel(DataType.Person, 50);
|
|
92
|
+
const { space } = useClientProvider();
|
|
93
|
+
|
|
94
|
+
const handleCreate = useCallback(
|
|
95
|
+
(schema: Schema.Schema.AnyNoContext, values: any) => {
|
|
96
|
+
return client.spaces.default.db.add(Obj.make(schema, values));
|
|
97
|
+
},
|
|
98
|
+
[space],
|
|
99
|
+
);
|
|
92
100
|
|
|
93
101
|
return (
|
|
94
102
|
<div className='is-full bs-full grid grid-cols-2 divide-x divide-separator'>
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
<TableComponent.Root>
|
|
104
|
+
<TableComponent.Main
|
|
105
|
+
model={orgModel}
|
|
106
|
+
schema={DataType.Organization}
|
|
107
|
+
presentation={orgPresentation}
|
|
108
|
+
onCreate={handleCreate}
|
|
109
|
+
client={client}
|
|
110
|
+
ignoreAttention
|
|
111
|
+
testId='relations-0'
|
|
112
|
+
/>
|
|
113
|
+
</TableComponent.Root>
|
|
114
|
+
<TableComponent.Root>
|
|
115
|
+
<TableComponent.Main
|
|
116
|
+
model={contactModel}
|
|
117
|
+
schema={DataType.Person}
|
|
118
|
+
presentation={contactPresentation}
|
|
119
|
+
onCreate={handleCreate}
|
|
120
|
+
client={client}
|
|
121
|
+
ignoreAttention
|
|
122
|
+
testId='relations-1'
|
|
123
|
+
/>
|
|
124
|
+
</TableComponent.Root>
|
|
101
125
|
</div>
|
|
102
126
|
);
|
|
103
127
|
};
|
|
104
128
|
|
|
105
|
-
const meta
|
|
106
|
-
title: 'ui/react-ui-table/
|
|
129
|
+
const meta = {
|
|
130
|
+
title: 'ui/react-ui-table/Relations',
|
|
107
131
|
render: DefaultStory,
|
|
108
|
-
parameters: { translations, controls: { disable: true } },
|
|
109
132
|
decorators: [
|
|
133
|
+
withTheme,
|
|
110
134
|
withClientProvider({
|
|
111
|
-
types: [DataType.View, DataType.Organization, DataType.Person,
|
|
135
|
+
types: [DataType.View, DataType.Organization, DataType.Person, Table.Table],
|
|
112
136
|
createIdentity: true,
|
|
113
137
|
createSpace: true,
|
|
114
138
|
}),
|
|
115
|
-
withTheme,
|
|
116
|
-
withLayout({ fullscreen: true }),
|
|
117
139
|
],
|
|
118
|
-
|
|
140
|
+
parameters: {
|
|
141
|
+
layout: 'fullscreen',
|
|
142
|
+
controls: { disable: true },
|
|
143
|
+
translations: [...translations, ...formTranslations],
|
|
144
|
+
},
|
|
145
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
119
146
|
|
|
120
147
|
export default meta;
|
|
121
148
|
|
|
122
|
-
type Story = StoryObj<typeof
|
|
149
|
+
type Story = StoryObj<typeof meta>;
|
|
150
|
+
|
|
151
|
+
export const Default: Story = {
|
|
152
|
+
// TODO(wittjosiah): This test is flaky, especially in CI.
|
|
153
|
+
// Most typical failure is `targetCell` returns `null`.
|
|
154
|
+
_play: async ({ canvasElement }: any) => {
|
|
155
|
+
const canvas = within(canvasElement);
|
|
156
|
+
const body = within(document.body);
|
|
157
|
+
|
|
158
|
+
// Get all dx-grid elements (should have 2 - one for each table)
|
|
159
|
+
const firstGrid = await canvas.findByTestId('relations-0', undefined, { timeout: 30_000 });
|
|
160
|
+
const secondGrid = await canvas.findByTestId('relations-1', undefined, { timeout: 30_000 });
|
|
161
|
+
|
|
162
|
+
// Focus on the second table (Person/contacts table)
|
|
163
|
+
await expect(secondGrid).toBeVisible();
|
|
164
|
+
|
|
165
|
+
// Scroll to the relations column (column 4) - this mimics the scrollToColumn call
|
|
166
|
+
(secondGrid.closest('dx-grid') as DxGrid).scrollToColumn(4);
|
|
167
|
+
|
|
168
|
+
// Wait for scroll to complete
|
|
169
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
170
|
+
|
|
171
|
+
// Find and click the target cell (first row, relations column)
|
|
172
|
+
const targetCell = secondGrid.querySelector('[data-dx-grid-plane="grid"] [aria-rowindex="0"][aria-colindex="4"]');
|
|
173
|
+
await expect(targetCell).toBeVisible();
|
|
174
|
+
|
|
175
|
+
// Click to focus the cell
|
|
176
|
+
await userEvent.click(targetCell as HTMLElement);
|
|
177
|
+
await expect(targetCell).toHaveFocus();
|
|
178
|
+
await userEvent.keyboard('{Enter}');
|
|
179
|
+
|
|
180
|
+
// Look for the combobox that should appear in edit mode
|
|
181
|
+
const combobox = await body.findByRole('combobox', undefined, { timeout: 5000 });
|
|
182
|
+
await userEvent.click(combobox);
|
|
183
|
+
|
|
184
|
+
const searchField = await body.findByPlaceholderText('Search…');
|
|
185
|
+
await userEvent.click(searchField);
|
|
186
|
+
|
|
187
|
+
// Get the first organization name from the first table to search for
|
|
188
|
+
const orgCell = firstGrid.querySelector(
|
|
189
|
+
'[data-dx-grid-plane="grid"] [aria-rowindex="0"][aria-colindex="0"] .dx-grid__cell__content',
|
|
190
|
+
) as HTMLElement;
|
|
191
|
+
|
|
192
|
+
const orgName = orgCell.textContent;
|
|
193
|
+
// Type the first 4 characters to search
|
|
194
|
+
await userEvent.type(searchField, orgName.substring(0, 4));
|
|
195
|
+
|
|
196
|
+
// Look for an option to select
|
|
197
|
+
const option = await body.findAllByRole('option');
|
|
198
|
+
await expect(option[0]).toBeVisible();
|
|
199
|
+
|
|
200
|
+
// Press Enter to select
|
|
201
|
+
await userEvent.keyboard('{Enter}');
|
|
202
|
+
|
|
203
|
+
// Look for and click save button
|
|
204
|
+
const saveButton = await body.findByTestId('save-button');
|
|
205
|
+
await userEvent.click(saveButton);
|
|
206
|
+
|
|
207
|
+
// Verify the relation was set (cell should now contain the org name)
|
|
208
|
+
await expect(targetCell).toHaveTextContent(orgName.substring(0, 4));
|
|
209
|
+
|
|
210
|
+
// Test object creation (new relations) - equivalent to "new relations work as expected" test
|
|
211
|
+
// Find a different cell to test object creation (second row, relations column)
|
|
212
|
+
const newTargetCell = secondGrid.querySelector(
|
|
213
|
+
'[data-dx-grid-plane="grid"] [aria-rowindex="1"][aria-colindex="4"]',
|
|
214
|
+
);
|
|
215
|
+
await expect(newTargetCell).toBeTruthy();
|
|
216
|
+
|
|
217
|
+
// Click to focus the cell
|
|
218
|
+
await userEvent.click(newTargetCell as Element);
|
|
219
|
+
|
|
220
|
+
await userEvent.keyboard('{Enter}');
|
|
221
|
+
|
|
222
|
+
// Look for the combobox that should appear in edit mode
|
|
223
|
+
const newCombobox = await body.findByRole('combobox');
|
|
224
|
+
await userEvent.click(newCombobox);
|
|
225
|
+
|
|
226
|
+
const newSearchField = await body.findByPlaceholderText('Search…');
|
|
227
|
+
await userEvent.click(newSearchField);
|
|
228
|
+
|
|
229
|
+
// Type a new object name (this will create a new object)
|
|
230
|
+
const newOrgName = 'Salieri LLC';
|
|
231
|
+
await userEvent.type(newSearchField, newOrgName);
|
|
232
|
+
|
|
233
|
+
// Look for an option to select (should be the create new option)
|
|
234
|
+
const newOption = await body.findAllByRole('option');
|
|
235
|
+
await expect(newOption[0]).toBeVisible();
|
|
236
|
+
|
|
237
|
+
// Press Enter to select/create
|
|
238
|
+
await userEvent.keyboard('{Enter}');
|
|
239
|
+
|
|
240
|
+
// Look for and click save button
|
|
241
|
+
const createReferencedObjectForm = await body.findByTestId('create-referenced-object-form');
|
|
242
|
+
const saveObjectButton = await within(createReferencedObjectForm).findByTestId('save-button');
|
|
243
|
+
await userEvent.click(saveObjectButton);
|
|
123
244
|
|
|
124
|
-
|
|
245
|
+
// Verify the new object was created and relation was set
|
|
246
|
+
await expect(newTargetCell).toHaveTextContent(newOrgName);
|
|
247
|
+
},
|
|
248
|
+
} as any;
|