@dxos/react-ui-table 0.8.4-main.67995b8 → 0.8.4-main.69d29f4
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-I5IFW7UF.mjs +1746 -0
- package/dist/lib/browser/chunk-I5IFW7UF.mjs.map +7 -0
- package/dist/lib/browser/chunk-OZBLY7XM.mjs +76 -0
- package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1163 -1120
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +30 -37
- 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-DDJKYJFY.mjs +1748 -0
- package/dist/lib/node-esm/chunk-DDJKYJFY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs +77 -0
- package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1163 -1120
- 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 +30 -37
- 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 +2 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +3 -3
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +5 -6
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +37 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +111 -0
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +13 -9
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +108 -4
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +13 -9
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +11 -18
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -4
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +4 -4
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +23 -16
- 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 +6 -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 -8
- 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 +109 -28
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +5 -2
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/playwright/TableManager.d.ts +1 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +18 -34
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +4 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +31 -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 +13 -12
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -1
- 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/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +65 -64
- package/src/components/Table/ColumnActionsMenu.tsx +11 -7
- package/src/components/Table/ColumnSettings.tsx +7 -7
- package/src/components/Table/DynamicTable.stories.tsx +25 -22
- package/src/components/Table/DynamicTable.tsx +26 -21
- package/src/components/Table/Relations.stories.tsx +237 -0
- package/src/components/Table/RowActionsMenu.tsx +26 -17
- package/src/components/Table/Table.stories.tsx +110 -102
- package/src/components/Table/Table.tsx +353 -298
- package/src/components/TableCellEditor/CellValidationMessage.tsx +2 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +128 -40
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +30 -66
- package/src/components/TableCellEditor/TableCellEditor.tsx +88 -238
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/TableToolbar/TableToolbar.tsx +49 -33
- package/src/components/testing.ts +39 -13
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +14 -14
- package/src/hooks/useProjectionModel.ts +39 -0
- package/src/hooks/useTableModel.ts +35 -33
- package/src/model/modal-controller.ts +24 -41
- package/src/model/selection-model.ts +75 -43
- package/src/model/table-model.test.ts +92 -55
- package/src/model/table-model.ts +445 -168
- package/src/model/table-presentation.test.ts +70 -58
- package/src/model/table-presentation.ts +103 -57
- package/src/playwright/TableManager.ts +5 -5
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +135 -40
- package/src/testing/useTestTableModel.ts +45 -34
- package/src/translations.ts +3 -3
- package/src/types/Table.ts +90 -0
- package/src/types/index.ts +1 -1
- package/src/util/dynamic-table.ts +44 -32
- package/src/util/index.ts +2 -1
- package/src/util/query-ast.ts +19 -0
- package/src/util/schema.ts +4 -4
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +4 -3
- package/src/util/table-controls.ts +4 -1
- package/dist/lib/browser/chunk-5XLSHLOG.mjs +0 -1751
- package/dist/lib/browser/chunk-5XLSHLOG.mjs.map +0 -7
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y66YLSTC.mjs +0 -1752
- package/dist/lib/node-esm/chunk-Y66YLSTC.mjs.map +0 -7
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
- package/dist/types/src/components/Table/relations.stories.d.ts +0 -9
- package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/model/table-sorting.d.ts +0 -53
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -8
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -11
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/Table/relations.stories.tsx +0 -116
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/model/table-sorting.ts +0 -216
- package/src/types/schema.ts +0 -16
- package/src/util/table.ts +0 -49
|
@@ -2,45 +2,37 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj, type Meta } from '@storybook/react-vite';
|
|
8
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
9
7
|
import React, { useCallback } from 'react';
|
|
10
8
|
|
|
11
|
-
import { Obj, Type } from '@dxos/echo';
|
|
12
|
-
import {
|
|
13
|
-
FormatEnum,
|
|
14
|
-
EchoObject,
|
|
15
|
-
GeneratorAnnotation,
|
|
16
|
-
FormatAnnotation,
|
|
17
|
-
PropertyMetaAnnotationId,
|
|
18
|
-
} from '@dxos/echo-schema';
|
|
9
|
+
import { Annotation, type Database, Format, Obj, type QueryAST, Type } from '@dxos/echo';
|
|
10
|
+
import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
|
|
19
11
|
import { invariant } from '@dxos/invariant';
|
|
20
12
|
import { faker } from '@dxos/random';
|
|
21
13
|
import { PublicKey } from '@dxos/react-client';
|
|
22
|
-
import { live, type Space } from '@dxos/react-client/echo';
|
|
23
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
24
|
-
import {
|
|
15
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
|
+
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
25
17
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
26
|
-
import { getSchemaFromPropertyDefinitions,
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
18
|
+
import { View, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
|
|
19
|
+
import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
|
|
20
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
29
21
|
|
|
30
|
-
import { Table } from './Table';
|
|
31
22
|
import { useTestTableModel } from '../../testing';
|
|
32
23
|
import { translations } from '../../translations';
|
|
33
|
-
import {
|
|
34
|
-
import { createTable } from '../../util';
|
|
24
|
+
import { Table } from '../../types';
|
|
35
25
|
import { TableToolbar } from '../TableToolbar';
|
|
36
26
|
|
|
37
|
-
|
|
27
|
+
import { Table as TableComponent } from './Table';
|
|
28
|
+
|
|
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,30 +47,35 @@ const TestSchema = Schema.Struct({
|
|
|
55
47
|
}),
|
|
56
48
|
),
|
|
57
49
|
description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
|
|
58
|
-
parent: Schema.optional(Schema.suspend((): Type.Ref<
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))).annotations({
|
|
59
51
|
title: 'Parent',
|
|
60
52
|
}),
|
|
61
|
-
}).pipe(
|
|
62
|
-
|
|
53
|
+
}).pipe(
|
|
54
|
+
Type.object({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
|
|
55
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
56
|
+
);
|
|
57
|
+
interface Example extends Schema.Schema.Type<typeof Example> {}
|
|
63
58
|
|
|
64
59
|
const StoryViewEditor = ({
|
|
65
60
|
view,
|
|
66
61
|
schema,
|
|
67
|
-
|
|
62
|
+
db,
|
|
68
63
|
handleDeleteColumn,
|
|
69
64
|
}: {
|
|
70
|
-
view?:
|
|
65
|
+
view?: View.View;
|
|
71
66
|
schema?: Schema.Schema.AnyNoContext;
|
|
72
|
-
|
|
67
|
+
db?: Database.Database;
|
|
73
68
|
handleDeleteColumn: (fieldId: string) => void;
|
|
74
69
|
}) => {
|
|
75
|
-
const
|
|
76
|
-
(
|
|
70
|
+
const handleQueryChanged = useCallback(
|
|
71
|
+
(newQuery: QueryAST.Query) => {
|
|
77
72
|
invariant(schema);
|
|
78
73
|
invariant(Type.isMutable(schema));
|
|
79
|
-
schema.updateTypename(
|
|
74
|
+
schema.updateTypename(getTypenameFromQuery(newQuery));
|
|
80
75
|
invariant(view);
|
|
81
|
-
view
|
|
76
|
+
Obj.change(view, (v) => {
|
|
77
|
+
v.query.ast = newQuery as Mutable<typeof newQuery>;
|
|
78
|
+
});
|
|
82
79
|
},
|
|
83
80
|
[schema, view],
|
|
84
81
|
);
|
|
@@ -89,10 +86,10 @@ const StoryViewEditor = ({
|
|
|
89
86
|
|
|
90
87
|
return (
|
|
91
88
|
<ViewEditor
|
|
92
|
-
registry={
|
|
89
|
+
registry={db?.schemaRegistry}
|
|
93
90
|
schema={schema}
|
|
94
91
|
view={view}
|
|
95
|
-
|
|
92
|
+
onQueryChanged={handleQueryChanged}
|
|
96
93
|
onDelete={handleDeleteColumn}
|
|
97
94
|
/>
|
|
98
95
|
);
|
|
@@ -103,20 +100,10 @@ const StoryViewEditor = ({
|
|
|
103
100
|
//
|
|
104
101
|
|
|
105
102
|
const DefaultStory = () => {
|
|
106
|
-
const {
|
|
107
|
-
|
|
108
|
-
schema,
|
|
109
|
-
view,
|
|
110
|
-
tableRef,
|
|
111
|
-
model,
|
|
112
|
-
presentation,
|
|
113
|
-
client,
|
|
114
|
-
handleInsertRow,
|
|
115
|
-
handleSaveView,
|
|
116
|
-
handleDeleteColumn,
|
|
117
|
-
} = useTestTableModel();
|
|
103
|
+
const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
|
|
104
|
+
useTestTableModel();
|
|
118
105
|
|
|
119
|
-
if (!schema || !view) {
|
|
106
|
+
if (!schema || !table?.view.target) {
|
|
120
107
|
return <div />;
|
|
121
108
|
}
|
|
122
109
|
|
|
@@ -124,21 +111,20 @@ const DefaultStory = () => {
|
|
|
124
111
|
<div className='grow grid grid-cols-[1fr_350px]'>
|
|
125
112
|
<div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
|
|
126
113
|
<TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
|
|
127
|
-
<
|
|
128
|
-
<
|
|
114
|
+
<TableComponent.Root>
|
|
115
|
+
<TableComponent.Main
|
|
129
116
|
ref={tableRef}
|
|
117
|
+
schema={schema}
|
|
130
118
|
model={model}
|
|
131
119
|
presentation={presentation}
|
|
132
|
-
schema={schema}
|
|
133
|
-
client={client}
|
|
134
120
|
ignoreAttention
|
|
135
121
|
/>
|
|
136
|
-
</
|
|
122
|
+
</TableComponent.Root>
|
|
137
123
|
</div>
|
|
138
|
-
<div className='flex flex-col
|
|
139
|
-
<StoryViewEditor view={view} schema={schema}
|
|
140
|
-
<SyntaxHighlighter language='json' className='
|
|
141
|
-
{JSON.stringify({ view, schema }, null, 2)}
|
|
124
|
+
<div className='flex flex-col bs-full border-l border-separator overflow-y-auto'>
|
|
125
|
+
<StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
|
|
126
|
+
<SyntaxHighlighter language='json' className='text-xs'>
|
|
127
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
142
128
|
</SyntaxHighlighter>
|
|
143
129
|
</div>
|
|
144
130
|
</div>
|
|
@@ -153,27 +139,28 @@ type StoryProps = { rows?: number };
|
|
|
153
139
|
|
|
154
140
|
// TODO(burdon): Need super simple story.
|
|
155
141
|
|
|
156
|
-
const meta
|
|
142
|
+
const meta = {
|
|
157
143
|
title: 'ui/react-ui-table/Table',
|
|
158
144
|
render: DefaultStory,
|
|
159
|
-
parameters: {
|
|
160
|
-
translations,
|
|
161
|
-
layout: 'fullscreen',
|
|
162
|
-
controls: {
|
|
163
|
-
disable: true,
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
145
|
decorators: [
|
|
167
146
|
withTheme,
|
|
168
|
-
|
|
147
|
+
withRegistry,
|
|
169
148
|
withClientProvider({
|
|
170
|
-
types: [
|
|
149
|
+
types: [View.View, Table.Table],
|
|
171
150
|
createIdentity: true,
|
|
172
151
|
createSpace: true,
|
|
173
|
-
|
|
174
|
-
const [schema] = await space.db.schemaRegistry.register([
|
|
175
|
-
const { view } = await
|
|
176
|
-
|
|
152
|
+
onCreateSpace: async ({ space }) => {
|
|
153
|
+
const [schema] = await space.db.schemaRegistry.register([Example]);
|
|
154
|
+
const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename: schema.typename });
|
|
155
|
+
const table = Table.make({ view, jsonSchema });
|
|
156
|
+
Obj.change(view, (v) => {
|
|
157
|
+
v.projection.fields = [
|
|
158
|
+
v.projection.fields.find((field) => field.path === 'name')!,
|
|
159
|
+
...v.projection.fields.filter((field) => field.path !== 'name'),
|
|
160
|
+
];
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
space.db.add(table);
|
|
177
164
|
|
|
178
165
|
Array.from({ length: 10 }).map(() => {
|
|
179
166
|
return space.db.add(
|
|
@@ -187,38 +174,52 @@ const meta: Meta<StoryProps> = {
|
|
|
187
174
|
},
|
|
188
175
|
}),
|
|
189
176
|
],
|
|
190
|
-
|
|
177
|
+
parameters: {
|
|
178
|
+
layout: 'fullscreen',
|
|
179
|
+
controls: {
|
|
180
|
+
disable: true,
|
|
181
|
+
},
|
|
182
|
+
translations: [...translations, ...formTranslations],
|
|
183
|
+
},
|
|
184
|
+
} satisfies Meta<typeof TableComponent>;
|
|
191
185
|
|
|
192
186
|
export default meta;
|
|
193
187
|
|
|
194
|
-
|
|
188
|
+
type Story = StoryObj<typeof meta>;
|
|
189
|
+
|
|
190
|
+
export const Default: Story = {};
|
|
195
191
|
|
|
196
192
|
export const StaticSchema: StoryObj = {
|
|
197
193
|
render: DefaultStory,
|
|
198
|
-
parameters: { translations },
|
|
199
194
|
decorators: [
|
|
200
195
|
withClientProvider({
|
|
201
|
-
types: [
|
|
196
|
+
types: [View.View, Table.Table],
|
|
202
197
|
createIdentity: true,
|
|
203
198
|
createSpace: true,
|
|
204
|
-
|
|
205
|
-
const { view } = await
|
|
206
|
-
|
|
199
|
+
onCreateSpace: async ({ space }) => {
|
|
200
|
+
const { view, jsonSchema } = await View.makeFromDatabase({
|
|
201
|
+
db: space.db,
|
|
202
|
+
typename: TestSchema.Person.typename,
|
|
203
|
+
});
|
|
204
|
+
const table = Table.make({ view, jsonSchema });
|
|
205
|
+
space.db.add(table);
|
|
207
206
|
|
|
208
207
|
const factory = createObjectFactory(space.db, faker as any);
|
|
209
208
|
await factory([
|
|
210
|
-
{ type:
|
|
211
|
-
// { type:
|
|
209
|
+
{ type: TestSchema.Person, count: 10 },
|
|
210
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
212
211
|
]);
|
|
213
212
|
},
|
|
214
213
|
}),
|
|
215
|
-
withLayout({ fullscreen: true }),
|
|
216
|
-
withTheme,
|
|
217
214
|
],
|
|
215
|
+
parameters: {
|
|
216
|
+
layout: 'fullscreen',
|
|
217
|
+
translations: [...translations, ...formTranslations],
|
|
218
|
+
},
|
|
218
219
|
};
|
|
219
220
|
|
|
220
221
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
221
|
-
name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
|
|
222
|
+
name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
|
|
222
223
|
emails: Schema.optional(
|
|
223
224
|
Schema.Array(
|
|
224
225
|
Schema.Struct({
|
|
@@ -228,7 +229,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
228
229
|
),
|
|
229
230
|
),
|
|
230
231
|
}).pipe(
|
|
231
|
-
|
|
232
|
+
Type.object({
|
|
232
233
|
typename: 'dxos.org/type/ContactWithArrayOfEmails',
|
|
233
234
|
version: '0.1.0',
|
|
234
235
|
}),
|
|
@@ -236,39 +237,43 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
236
237
|
|
|
237
238
|
export const ArrayOfObjects: StoryObj = {
|
|
238
239
|
render: DefaultStory,
|
|
239
|
-
parameters: { translations },
|
|
240
240
|
decorators: [
|
|
241
241
|
withClientProvider({
|
|
242
|
-
types: [
|
|
242
|
+
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
243
243
|
createIdentity: true,
|
|
244
244
|
createSpace: true,
|
|
245
|
-
|
|
246
|
-
const { view } = await
|
|
247
|
-
|
|
245
|
+
onCreateSpace: async ({ space }) => {
|
|
246
|
+
const { view, jsonSchema } = await View.makeFromDatabase({
|
|
247
|
+
db: space.db,
|
|
248
|
+
typename: ContactWithArrayOfEmails.typename,
|
|
249
|
+
});
|
|
250
|
+
const table = Table.make({ view, jsonSchema });
|
|
251
|
+
space.db.add(table);
|
|
248
252
|
|
|
249
253
|
const factory = createObjectFactory(space.db, faker as any);
|
|
250
254
|
await factory([
|
|
251
|
-
// { type:
|
|
252
|
-
// { type:
|
|
255
|
+
// { type: TestSchema.Person, count: 10 },
|
|
256
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
253
257
|
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
254
258
|
]);
|
|
255
259
|
},
|
|
256
260
|
}),
|
|
257
|
-
withLayout({ fullscreen: true }),
|
|
258
|
-
withTheme,
|
|
259
261
|
],
|
|
262
|
+
parameters: {
|
|
263
|
+
layout: 'fullscreen',
|
|
264
|
+
translations,
|
|
265
|
+
},
|
|
260
266
|
};
|
|
261
267
|
|
|
262
268
|
export const Tags: Meta<StoryProps> = {
|
|
263
269
|
title: 'ui/react-ui-table/Table',
|
|
264
270
|
render: DefaultStory,
|
|
265
|
-
parameters: { translations },
|
|
266
271
|
decorators: [
|
|
267
272
|
withClientProvider({
|
|
268
|
-
types: [
|
|
273
|
+
types: [View.View, Table.Table],
|
|
269
274
|
createIdentity: true,
|
|
270
275
|
createSpace: true,
|
|
271
|
-
|
|
276
|
+
onCreateSpace: async ({ space }) => {
|
|
272
277
|
// Configure schema.
|
|
273
278
|
const typename = 'example.com/SingleSelect';
|
|
274
279
|
const selectOptions = [
|
|
@@ -284,25 +289,26 @@ export const Tags: Meta<StoryProps> = {
|
|
|
284
289
|
const schema = getSchemaFromPropertyDefinitions(typename, [
|
|
285
290
|
{
|
|
286
291
|
name: 'single',
|
|
287
|
-
format:
|
|
292
|
+
format: Format.TypeFormat.SingleSelect,
|
|
288
293
|
config: { options: selectOptions },
|
|
289
294
|
},
|
|
290
295
|
{
|
|
291
296
|
name: 'multiple',
|
|
292
|
-
format:
|
|
297
|
+
format: Format.TypeFormat.MultiSelect,
|
|
293
298
|
config: { options: selectOptions },
|
|
294
299
|
},
|
|
295
300
|
]);
|
|
296
301
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
297
302
|
|
|
298
303
|
// Initialize table.
|
|
299
|
-
const { view } = await
|
|
300
|
-
|
|
304
|
+
const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename });
|
|
305
|
+
const table = Table.make({ view, jsonSchema });
|
|
306
|
+
space.db.add(table);
|
|
301
307
|
|
|
302
308
|
// Populate.
|
|
303
309
|
Array.from({ length: 10 }).map(() => {
|
|
304
310
|
return space.db.add(
|
|
305
|
-
|
|
311
|
+
Obj.make(storedSchema, {
|
|
306
312
|
single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
307
313
|
multiple: faker.helpers.randomSubset(selectOptionIds),
|
|
308
314
|
}),
|
|
@@ -310,7 +316,9 @@ export const Tags: Meta<StoryProps> = {
|
|
|
310
316
|
});
|
|
311
317
|
},
|
|
312
318
|
}),
|
|
313
|
-
withLayout({ fullscreen: true }),
|
|
314
|
-
withTheme,
|
|
315
319
|
],
|
|
320
|
+
parameters: {
|
|
321
|
+
layout: 'fullscreen',
|
|
322
|
+
translations,
|
|
323
|
+
},
|
|
316
324
|
};
|