@dxos/react-ui-table 0.8.1 → 0.8.2-main.2f9c567
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-UGGYKLOH.mjs +28 -0
- package/dist/lib/browser/chunk-UGGYKLOH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +91 -126
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-TGG6OZ54.cjs → chunk-2QLLIPZK.cjs} +13 -11
- package/dist/lib/node/chunk-2QLLIPZK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +145 -180
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-KKLP54L3.mjs → chunk-N2RRVR7F.mjs} +11 -9
- package/dist/lib/node-esm/chunk-N2RRVR7F.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +91 -126
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +40 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- 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/types/table.d.ts +43 -43
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +0 -14
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +2 -2
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/dist/types/src/util/tag.d.ts +11 -0
- package/dist/types/src/util/tag.d.ts.map +1 -0
- package/package.json +35 -33
- package/src/components/Table/CreateRefPanel.tsx +5 -5
- package/src/components/Table/DynamicTable.stories.tsx +2 -2
- package/src/components/Table/Table.stories.tsx +10 -11
- package/src/components/Table/Table.tsx +18 -24
- package/src/components/Table/relations.stories.tsx +34 -24
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +3 -3
- package/src/components/TableToolbar/TableToolbar.tsx +2 -2
- package/src/components/testing.ts +10 -9
- package/src/hooks/useTableModel.ts +2 -2
- package/src/model/modal-controller.ts +3 -3
- package/src/model/table-model.test.ts +7 -6
- package/src/model/table-model.ts +19 -2
- package/src/model/table-presentation.test.ts +7 -6
- package/src/model/table-presentation.ts +3 -5
- package/src/types/table.ts +16 -8
- package/src/util/dynamic-table.ts +2 -2
- package/src/util/table-buttons.ts +0 -23
- package/src/util/table.ts +10 -14
- package/src/util/tag.ts +33 -0
- package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
- package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
- package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
- package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
- package/src/components/Table/RefPanel.tsx +0 -52
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/util/table.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/util/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAC;AAW3C,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAiB,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,oDAMzB,oBAAoB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CA0C3D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex pattern for matching tags in the format [Label](id)
|
|
3
|
+
*/
|
|
4
|
+
export declare const TAG_PATTERN_REGEX: RegExp;
|
|
5
|
+
/**
|
|
6
|
+
* Extracts tag IDs from a string in the format [Label](id)
|
|
7
|
+
* @param value The string to extract IDs from
|
|
8
|
+
* @returns Array of extracted IDs or undefined if no matches or value is not a string
|
|
9
|
+
*/
|
|
10
|
+
export declare const extractTagIds: (value: unknown) => string[] | undefined;
|
|
11
|
+
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/util/tag.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAA6B,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,MAAM,EAAE,GAAG,SAgBzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-table",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-main.2f9c567",
|
|
4
4
|
"description": "A table component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -51,31 +51,33 @@
|
|
|
51
51
|
"@radix-ui/react-slot": "1.1.2",
|
|
52
52
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
53
53
|
"date-fns": "^3.3.1",
|
|
54
|
+
"effect": "3.14.21",
|
|
54
55
|
"lodash.orderby": "^4.6.0",
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/effect": "0.8.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/lit-grid": "0.8.
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/react-
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/react-ui-
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/react-ui-
|
|
76
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
56
|
+
"@dxos/debug": "0.8.2-main.2f9c567",
|
|
57
|
+
"@dxos/echo-schema": "0.8.2-main.2f9c567",
|
|
58
|
+
"@dxos/effect": "0.8.2-main.2f9c567",
|
|
59
|
+
"@dxos/context": "0.8.2-main.2f9c567",
|
|
60
|
+
"@dxos/invariant": "0.8.2-main.2f9c567",
|
|
61
|
+
"@dxos/lit-grid": "0.8.2-main.2f9c567",
|
|
62
|
+
"@dxos/echo": "0.8.2-main.2f9c567",
|
|
63
|
+
"@dxos/keys": "0.8.2-main.2f9c567",
|
|
64
|
+
"@dxos/live-object": "0.8.2-main.2f9c567",
|
|
65
|
+
"@dxos/log": "0.8.2-main.2f9c567",
|
|
66
|
+
"@dxos/plugin-search": "0.8.2-main.2f9c567",
|
|
67
|
+
"@dxos/plugin-space": "0.8.2-main.2f9c567",
|
|
68
|
+
"@dxos/react-client": "0.8.2-main.2f9c567",
|
|
69
|
+
"@dxos/react-ui-attention": "0.8.2-main.2f9c567",
|
|
70
|
+
"@dxos/react-ui-editor": "0.8.2-main.2f9c567",
|
|
71
|
+
"@dxos/react-ui-form": "0.8.2-main.2f9c567",
|
|
72
|
+
"@dxos/react-ui-grid": "0.8.2-main.2f9c567",
|
|
73
|
+
"@dxos/react-ui-menu": "0.8.2-main.2f9c567",
|
|
74
|
+
"@dxos/react-ui-stack": "0.8.2-main.2f9c567",
|
|
75
|
+
"@dxos/react-ui-searchlist": "0.8.2-main.2f9c567",
|
|
76
|
+
"@dxos/react-ui-tag-picker": "0.8.2-main.2f9c567",
|
|
77
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.2-main.2f9c567",
|
|
78
|
+
"@dxos/react-ui-types": "0.8.2-main.2f9c567",
|
|
79
|
+
"@dxos/schema": "0.8.2-main.2f9c567",
|
|
80
|
+
"@dxos/util": "0.8.2-main.2f9c567"
|
|
79
81
|
},
|
|
80
82
|
"devDependencies": {
|
|
81
83
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -86,19 +88,19 @@
|
|
|
86
88
|
"react": "~18.2.0",
|
|
87
89
|
"react-dom": "~18.2.0",
|
|
88
90
|
"vite": "5.4.7",
|
|
89
|
-
"@dxos/echo-signals": "0.8.
|
|
90
|
-
"@dxos/random": "0.8.
|
|
91
|
-
"@dxos/react-ui": "0.8.
|
|
92
|
-
"@dxos/react-ui-theme": "0.8.
|
|
93
|
-
"@dxos/storybook-utils": "0.8.
|
|
94
|
-
"@dxos/test-utils": "0.8.
|
|
91
|
+
"@dxos/echo-signals": "0.8.2-main.2f9c567",
|
|
92
|
+
"@dxos/random": "0.8.2-main.2f9c567",
|
|
93
|
+
"@dxos/react-ui": "0.8.2-main.2f9c567",
|
|
94
|
+
"@dxos/react-ui-theme": "0.8.2-main.2f9c567",
|
|
95
|
+
"@dxos/storybook-utils": "0.8.2-main.2f9c567",
|
|
96
|
+
"@dxos/test-utils": "0.8.2-main.2f9c567"
|
|
95
97
|
},
|
|
96
98
|
"peerDependencies": {
|
|
97
99
|
"@phosphor-icons/react": "^2.1.5",
|
|
98
100
|
"react": "~18.2.0",
|
|
99
101
|
"react-dom": "~18.2.0",
|
|
100
|
-
"@dxos/react-ui
|
|
101
|
-
"@dxos/react-ui": "0.8.
|
|
102
|
+
"@dxos/react-ui": "0.8.2-main.2f9c567",
|
|
103
|
+
"@dxos/react-ui-theme": "0.8.2-main.2f9c567"
|
|
102
104
|
},
|
|
103
105
|
"publishConfig": {
|
|
104
106
|
"access": "public"
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
import React, { useCallback, useMemo } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import { create } from '@dxos/react-client/echo';
|
|
8
|
+
import { live } from '@dxos/react-client/echo';
|
|
9
9
|
import { Popover } from '@dxos/react-ui';
|
|
10
10
|
import { Form } from '@dxos/react-ui-form';
|
|
11
11
|
import { type GridScopedProps, useGridContext } from '@dxos/react-ui-grid';
|
|
@@ -20,14 +20,14 @@ export const CreateRefPanel = ({ model, modals, __gridScope }: GridScopedProps<C
|
|
|
20
20
|
const space = model?.space;
|
|
21
21
|
const state = modals.state.value;
|
|
22
22
|
|
|
23
|
-
const schema = useMemo<
|
|
23
|
+
const schema = useMemo<Schema.Schema<any> | undefined>(() => {
|
|
24
24
|
if (!space || state?.type !== 'createRefPanel') {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const [schema] = space.db.schemaRegistry.query({ typename: state.typename }).runSync();
|
|
29
29
|
if (schema) {
|
|
30
|
-
const omit =
|
|
30
|
+
const omit = Schema.omit<any, any, ['id']>('id');
|
|
31
31
|
return omit(schema);
|
|
32
32
|
}
|
|
33
33
|
}, [space, state]);
|
|
@@ -40,7 +40,7 @@ export const CreateRefPanel = ({ model, modals, __gridScope }: GridScopedProps<C
|
|
|
40
40
|
|
|
41
41
|
const [schema] = space.db.schemaRegistry.query({ typename: state.typename }).runSync();
|
|
42
42
|
if (schema) {
|
|
43
|
-
const obj = space.db.add(
|
|
43
|
+
const obj = space.db.add(live(schema, values));
|
|
44
44
|
state.onCreate?.(obj);
|
|
45
45
|
}
|
|
46
46
|
void modals.close();
|
|
@@ -10,7 +10,7 @@ import React, { useMemo, useState } from 'react';
|
|
|
10
10
|
import { FormatEnum, type JsonSchemaType } from '@dxos/echo-schema';
|
|
11
11
|
import { faker } from '@dxos/random';
|
|
12
12
|
import { useClient } from '@dxos/react-client';
|
|
13
|
-
import { Filter, useQuery, useSchema,
|
|
13
|
+
import { Filter, useQuery, useSchema, live } from '@dxos/react-client/echo';
|
|
14
14
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
15
15
|
import { type SchemaPropertyDefinition } from '@dxos/schema';
|
|
16
16
|
import { Testing } from '@dxos/schema/testing';
|
|
@@ -143,7 +143,7 @@ export const WithEchoSchema: StoryObj = {
|
|
|
143
143
|
onSpaceCreated: async ({ space }) => {
|
|
144
144
|
Array.from({ length: 10 }).forEach(() => {
|
|
145
145
|
space.db.add(
|
|
146
|
-
|
|
146
|
+
live(Testing.Contact, {
|
|
147
147
|
name: faker.person.fullName(),
|
|
148
148
|
email: faker.internet.email(),
|
|
149
149
|
}),
|
|
@@ -12,7 +12,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
12
12
|
import { useGlobalFilteredObjects } from '@dxos/plugin-search';
|
|
13
13
|
import { faker } from '@dxos/random';
|
|
14
14
|
import { useClient } from '@dxos/react-client';
|
|
15
|
-
import { Filter, useQuery, useSchema,
|
|
15
|
+
import { Filter, useQuery, useSchema, live } from '@dxos/react-client/echo';
|
|
16
16
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
17
17
|
import { ViewEditor } from '@dxos/react-ui-form';
|
|
18
18
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
@@ -28,8 +28,7 @@ import { TableType } from '../../types';
|
|
|
28
28
|
import { initializeTable } from '../../util';
|
|
29
29
|
import { TableToolbar } from '../TableToolbar';
|
|
30
30
|
|
|
31
|
-
// NOTE(ZaymonFC):
|
|
32
|
-
faker.seed(0);
|
|
31
|
+
faker.seed(0); // NOTE(ZaymonFC): Required for smoke tests.
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* Custom hook to create and manage a test table model for storybook demonstrations.
|
|
@@ -73,7 +72,7 @@ const useTestTableModel = () => {
|
|
|
73
72
|
|
|
74
73
|
const handleInsertRow = useCallback(() => {
|
|
75
74
|
if (space && schema) {
|
|
76
|
-
space.db.add(
|
|
75
|
+
space.db.add(live(schema, {}));
|
|
77
76
|
}
|
|
78
77
|
}, [space, schema]);
|
|
79
78
|
|
|
@@ -222,11 +221,11 @@ const meta: Meta<StoryProps> = {
|
|
|
222
221
|
createIdentity: true,
|
|
223
222
|
createSpace: true,
|
|
224
223
|
onSpaceCreated: async ({ client, space }) => {
|
|
225
|
-
const table = space.db.add(
|
|
224
|
+
const table = space.db.add(live(TableType, {}));
|
|
226
225
|
const schema = await initializeTable({ client, space, table, initialRow: false });
|
|
227
226
|
Array.from({ length: 10 }).map(() => {
|
|
228
227
|
return space.db.add(
|
|
229
|
-
|
|
228
|
+
live(schema, {
|
|
230
229
|
name: faker.person.fullName(),
|
|
231
230
|
}),
|
|
232
231
|
);
|
|
@@ -247,17 +246,17 @@ export const StaticSchema: StoryObj = {
|
|
|
247
246
|
parameters: { translations },
|
|
248
247
|
decorators: [
|
|
249
248
|
withClientProvider({
|
|
250
|
-
types: [TableType, ViewType, Testing.Contact, Testing.
|
|
249
|
+
types: [TableType, ViewType, Testing.Contact, Testing.Organization],
|
|
251
250
|
createIdentity: true,
|
|
252
251
|
createSpace: true,
|
|
253
252
|
onSpaceCreated: async ({ client, space }) => {
|
|
254
|
-
const table = space.db.add(
|
|
253
|
+
const table = space.db.add(live(TableType, {}));
|
|
255
254
|
await initializeTable({ client, space, table, typename: Testing.Contact.typename });
|
|
256
255
|
|
|
257
256
|
const factory = createObjectFactory(space.db, faker as any);
|
|
258
257
|
await factory([
|
|
259
258
|
{ type: Testing.Contact, count: 10 },
|
|
260
|
-
{ type: Testing.
|
|
259
|
+
{ type: Testing.Organization, count: 1 },
|
|
261
260
|
]);
|
|
262
261
|
},
|
|
263
262
|
}),
|
|
@@ -303,13 +302,13 @@ export const Tags: Meta<StoryProps> = {
|
|
|
303
302
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
304
303
|
|
|
305
304
|
// Initialize table.
|
|
306
|
-
const table = space.db.add(
|
|
305
|
+
const table = space.db.add(live(TableType, {}));
|
|
307
306
|
await initializeTable({ client, space, table, initialRow: false, typename });
|
|
308
307
|
|
|
309
308
|
// Populate.
|
|
310
309
|
Array.from({ length: 10 }).map(() => {
|
|
311
310
|
return space.db.add(
|
|
312
|
-
|
|
311
|
+
live(storedSchema, {
|
|
313
312
|
single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
314
313
|
multiple: faker.helpers.randomSubset(selectOptionIds),
|
|
315
314
|
}),
|
|
@@ -19,27 +19,29 @@ import { invariant } from '@dxos/invariant';
|
|
|
19
19
|
import { Filter } from '@dxos/react-client/echo';
|
|
20
20
|
import { useTranslation } from '@dxos/react-ui';
|
|
21
21
|
import { useAttention } from '@dxos/react-ui-attention';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
closestCell,
|
|
24
|
+
type DxGridElement,
|
|
25
|
+
type DxGridPosition,
|
|
26
|
+
type GridContentProps,
|
|
27
|
+
Grid,
|
|
28
|
+
type DxGridPlane,
|
|
29
|
+
type DxGridPlaneRange,
|
|
30
|
+
gridSeparatorInlineEnd,
|
|
31
|
+
gridSeparatorBlockEnd,
|
|
32
|
+
} from '@dxos/react-ui-grid';
|
|
23
33
|
import { mx } from '@dxos/react-ui-theme';
|
|
24
34
|
import { isNotFalsy, safeParseInt } from '@dxos/util';
|
|
25
35
|
|
|
26
36
|
import { ColumnActionsMenu } from './ColumnActionsMenu';
|
|
27
37
|
import { ColumnSettings } from './ColumnSettings';
|
|
28
38
|
import { CreateRefPanel } from './CreateRefPanel';
|
|
29
|
-
import { RefPanel } from './RefPanel';
|
|
30
39
|
import { RowActionsMenu } from './RowActionsMenu';
|
|
31
40
|
import { ModalController, type TableModel, type TablePresentation } from '../../model';
|
|
32
41
|
import { translationKey } from '../../translations';
|
|
33
42
|
import { tableButtons, tableControls } from '../../util';
|
|
34
43
|
import { createOption, TableCellEditor, type TableCellEditorProps } from '../TableCellEditor';
|
|
35
44
|
|
|
36
|
-
// NOTE(Zan): These fragments add border to inline-end and block-end of the grid using pseudo-elements.
|
|
37
|
-
// These are offset by 1px to avoid double borders in planks.
|
|
38
|
-
const inlineEndLine =
|
|
39
|
-
'[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-block-0 [&>.dx-grid]:after:-inline-end-px [&>.dx-grid]:after:is-px [&>.dx-grid]:after:bg-separator';
|
|
40
|
-
const blockEndLine =
|
|
41
|
-
'[&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-inline-0 [&>.dx-grid]:before:-block-end-px [&>.dx-grid]:before:bs-px [&>.dx-grid]:before:bg-separator';
|
|
42
|
-
|
|
43
45
|
//
|
|
44
46
|
// Table.Root
|
|
45
47
|
//
|
|
@@ -98,20 +100,17 @@ const TableMain = forwardRef<TableController, TableMainProps>(
|
|
|
98
100
|
};
|
|
99
101
|
}, [model]);
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// );
|
|
103
|
+
const getCells = useCallback<NonNullable<GridContentProps['getCells']>>(
|
|
104
|
+
(range: DxGridPlaneRange, plane: DxGridPlane) => presentation?.getCells(range, plane) ?? {},
|
|
105
|
+
[presentation],
|
|
106
|
+
);
|
|
106
107
|
|
|
107
108
|
useEffect(() => {
|
|
108
109
|
if (!presentation || !dxGrid) {
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
dxGrid.getCells = (range, plane) => presentation.getCells(range, plane);
|
|
114
|
-
}, [presentation, dxGrid]);
|
|
112
|
+
dxGrid.getCells = getCells;
|
|
113
|
+
}, [presentation, dxGrid, getCells]);
|
|
115
114
|
|
|
116
115
|
/**
|
|
117
116
|
* Provides an external controller that can be called to repaint the table.
|
|
@@ -181,10 +180,6 @@ const TableMain = forwardRef<TableController, TableMainProps>(
|
|
|
181
180
|
modals.showColumnCreator();
|
|
182
181
|
break;
|
|
183
182
|
}
|
|
184
|
-
case 'referencedCell': {
|
|
185
|
-
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
183
|
case 'sort': {
|
|
189
184
|
model?.sorting?.toggleSort(data.fieldId);
|
|
190
185
|
break;
|
|
@@ -356,7 +351,7 @@ const TableMain = forwardRef<TableController, TableMainProps>(
|
|
|
356
351
|
onQuery={handleQuery}
|
|
357
352
|
/>
|
|
358
353
|
<Grid.Content
|
|
359
|
-
className={mx('[--dx-grid-base:var(--surface-bg)]',
|
|
354
|
+
className={mx('[--dx-grid-base:var(--surface-bg)]', gridSeparatorInlineEnd, gridSeparatorBlockEnd)}
|
|
360
355
|
frozen={frozen}
|
|
361
356
|
// getCells={getCells}
|
|
362
357
|
columns={model.columnMeta.value}
|
|
@@ -373,7 +368,6 @@ const TableMain = forwardRef<TableController, TableMainProps>(
|
|
|
373
368
|
<ColumnActionsMenu model={model} modals={modals} />
|
|
374
369
|
<ColumnSettings model={model} modals={modals} onNewColumn={handleNewColumn} />
|
|
375
370
|
<CreateRefPanel model={model} modals={modals} />
|
|
376
|
-
<RefPanel model={model} modals={modals} />
|
|
377
371
|
</Grid.Root>
|
|
378
372
|
);
|
|
379
373
|
},
|
|
@@ -5,20 +5,21 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import { SchemaAST } from 'effect';
|
|
8
9
|
import React, { useEffect, useMemo } from 'react';
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
+
import { type BaseObject, ImmutableSchema, type BaseSchema, type HasId } from '@dxos/echo-schema';
|
|
11
12
|
import { getAnnotation } from '@dxos/effect';
|
|
12
13
|
import { faker } from '@dxos/random';
|
|
13
|
-
import {
|
|
14
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
|
-
import { createView, ViewProjection, ViewType } from '@dxos/schema';
|
|
16
|
-
import {
|
|
14
|
+
import { live, makeRef } from '@dxos/react-client/echo';
|
|
15
|
+
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { DataType, createView, ViewProjection, ViewType } from '@dxos/schema';
|
|
17
|
+
import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
|
|
17
18
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
19
|
|
|
19
20
|
import { Table } from './Table';
|
|
20
21
|
import { useTableModel } from '../../hooks';
|
|
21
|
-
import { TablePresentation } from '../../model';
|
|
22
|
+
import { type TableFeatures, TablePresentation, type TableRow } from '../../model';
|
|
22
23
|
import translations from '../../translations';
|
|
23
24
|
import { TableType } from '../../types';
|
|
24
25
|
|
|
@@ -30,12 +31,14 @@ const generator: ValueGenerator = faker as any;
|
|
|
30
31
|
// TODO(burdon): Reconcile schemas types and utils (see API PR).
|
|
31
32
|
// TODO(burdon): Base type for T (with id); see ECHO API PR?
|
|
32
33
|
const useTestModel = <T extends BaseObject & HasId>(schema: BaseSchema<T>, count: number) => {
|
|
34
|
+
const { space } = useClientProvider();
|
|
35
|
+
|
|
33
36
|
const table = useMemo(() => {
|
|
34
|
-
// const { typename } = pipe(schema.ast,
|
|
37
|
+
// const { typename } = pipe(schema.ast, SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId), Option.getOrThrow);
|
|
35
38
|
const typename = schema.typename;
|
|
36
|
-
const name = getAnnotation<string>(
|
|
39
|
+
const name = getAnnotation<string>(SchemaAST.TitleAnnotationId)(schema.ast) ?? typename;
|
|
37
40
|
const view = createView({ name, typename, jsonSchema: schema.jsonSchema });
|
|
38
|
-
return
|
|
41
|
+
return live(TableType, { view: makeRef(view) });
|
|
39
42
|
}, [schema]);
|
|
40
43
|
|
|
41
44
|
const projection = useMemo(() => {
|
|
@@ -47,16 +50,24 @@ const useTestModel = <T extends BaseObject & HasId>(schema: BaseSchema<T>, count
|
|
|
47
50
|
return new ViewProjection(schema.jsonSchema, table.view.target);
|
|
48
51
|
}, [schema, table]);
|
|
49
52
|
|
|
50
|
-
const
|
|
53
|
+
const features = useMemo<TableFeatures>(
|
|
54
|
+
() => ({ schemaEditable: false, dataEditable: true, selection: { enabled: false } }),
|
|
55
|
+
[],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const model = useTableModel<TableRow>({ table, projection, rows: [], features });
|
|
51
59
|
useEffect(() => {
|
|
52
|
-
if (!model) {
|
|
60
|
+
if (!model || !space) {
|
|
53
61
|
return;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
const objectGenerator =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
const objectGenerator = createAsyncGenerator(generator, schema, { optional: true, db: space?.db });
|
|
65
|
+
void objectGenerator.createObjects(count).then((objects) => {
|
|
66
|
+
model.setRows(objects);
|
|
67
|
+
});
|
|
68
|
+
}, [model, space]);
|
|
69
|
+
|
|
70
|
+
console.log(projection?.getFieldProjections());
|
|
60
71
|
|
|
61
72
|
const presentation = useMemo(() => {
|
|
62
73
|
if (!model) {
|
|
@@ -71,21 +82,20 @@ const useTestModel = <T extends BaseObject & HasId>(schema: BaseSchema<T>, count
|
|
|
71
82
|
|
|
72
83
|
const DefaultStory = () => {
|
|
73
84
|
// TODO(burdon): Remove need for ImmutableSchema wrapper at API-level.
|
|
74
|
-
const orgSchema = useMemo(() => new ImmutableSchema(
|
|
75
|
-
const { model: orgModel, presentation: orgPresentation } = useTestModel<
|
|
85
|
+
const orgSchema = useMemo(() => new ImmutableSchema(DataType.Organization), []);
|
|
86
|
+
const { model: orgModel, presentation: orgPresentation } = useTestModel<DataType.Organization>(orgSchema, 50);
|
|
76
87
|
|
|
77
88
|
// TODO(burdon): Generate links with references.
|
|
78
|
-
const contactSchema = useMemo(() => new ImmutableSchema(
|
|
79
|
-
const { model: contactModel, presentation: contactPresentation } = useTestModel<
|
|
89
|
+
const contactSchema = useMemo(() => new ImmutableSchema(DataType.Person), []);
|
|
90
|
+
const { model: contactModel, presentation: contactPresentation } = useTestModel<DataType.Person>(contactSchema, 50);
|
|
80
91
|
|
|
81
|
-
// TODO(burdon): Scrolling isn't working.
|
|
82
92
|
return (
|
|
83
|
-
<div className='
|
|
93
|
+
<div className='is-full bs-full grid grid-cols-2 divide-x divide-separator'>
|
|
84
94
|
<Table.Root>
|
|
85
|
-
<Table.Main model={orgModel} presentation={orgPresentation} />
|
|
95
|
+
<Table.Main model={orgModel} presentation={orgPresentation} ignoreAttention />
|
|
86
96
|
</Table.Root>
|
|
87
97
|
<Table.Root>
|
|
88
|
-
<Table.Main model={contactModel} presentation={contactPresentation} />
|
|
98
|
+
<Table.Main model={contactModel} presentation={contactPresentation} ignoreAttention />
|
|
89
99
|
</Table.Root>
|
|
90
100
|
</div>
|
|
91
101
|
);
|
|
@@ -97,7 +107,7 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
97
107
|
parameters: { translations },
|
|
98
108
|
decorators: [
|
|
99
109
|
withClientProvider({
|
|
100
|
-
types: [TableType, ViewType,
|
|
110
|
+
types: [TableType, ViewType, DataType.Organization, DataType.Person],
|
|
101
111
|
createIdentity: true,
|
|
102
112
|
createSpace: true,
|
|
103
113
|
}),
|
|
@@ -10,7 +10,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
10
10
|
import { ImmutableSchema, type EchoSchema } from '@dxos/echo-schema';
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
|
-
import { Filter, useQuery,
|
|
13
|
+
import { Filter, useQuery, live } from '@dxos/react-client/echo';
|
|
14
14
|
import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
15
15
|
import { defaultSizeRow, Grid, type GridEditing } from '@dxos/react-ui-grid';
|
|
16
16
|
import { ViewProjection, ViewType } from '@dxos/schema';
|
|
@@ -95,11 +95,11 @@ const meta: Meta<StoryProps> = {
|
|
|
95
95
|
createIdentity: true,
|
|
96
96
|
createSpace: true,
|
|
97
97
|
onSpaceCreated: async ({ client, space }) => {
|
|
98
|
-
const table = space.db.add(
|
|
98
|
+
const table = space.db.add(live(TableType, {}));
|
|
99
99
|
const schema = await initializeTable({ client, space, table });
|
|
100
100
|
Array.from({ length: 10 }).forEach(() => {
|
|
101
101
|
space.db.add(
|
|
102
|
-
|
|
102
|
+
live(schema, {
|
|
103
103
|
name: faker.person.fullName(),
|
|
104
104
|
}),
|
|
105
105
|
);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { live } from '@dxos/live-object';
|
|
8
8
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
9
|
import {
|
|
10
10
|
createGapSeparator,
|
|
@@ -60,7 +60,7 @@ const createTableToolbarActions = (state: TableToolbarState) => {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
export const TableToolbar = ({ classNames, viewDirty, attendableId, onAction }: TableToolbarProps) => {
|
|
63
|
-
const state = useMemo(() =>
|
|
63
|
+
const state = useMemo(() => live<TableToolbarState>({ viewDirty }), []);
|
|
64
64
|
const actionsCreator = useCallback(() => createTableToolbarActions(state), [state]);
|
|
65
65
|
const menu = useMenuActions(actionsCreator);
|
|
66
66
|
|
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
import { useEffect } from 'react';
|
|
6
7
|
|
|
7
|
-
import { setValue, toJsonSchema,
|
|
8
|
+
import { setValue, toJsonSchema, TypeEnum, TypedObject, FormatEnum, ObjectId } from '@dxos/echo-schema';
|
|
8
9
|
import { faker } from '@dxos/random';
|
|
9
|
-
import {
|
|
10
|
+
import { live, makeRef } from '@dxos/react-client/echo';
|
|
10
11
|
import { createView, type ViewProjection } from '@dxos/schema';
|
|
11
12
|
|
|
12
13
|
import { TableType } from '../types';
|
|
13
14
|
|
|
14
15
|
export const TestSchema = TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
|
|
15
|
-
id:
|
|
16
|
-
name:
|
|
17
|
-
age:
|
|
18
|
-
active:
|
|
19
|
-
netWorth:
|
|
16
|
+
id: ObjectId,
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
|
+
age: Schema.optional(Schema.Number),
|
|
19
|
+
active: Schema.optional(Schema.Boolean),
|
|
20
|
+
netWorth: Schema.optional(Schema.Number),
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
export const createTable = (schema = TestSchema) => {
|
|
23
|
-
return
|
|
24
|
+
return live(TableType, {
|
|
24
25
|
view: makeRef(
|
|
25
26
|
createView({
|
|
26
27
|
name: 'Test',
|
|
@@ -32,7 +33,7 @@ export const createTable = (schema = TestSchema) => {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export const createItems = (n: number) => {
|
|
35
|
-
const { data } =
|
|
36
|
+
const { data } = live({
|
|
36
37
|
data: Array.from({ length: n }, () => ({
|
|
37
38
|
name: faker.person.fullName(),
|
|
38
39
|
age: faker.number.int({ min: 20, max: 70 }),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { effect } from '@preact/signals-core';
|
|
6
6
|
import { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { fullyQualifiedId, getSpace, type
|
|
8
|
+
import { fullyQualifiedId, getSpace, type Live } from '@dxos/react-client/echo';
|
|
9
9
|
import { useSelectionActions } from '@dxos/react-ui-attention';
|
|
10
10
|
import { type ViewProjection } from '@dxos/schema';
|
|
11
11
|
import { isNonNullable } from '@dxos/util';
|
|
@@ -16,7 +16,7 @@ import { type TableType } from '../types';
|
|
|
16
16
|
export type UseTableModelParams<T extends TableRow = TableRow> = {
|
|
17
17
|
table?: TableType;
|
|
18
18
|
projection?: ViewProjection;
|
|
19
|
-
rows?:
|
|
19
|
+
rows?: Live<T>[];
|
|
20
20
|
rowActions?: TableRowAction[];
|
|
21
21
|
onSelectionChanged?: (selection: string[]) => void;
|
|
22
22
|
onRowAction?: (actionId: string, data: T) => void;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { signal } from '@preact/signals-core';
|
|
6
6
|
import { type RefObject, type MutableRefObject } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type Live } from '@dxos/live-object';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
|
|
11
11
|
export type ColumnSettingsMode = { type: 'create' } | { type: 'edit'; fieldId: string };
|
|
@@ -18,7 +18,7 @@ export type ModalState =
|
|
|
18
18
|
type: 'createRefPanel';
|
|
19
19
|
typename: string;
|
|
20
20
|
initialValues?: Record<string, string>;
|
|
21
|
-
onCreate?: (obj:
|
|
21
|
+
onCreate?: (obj: Live<any>) => void;
|
|
22
22
|
}
|
|
23
23
|
| { type: 'columnSettings'; mode: ColumnSettingsMode }
|
|
24
24
|
| { type: 'closed' };
|
|
@@ -72,7 +72,7 @@ export class ModalController {
|
|
|
72
72
|
typename: string,
|
|
73
73
|
anchorCell: Element | null,
|
|
74
74
|
initialValues?: Record<string, string>,
|
|
75
|
-
onCreate?: (obj:
|
|
75
|
+
onCreate?: (obj: Live<any>) => void,
|
|
76
76
|
) => {
|
|
77
77
|
if (anchorCell) {
|
|
78
78
|
this._triggerRef.current = anchorCell as HTMLElement;
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { computed } from '@preact/signals-core';
|
|
6
|
+
import { Schema } from 'effect';
|
|
6
7
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { TypedObject } from '@dxos/echo-schema';
|
|
9
10
|
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
10
11
|
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
11
12
|
import { createEchoSchema } from '@dxos/live-object/testing';
|
|
12
|
-
import {
|
|
13
|
+
import { live, makeRef } from '@dxos/react-client/echo';
|
|
13
14
|
import { createView, ViewProjection } from '@dxos/schema';
|
|
14
15
|
|
|
15
16
|
import { TableModel, type TableModelProps } from './table-model';
|
|
@@ -69,7 +70,7 @@ describe('TableModel', () => {
|
|
|
69
70
|
|
|
70
71
|
describe('reactivity', () => {
|
|
71
72
|
it('pure signals should nest', () => {
|
|
72
|
-
const signal$ =
|
|
73
|
+
const signal$ = live({ arr: [{ thingInside: 1 }, { thingInside: 2 }] });
|
|
73
74
|
|
|
74
75
|
const computed$ = computed(() => {
|
|
75
76
|
return signal$.arr.map((row) =>
|
|
@@ -99,14 +100,14 @@ describe('TableModel', () => {
|
|
|
99
100
|
});
|
|
100
101
|
|
|
101
102
|
class Test extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
|
|
102
|
-
title:
|
|
103
|
-
completed:
|
|
103
|
+
title: Schema.String,
|
|
104
|
+
completed: Schema.Boolean,
|
|
104
105
|
}) {}
|
|
105
106
|
|
|
106
107
|
const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
|
|
107
108
|
const schema = createEchoSchema(Test);
|
|
108
109
|
const view = createView({ name: 'Test', typename: schema.typename, jsonSchema: schema.jsonSchema });
|
|
109
110
|
const projection = new ViewProjection(schema.jsonSchema, view);
|
|
110
|
-
const table =
|
|
111
|
+
const table = live(TableType, { view: makeRef(view) });
|
|
111
112
|
return new TableModel({ id: table.id, space: undefined, view, projection, ...props });
|
|
112
113
|
};
|