@dxos/react-ui-table 0.8.4-main.5ea62a8 → 0.8.4-main.ae835ea
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-63UUF4IG.mjs → chunk-4K7JPALT.mjs} +5 -5
- package/dist/lib/browser/chunk-4K7JPALT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RQYXNWWN.mjs → chunk-G7MGPBSR.mjs} +444 -490
- package/dist/lib/browser/chunk-G7MGPBSR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +132 -283
- 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 -6
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-QNDUGIS7.mjs → chunk-LD5JEBA6.mjs} +444 -490
- package/dist/lib/node-esm/chunk-LD5JEBA6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K734DJB7.mjs → chunk-MK6OVUF6.mjs} +5 -5
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +132 -283
- 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 -6
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +1 -1
- 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 +3 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +71 -7
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +5 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +5 -6
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +7 -5
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +1 -2
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.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 +1 -1
- 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 +2 -2
- 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/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 -17
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +3 -3
- 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/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -51
- package/src/components/Table/DynamicTable.stories.tsx +8 -7
- package/src/components/Table/DynamicTable.tsx +4 -7
- package/src/components/Table/Relations.stories.tsx +119 -11
- package/src/components/Table/Table.stories.tsx +36 -35
- package/src/components/Table/Table.tsx +13 -9
- package/src/components/TableCellEditor/FormCellEditor.tsx +51 -41
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +17 -45
- package/src/components/TableCellEditor/TableCellEditor.tsx +17 -112
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +3 -0
- package/src/components/testing.ts +2 -2
- package/src/hooks/useAddRow.ts +1 -1
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/modal-controller.ts +0 -28
- package/src/model/table-model.test.ts +16 -6
- package/src/model/table-model.ts +10 -3
- package/src/model/table-presentation.test.ts +19 -17
- package/src/model/table-presentation.ts +4 -5
- package/src/model/table-sorting.ts +15 -6
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +7 -4
- package/src/types/schema.ts +4 -4
- package/src/util/dynamic-table.ts +8 -8
- package/src/util/schema.ts +4 -4
- package/dist/lib/browser/chunk-63UUF4IG.mjs.map +0 -7
- package/dist/lib/browser/chunk-RQYXNWWN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QNDUGIS7.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/src/components/Table/CreateRefPanel.tsx +0 -103
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.ae835ea",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -53,73 +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/async": "0.8.4-main.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/echo-db": "0.8.4-main.
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/plugin-search": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
84
|
-
"@dxos/react-ui-
|
|
85
|
-
"@dxos/react-ui-
|
|
86
|
-
"@dxos/react-ui-menu": "0.8.4-main.
|
|
87
|
-
"@dxos/react-ui-
|
|
88
|
-
"@dxos/react-ui-
|
|
89
|
-
"@dxos/react-ui-
|
|
90
|
-
"@dxos/react-ui-
|
|
91
|
-
"@dxos/
|
|
92
|
-
"@dxos/react-ui-
|
|
93
|
-
"@dxos/
|
|
94
|
-
"@dxos/util": "0.8.4-main.5ea62a8"
|
|
68
|
+
"@dxos/async": "0.8.4-main.ae835ea",
|
|
69
|
+
"@dxos/context": "0.8.4-main.ae835ea",
|
|
70
|
+
"@dxos/debug": "0.8.4-main.ae835ea",
|
|
71
|
+
"@dxos/effect": "0.8.4-main.ae835ea",
|
|
72
|
+
"@dxos/echo-db": "0.8.4-main.ae835ea",
|
|
73
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
74
|
+
"@dxos/keys": "0.8.4-main.ae835ea",
|
|
75
|
+
"@dxos/lit-grid": "0.8.4-main.ae835ea",
|
|
76
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
77
|
+
"@dxos/live-object": "0.8.4-main.ae835ea",
|
|
78
|
+
"@dxos/echo": "0.8.4-main.ae835ea",
|
|
79
|
+
"@dxos/plugin-search": "0.8.4-main.ae835ea",
|
|
80
|
+
"@dxos/react-client": "0.8.4-main.ae835ea",
|
|
81
|
+
"@dxos/react-ui-attention": "0.8.4-main.ae835ea",
|
|
82
|
+
"@dxos/random": "0.8.4-main.ae835ea",
|
|
83
|
+
"@dxos/react-ui-editor": "0.8.4-main.ae835ea",
|
|
84
|
+
"@dxos/react-ui-components": "0.8.4-main.ae835ea",
|
|
85
|
+
"@dxos/react-ui-form": "0.8.4-main.ae835ea",
|
|
86
|
+
"@dxos/react-ui-menu": "0.8.4-main.ae835ea",
|
|
87
|
+
"@dxos/react-ui-grid": "0.8.4-main.ae835ea",
|
|
88
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.ae835ea",
|
|
89
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.ae835ea",
|
|
90
|
+
"@dxos/react-ui-stack": "0.8.4-main.ae835ea",
|
|
91
|
+
"@dxos/schema": "0.8.4-main.ae835ea",
|
|
92
|
+
"@dxos/react-ui-types": "0.8.4-main.ae835ea",
|
|
93
|
+
"@dxos/util": "0.8.4-main.ae835ea"
|
|
95
94
|
},
|
|
96
95
|
"devDependencies": {
|
|
97
|
-
"@effect-rx/rx-react": "0.
|
|
98
|
-
"@effect/platform": "0.
|
|
96
|
+
"@effect-rx/rx-react": "0.42.4",
|
|
97
|
+
"@effect/platform": "0.92.1",
|
|
99
98
|
"@types/lodash.orderby": "^4.6.9",
|
|
100
|
-
"@types/react": "~
|
|
101
|
-
"@types/react-dom": "~
|
|
102
|
-
"effect": "3.
|
|
99
|
+
"@types/react": "~19.2.2",
|
|
100
|
+
"@types/react-dom": "~19.2.2",
|
|
101
|
+
"effect": "3.18.3",
|
|
103
102
|
"fast-check": "^3.19.0",
|
|
104
|
-
"react": "~
|
|
105
|
-
"react-dom": "~
|
|
106
|
-
"vite": "7.1.
|
|
107
|
-
"@dxos/
|
|
108
|
-
"@dxos/
|
|
109
|
-
"@dxos/
|
|
110
|
-
"@dxos/
|
|
111
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
112
|
-
"@dxos/
|
|
113
|
-
"@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.ae835ea",
|
|
107
|
+
"@dxos/plugin-search": "0.8.4-main.ae835ea",
|
|
108
|
+
"@dxos/random": "0.8.4-main.ae835ea",
|
|
109
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
110
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea",
|
|
111
|
+
"@dxos/lit-ui": "0.8.4-main.ae835ea",
|
|
112
|
+
"@dxos/storybook-utils": "0.8.4-main.ae835ea",
|
|
113
|
+
"@dxos/test-utils": "0.8.4-main.ae835ea"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@effect-rx/rx-react": "^0.34.1",
|
|
117
117
|
"@effect/platform": "^0.80.12",
|
|
118
118
|
"effect": "^3.13.3",
|
|
119
|
-
"react": "
|
|
120
|
-
"react-dom": "
|
|
121
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
122
|
-
"@dxos/react-ui
|
|
119
|
+
"react": "^19.0.0",
|
|
120
|
+
"react-dom": "^19.0.0",
|
|
121
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea",
|
|
122
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea"
|
|
123
123
|
},
|
|
124
124
|
"publishConfig": {
|
|
125
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';
|
|
@@ -60,8 +58,11 @@ const DynamicTableStory = () => {
|
|
|
60
58
|
const meta = {
|
|
61
59
|
title: 'ui/react-ui-table/DynamicTable',
|
|
62
60
|
component: DynamicTable,
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
decorators: [withTheme],
|
|
62
|
+
parameters: {
|
|
63
|
+
layout: 'fullscreen',
|
|
64
|
+
translations,
|
|
65
|
+
},
|
|
65
66
|
} satisfies Meta<typeof DynamicTable>;
|
|
66
67
|
|
|
67
68
|
export default meta;
|
|
@@ -144,7 +145,7 @@ export const WithEchoSchema: StoryObj = {
|
|
|
144
145
|
types: [Testing.Contact],
|
|
145
146
|
createIdentity: true,
|
|
146
147
|
createSpace: true,
|
|
147
|
-
|
|
148
|
+
onCreateSpace: async ({ space }) => {
|
|
148
149
|
Array.from({ length: 10 }).forEach(() => {
|
|
149
150
|
space.db.add(
|
|
150
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,20 +2,23 @@
|
|
|
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';
|
|
15
17
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
18
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
|
+
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
16
20
|
import { DataType } from '@dxos/schema';
|
|
17
21
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
18
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
19
22
|
|
|
20
23
|
import { useTableModel } from '../../hooks';
|
|
21
24
|
import { type TableFeatures, TablePresentation, type TableRow } from '../../model';
|
|
@@ -86,6 +89,14 @@ const DefaultStory = () => {
|
|
|
86
89
|
const client = useClient();
|
|
87
90
|
const { model: orgModel, presentation: orgPresentation } = useTestModel(DataType.Organization, 50);
|
|
88
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
|
+
);
|
|
89
100
|
|
|
90
101
|
return (
|
|
91
102
|
<div className='is-full bs-full grid grid-cols-2 divide-x divide-separator'>
|
|
@@ -94,8 +105,10 @@ const DefaultStory = () => {
|
|
|
94
105
|
model={orgModel}
|
|
95
106
|
schema={DataType.Organization}
|
|
96
107
|
presentation={orgPresentation}
|
|
108
|
+
onCreate={handleCreate}
|
|
97
109
|
client={client}
|
|
98
110
|
ignoreAttention
|
|
111
|
+
testId='relations-0'
|
|
99
112
|
/>
|
|
100
113
|
</TableComponent.Root>
|
|
101
114
|
<TableComponent.Root>
|
|
@@ -103,8 +116,10 @@ const DefaultStory = () => {
|
|
|
103
116
|
model={contactModel}
|
|
104
117
|
schema={DataType.Person}
|
|
105
118
|
presentation={contactPresentation}
|
|
119
|
+
onCreate={handleCreate}
|
|
106
120
|
client={client}
|
|
107
121
|
ignoreAttention
|
|
122
|
+
testId='relations-1'
|
|
108
123
|
/>
|
|
109
124
|
</TableComponent.Root>
|
|
110
125
|
</div>
|
|
@@ -114,20 +129,113 @@ const DefaultStory = () => {
|
|
|
114
129
|
const meta = {
|
|
115
130
|
title: 'ui/react-ui-table/Relations',
|
|
116
131
|
render: DefaultStory,
|
|
117
|
-
parameters: { translations, controls: { disable: true } },
|
|
118
132
|
decorators: [
|
|
133
|
+
withTheme,
|
|
134
|
+
// TODO(thure): Shouldn’t `layout: 'fullscreen'` below make this unnecessary?
|
|
135
|
+
withLayout({ classNames: 'fixed inset-0' }),
|
|
119
136
|
withClientProvider({
|
|
120
137
|
types: [DataType.View, DataType.Organization, DataType.Person, Table.Table],
|
|
121
138
|
createIdentity: true,
|
|
122
139
|
createSpace: true,
|
|
123
140
|
}),
|
|
124
|
-
withTheme,
|
|
125
|
-
withLayout({ fullscreen: true }),
|
|
126
141
|
],
|
|
142
|
+
parameters: {
|
|
143
|
+
layout: 'fullscreen',
|
|
144
|
+
controls: { disable: true },
|
|
145
|
+
translations: [...translations, ...formTranslations],
|
|
146
|
+
},
|
|
127
147
|
} satisfies Meta<typeof DefaultStory>;
|
|
128
148
|
|
|
129
149
|
export default meta;
|
|
130
150
|
|
|
131
151
|
type Story = StoryObj<typeof meta>;
|
|
132
152
|
|
|
133
|
-
export const Default: Story = {
|
|
153
|
+
export const Default: Story = {
|
|
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
|
+
// Find and click the target cell (first row, relations column)
|
|
169
|
+
const targetCell = await within(secondGrid).findByTestId('grid.4.0', undefined, { timeout: 10_000 });
|
|
170
|
+
await expect(targetCell).toBeVisible();
|
|
171
|
+
|
|
172
|
+
// Click to focus the cell
|
|
173
|
+
await userEvent.click(targetCell as HTMLElement);
|
|
174
|
+
await expect(targetCell).toHaveFocus();
|
|
175
|
+
await userEvent.keyboard('{Enter}');
|
|
176
|
+
|
|
177
|
+
// Look for the combobox that should appear in edit mode
|
|
178
|
+
const combobox = await body.findByRole('combobox', undefined, { timeout: 5000 });
|
|
179
|
+
await userEvent.click(combobox);
|
|
180
|
+
|
|
181
|
+
const searchField = await body.findByPlaceholderText('Search…');
|
|
182
|
+
await userEvent.click(searchField);
|
|
183
|
+
|
|
184
|
+
// Get the first organization name from the first table to search for
|
|
185
|
+
const orgCell = await within(firstGrid).findByTestId('grid.0.0', undefined, { timeout: 10_000 });
|
|
186
|
+
|
|
187
|
+
const orgName = (orgCell.querySelector('.dx-grid__cell__content') as HTMLElement).textContent;
|
|
188
|
+
// Type the first 4 characters to search
|
|
189
|
+
await userEvent.type(searchField, orgName.substring(0, 4));
|
|
190
|
+
|
|
191
|
+
// Look for an option to select
|
|
192
|
+
const option = await body.findAllByRole('option');
|
|
193
|
+
await expect(option[0]).toBeVisible();
|
|
194
|
+
|
|
195
|
+
// Press Enter to select
|
|
196
|
+
await userEvent.keyboard('{Enter}');
|
|
197
|
+
|
|
198
|
+
// Look for and click save button
|
|
199
|
+
const saveButton = await body.findByTestId('save-button');
|
|
200
|
+
await userEvent.click(saveButton);
|
|
201
|
+
|
|
202
|
+
// Verify the relation was set (cell should now contain the org name)
|
|
203
|
+
await expect(targetCell).toHaveTextContent(orgName.substring(0, 4));
|
|
204
|
+
|
|
205
|
+
// Test object creation (new relations) - equivalent to "new relations work as expected" test
|
|
206
|
+
// Find a different cell to test object creation (second row, relations column)
|
|
207
|
+
const newTargetCell = await within(secondGrid).findByTestId('grid.4.1', undefined, { timeout: 10_000 });
|
|
208
|
+
await expect(newTargetCell).toBeTruthy();
|
|
209
|
+
|
|
210
|
+
// Click to focus the cell
|
|
211
|
+
await userEvent.click(newTargetCell as Element);
|
|
212
|
+
|
|
213
|
+
await userEvent.keyboard('{Enter}');
|
|
214
|
+
|
|
215
|
+
// Look for the combobox that should appear in edit mode
|
|
216
|
+
const newCombobox = await body.findByRole('combobox');
|
|
217
|
+
await userEvent.click(newCombobox);
|
|
218
|
+
|
|
219
|
+
const newSearchField = await body.findByPlaceholderText('Search…');
|
|
220
|
+
await userEvent.click(newSearchField);
|
|
221
|
+
|
|
222
|
+
// Type a new object name (this will create a new object)
|
|
223
|
+
const newOrgName = 'Salieri LLC';
|
|
224
|
+
await userEvent.type(newSearchField, newOrgName);
|
|
225
|
+
|
|
226
|
+
// Look for an option to select (should be the create new option)
|
|
227
|
+
const newOption = await body.findAllByRole('option');
|
|
228
|
+
await expect(newOption[0]).toBeVisible();
|
|
229
|
+
|
|
230
|
+
// Press Enter to select/create
|
|
231
|
+
await userEvent.keyboard('{Enter}');
|
|
232
|
+
|
|
233
|
+
// Look for and click save button
|
|
234
|
+
const createReferencedObjectForm = await body.findByTestId('create-referenced-object-form');
|
|
235
|
+
const saveObjectButton = await within(createReferencedObjectForm).findByTestId('save-button');
|
|
236
|
+
await userEvent.click(saveObjectButton);
|
|
237
|
+
|
|
238
|
+
// Verify the new object was created and relation was set
|
|
239
|
+
await expect(newTargetCell).toHaveTextContent(newOrgName);
|
|
240
|
+
},
|
|
241
|
+
} as any;
|
|
@@ -2,13 +2,11 @@
|
|
|
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
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
9
7
|
import React, { useCallback } from 'react';
|
|
10
8
|
|
|
11
|
-
import { Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { Obj, type QueryAST, Type } from '@dxos/echo';
|
|
12
10
|
import {
|
|
13
11
|
EchoObject,
|
|
14
12
|
FormatAnnotation,
|
|
@@ -16,17 +14,18 @@ import {
|
|
|
16
14
|
GeneratorAnnotation,
|
|
17
15
|
LabelAnnotation,
|
|
18
16
|
PropertyMetaAnnotationId,
|
|
19
|
-
} from '@dxos/echo
|
|
17
|
+
} from '@dxos/echo/internal';
|
|
18
|
+
import { live } from '@dxos/echo/internal';
|
|
20
19
|
import { invariant } from '@dxos/invariant';
|
|
21
20
|
import { faker } from '@dxos/random';
|
|
22
21
|
import { PublicKey } from '@dxos/react-client';
|
|
23
|
-
import { type Space
|
|
22
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
24
23
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
24
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
25
25
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
26
26
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
27
|
-
import { DataType, getSchemaFromPropertyDefinitions } from '@dxos/schema';
|
|
27
|
+
import { DataType, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
28
28
|
import { Testing, createObjectFactory } from '@dxos/schema/testing';
|
|
29
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
30
29
|
|
|
31
30
|
import { useTestTableModel } from '../../testing';
|
|
32
31
|
import { translations } from '../../translations';
|
|
@@ -76,13 +75,13 @@ const StoryViewEditor = ({
|
|
|
76
75
|
space?: Space;
|
|
77
76
|
handleDeleteColumn: (fieldId: string) => void;
|
|
78
77
|
}) => {
|
|
79
|
-
const
|
|
80
|
-
(
|
|
78
|
+
const handleQueryChanged = useCallback(
|
|
79
|
+
(newQuery: QueryAST.Query) => {
|
|
81
80
|
invariant(schema);
|
|
82
81
|
invariant(Type.isMutable(schema));
|
|
83
|
-
schema.updateTypename(
|
|
82
|
+
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
84
83
|
invariant(view);
|
|
85
|
-
view.query.
|
|
84
|
+
view.query.ast = newQuery;
|
|
86
85
|
},
|
|
87
86
|
[schema, view],
|
|
88
87
|
);
|
|
@@ -96,7 +95,7 @@ const StoryViewEditor = ({
|
|
|
96
95
|
registry={space?.db.schemaRegistry}
|
|
97
96
|
schema={schema}
|
|
98
97
|
view={view}
|
|
99
|
-
|
|
98
|
+
onQueryChanged={handleQueryChanged}
|
|
100
99
|
onDelete={handleDeleteColumn}
|
|
101
100
|
/>
|
|
102
101
|
);
|
|
@@ -141,7 +140,7 @@ const DefaultStory = () => {
|
|
|
141
140
|
</div>
|
|
142
141
|
<div className='flex flex-col h-full border-l border-separator overflow-y-auto'>
|
|
143
142
|
<StoryViewEditor view={view} schema={schema} space={space} handleDeleteColumn={handleDeleteColumn} />
|
|
144
|
-
<SyntaxHighlighter language='json' className='
|
|
143
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
145
144
|
{JSON.stringify({ view, schema }, null, 2)}
|
|
146
145
|
</SyntaxHighlighter>
|
|
147
146
|
</div>
|
|
@@ -160,21 +159,13 @@ type StoryProps = { rows?: number };
|
|
|
160
159
|
const meta = {
|
|
161
160
|
title: 'ui/react-ui-table/Table',
|
|
162
161
|
render: DefaultStory,
|
|
163
|
-
parameters: {
|
|
164
|
-
translations,
|
|
165
|
-
layout: 'fullscreen',
|
|
166
|
-
controls: {
|
|
167
|
-
disable: true,
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
162
|
decorators: [
|
|
171
163
|
withTheme,
|
|
172
|
-
withLayout({ fullscreen: true }),
|
|
173
164
|
withClientProvider({
|
|
174
165
|
types: [DataType.View, Table.Table],
|
|
175
166
|
createIdentity: true,
|
|
176
167
|
createSpace: true,
|
|
177
|
-
|
|
168
|
+
onCreateSpace: async ({ client, space }) => {
|
|
178
169
|
const [schema] = await space.db.schemaRegistry.register([TestSchema]);
|
|
179
170
|
const { view } = await Table.makeView({ client, space, typename: schema.typename });
|
|
180
171
|
view.projection.fields = [
|
|
@@ -196,6 +187,13 @@ const meta = {
|
|
|
196
187
|
},
|
|
197
188
|
}),
|
|
198
189
|
],
|
|
190
|
+
parameters: {
|
|
191
|
+
layout: 'fullscreen',
|
|
192
|
+
controls: {
|
|
193
|
+
disable: true,
|
|
194
|
+
},
|
|
195
|
+
translations,
|
|
196
|
+
},
|
|
199
197
|
} satisfies Meta<typeof TableComponent>;
|
|
200
198
|
|
|
201
199
|
export default meta;
|
|
@@ -206,13 +204,12 @@ export const Default: Story = {};
|
|
|
206
204
|
|
|
207
205
|
export const StaticSchema: StoryObj = {
|
|
208
206
|
render: DefaultStory,
|
|
209
|
-
parameters: { translations },
|
|
210
207
|
decorators: [
|
|
211
208
|
withClientProvider({
|
|
212
209
|
types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization],
|
|
213
210
|
createIdentity: true,
|
|
214
211
|
createSpace: true,
|
|
215
|
-
|
|
212
|
+
onCreateSpace: async ({ client, space }) => {
|
|
216
213
|
const { view } = await Table.makeView({ client, space, typename: Testing.Contact.typename });
|
|
217
214
|
space.db.add(view);
|
|
218
215
|
|
|
@@ -223,9 +220,11 @@ export const StaticSchema: StoryObj = {
|
|
|
223
220
|
]);
|
|
224
221
|
},
|
|
225
222
|
}),
|
|
226
|
-
withLayout({ fullscreen: true }),
|
|
227
|
-
withTheme,
|
|
228
223
|
],
|
|
224
|
+
parameters: {
|
|
225
|
+
layout: 'fullscreen',
|
|
226
|
+
translations,
|
|
227
|
+
},
|
|
229
228
|
};
|
|
230
229
|
|
|
231
230
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
@@ -247,13 +246,12 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
247
246
|
|
|
248
247
|
export const ArrayOfObjects: StoryObj = {
|
|
249
248
|
render: DefaultStory,
|
|
250
|
-
parameters: { translations },
|
|
251
249
|
decorators: [
|
|
252
250
|
withClientProvider({
|
|
253
251
|
types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
|
|
254
252
|
createIdentity: true,
|
|
255
253
|
createSpace: true,
|
|
256
|
-
|
|
254
|
+
onCreateSpace: async ({ client, space }) => {
|
|
257
255
|
const { view } = await Table.makeView({ client, space, typename: ContactWithArrayOfEmails.typename });
|
|
258
256
|
space.db.add(view);
|
|
259
257
|
|
|
@@ -265,21 +263,22 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
265
263
|
]);
|
|
266
264
|
},
|
|
267
265
|
}),
|
|
268
|
-
withLayout({ fullscreen: true }),
|
|
269
|
-
withTheme,
|
|
270
266
|
],
|
|
267
|
+
parameters: {
|
|
268
|
+
layout: 'fullscreen',
|
|
269
|
+
translations,
|
|
270
|
+
},
|
|
271
271
|
};
|
|
272
272
|
|
|
273
273
|
export const Tags: Meta<StoryProps> = {
|
|
274
274
|
title: 'ui/react-ui-table/Table',
|
|
275
275
|
render: DefaultStory,
|
|
276
|
-
parameters: { translations },
|
|
277
276
|
decorators: [
|
|
278
277
|
withClientProvider({
|
|
279
278
|
types: [DataType.View, Table.Table],
|
|
280
279
|
createIdentity: true,
|
|
281
280
|
createSpace: true,
|
|
282
|
-
|
|
281
|
+
onCreateSpace: async ({ client, space }) => {
|
|
283
282
|
// Configure schema.
|
|
284
283
|
const typename = 'example.com/SingleSelect';
|
|
285
284
|
const selectOptions = [
|
|
@@ -321,7 +320,9 @@ export const Tags: Meta<StoryProps> = {
|
|
|
321
320
|
});
|
|
322
321
|
},
|
|
323
322
|
}),
|
|
324
|
-
withLayout({ fullscreen: true }),
|
|
325
|
-
withTheme,
|
|
326
323
|
],
|
|
324
|
+
parameters: {
|
|
325
|
+
layout: 'fullscreen',
|
|
326
|
+
translations,
|
|
327
|
+
},
|
|
327
328
|
};
|