@dxos/react-ui-table 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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-G7MGPBSR.mjs → chunk-I5IFW7UF.mjs} +633 -663
- 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 +1131 -999
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +29 -41
- 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-LD5JEBA6.mjs → chunk-DDJKYJFY.mjs} +633 -662
- 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 +1131 -999
- 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 +29 -41
- 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 +4 -5
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +4 -18
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +12 -9
- 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 +8 -8
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +71 -5
- 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/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 +4 -4
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.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 +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 +8 -8
- 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 +102 -23
- 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 +1 -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 +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 -11
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- 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 +53 -53
- package/src/components/Table/ColumnActionsMenu.tsx +10 -6
- package/src/components/Table/ColumnSettings.tsx +6 -6
- package/src/components/Table/DynamicTable.stories.tsx +12 -13
- package/src/components/Table/DynamicTable.tsx +21 -14
- package/src/components/Table/Relations.stories.tsx +35 -39
- package/src/components/Table/RowActionsMenu.tsx +24 -15
- package/src/components/Table/Table.stories.tsx +71 -75
- package/src/components/Table/Table.tsx +335 -305
- package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -1
- package/src/components/TableCellEditor/FormCellEditor.tsx +110 -133
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +16 -12
- package/src/components/TableCellEditor/TableCellEditor.tsx +31 -31
- package/src/components/TableToolbar/TableToolbar.tsx +44 -31
- package/src/components/testing.ts +38 -12
- 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 +35 -33
- package/src/model/modal-controller.ts +23 -12
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +82 -54
- package/src/model/table-model.ts +428 -163
- package/src/model/table-presentation.test.ts +59 -49
- package/src/model/table-presentation.ts +31 -26
- package/src/playwright/TableManager.ts +5 -5
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +8 -5
- package/src/testing/useTestTableModel.ts +44 -37
- 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 +39 -27
- package/src/util/index.ts +2 -0
- package/src/util/query-ast.ts +19 -0
- package/src/util/sort.ts +90 -0
- package/dist/lib/browser/chunk-4K7JPALT.mjs +0 -66
- package/dist/lib/browser/chunk-4K7JPALT.mjs.map +0 -7
- package/dist/lib/browser/chunk-G7MGPBSR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LD5JEBA6.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/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/model/table-sorting.ts +0 -225
- package/src/types/schema.ts +0 -73
|
@@ -6,26 +6,18 @@ 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
|
-
EchoObject,
|
|
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, 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 { type Space } from '@dxos/react-client/echo';
|
|
23
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
24
15
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
25
|
-
import { ViewEditor } from '@dxos/react-ui-form';
|
|
16
|
+
import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
|
|
26
17
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
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
22
|
import { useTestTableModel } from '../../testing';
|
|
31
23
|
import { translations } from '../../translations';
|
|
@@ -34,13 +26,13 @@ import { TableToolbar } from '../TableToolbar';
|
|
|
34
26
|
|
|
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((): Type.Ref<
|
|
50
|
+
parent: Schema.optional(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))).annotations({
|
|
59
51
|
title: 'Parent',
|
|
60
52
|
}),
|
|
61
53
|
}).pipe(
|
|
62
|
-
Type.
|
|
63
|
-
LabelAnnotation.set(['name']),
|
|
54
|
+
Type.object({ typename: `example.com/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, (v) => {
|
|
77
|
+
v.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,20 +100,10 @@ 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
|
-
if (!schema || !view) {
|
|
106
|
+
if (!schema || !table?.view.target) {
|
|
123
107
|
return <div />;
|
|
124
108
|
}
|
|
125
109
|
|
|
@@ -130,18 +114,17 @@ const DefaultStory = () => {
|
|
|
130
114
|
<TableComponent.Root>
|
|
131
115
|
<TableComponent.Main
|
|
132
116
|
ref={tableRef}
|
|
117
|
+
schema={schema}
|
|
133
118
|
model={model}
|
|
134
119
|
presentation={presentation}
|
|
135
|
-
schema={schema}
|
|
136
|
-
client={client}
|
|
137
120
|
ignoreAttention
|
|
138
121
|
/>
|
|
139
122
|
</TableComponent.Root>
|
|
140
123
|
</div>
|
|
141
|
-
<div className='flex flex-col
|
|
142
|
-
<StoryViewEditor view={view} schema={schema}
|
|
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} />
|
|
143
126
|
<SyntaxHighlighter language='json' className='text-xs'>
|
|
144
|
-
{JSON.stringify({ view, schema }, null, 2)}
|
|
127
|
+
{JSON.stringify({ view: table.view.target, schema }, null, 2)}
|
|
145
128
|
</SyntaxHighlighter>
|
|
146
129
|
</div>
|
|
147
130
|
</div>
|
|
@@ -161,19 +144,23 @@ const meta = {
|
|
|
161
144
|
render: DefaultStory,
|
|
162
145
|
decorators: [
|
|
163
146
|
withTheme,
|
|
147
|
+
withRegistry,
|
|
164
148
|
withClientProvider({
|
|
165
|
-
types: [
|
|
149
|
+
types: [View.View, Table.Table],
|
|
166
150
|
createIdentity: true,
|
|
167
151
|
createSpace: true,
|
|
168
|
-
onCreateSpace: async ({
|
|
169
|
-
const [schema] = await space.db.schemaRegistry.register([
|
|
170
|
-
const { view } = await
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
+
});
|
|
175
162
|
|
|
176
|
-
space.db.add(
|
|
163
|
+
space.db.add(table);
|
|
177
164
|
|
|
178
165
|
Array.from({ length: 10 }).map(() => {
|
|
179
166
|
return space.db.add(
|
|
@@ -192,7 +179,7 @@ const meta = {
|
|
|
192
179
|
controls: {
|
|
193
180
|
disable: true,
|
|
194
181
|
},
|
|
195
|
-
translations,
|
|
182
|
+
translations: [...translations, ...formTranslations],
|
|
196
183
|
},
|
|
197
184
|
} satisfies Meta<typeof TableComponent>;
|
|
198
185
|
|
|
@@ -206,29 +193,33 @@ export const StaticSchema: StoryObj = {
|
|
|
206
193
|
render: DefaultStory,
|
|
207
194
|
decorators: [
|
|
208
195
|
withClientProvider({
|
|
209
|
-
types: [
|
|
196
|
+
types: [View.View, Table.Table],
|
|
210
197
|
createIdentity: true,
|
|
211
198
|
createSpace: true,
|
|
212
|
-
onCreateSpace: async ({
|
|
213
|
-
const { view } = await
|
|
214
|
-
|
|
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);
|
|
215
206
|
|
|
216
207
|
const factory = createObjectFactory(space.db, faker as any);
|
|
217
208
|
await factory([
|
|
218
|
-
{ type:
|
|
219
|
-
// { type:
|
|
209
|
+
{ type: TestSchema.Person, count: 10 },
|
|
210
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
220
211
|
]);
|
|
221
212
|
},
|
|
222
213
|
}),
|
|
223
214
|
],
|
|
224
215
|
parameters: {
|
|
225
216
|
layout: 'fullscreen',
|
|
226
|
-
translations,
|
|
217
|
+
translations: [...translations, ...formTranslations],
|
|
227
218
|
},
|
|
228
219
|
};
|
|
229
220
|
|
|
230
221
|
const ContactWithArrayOfEmails = Schema.Struct({
|
|
231
|
-
name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
|
|
222
|
+
name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
|
|
232
223
|
emails: Schema.optional(
|
|
233
224
|
Schema.Array(
|
|
234
225
|
Schema.Struct({
|
|
@@ -238,7 +229,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
|
|
|
238
229
|
),
|
|
239
230
|
),
|
|
240
231
|
}).pipe(
|
|
241
|
-
|
|
232
|
+
Type.object({
|
|
242
233
|
typename: 'dxos.org/type/ContactWithArrayOfEmails',
|
|
243
234
|
version: '0.1.0',
|
|
244
235
|
}),
|
|
@@ -248,17 +239,21 @@ export const ArrayOfObjects: StoryObj = {
|
|
|
248
239
|
render: DefaultStory,
|
|
249
240
|
decorators: [
|
|
250
241
|
withClientProvider({
|
|
251
|
-
types: [
|
|
242
|
+
types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
|
|
252
243
|
createIdentity: true,
|
|
253
244
|
createSpace: true,
|
|
254
|
-
onCreateSpace: async ({
|
|
255
|
-
const { view } = await
|
|
256
|
-
|
|
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);
|
|
257
252
|
|
|
258
253
|
const factory = createObjectFactory(space.db, faker as any);
|
|
259
254
|
await factory([
|
|
260
|
-
// { type:
|
|
261
|
-
// { type:
|
|
255
|
+
// { type: TestSchema.Person, count: 10 },
|
|
256
|
+
// { type: TestSchema.Organization, count: 1 },
|
|
262
257
|
{ type: ContactWithArrayOfEmails, count: 10 },
|
|
263
258
|
]);
|
|
264
259
|
},
|
|
@@ -275,10 +270,10 @@ export const Tags: Meta<StoryProps> = {
|
|
|
275
270
|
render: DefaultStory,
|
|
276
271
|
decorators: [
|
|
277
272
|
withClientProvider({
|
|
278
|
-
types: [
|
|
273
|
+
types: [View.View, Table.Table],
|
|
279
274
|
createIdentity: true,
|
|
280
275
|
createSpace: true,
|
|
281
|
-
onCreateSpace: async ({
|
|
276
|
+
onCreateSpace: async ({ space }) => {
|
|
282
277
|
// Configure schema.
|
|
283
278
|
const typename = 'example.com/SingleSelect';
|
|
284
279
|
const selectOptions = [
|
|
@@ -294,25 +289,26 @@ export const Tags: Meta<StoryProps> = {
|
|
|
294
289
|
const schema = getSchemaFromPropertyDefinitions(typename, [
|
|
295
290
|
{
|
|
296
291
|
name: 'single',
|
|
297
|
-
format:
|
|
292
|
+
format: Format.TypeFormat.SingleSelect,
|
|
298
293
|
config: { options: selectOptions },
|
|
299
294
|
},
|
|
300
295
|
{
|
|
301
296
|
name: 'multiple',
|
|
302
|
-
format:
|
|
297
|
+
format: Format.TypeFormat.MultiSelect,
|
|
303
298
|
config: { options: selectOptions },
|
|
304
299
|
},
|
|
305
300
|
]);
|
|
306
301
|
const [storedSchema] = await space.db.schemaRegistry.register([schema]);
|
|
307
302
|
|
|
308
303
|
// Initialize table.
|
|
309
|
-
const { view } = await
|
|
310
|
-
|
|
304
|
+
const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename });
|
|
305
|
+
const table = Table.make({ view, jsonSchema });
|
|
306
|
+
space.db.add(table);
|
|
311
307
|
|
|
312
308
|
// Populate.
|
|
313
309
|
Array.from({ length: 10 }).map(() => {
|
|
314
310
|
return space.db.add(
|
|
315
|
-
|
|
311
|
+
Obj.make(storedSchema, {
|
|
316
312
|
single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
|
|
317
313
|
multiple: faker.helpers.randomSubset(selectOptionIds),
|
|
318
314
|
}),
|