@dxos/react-ui-table 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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-FBURZBPH.mjs} +17 -23
- package/dist/lib/browser/chunk-FBURZBPH.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GTGYBRJA.mjs → chunk-YGC7LZJN.mjs} +31 -84
- package/dist/lib/browser/chunk-YGC7LZJN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +197 -234
- 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 -5
- 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-WNZSKIRF.mjs → chunk-DKKMSVKP.mjs} +17 -23
- package/dist/lib/node-esm/chunk-DKKMSVKP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DPNSZHU5.mjs → chunk-GKIWDEZ7.mjs} +31 -84
- package/dist/lib/node-esm/chunk-GKIWDEZ7.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/index.mjs +197 -234
- 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 -5
- 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.map +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 +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 +82 -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 +84 -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/CellValidationMessage.d.ts.map +1 -1
- 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/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/useProjectionModel.d.ts +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 +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.map +1 -1
- package/dist/types/src/playwright/playwright.config.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 +2 -2
- 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 +50 -59
- package/src/components/Table/ColumnActionsMenu.tsx +7 -6
- package/src/components/Table/ColumnSettings.tsx +3 -4
- package/src/components/Table/DynamicTable.stories.tsx +15 -15
- package/src/components/Table/DynamicTable.tsx +10 -18
- package/src/components/Table/Relations.stories.tsx +77 -33
- package/src/components/Table/RowActionsMenu.tsx +3 -2
- package/src/components/Table/Table.stories.tsx +58 -51
- package/src/components/Table/Table.tsx +41 -435
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/{TableToolbar → Table}/TableToolbar.tsx +36 -43
- package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
- package/src/components/TableCellEditor/FormCellEditor.tsx +14 -7
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +12 -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/index.ts +0 -4
- package/src/model/table-model.test.ts +5 -6
- package/src/model/table-model.ts +11 -10
- package/src/model/table-presentation.test.ts +5 -6
- package/src/model/table-presentation.ts +12 -12
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/useTestTableModel.ts +5 -5
- package/src/translations.ts +19 -21
- package/src/types/Table.ts +12 -23
- package/src/util/dynamic-table.test.ts +4 -4
- package/src/util/dynamic-table.ts +11 -10
- 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-GTGYBRJA.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DPNSZHU5.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,25 +6,26 @@ 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 { ScrollArea } from '@dxos/react-ui';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
16
|
+
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
17
|
+
import { ViewEditor } from '@dxos/react-ui-form';
|
|
18
|
+
import { translations as formTranslations } from '@dxos/react-ui-form/translations';
|
|
19
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
20
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
21
|
+
import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
20
22
|
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
21
23
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
22
24
|
|
|
25
|
+
import { translations } from '#translations';
|
|
26
|
+
|
|
23
27
|
import { useTestTableModel } from '../../testing';
|
|
24
|
-
import { translations } from '../../translations';
|
|
25
28
|
import { Table } from '../../types';
|
|
26
|
-
import { TableToolbar } from '../TableToolbar';
|
|
27
|
-
|
|
28
29
|
import { Table as TableComponent } from './Table';
|
|
29
30
|
|
|
30
31
|
const Example = Schema.Struct({
|
|
@@ -48,11 +49,11 @@ const Example = Schema.Struct({
|
|
|
48
49
|
}),
|
|
49
50
|
),
|
|
50
51
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
51
|
-
parent: Schema.optional(Schema.suspend(():
|
|
52
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
52
53
|
title: 'Parent',
|
|
53
54
|
}),
|
|
54
55
|
}).pipe(
|
|
55
|
-
Type.object({ typename: `example.
|
|
56
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
56
57
|
Annotation.LabelAnnotation.set(['name']),
|
|
57
58
|
);
|
|
58
59
|
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
@@ -74,8 +75,8 @@ const StoryViewEditor = ({
|
|
|
74
75
|
invariant(Type.isMutable(schema));
|
|
75
76
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
76
77
|
invariant(view);
|
|
77
|
-
Obj.
|
|
78
|
-
|
|
78
|
+
Obj.update(view, (view) => {
|
|
79
|
+
view.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
79
80
|
});
|
|
80
81
|
},
|
|
81
82
|
[schema, view],
|
|
@@ -119,44 +120,50 @@ const DefaultStory = () => {
|
|
|
119
120
|
|
|
120
121
|
return (
|
|
121
122
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
122
|
-
<
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
123
|
+
<TableComponent.Root ref={tableRef}>
|
|
124
|
+
<Panel.Root>
|
|
125
|
+
<Panel.Toolbar asChild>
|
|
126
|
+
<TableComponent.Toolbar
|
|
127
|
+
classNames='border-b border-subdued-separator'
|
|
128
|
+
onAdd={handleInsertRow}
|
|
129
|
+
onSave={handleSaveView}
|
|
130
|
+
/>
|
|
131
|
+
</Panel.Toolbar>
|
|
132
|
+
<Panel.Content asChild>
|
|
133
|
+
<TableComponent.Content
|
|
134
|
+
schema={schema}
|
|
135
|
+
model={model}
|
|
136
|
+
presentation={presentation}
|
|
137
|
+
onRowClick={handleRowClick}
|
|
138
|
+
ignoreAttention
|
|
139
|
+
/>
|
|
140
|
+
</Panel.Content>
|
|
141
|
+
</Panel.Root>
|
|
142
|
+
</TableComponent.Root>
|
|
143
|
+
<ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
|
|
136
144
|
<ScrollArea.Viewport>
|
|
137
145
|
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
138
|
-
<
|
|
139
|
-
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
140
|
-
</SyntaxHighlighter>
|
|
146
|
+
<JsonHighlighter data={{ view: table.view.target, schema }} classNames='text-xs' />
|
|
141
147
|
</ScrollArea.Viewport>
|
|
142
148
|
</ScrollArea.Root>
|
|
143
149
|
</div>
|
|
144
150
|
);
|
|
145
151
|
};
|
|
146
152
|
|
|
147
|
-
type
|
|
153
|
+
type DefaultStoryProps = { rows?: number };
|
|
148
154
|
|
|
149
155
|
//
|
|
150
156
|
// Story definitions.
|
|
151
157
|
//
|
|
152
158
|
|
|
153
|
-
// TODO(burdon): Need
|
|
159
|
+
// TODO(burdon): Need simpler story.
|
|
154
160
|
|
|
155
161
|
const meta = {
|
|
156
162
|
title: 'ui/react-ui-table/Table',
|
|
157
163
|
render: DefaultStory,
|
|
158
164
|
decorators: [
|
|
159
165
|
withTheme(),
|
|
166
|
+
withLayout({ layout: 'fullscreen' }),
|
|
160
167
|
withRegistry,
|
|
161
168
|
withClientProvider({
|
|
162
169
|
types: [View.View, Table.Table],
|
|
@@ -164,12 +171,12 @@ const meta = {
|
|
|
164
171
|
createSpace: true,
|
|
165
172
|
onCreateSpace: async ({ space }) => {
|
|
166
173
|
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
167
|
-
const { view, jsonSchema } = await
|
|
174
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
168
175
|
const table = Table.make({ view, jsonSchema });
|
|
169
|
-
Obj.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
...
|
|
176
|
+
Obj.update(view, (view) => {
|
|
177
|
+
view.projection.fields = [
|
|
178
|
+
view.projection.fields.find((field) => field.path === 'name')!,
|
|
179
|
+
...view.projection.fields.filter((field) => field.path !== 'name'),
|
|
173
180
|
];
|
|
174
181
|
});
|
|
175
182
|
|
|
@@ -178,9 +185,9 @@ const meta = {
|
|
|
178
185
|
Array.from({ length: 10 }).map(() => {
|
|
179
186
|
return space.db.add(
|
|
180
187
|
Obj.make(schema, {
|
|
181
|
-
name:
|
|
182
|
-
status:
|
|
183
|
-
description:
|
|
188
|
+
name: random.lorem.sentence(),
|
|
189
|
+
status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
|
|
190
|
+
description: random.lorem.paragraph(),
|
|
184
191
|
}),
|
|
185
192
|
);
|
|
186
193
|
});
|
|
@@ -210,14 +217,14 @@ export const StaticSchema: StoryObj = {
|
|
|
210
217
|
createIdentity: true,
|
|
211
218
|
createSpace: true,
|
|
212
219
|
onCreateSpace: async ({ space }) => {
|
|
213
|
-
const { view, jsonSchema } = await
|
|
220
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
214
221
|
db: space.db,
|
|
215
222
|
typename: TestSchema.Person.typename,
|
|
216
223
|
});
|
|
217
224
|
const table = Table.make({ view, jsonSchema });
|
|
218
225
|
space.db.add(table);
|
|
219
226
|
|
|
220
|
-
const factory = createObjectFactory(space.db,
|
|
227
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
221
228
|
await factory([
|
|
222
229
|
{ type: TestSchema.Person, count: 10 },
|
|
223
230
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -243,7 +250,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
243
250
|
),
|
|
244
251
|
}).pipe(
|
|
245
252
|
Type.object({
|
|
246
|
-
typename: 'dxos.
|
|
253
|
+
typename: 'org.dxos.type.contactWithArrayOfEmails',
|
|
247
254
|
version: '0.1.0',
|
|
248
255
|
}),
|
|
249
256
|
);
|
|
@@ -256,14 +263,14 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
256
263
|
createIdentity: true,
|
|
257
264
|
createSpace: true,
|
|
258
265
|
onCreateSpace: async ({ space }) => {
|
|
259
|
-
const { view, jsonSchema } = await
|
|
266
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
260
267
|
db: space.db,
|
|
261
268
|
typename: ContactWithArrayOfEmails.typename,
|
|
262
269
|
});
|
|
263
270
|
const table = Table.make({ view, jsonSchema });
|
|
264
271
|
space.db.add(table);
|
|
265
272
|
|
|
266
|
-
const factory = createObjectFactory(space.db,
|
|
273
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
267
274
|
await factory([
|
|
268
275
|
// { type: TestSchema.Person, count: 10 },
|
|
269
276
|
// { type: TestSchema.Organization, count: 1 },
|
|
@@ -278,7 +285,7 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
278
285
|
},
|
|
279
286
|
};
|
|
280
287
|
|
|
281
|
-
export const Tags: Meta<
|
|
288
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
282
289
|
title: 'ui/react-ui-table/Table',
|
|
283
290
|
render: DefaultStory,
|
|
284
291
|
decorators: [
|
|
@@ -288,7 +295,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
288
295
|
createSpace: true,
|
|
289
296
|
onCreateSpace: async ({ space }) => {
|
|
290
297
|
// Configure schema.
|
|
291
|
-
const typename = 'example.
|
|
298
|
+
const typename = 'com.example.type.single-select';
|
|
292
299
|
const selectOptions = [
|
|
293
300
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
294
301
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -314,7 +321,7 @@ export const Tags: Meta<StoryProps> = {
|
|
|
314
321
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
315
322
|
|
|
316
323
|
// Initialize table.
|
|
317
|
-
const { view, jsonSchema } = await
|
|
324
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
318
325
|
const table = Table.make({ view, jsonSchema });
|
|
319
326
|
space.db.add(table);
|
|
320
327
|
|
|
@@ -322,8 +329,8 @@ export const Tags: Meta<StoryProps> = {
|
|
|
322
329
|
Array.from({ length: 10 }).map(() => {
|
|
323
330
|
return space.db.add(
|
|
324
331
|
Obj.make(storedSchema, {
|
|
325
|
-
single:
|
|
326
|
-
multiple:
|
|
332
|
+
single: random.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
333
|
+
multiple: random.helpers.randomSubset(selectOptionIds),
|
|
327
334
|
}),
|
|
328
335
|
);
|
|
329
336
|
});
|