@dxos/react-ui-table 0.8.4-main.406dc2a → 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-BF54SSNL.mjs +70 -0
- package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
- package/dist/lib/browser/chunk-G5EDJPD2.mjs +1751 -0
- package/dist/lib/browser/chunk-G5EDJPD2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1191 -1033
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +32 -44
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/types/index.mjs +3 -3
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs +71 -0
- package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZZ3SYTIL.mjs +1753 -0
- package/dist/lib/node-esm/chunk-ZZ3SYTIL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1191 -1033
- 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 +32 -44
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/types/index.mjs +3 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
- 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 +7 -7
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -37
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +84 -81
- 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 +92 -26
- 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 +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +10 -12
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -7
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +24 -26
- 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 +22 -15
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +5 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +9 -9
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +17 -8
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +105 -25
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +3 -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 +18 -15
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +21 -23
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +26 -0
- package/dist/types/src/types/Table.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +14 -11
- 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/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts +7 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -0
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -68
- package/src/components/Table/ColumnActionsMenu.tsx +15 -11
- package/src/components/Table/ColumnSettings.tsx +8 -9
- package/src/components/Table/DynamicTable.stories.tsx +27 -28
- package/src/components/Table/DynamicTable.tsx +32 -32
- package/src/components/Table/Relations.stories.tsx +110 -78
- package/src/components/Table/RowActionsMenu.tsx +24 -15
- package/src/components/Table/Table.stories.tsx +121 -107
- package/src/components/Table/Table.tsx +43 -407
- package/src/components/Table/TableContent.tsx +421 -0
- package/src/components/Table/TableToolbar.tsx +111 -0
- package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -5
- package/src/components/TableCellEditor/FormCellEditor.tsx +117 -134
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +24 -20
- package/src/components/TableCellEditor/TableCellEditor.tsx +35 -33
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +43 -17
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +8 -10
- package/src/hooks/useProjectionModel.ts +39 -0
- package/src/hooks/useTableModel.ts +36 -34
- package/src/model/modal-controller.ts +23 -12
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +82 -55
- package/src/model/table-model.ts +436 -170
- package/src/model/table-presentation.test.ts +59 -50
- package/src/model/table-presentation.ts +43 -38
- package/src/playwright/TableManager.ts +13 -6
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +59 -13
- package/src/testing/useTestTableModel.ts +48 -41
- package/src/translations.ts +20 -22
- package/src/types/Table.ts +79 -0
- package/src/types/index.ts +1 -1
- package/src/util/dynamic-table.test.ts +70 -0
- package/src/util/dynamic-table.ts +41 -28
- package/src/util/index.ts +2 -0
- package/src/util/query-ast.ts +22 -0
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-4K7JPALT.mjs +0 -66
- package/dist/lib/browser/chunk-4K7JPALT.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZTXLZGM.mjs +0 -1804
- package/dist/lib/browser/chunk-OZTXLZGM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs +0 -67
- package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-S56Z4V4X.mjs +0 -1805
- package/dist/lib/node-esm/chunk-S56Z4V4X.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/dist/types/src/model/table-sorting.d.ts +0 -52
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -28
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/components/TableToolbar/TableToolbar.tsx +0 -102
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -225
- package/src/types/schema.ts +0 -73
|
@@ -6,41 +6,33 @@ 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 { Obj, type QueryAST, Type } from '@dxos/echo';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
FormatAnnotation,
|
|
13
|
-
FormatEnum,
|
|
14
|
-
GeneratorAnnotation,
|
|
15
|
-
LabelAnnotation,
|
|
16
|
-
PropertyMetaAnnotationId,
|
|
17
|
-
} from '@dxos/echo/internal';
|
|
18
|
-
import { live } from '@dxos/echo/internal';
|
|
9
|
+
import { Annotation, type Database, Format, Obj, type QueryAST, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { View } from '@dxos/echo';
|
|
11
|
+
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
19
12
|
import { invariant } from '@dxos/invariant';
|
|
20
|
-
import {
|
|
13
|
+
import { random } from '@dxos/random';
|
|
21
14
|
import { PublicKey } from '@dxos/react-client';
|
|
22
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
23
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
24
|
-
import {
|
|
25
|
-
import { ViewEditor } from '@dxos/react-ui-form';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
16
|
+
import { Panel, ScrollArea } from '@dxos/react-ui';
|
|
17
|
+
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
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';
|
|
21
|
+
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
22
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
29
23
|
|
|
30
24
|
import { useTestTableModel } from '../../testing';
|
|
31
25
|
import { translations } from '../../translations';
|
|
32
26
|
import { Table } from '../../types';
|
|
33
|
-
import { TableToolbar } from '../TableToolbar';
|
|
34
|
-
|
|
35
27
|
import { Table as TableComponent } from './Table';
|
|
36
28
|
|
|
37
|
-
const
|
|
29
|
+
const Example = Schema.Struct({
|
|
38
30
|
// TODO(wittjosiah): Should be title. Currently name to work with default label.
|
|
39
31
|
name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
|
|
40
32
|
urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
|
|
41
33
|
status: Schema.optional(
|
|
42
34
|
Schema.Literal('todo', 'in-progress', 'done')
|
|
43
|
-
.pipe(FormatAnnotation.set(
|
|
35
|
+
.pipe(Format.FormatAnnotation.set(Format.TypeFormat.SingleSelect))
|
|
44
36
|
.annotations({
|
|
45
37
|
title: 'Status',
|
|
46
38
|
[PropertyMetaAnnotationId]: {
|
|
@@ -55,24 +47,24 @@ const TestSchema = Schema.Struct({
|
|
|
55
47
|
}),
|
|
56
48
|
),
|
|
57
49
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
58
|
-
parent: Schema.optional(Schema.suspend(():
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
|
|
59
51
|
title: 'Parent',
|
|
60
52
|
}),
|
|
61
53
|
}).pipe(
|
|
62
|
-
Type.
|
|
63
|
-
LabelAnnotation.set(['name']),
|
|
54
|
+
Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
64
56
|
);
|
|
65
|
-
interface
|
|
57
|
+
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
66
58
|
|
|
67
59
|
const StoryViewEditor = ({
|
|
68
60
|
view,
|
|
69
61
|
schema,
|
|
70
|
-
|
|
62
|
+
db,
|
|
71
63
|
handleDeleteColumn,
|
|
72
64
|
}: {
|
|
73
|
-
view?:
|
|
65
|
+
view?: View.View;
|
|
74
66
|
schema?: Schema.Schema.AnyNoContext;
|
|
75
|
-
|
|
67
|
+
db?: Database.Database;
|
|
76
68
|
handleDeleteColumn: (fieldId: string) => void;
|
|
77
69
|
}) => {
|
|
78
70
|
const handleQueryChanged = useCallback(
|
|
@@ -81,7 +73,9 @@ const StoryViewEditor = ({
|
|
|
81
73
|
invariant(Type.isMutable(schema));
|
|
82
74
|
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
83
75
|
invariant(view);
|
|
84
|
-
view
|
|
76
|
+
Obj.change(view, (view) => {
|
|
77
|
+
view.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
|
+
});
|
|
85
79
|
},
|
|
86
80
|
[schema, view],
|
|
87
81
|
);
|
|
@@ -92,7 +86,7 @@ const StoryViewEditor = ({
|
|
|
92
86
|
|
|
93
87
|
return (
|
|
94
88
|
<ViewEditor
|
|
95
|
-
registry={
|
|
89
|
+
registry={db?.schemaRegistry}
|
|
96
90
|
schema={schema}
|
|
97
91
|
view={view}
|
|
98
92
|
onQueryChanged={handleQueryChanged}
|
|
@@ -106,81 +100,92 @@ const StoryViewEditor = ({
|
|
|
106
100
|
//
|
|
107
101
|
|
|
108
102
|
const DefaultStory = () => {
|
|
109
|
-
const {
|
|
110
|
-
|
|
111
|
-
schema,
|
|
112
|
-
view,
|
|
113
|
-
tableRef,
|
|
114
|
-
model,
|
|
115
|
-
presentation,
|
|
116
|
-
client,
|
|
117
|
-
handleInsertRow,
|
|
118
|
-
handleSaveView,
|
|
119
|
-
handleDeleteColumn,
|
|
120
|
-
} = useTestTableModel();
|
|
103
|
+
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
|
+
useTestTableModel();
|
|
121
105
|
|
|
122
|
-
|
|
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
|
+
|
|
115
|
+
if (!schema || !table?.view.target) {
|
|
123
116
|
return <div />;
|
|
124
117
|
}
|
|
125
118
|
|
|
126
119
|
return (
|
|
127
120
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
128
|
-
<
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
<JsonHighlighter data={{ view: table.view.target, schema }} classNames='text-xs' />
|
|
145
|
+
</ScrollArea.Viewport>
|
|
146
|
+
</ScrollArea.Root>
|
|
147
147
|
</div>
|
|
148
148
|
);
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
type
|
|
151
|
+
type DefaultStoryProps = { rows?: number };
|
|
152
152
|
|
|
153
153
|
//
|
|
154
154
|
// Story definitions.
|
|
155
155
|
//
|
|
156
156
|
|
|
157
|
-
// TODO(burdon): Need
|
|
157
|
+
// TODO(burdon): Need simpler story.
|
|
158
158
|
|
|
159
159
|
const meta = {
|
|
160
160
|
title: 'ui/react-ui-table/Table',
|
|
161
161
|
render: DefaultStory,
|
|
162
162
|
decorators: [
|
|
163
|
-
withTheme,
|
|
163
|
+
withTheme(),
|
|
164
|
+
withLayout({ layout: 'fullscreen' }),
|
|
165
|
+
withRegistry,
|
|
164
166
|
withClientProvider({
|
|
165
|
-
types: [
|
|
167
|
+
types: [View.View, Table.Table],
|
|
166
168
|
createIdentity: true,
|
|
167
169
|
createSpace: true,
|
|
168
|
-
onCreateSpace: async ({
|
|
169
|
-
const [schema] = await space.db.schemaRegistry.register([
|
|
170
|
-
const { view } = await
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
onCreateSpace: async ({ space }) => {
|
|
171
|
+
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
172
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
173
|
+
const table = Table.make({ view, jsonSchema });
|
|
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'),
|
|
178
|
+
];
|
|
179
|
+
});
|
|
175
180
|
|
|
176
|
-
space.db.add(
|
|
181
|
+
space.db.add(table);
|
|
177
182
|
|
|
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
|
});
|
|
@@ -192,7 +197,7 @@ const meta = {
|
|
|
192
197
|
controls: {
|
|
193
198
|
disable: true,
|
|
194
199
|
},
|
|
195
|
-
translations,
|
|
200
|
+
translations: [...translations, ...formTranslations],
|
|
196
201
|
},
|
|
197
202
|
} satisfies Meta<typeof TableComponent>;
|
|
198
203
|
|
|
@@ -206,29 +211,33 @@ export const StaticSchema: StoryObj = {
|
|
|
206
211
|
render: DefaultStory,
|
|
207
212
|
decorators: [
|
|
208
213
|
withClientProvider({
|
|
209
|
-
types: [
|
|
214
|
+
types: [View.View, Table.Table],
|
|
210
215
|
createIdentity: true,
|
|
211
216
|
createSpace: true,
|
|
212
|
-
onCreateSpace: async ({
|
|
213
|
-
const { view } = await
|
|
214
|
-
|
|
217
|
+
onCreateSpace: async ({ space }) => {
|
|
218
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
219
|
+
db: space.db,
|
|
220
|
+
typename: TestSchema.Person.typename,
|
|
221
|
+
});
|
|
222
|
+
const table = Table.make({ view, jsonSchema });
|
|
223
|
+
space.db.add(table);
|
|
215
224
|
|
|
216
|
-
const factory = createObjectFactory(space.db,
|
|
225
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
217
226
|
await factory([
|
|
218
|
-
{ type:
|
|
219
|
-
// { type:
|
|
227
|
+
{ type: TestSchema.Person, count: 10 },
|
|
228
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
220
229
|
]);
|
|
221
230
|
},
|
|
222
231
|
}),
|
|
223
232
|
],
|
|
224
233
|
parameters: {
|
|
225
234
|
layout: 'fullscreen',
|
|
226
|
-
translations,
|
|
235
|
+
translations: [...translations, ...formTranslations],
|
|
227
236
|
},
|
|
228
237
|
};
|
|
229
238
|
|
|
230
239
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
231
|
-
name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
|
|
240
|
+
name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
|
|
232
241
|
emails: Schema.optional(
|
|
233
242
|
Schema.Array(
|
|
234
243
|
Schema.Struct({
|
|
@@ -238,8 +247,8 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
238
247
|
),
|
|
239
248
|
),
|
|
240
249
|
}).pipe(
|
|
241
|
-
|
|
242
|
-
typename: 'dxos.
|
|
250
|
+
Type.object({
|
|
251
|
+
typename: 'org.dxos.type.contactWithArrayOfEmails',
|
|
243
252
|
version: '0.1.0',
|
|
244
253
|
}),
|
|
245
254
|
);
|
|
@@ -248,17 +257,21 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
248
257
|
render: DefaultStory,
|
|
249
258
|
decorators: [
|
|
250
259
|
withClientProvider({
|
|
251
|
-
types: [
|
|
260
|
+
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
252
261
|
createIdentity: true,
|
|
253
262
|
createSpace: true,
|
|
254
|
-
onCreateSpace: async ({
|
|
255
|
-
const { view } = await
|
|
256
|
-
|
|
263
|
+
onCreateSpace: async ({ space }) => {
|
|
264
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({
|
|
265
|
+
db: space.db,
|
|
266
|
+
typename: ContactWithArrayOfEmails.typename,
|
|
267
|
+
});
|
|
268
|
+
const table = Table.make({ view, jsonSchema });
|
|
269
|
+
space.db.add(table);
|
|
257
270
|
|
|
258
|
-
const factory = createObjectFactory(space.db,
|
|
271
|
+
const factory = createObjectFactory(space.db, random as any);
|
|
259
272
|
await factory([
|
|
260
|
-
// { type:
|
|
261
|
-
// { type:
|
|
273
|
+
// { type: TestSchema.Person, count: 10 },
|
|
274
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
262
275
|
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
263
276
|
]);
|
|
264
277
|
},
|
|
@@ -270,17 +283,17 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
270
283
|
},
|
|
271
284
|
};
|
|
272
285
|
|
|
273
|
-
export const Tags: Meta<
|
|
286
|
+
export const Tags: Meta<DefaultStoryProps> = {
|
|
274
287
|
title: 'ui/react-ui-table/Table',
|
|
275
288
|
render: DefaultStory,
|
|
276
289
|
decorators: [
|
|
277
290
|
withClientProvider({
|
|
278
|
-
types: [
|
|
291
|
+
types: [View.View, Table.Table],
|
|
279
292
|
createIdentity: true,
|
|
280
293
|
createSpace: true,
|
|
281
|
-
onCreateSpace: async ({
|
|
294
|
+
onCreateSpace: async ({ space }) => {
|
|
282
295
|
// Configure schema.
|
|
283
|
-
const typename = 'example.
|
|
296
|
+
const typename = 'com.example.type.single-select';
|
|
284
297
|
const selectOptions = [
|
|
285
298
|
{ id: 'one', title: 'One', color: 'emerald' },
|
|
286
299
|
{ id: 'two', title: 'Two', color: 'blue' },
|
|
@@ -294,27 +307,28 @@ export const Tags: Meta<StoryProps> = {
|
|
|
294
307
|
const schema = getSchemaFromPropertyDefinitions(typename, [
|
|
295
308
|
{
|
|
296
309
|
name: 'single',
|
|
297
|
-
format:
|
|
310
|
+
format: Format.TypeFormat.SingleSelect,
|
|
298
311
|
config: { options: selectOptions },
|
|
299
312
|
},
|
|
300
313
|
{
|
|
301
314
|
name: 'multiple',
|
|
302
|
-
format:
|
|
315
|
+
format: Format.TypeFormat.MultiSelect,
|
|
303
316
|
config: { options: selectOptions },
|
|
304
317
|
},
|
|
305
318
|
]);
|
|
306
319
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
307
320
|
|
|
308
321
|
// Initialize table.
|
|
309
|
-
const { view } = await
|
|
310
|
-
|
|
322
|
+
const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
|
|
323
|
+
const table = Table.make({ view, jsonSchema });
|
|
324
|
+
space.db.add(table);
|
|
311
325
|
|
|
312
326
|
// Populate.
|
|
313
327
|
Array.from({ length: 10 }).map(() => {
|
|
314
328
|
return space.db.add(
|
|
315
|
-
|
|
316
|
-
single:
|
|
317
|
-
multiple:
|
|
329
|
+
Obj.make(storedSchema, {
|
|
330
|
+
single: random.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
331
|
+
multiple: random.helpers.randomSubset(selectOptionIds),
|
|
318
332
|
}),
|
|
319
333
|
);
|
|
320
334
|
});
|