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