@dxos/react-ui-table 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
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-F7Y374KL.mjs} +39 -34
- package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +205 -179
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +6 -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-DDJKYJFY.mjs → chunk-CCJ4LOVM.mjs} +39 -34
- package/dist/lib/node-esm/chunk-CCJ4LOVM.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 +205 -179
- 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 +6 -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/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 +81 -82
- package/dist/types/src/components/Table/Relations.stories.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 +83 -84
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +17 -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/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 +17 -17
- package/src/components/Table/DynamicTable.tsx +13 -20
- package/src/components/Table/Relations.stories.tsx +38 -30
- package/src/components/Table/Table.stories.tsx +69 -49
- package/src/components/Table/Table.tsx +41 -435
- package/src/components/Table/TableContent.tsx +421 -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 +11 -11
- package/src/components/TableCellEditor/TableCellEditor.tsx +12 -10
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +10 -10
- 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 -6
- package/src/model/table-model.ts +15 -14
- package/src/model/table-presentation.test.ts +5 -6
- package/src/model/table-presentation.ts +12 -12
- package/src/playwright/TableManager.ts +10 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +48 -5
- package/src/testing/useTestTableModel.ts +6 -6
- 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,24 +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
|
-
import {
|
|
13
|
+
import { random } 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';
|
|
16
17
|
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
17
18
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
18
|
-
import {
|
|
19
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
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
|
import { Table as TableComponent } from './Table';
|
|
28
28
|
|
|
29
29
|
const Example = Schema.Struct({
|
|
@@ -47,11 +47,11 @@ const Example = Schema.Struct({
|
|
|
47
47
|
}),
|
|
48
48
|
),
|
|
49
49
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
50
|
-
parent: Schema.optional(Schema.suspend(():
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
51
51
|
title: 'Parent',
|
|
52
52
|
}),
|
|
53
53
|
}).pipe(
|
|
54
|
-
Type.object({ typename: `example.
|
|
54
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
55
|
Annotation.LabelAnnotation.set(['name']),
|
|
56
56
|
);
|
|
57
57
|
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
@@ -73,8 +73,8 @@ const StoryViewEditor = ({
|
|
|
73
73
|
invariant(Type.isMutable(schema));
|
|
74
74
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
75
75
|
invariant(view);
|
|
76
|
-
Obj.change(view, (
|
|
77
|
-
|
|
76
|
+
Obj.change(view, (view) => {
|
|
77
|
+
view.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
78
|
});
|
|
79
79
|
},
|
|
80
80
|
[schema, view],
|
|
@@ -103,47 +103,67 @@ const DefaultStory = () => {
|
|
|
103
103
|
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
104
|
useTestTableModel();
|
|
105
105
|
|
|
106
|
+
const handleRowClick = useCallback(
|
|
107
|
+
(row: any) => {
|
|
108
|
+
if (model?.getDraftRowCount() === 0 && ['frozenRowsEnd', 'fixedEndStart', 'fixedEndEnd'].includes(row?.plane)) {
|
|
109
|
+
handleInsertRow();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[model, handleInsertRow],
|
|
113
|
+
);
|
|
114
|
+
|
|
106
115
|
if (!schema || !table?.view.target) {
|
|
107
116
|
return <div />;
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
return (
|
|
111
120
|
<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
|
-
|
|
121
|
+
<TableComponent.Root ref={tableRef}>
|
|
122
|
+
<Panel.Root>
|
|
123
|
+
<Panel.Toolbar asChild>
|
|
124
|
+
<TableComponent.Toolbar
|
|
125
|
+
classNames='border-b border-subdued-separator'
|
|
126
|
+
onAdd={handleInsertRow}
|
|
127
|
+
onSave={handleSaveView}
|
|
128
|
+
/>
|
|
129
|
+
</Panel.Toolbar>
|
|
130
|
+
<Panel.Content asChild>
|
|
131
|
+
<TableComponent.Content
|
|
132
|
+
schema={schema}
|
|
133
|
+
model={model}
|
|
134
|
+
presentation={presentation}
|
|
135
|
+
onRowClick={handleRowClick}
|
|
136
|
+
ignoreAttention
|
|
137
|
+
/>
|
|
138
|
+
</Panel.Content>
|
|
139
|
+
</Panel.Root>
|
|
140
|
+
</TableComponent.Root>
|
|
141
|
+
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
142
|
+
<ScrollArea.Viewport>
|
|
143
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
144
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
145
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
146
|
+
</SyntaxHighlighter>
|
|
147
|
+
</ScrollArea.Viewport>
|
|
148
|
+
</ScrollArea.Root>
|
|
130
149
|
</div>
|
|
131
150
|
);
|
|
132
151
|
};
|
|
133
152
|
|
|
134
|
-
type
|
|
153
|
+
type DefaultStoryProps = { rows?: number };
|
|
135
154
|
|
|
136
155
|
//
|
|
137
156
|
// Story definitions.
|
|
138
157
|
//
|
|
139
158
|
|
|
140
|
-
// TODO(burdon): Need
|
|
159
|
+
// TODO(burdon): Need simpler story.
|
|
141
160
|
|
|
142
161
|
const meta = {
|
|
143
162
|
title: 'ui/react-ui-table/Table',
|
|
144
163
|
render: DefaultStory,
|
|
145
164
|
decorators: [
|
|
146
|
-
withTheme,
|
|
165
|
+
withTheme(),
|
|
166
|
+
withLayout({ layout: 'fullscreen' }),
|
|
147
167
|
withRegistry,
|
|
148
168
|
withClientProvider({
|
|
149
169
|
types: [View.View, Table.Table],
|
|
@@ -151,12 +171,12 @@ const meta = {
|
|
|
151
171
|
createSpace: true,
|
|
152
172
|
onCreateSpace: async ({ space }) => {
|
|
153
173
|
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
154
|
-
const { view, jsonSchema } = await
|
|
174
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
155
175
|
const table = Table.make({ view, jsonSchema });
|
|
156
|
-
Obj.change(view, (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
...
|
|
176
|
+
Obj.change(view, (view) => {
|
|
177
|
+
view.projection.fields = [
|
|
178
|
+
view.projection.fields.find((field) => field.path === 'name')!,
|
|
179
|
+
...view.projection.fields.filter((field) => field.path !== 'name'),
|
|
160
180
|
];
|
|
161
181
|
});
|
|
162
182
|
|
|
@@ -165,9 +185,9 @@ const meta = {
|
|
|
165
185
|
Array.from({ length: 10 }).map(() => {
|
|
166
186
|
return space.db.add(
|
|
167
187
|
Obj.make(schema, {
|
|
168
|
-
name:
|
|
169
|
-
status:
|
|
170
|
-
description:
|
|
188
|
+
name: random.lorem.sentence(),
|
|
189
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
190
|
+
description: random.lorem.paragraph(),
|
|
171
191
|
}),
|
|
172
192
|
);
|
|
173
193
|
});
|
|
@@ -197,14 +217,14 @@ export const StaticSchema: StoryObj = {
|
|
|
197
217
|
createIdentity: true,
|
|
198
218
|
createSpace: true,
|
|
199
219
|
onCreateSpace: async ({ space }) => {
|
|
200
|
-
const { view, jsonSchema } = await
|
|
220
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
201
221
|
db: space.db,
|
|
202
222
|
typename: TestSchema.Person.typename,
|
|
203
223
|
});
|
|
204
224
|
const table = Table.make({ view, jsonSchema });
|
|
205
225
|
space.db.add(table);
|
|
206
226
|
|
|
207
|
-
const factory = createObjectFactory(space.db,
|
|
227
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
208
228
|
await factory([
|
|
209
229
|
{ type: TestSchema.Person, count: 10 },
|
|
210
230
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -230,7 +250,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
230
250
|
),
|
|
231
251
|
}).pipe(
|
|
232
252
|
Type.object({
|
|
233
|
-
typename: 'dxos.
|
|
253
|
+
typename: 'org.dxos.type.contactWithArrayOfEmails',
|
|
234
254
|
version: '0.1.0',
|
|
235
255
|
}),
|
|
236
256
|
);
|
|
@@ -243,14 +263,14 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
243
263
|
createIdentity: true,
|
|
244
264
|
createSpace: true,
|
|
245
265
|
onCreateSpace: async ({ space }) => {
|
|
246
|
-
const { view, jsonSchema } = await
|
|
266
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
247
267
|
db: space.db,
|
|
248
268
|
typename: ContactWithArrayOfEmails.typename,
|
|
249
269
|
});
|
|
250
270
|
const table = Table.make({ view, jsonSchema });
|
|
251
271
|
space.db.add(table);
|
|
252
272
|
|
|
253
|
-
const factory = createObjectFactory(space.db,
|
|
273
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
254
274
|
await factory([
|
|
255
275
|
// { type: TestSchema.Person, count: 10 },
|
|
256
276
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -265,7 +285,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
265
285
|
},
|
|
266
286
|
};
|
|
267
287
|
|
|
268
|
-
export const Tags: Meta<
|
|
288
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
269
289
|
title: 'ui/react-ui-table/Table',
|
|
270
290
|
render: DefaultStory,
|
|
271
291
|
decorators: [
|
|
@@ -275,7 +295,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
275
295
|
createSpace: true,
|
|
276
296
|
onCreateSpace: async ({ space }) => {
|
|
277
297
|
// Configure schema.
|
|
278
|
-
const typename = 'example.
|
|
298
|
+
const typename = 'com.example.type.single-select';
|
|
279
299
|
const selectOptions = [
|
|
280
300
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
281
301
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -301,7 +321,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
301
321
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
302
322
|
|
|
303
323
|
// Initialize table.
|
|
304
|
-
const { view, jsonSchema } = await
|
|
324
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
305
325
|
const table = Table.make({ view, jsonSchema });
|
|
306
326
|
space.db.add(table);
|
|
307
327
|
|
|
@@ -309,8 +329,8 @@ export const Tags: Meta<StoryProps> = {
|
|
|
309
329
|
Array.from({ length: 10 }).map(() => {
|
|
310
330
|
return space.db.add(
|
|
311
331
|
Obj.make(storedSchema, {
|
|
312
|
-
single:
|
|
313
|
-
multiple:
|
|
332
|
+
single: random.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
333
|
+
multiple: random.helpers.randomSubset(selectOptionIds),
|
|
314
334
|
}),
|
|
315
335
|
);
|
|
316
336
|
});
|