@dxos/react-ui-table 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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-OZBLY7XM.mjs → chunk-BF54SSNL.mjs} +12 -18
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-I5IFW7UF.mjs → chunk-EK6D2CVM.mjs} +37 -32
- package/dist/lib/browser/chunk-EK6D2CVM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +200 -173
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +4 -4
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-DDJKYJFY.mjs → chunk-LYYDF6JP.mjs} +37 -32
- package/dist/lib/node-esm/chunk-LYYDF6JP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WNZSKIRF.mjs → chunk-SIRDIPHZ.mjs} +12 -18
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +200 -173
- 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 +4 -4
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +5 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +20 -22
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +80 -82
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +28 -21
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +82 -84
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +21 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +25 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -3
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
- 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/hooks/useAddRow.d.ts +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +1 -1
- package/dist/types/src/model/table-model.d.ts +5 -4
- 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 +2 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +2 -2
- 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 +1 -6
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +6 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
- package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -43
- package/src/components/Table/ColumnActionsMenu.tsx +5 -5
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +6 -5
- package/src/components/Table/DynamicTable.tsx +13 -19
- package/src/components/Table/Relations.stories.tsx +35 -25
- package/src/components/Table/Table.stories.tsx +61 -40
- package/src/components/Table/Table.tsx +41 -434
- package/src/components/Table/TableContent.tsx +422 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +35 -42
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
- package/src/components/TableCellEditor/FormCellEditor.tsx +12 -6
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +6 -5
- package/src/components/TableCellEditor/TableCellEditor.tsx +10 -5
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +1 -1
- package/src/hooks/useAddRow.ts +1 -1
- package/src/hooks/useProjectionModel.ts +3 -3
- package/src/hooks/useTableModel.ts +1 -1
- package/src/model/table-model.test.ts +5 -5
- package/src/model/table-model.ts +13 -12
- package/src/model/table-presentation.test.ts +5 -5
- package/src/model/table-presentation.ts +12 -11
- package/src/playwright/TableManager.ts +10 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +45 -2
- package/src/testing/useTestTableModel.ts +4 -4
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +11 -22
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +17 -16
- package/src/util/query-ast.ts +3 -0
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-I5IFW7UF.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DDJKYJFY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WNZSKIRF.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,23 +6,24 @@ 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, Type } from '@dxos/echo';
|
|
9
|
+
import { Annotation, type Database, Format, Obj, type QueryAST, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { View } from '@dxos/echo';
|
|
10
11
|
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
11
12
|
import { invariant } from '@dxos/invariant';
|
|
12
13
|
import { faker } from '@dxos/random';
|
|
13
14
|
import { PublicKey } from '@dxos/react-client';
|
|
14
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
|
-
import {
|
|
16
|
+
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
17
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
18
|
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
17
19
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
18
|
-
import {
|
|
20
|
+
import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
19
21
|
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
20
22
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
21
23
|
|
|
22
24
|
import { useTestTableModel } from '../../testing';
|
|
23
25
|
import { translations } from '../../translations';
|
|
24
26
|
import { Table } from '../../types';
|
|
25
|
-
import { TableToolbar } from '../TableToolbar';
|
|
26
27
|
|
|
27
28
|
import { Table as TableComponent } from './Table';
|
|
28
29
|
|
|
@@ -47,11 +48,11 @@ const Example = Schema.Struct({
|
|
|
47
48
|
}),
|
|
48
49
|
),
|
|
49
50
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
50
|
-
parent: Schema.optional(Schema.suspend(():
|
|
51
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
51
52
|
title: 'Parent',
|
|
52
53
|
}),
|
|
53
54
|
}).pipe(
|
|
54
|
-
Type.object({ typename: `example.
|
|
55
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
56
|
Annotation.LabelAnnotation.set(['name']),
|
|
56
57
|
);
|
|
57
58
|
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
@@ -73,8 +74,8 @@ const StoryViewEditor = ({
|
|
|
73
74
|
invariant(Type.isMutable(schema));
|
|
74
75
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
75
76
|
invariant(view);
|
|
76
|
-
Obj.change(view, (
|
|
77
|
-
|
|
77
|
+
Obj.change(view, (obj) => {
|
|
78
|
+
obj.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
79
|
});
|
|
79
80
|
},
|
|
80
81
|
[schema, view],
|
|
@@ -103,47 +104,67 @@ const DefaultStory = () => {
|
|
|
103
104
|
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
105
|
useTestTableModel();
|
|
105
106
|
|
|
107
|
+
const handleRowClick = useCallback(
|
|
108
|
+
(row: any) => {
|
|
109
|
+
if (model?.getDraftRowCount() === 0 && ['frozenRowsEnd', 'fixedEndStart', 'fixedEndEnd'].includes(row?.plane)) {
|
|
110
|
+
handleInsertRow();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[model, handleInsertRow],
|
|
114
|
+
);
|
|
115
|
+
|
|
106
116
|
if (!schema || !table?.view.target) {
|
|
107
117
|
return <div />;
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
return (
|
|
111
121
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
<TableComponent.Root ref={tableRef}>
|
|
123
|
+
<Panel.Root>
|
|
124
|
+
<Panel.Toolbar asChild>
|
|
125
|
+
<TableComponent.Toolbar
|
|
126
|
+
classNames='border-b border-subdued-separator'
|
|
127
|
+
onAdd={handleInsertRow}
|
|
128
|
+
onSave={handleSaveView}
|
|
129
|
+
/>
|
|
130
|
+
</Panel.Toolbar>
|
|
131
|
+
<Panel.Content asChild>
|
|
132
|
+
<TableComponent.Content
|
|
133
|
+
schema={schema}
|
|
134
|
+
model={model}
|
|
135
|
+
presentation={presentation}
|
|
136
|
+
onRowClick={handleRowClick}
|
|
137
|
+
ignoreAttention
|
|
138
|
+
/>
|
|
139
|
+
</Panel.Content>
|
|
140
|
+
</Panel.Root>
|
|
141
|
+
</TableComponent.Root>
|
|
142
|
+
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
143
|
+
<ScrollArea.Viewport>
|
|
144
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
145
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
146
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
147
|
+
</SyntaxHighlighter>
|
|
148
|
+
</ScrollArea.Viewport>
|
|
149
|
+
</ScrollArea.Root>
|
|
130
150
|
</div>
|
|
131
151
|
);
|
|
132
152
|
};
|
|
133
153
|
|
|
134
|
-
type
|
|
154
|
+
type DefaultStoryProps = { rows?: number };
|
|
135
155
|
|
|
136
156
|
//
|
|
137
157
|
// Story definitions.
|
|
138
158
|
//
|
|
139
159
|
|
|
140
|
-
// TODO(burdon): Need
|
|
160
|
+
// TODO(burdon): Need simpler story.
|
|
141
161
|
|
|
142
162
|
const meta = {
|
|
143
163
|
title: 'ui/react-ui-table/Table',
|
|
144
164
|
render: DefaultStory,
|
|
145
165
|
decorators: [
|
|
146
|
-
withTheme,
|
|
166
|
+
withTheme(),
|
|
167
|
+
withLayout({ layout: 'fullscreen' }),
|
|
147
168
|
withRegistry,
|
|
148
169
|
withClientProvider({
|
|
149
170
|
types: [View.View, Table.Table],
|
|
@@ -151,12 +172,12 @@ const meta = {
|
|
|
151
172
|
createSpace: true,
|
|
152
173
|
onCreateSpace: async ({ space }) => {
|
|
153
174
|
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
154
|
-
const { view, jsonSchema } = await
|
|
175
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
155
176
|
const table = Table.make({ view, jsonSchema });
|
|
156
|
-
Obj.change(view, (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
...
|
|
177
|
+
Obj.change(view, (obj) => {
|
|
178
|
+
obj.projection.fields = [
|
|
179
|
+
obj.projection.fields.find((field) => field.path === 'name')!,
|
|
180
|
+
...obj.projection.fields.filter((field) => field.path !== 'name'),
|
|
160
181
|
];
|
|
161
182
|
});
|
|
162
183
|
|
|
@@ -197,7 +218,7 @@ export const StaticSchema: StoryObj = {
|
|
|
197
218
|
createIdentity: true,
|
|
198
219
|
createSpace: true,
|
|
199
220
|
onCreateSpace: async ({ space }) => {
|
|
200
|
-
const { view, jsonSchema } = await
|
|
221
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
201
222
|
db: space.db,
|
|
202
223
|
typename: TestSchema.Person.typename,
|
|
203
224
|
});
|
|
@@ -230,7 +251,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
230
251
|
),
|
|
231
252
|
}).pipe(
|
|
232
253
|
Type.object({
|
|
233
|
-
typename: 'dxos.
|
|
254
|
+
typename: 'org.dxos.type.contactWithArrayOfEmails',
|
|
234
255
|
version: '0.1.0',
|
|
235
256
|
}),
|
|
236
257
|
);
|
|
@@ -243,7 +264,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
243
264
|
createIdentity: true,
|
|
244
265
|
createSpace: true,
|
|
245
266
|
onCreateSpace: async ({ space }) => {
|
|
246
|
-
const { view, jsonSchema } = await
|
|
267
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
247
268
|
db: space.db,
|
|
248
269
|
typename: ContactWithArrayOfEmails.typename,
|
|
249
270
|
});
|
|
@@ -265,7 +286,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
265
286
|
},
|
|
266
287
|
};
|
|
267
288
|
|
|
268
|
-
export const Tags: Meta<
|
|
289
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
269
290
|
title: 'ui/react-ui-table/Table',
|
|
270
291
|
render: DefaultStory,
|
|
271
292
|
decorators: [
|
|
@@ -275,7 +296,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
275
296
|
createSpace: true,
|
|
276
297
|
onCreateSpace: async ({ space }) => {
|
|
277
298
|
// Configure schema.
|
|
278
|
-
const typename = 'example.
|
|
299
|
+
const typename = 'com.example.type.single-select';
|
|
279
300
|
const selectOptions = [
|
|
280
301
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
281
302
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -301,7 +322,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
301
322
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
302
323
|
|
|
303
324
|
// Initialize table.
|
|
304
|
-
const { view, jsonSchema } = await
|
|
325
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
305
326
|
const table = Table.make({ view, jsonSchema });
|
|
306
327
|
space.db.add(table);
|
|
307
328
|
|