@dxos/react-ui-table 0.8.4-main.d05673bc65 → 0.8.4-main.d9fc60f731
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-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PTHMYAAM.mjs → chunk-X7A7G6RR.mjs} +28 -83
- package/dist/lib/browser/chunk-X7A7G6RR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-YURROGGF.mjs} +12 -15
- package/dist/lib/browser/chunk-YURROGGF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +230 -280
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +10 -9
- 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-DLAGRBKD.mjs} +12 -15
- package/dist/lib/node-esm/chunk-DLAGRBKD.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-GI72MQSG.mjs → chunk-Q4HSBRJJ.mjs} +28 -83
- package/dist/lib/node-esm/chunk-Q4HSBRJJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +230 -280
- 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 +10 -9
- 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 -22
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +83 -82
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +20 -21
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +85 -84
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +18 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +1 -1
- 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 +22 -24
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.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 +4 -5
- 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 -21
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +11 -5
- 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 +55 -64
- package/src/components/Table/ColumnActionsMenu.tsx +7 -6
- package/src/components/Table/ColumnSettings.tsx +2 -2
- package/src/components/Table/DynamicTable.stories.tsx +19 -19
- package/src/components/Table/DynamicTable.tsx +13 -22
- package/src/components/Table/Relations.stories.tsx +76 -34
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +46 -51
- package/src/components/Table/Table.tsx +37 -426
- package/src/components/Table/TableContent.tsx +426 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +34 -41
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +7 -6
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +14 -12
- package/src/components/TableCellEditor/TableCellEditor.tsx +10 -8
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +11 -16
- 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 -10
- package/src/model/table-model.ts +15 -15
- package/src/model/table-presentation.test.ts +4 -10
- package/src/model/table-presentation.ts +5 -7
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +7 -8
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +12 -13
- package/src/util/dynamic-table.test.ts +13 -20
- package/src/util/dynamic-table.ts +21 -20
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
- package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GI72MQSG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +0 -7
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
- package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
- package/src/components/TableToolbar/index.ts +0 -5
|
@@ -6,25 +6,25 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import * as Schema from 'effect/Schema';
|
|
7
7
|
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import { Annotation, type Database, Format, Obj, type QueryAST, Ref, Type } from '@dxos/echo';
|
|
10
|
-
import { View } from '@dxos/echo';
|
|
9
|
+
import { DXN, Annotation, type Database, Format, Obj, type QueryAST, Ref, Type, View } from '@dxos/echo';
|
|
11
10
|
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
12
11
|
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import {
|
|
12
|
+
import { random } from '@dxos/random';
|
|
14
13
|
import { PublicKey } from '@dxos/react-client';
|
|
15
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
15
|
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
16
|
+
import { ViewEditor } from '@dxos/react-ui-form';
|
|
17
|
+
import { translations as formTranslations } from '@dxos/react-ui-form/translations';
|
|
18
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
19
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
18
|
-
import {
|
|
19
|
-
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
20
|
-
import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
20
|
+
import { ViewModel, getSchemaFromPropertyDefinitions } from '@dxos/schema';
|
|
21
21
|
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
22
22
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
23
23
|
|
|
24
|
+
import { translations } from '#translations';
|
|
25
|
+
|
|
24
26
|
import { useTestTableModel } from '../../testing';
|
|
25
|
-
import { translations } from '../../translations';
|
|
26
27
|
import { Table } from '../../types';
|
|
27
|
-
|
|
28
28
|
import { Table as TableComponent } from './Table';
|
|
29
29
|
|
|
30
30
|
const Example = Schema.Struct({
|
|
@@ -52,10 +52,11 @@ const Example = Schema.Struct({
|
|
|
52
52
|
title: 'Parent',
|
|
53
53
|
}),
|
|
54
54
|
}).pipe(
|
|
55
|
-
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
56
55
|
Annotation.LabelAnnotation.set(['name']),
|
|
56
|
+
// NSID last segment must start with a letter (DXN spec), so prefix the random hex.
|
|
57
|
+
Type.makeObject(DXN.make(`com.example.type.example${PublicKey.random().truncate()}`, '0.1.0')),
|
|
57
58
|
);
|
|
58
|
-
interface Example extends
|
|
59
|
+
interface Example extends Type.InstanceType<typeof Example> {}
|
|
59
60
|
|
|
60
61
|
const StoryViewEditor = ({
|
|
61
62
|
view,
|
|
@@ -64,18 +65,17 @@ const StoryViewEditor = ({
|
|
|
64
65
|
handleDeleteColumn,
|
|
65
66
|
}: {
|
|
66
67
|
view?: View.View;
|
|
67
|
-
schema?:
|
|
68
|
+
schema?: Type.AnyEntity;
|
|
68
69
|
db?: Database.Database;
|
|
69
70
|
handleDeleteColumn: (fieldId: string) => void;
|
|
70
71
|
}) => {
|
|
71
72
|
const handleQueryChanged = useCallback(
|
|
72
73
|
(newQuery: QueryAST.Query) => {
|
|
73
74
|
invariant(schema);
|
|
74
|
-
invariant(Type.
|
|
75
|
-
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
75
|
+
invariant(Type.getDatabase(schema) != null);
|
|
76
76
|
invariant(view);
|
|
77
|
-
Obj.
|
|
78
|
-
|
|
77
|
+
Obj.update(view, (view) => {
|
|
78
|
+
view.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
79
79
|
});
|
|
80
80
|
},
|
|
81
81
|
[schema, view],
|
|
@@ -87,8 +87,8 @@ const StoryViewEditor = ({
|
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
89
|
<ViewEditor
|
|
90
|
-
registry={db?.
|
|
91
|
-
|
|
90
|
+
registry={db?.graph.registry}
|
|
91
|
+
type={schema}
|
|
92
92
|
view={view}
|
|
93
93
|
onQueryChanged={handleQueryChanged}
|
|
94
94
|
onDelete={handleDeleteColumn}
|
|
@@ -119,7 +119,7 @@ const DefaultStory = () => {
|
|
|
119
119
|
|
|
120
120
|
return (
|
|
121
121
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
122
|
-
<TableComponent.Root>
|
|
122
|
+
<TableComponent.Root ref={tableRef}>
|
|
123
123
|
<Panel.Root>
|
|
124
124
|
<Panel.Toolbar asChild>
|
|
125
125
|
<TableComponent.Toolbar
|
|
@@ -129,8 +129,7 @@ const DefaultStory = () => {
|
|
|
129
129
|
/>
|
|
130
130
|
</Panel.Toolbar>
|
|
131
131
|
<Panel.Content asChild>
|
|
132
|
-
<TableComponent.
|
|
133
|
-
ref={tableRef}
|
|
132
|
+
<TableComponent.Content
|
|
134
133
|
schema={schema}
|
|
135
134
|
model={model}
|
|
136
135
|
presentation={presentation}
|
|
@@ -143,16 +142,14 @@ const DefaultStory = () => {
|
|
|
143
142
|
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
144
143
|
<ScrollArea.Viewport>
|
|
145
144
|
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
146
|
-
<
|
|
147
|
-
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
148
|
-
</SyntaxHighlighter>
|
|
145
|
+
<JsonHighlighter data={{ view: table.view.target, schema }} classNames='text-xs' />
|
|
149
146
|
</ScrollArea.Viewport>
|
|
150
147
|
</ScrollArea.Root>
|
|
151
148
|
</div>
|
|
152
149
|
);
|
|
153
150
|
};
|
|
154
151
|
|
|
155
|
-
type
|
|
152
|
+
type DefaultStoryProps = { rows?: number };
|
|
156
153
|
|
|
157
154
|
//
|
|
158
155
|
// Story definitions.
|
|
@@ -172,13 +169,16 @@ const meta = {
|
|
|
172
169
|
createIdentity: true,
|
|
173
170
|
createSpace: true,
|
|
174
171
|
onCreateSpace: async ({ space }) => {
|
|
175
|
-
const
|
|
176
|
-
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
172
|
+
const type = await space.db.addType(Example);
|
|
173
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
174
|
+
db: space.db,
|
|
175
|
+
typename: Type.getTypename(type),
|
|
176
|
+
});
|
|
177
177
|
const table = Table.make({ view, jsonSchema });
|
|
178
|
-
Obj.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
...
|
|
178
|
+
Obj.update(view, (view) => {
|
|
179
|
+
view.projection.fields = [
|
|
180
|
+
view.projection.fields.find((field) => field.path === 'name')!,
|
|
181
|
+
...view.projection.fields.filter((field) => field.path !== 'name'),
|
|
182
182
|
];
|
|
183
183
|
});
|
|
184
184
|
|
|
@@ -186,10 +186,10 @@ const meta = {
|
|
|
186
186
|
|
|
187
187
|
Array.from({ length: 10 }).map(() => {
|
|
188
188
|
return space.db.add(
|
|
189
|
-
Obj.make(
|
|
190
|
-
name:
|
|
191
|
-
status:
|
|
192
|
-
description:
|
|
189
|
+
Obj.make(type, {
|
|
190
|
+
name: random.lorem.sentence(),
|
|
191
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
192
|
+
description: random.lorem.paragraph(),
|
|
193
193
|
}),
|
|
194
194
|
);
|
|
195
195
|
});
|
|
@@ -221,12 +221,12 @@ export const StaticSchema: StoryObj = {
|
|
|
221
221
|
onCreateSpace: async ({ space }) => {
|
|
222
222
|
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
223
223
|
db: space.db,
|
|
224
|
-
typename: TestSchema.Person
|
|
224
|
+
typename: Type.getTypename(TestSchema.Person),
|
|
225
225
|
});
|
|
226
226
|
const table = Table.make({ view, jsonSchema });
|
|
227
227
|
space.db.add(table);
|
|
228
228
|
|
|
229
|
-
const factory = createObjectFactory(space.db,
|
|
229
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
230
230
|
await factory([
|
|
231
231
|
{ type: TestSchema.Person, count: 10 },
|
|
232
232
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -250,12 +250,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
250
250
|
}),
|
|
251
251
|
),
|
|
252
252
|
),
|
|
253
|
-
}).pipe(
|
|
254
|
-
Type.object({
|
|
255
|
-
typename: 'org.dxos.type.contact-with-array-of-emails',
|
|
256
|
-
version: '0.1.0',
|
|
257
|
-
}),
|
|
258
|
-
);
|
|
253
|
+
}).pipe(Type.makeObject(DXN.make('org.dxos.type.contactWithArrayOfEmails', '0.1.0')));
|
|
259
254
|
|
|
260
255
|
export const ArrayOfObjects: StoryObj = {
|
|
261
256
|
render: DefaultStory,
|
|
@@ -267,12 +262,12 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
267
262
|
onCreateSpace: async ({ space }) => {
|
|
268
263
|
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
269
264
|
db: space.db,
|
|
270
|
-
typename: ContactWithArrayOfEmails
|
|
265
|
+
typename: Type.getTypename(ContactWithArrayOfEmails),
|
|
271
266
|
});
|
|
272
267
|
const table = Table.make({ view, jsonSchema });
|
|
273
268
|
space.db.add(table);
|
|
274
269
|
|
|
275
|
-
const factory = createObjectFactory(space.db,
|
|
270
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
276
271
|
await factory([
|
|
277
272
|
// { type: TestSchema.Person, count: 10 },
|
|
278
273
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -287,7 +282,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
287
282
|
},
|
|
288
283
|
};
|
|
289
284
|
|
|
290
|
-
export const Tags: Meta<
|
|
285
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
291
286
|
title: 'ui/react-ui-table/Table',
|
|
292
287
|
render: DefaultStory,
|
|
293
288
|
decorators: [
|
|
@@ -297,7 +292,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
297
292
|
createSpace: true,
|
|
298
293
|
onCreateSpace: async ({ space }) => {
|
|
299
294
|
// Configure schema.
|
|
300
|
-
const typename = 'com.example.type.
|
|
295
|
+
const typename = 'com.example.type.singleSelect';
|
|
301
296
|
const selectOptions = [
|
|
302
297
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
303
298
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -308,7 +303,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
308
303
|
|
|
309
304
|
const selectOptionIds = selectOptions.map((o) => o.id);
|
|
310
305
|
|
|
311
|
-
const
|
|
306
|
+
const type = getSchemaFromPropertyDefinitions(typename, [
|
|
312
307
|
{
|
|
313
308
|
name: 'single',
|
|
314
309
|
format: Format.TypeFormat.SingleSelect,
|
|
@@ -320,7 +315,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
320
315
|
config: { options: selectOptions },
|
|
321
316
|
},
|
|
322
317
|
]);
|
|
323
|
-
const
|
|
318
|
+
const storedType = await space.db.addType(type);
|
|
324
319
|
|
|
325
320
|
// Initialize table.
|
|
326
321
|
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
@@ -330,9 +325,9 @@ export const Tags: Meta<StoryProps> = {
|
|
|
330
325
|
// Populate.
|
|
331
326
|
Array.from({ length: 10 }).map(() => {
|
|
332
327
|
return space.db.add(
|
|
333
|
-
Obj.make(
|
|
334
|
-
single:
|
|
335
|
-
multiple:
|
|
328
|
+
Obj.make(Type.assertObject(storedType), {
|
|
329
|
+
single: random.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
330
|
+
multiple: random.helpers.randomSubset(selectOptionIds),
|
|
336
331
|
}),
|
|
337
332
|
);
|
|
338
333
|
});
|