@dxos/react-ui-table 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51

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.
Files changed (134) hide show
  1. package/dist/lib/browser/chunk-GTGYBRJA.mjs +1748 -0
  2. package/dist/lib/browser/chunk-GTGYBRJA.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-OZBLY7XM.mjs +76 -0
  4. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1131 -999
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +30 -42
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types/index.mjs +3 -3
  11. package/dist/lib/node-esm/chunk-DPNSZHU5.mjs +1750 -0
  12. package/dist/lib/node-esm/chunk-DPNSZHU5.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs +77 -0
  14. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1131 -999
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +30 -42
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/types/index.mjs +3 -3
  21. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
  22. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -2
  24. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/DynamicTable.d.ts +7 -7
  26. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +4 -18
  28. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  29. package/dist/types/src/components/Table/Relations.stories.d.ts +12 -9
  30. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/Table.d.ts +8 -8
  33. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/Table.stories.d.ts +71 -5
  35. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
  37. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +10 -12
  38. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  39. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -7
  40. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  41. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +4 -4
  42. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  43. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +4 -4
  44. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  45. package/dist/types/src/components/testing.d.ts +22 -15
  46. package/dist/types/src/components/testing.d.ts.map +1 -1
  47. package/dist/types/src/hooks/index.d.ts +2 -1
  48. package/dist/types/src/hooks/index.d.ts.map +1 -1
  49. package/dist/types/src/hooks/useAddRow.d.ts +5 -6
  50. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  51. package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
  52. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
  53. package/dist/types/src/hooks/useTableModel.d.ts +9 -9
  54. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  55. package/dist/types/src/model/modal-controller.d.ts +5 -1
  56. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  57. package/dist/types/src/model/selection-model.d.ts +17 -8
  58. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  59. package/dist/types/src/model/table-model.d.ts +104 -25
  60. package/dist/types/src/model/table-model.d.ts.map +1 -1
  61. package/dist/types/src/model/table-presentation.d.ts +3 -1
  62. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  63. package/dist/types/src/playwright/TableManager.d.ts +2 -1
  64. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  65. package/dist/types/src/testing/useTestTableModel.d.ts +18 -15
  66. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  67. package/dist/types/src/translations.d.ts +4 -4
  68. package/dist/types/src/translations.d.ts.map +1 -1
  69. package/dist/types/src/types/Table.d.ts +31 -0
  70. package/dist/types/src/types/Table.d.ts.map +1 -0
  71. package/dist/types/src/types/index.d.ts +1 -1
  72. package/dist/types/src/types/index.d.ts.map +1 -1
  73. package/dist/types/src/util/dynamic-table.d.ts +14 -11
  74. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  75. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  76. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  77. package/dist/types/src/util/index.d.ts +2 -0
  78. package/dist/types/src/util/index.d.ts.map +1 -1
  79. package/dist/types/src/util/query-ast.d.ts +7 -0
  80. package/dist/types/src/util/query-ast.d.ts.map +1 -0
  81. package/dist/types/src/util/sort.d.ts +12 -0
  82. package/dist/types/src/util/sort.d.ts.map +1 -0
  83. package/dist/types/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +53 -53
  85. package/src/components/Table/ColumnActionsMenu.tsx +10 -6
  86. package/src/components/Table/ColumnSettings.tsx +6 -6
  87. package/src/components/Table/DynamicTable.stories.tsx +15 -15
  88. package/src/components/Table/DynamicTable.tsx +24 -16
  89. package/src/components/Table/Relations.stories.tsx +43 -54
  90. package/src/components/Table/RowActionsMenu.tsx +24 -15
  91. package/src/components/Table/Table.stories.tsx +89 -80
  92. package/src/components/Table/Table.tsx +335 -305
  93. package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -1
  94. package/src/components/TableCellEditor/FormCellEditor.tsx +110 -133
  95. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +17 -13
  96. package/src/components/TableCellEditor/TableCellEditor.tsx +31 -31
  97. package/src/components/TableToolbar/TableToolbar.tsx +47 -31
  98. package/src/components/testing.ts +38 -12
  99. package/src/hooks/index.ts +2 -1
  100. package/src/hooks/useAddRow.ts +8 -10
  101. package/src/hooks/useProjectionModel.ts +39 -0
  102. package/src/hooks/useTableModel.ts +36 -34
  103. package/src/model/modal-controller.ts +23 -12
  104. package/src/model/selection-model.ts +75 -44
  105. package/src/model/table-model.test.ts +82 -54
  106. package/src/model/table-model.ts +435 -170
  107. package/src/model/table-presentation.test.ts +59 -49
  108. package/src/model/table-presentation.ts +32 -27
  109. package/src/playwright/TableManager.ts +13 -6
  110. package/src/playwright/playwright.config.ts +1 -1
  111. package/src/playwright/smoke.spec.ts +56 -10
  112. package/src/testing/useTestTableModel.ts +45 -38
  113. package/src/translations.ts +3 -3
  114. package/src/types/Table.ts +90 -0
  115. package/src/types/index.ts +1 -1
  116. package/src/util/dynamic-table.test.ts +70 -0
  117. package/src/util/dynamic-table.ts +40 -28
  118. package/src/util/index.ts +2 -0
  119. package/src/util/query-ast.ts +19 -0
  120. package/src/util/sort.ts +90 -0
  121. package/dist/lib/browser/chunk-4K7JPALT.mjs +0 -66
  122. package/dist/lib/browser/chunk-4K7JPALT.mjs.map +0 -7
  123. package/dist/lib/browser/chunk-OZTXLZGM.mjs +0 -1804
  124. package/dist/lib/browser/chunk-OZTXLZGM.mjs.map +0 -7
  125. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs +0 -67
  126. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +0 -7
  127. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs +0 -1805
  128. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs.map +0 -7
  129. package/dist/types/src/model/table-sorting.d.ts +0 -52
  130. package/dist/types/src/model/table-sorting.d.ts.map +0 -1
  131. package/dist/types/src/types/schema.d.ts +0 -28
  132. package/dist/types/src/types/schema.d.ts.map +0 -1
  133. package/src/model/table-sorting.ts +0 -225
  134. package/src/types/schema.ts +0 -73
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { useAtomValue } from '@effect-atom/atom-react';
5
6
  import React from 'react';
6
7
 
7
8
  import { DropdownMenu, toLocalizedString, useTranslation } from '@dxos/react-ui';
@@ -13,8 +14,8 @@ type RowActionsMenuProps = { model: TableModel; modals: ModalController };
13
14
 
14
15
  export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
15
16
  const { t } = useTranslation(translationKey);
16
- const hasSelection = model.selection.hasSelection.value;
17
- const state = modals.state.value;
17
+ const hasSelection = model.selection.hasSelection;
18
+ const state = useAtomValue(modals.state);
18
19
  if (state?.type !== 'row') {
19
20
  return null;
20
21
  }
@@ -23,24 +24,32 @@ export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
23
24
  <DropdownMenu.VirtualTrigger virtualRef={modals.trigger} />
24
25
  <DropdownMenu.Content>
25
26
  <DropdownMenu.Viewport>
27
+ {/* Custom actions */}
28
+ {model.rowActions?.length > 0 && (
29
+ <>
30
+ <DropdownMenu.Group>
31
+ {model.rowActions?.map((action) => (
32
+ <DropdownMenu.Item
33
+ key={action.id}
34
+ data-testid={`row-action-${action.id}`}
35
+ onClick={() => {
36
+ modals.close();
37
+ model.handleRowAction(action.id, state.rowIndex);
38
+ }}
39
+ >
40
+ {toLocalizedString(action.label, t)}
41
+ </DropdownMenu.Item>
42
+ ))}
43
+ </DropdownMenu.Group>
44
+ <DropdownMenu.Separator />
45
+ </>
46
+ )}
47
+ {/* Default actions */}
26
48
  {model.features.dataEditable !== false && (
27
49
  <DropdownMenu.Item data-testid='row-menu-delete' onClick={() => model.deleteRow(state.rowIndex)}>
28
50
  {t(hasSelection ? 'bulk delete row label' : 'delete row label')}
29
51
  </DropdownMenu.Item>
30
52
  )}
31
- {/* Custom actions */}
32
- {model.rowActions?.map((action) => (
33
- <DropdownMenu.Item
34
- key={action.id}
35
- data-testid={`row-action-${action.id}`}
36
- onClick={() => {
37
- modals.close();
38
- model.handleRowAction(action.id, state.rowIndex);
39
- }}
40
- >
41
- {toLocalizedString(action.label, t)}
42
- </DropdownMenu.Item>
43
- ))}
44
53
  </DropdownMenu.Viewport>
45
54
  <DropdownMenu.Arrow />
46
55
  </DropdownMenu.Content>
@@ -6,26 +6,19 @@ 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';
15
+ import { ScrollArea } from '@dxos/react-ui';
24
16
  import { withTheme } from '@dxos/react-ui/testing';
25
- import { ViewEditor } from '@dxos/react-ui-form';
17
+ import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
26
18
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
27
- import { DataType, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
28
- import { Testing, createObjectFactory } from '@dxos/schema/testing';
19
+ import { View, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
20
+ import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
21
+ import { withRegistry } from '@dxos/storybook-utils';
29
22
 
30
23
  import { useTestTableModel } from '../../testing';
31
24
  import { translations } from '../../translations';
@@ -34,13 +27,13 @@ import { TableToolbar } from '../TableToolbar';
34
27
 
35
28
  import { Table as TableComponent } from './Table';
36
29
 
37
- const TestSchema = Schema.Struct({
30
+ const Example = Schema.Struct({
38
31
  // TODO(wittjosiah): Should be title. Currently name to work with default label.
39
32
  name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
40
33
  urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
41
34
  status: Schema.optional(
42
35
  Schema.Literal('todo', 'in-progress', 'done')
43
- .pipe(FormatAnnotation.set(FormatEnum.SingleSelect))
36
+ .pipe(Format.FormatAnnotation.set(Format.TypeFormat.SingleSelect))
44
37
  .annotations({
45
38
  title: 'Status',
46
39
  [PropertyMetaAnnotationId]: {
@@ -55,24 +48,24 @@ const TestSchema = Schema.Struct({
55
48
  }),
56
49
  ),
57
50
  description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
58
- parent: Schema.optional(Schema.suspend((): Type.Ref<TestSchema> => Type.Ref(TestSchema))).annotations({
51
+ parent: Schema.optional(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))).annotations({
59
52
  title: 'Parent',
60
53
  }),
61
54
  }).pipe(
62
- Type.Obj({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
63
- LabelAnnotation.set(['name']),
55
+ Type.object({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
56
+ Annotation.LabelAnnotation.set(['name']),
64
57
  );
65
- interface TestSchema extends Schema.Schema.Type<typeof TestSchema> {}
58
+ interface Example extends Schema.Schema.Type<typeof Example> {}
66
59
 
67
60
  const StoryViewEditor = ({
68
61
  view,
69
62
  schema,
70
- space,
63
+ db,
71
64
  handleDeleteColumn,
72
65
  }: {
73
- view?: DataType.View;
66
+ view?: View.View;
74
67
  schema?: Schema.Schema.AnyNoContext;
75
- space?: Space;
68
+ db?: Database.Database;
76
69
  handleDeleteColumn: (fieldId: string) => void;
77
70
  }) => {
78
71
  const handleQueryChanged = useCallback(
@@ -81,7 +74,9 @@ const StoryViewEditor = ({
81
74
  invariant(Type.isMutable(schema));
82
75
  schema.updateTypename(getTypenameFromQuery(newQuery));
83
76
  invariant(view);
84
- view.query.ast = newQuery;
77
+ Obj.change(view, (v) => {
78
+ v.query.ast = newQuery as Mutable<typeof newQuery>;
79
+ });
85
80
  },
86
81
  [schema, view],
87
82
  );
@@ -92,7 +87,7 @@ const StoryViewEditor = ({
92
87
 
93
88
  return (
94
89
  <ViewEditor
95
- registry={space?.db.schemaRegistry}
90
+ registry={db?.schemaRegistry}
96
91
  schema={schema}
97
92
  view={view}
98
93
  onQueryChanged={handleQueryChanged}
@@ -106,20 +101,19 @@ const StoryViewEditor = ({
106
101
  //
107
102
 
108
103
  const DefaultStory = () => {
109
- const {
110
- space,
111
- schema,
112
- view,
113
- tableRef,
114
- model,
115
- presentation,
116
- client,
117
- handleInsertRow,
118
- handleSaveView,
119
- handleDeleteColumn,
120
- } = useTestTableModel();
121
-
122
- if (!schema || !view) {
104
+ const { db, schema, table, tableRef, model, presentation, handleInsertRow, handleSaveView, handleDeleteColumn } =
105
+ useTestTableModel();
106
+
107
+ const handleRowClick = useCallback(
108
+ (row: any) => {
109
+ if (model?.getDraftRowCount() === 0 && ['frozenRowsEnd', 'fixedEndStart', 'fixedEndEnd'].includes(row?.plane)) {
110
+ handleInsertRow();
111
+ }
112
+ },
113
+ [model, handleInsertRow],
114
+ );
115
+
116
+ if (!schema || !table?.view.target) {
123
117
  return <div />;
124
118
  }
125
119
 
@@ -130,20 +124,22 @@ const DefaultStory = () => {
130
124
  <TableComponent.Root>
131
125
  <TableComponent.Main
132
126
  ref={tableRef}
127
+ schema={schema}
133
128
  model={model}
134
129
  presentation={presentation}
135
- schema={schema}
136
- client={client}
130
+ onRowClick={handleRowClick}
137
131
  ignoreAttention
138
132
  />
139
133
  </TableComponent.Root>
140
134
  </div>
141
- <div className='flex flex-col h-full border-l border-separator overflow-y-auto'>
142
- <StoryViewEditor view={view} schema={schema} space={space} handleDeleteColumn={handleDeleteColumn} />
143
- <SyntaxHighlighter language='json' className='text-xs'>
144
- {JSON.stringify({ view, schema }, null, 2)}
145
- </SyntaxHighlighter>
146
- </div>
135
+ <ScrollArea.Root orientation='vertical' classNames='bs-full border-l border-separator'>
136
+ <ScrollArea.Viewport>
137
+ <StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
138
+ <SyntaxHighlighter language='json' className='text-xs'>
139
+ {JSON.stringify({ view: table.view.target, schema }, null, 2)}
140
+ </SyntaxHighlighter>
141
+ </ScrollArea.Viewport>
142
+ </ScrollArea.Root>
147
143
  </div>
148
144
  );
149
145
  };
@@ -160,20 +156,24 @@ const meta = {
160
156
  title: 'ui/react-ui-table/Table',
161
157
  render: DefaultStory,
162
158
  decorators: [
163
- withTheme,
159
+ withTheme(),
160
+ withRegistry,
164
161
  withClientProvider({
165
- types: [DataType.View, Table.Table],
162
+ types: [View.View, Table.Table],
166
163
  createIdentity: true,
167
164
  createSpace: true,
168
- onCreateSpace: async ({ client, space }) => {
169
- const [schema] = await space.db.schemaRegistry.register([TestSchema]);
170
- const { view } = await Table.makeView({ client, space, typename: schema.typename });
171
- view.projection.fields = [
172
- view.projection.fields.find((field) => field.path === 'name')!,
173
- ...view.projection.fields.filter((field) => field.path !== 'name'),
174
- ];
165
+ onCreateSpace: async ({ space }) => {
166
+ const [schema] = await space.db.schemaRegistry.register([Example]);
167
+ const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename: schema.typename });
168
+ const table = Table.make({ view, jsonSchema });
169
+ Obj.change(view, (v) => {
170
+ v.projection.fields = [
171
+ v.projection.fields.find((field) => field.path === 'name')!,
172
+ ...v.projection.fields.filter((field) => field.path !== 'name'),
173
+ ];
174
+ });
175
175
 
176
- space.db.add(view);
176
+ space.db.add(table);
177
177
 
178
178
  Array.from({ length: 10 }).map(() => {
179
179
  return space.db.add(
@@ -192,7 +192,7 @@ const meta = {
192
192
  controls: {
193
193
  disable: true,
194
194
  },
195
- translations,
195
+ translations: [...translations, ...formTranslations],
196
196
  },
197
197
  } satisfies Meta<typeof TableComponent>;
198
198
 
@@ -206,29 +206,33 @@ export const StaticSchema: StoryObj = {
206
206
  render: DefaultStory,
207
207
  decorators: [
208
208
  withClientProvider({
209
- types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization],
209
+ types: [View.View, Table.Table],
210
210
  createIdentity: true,
211
211
  createSpace: true,
212
- onCreateSpace: async ({ client, space }) => {
213
- const { view } = await Table.makeView({ client, space, typename: Testing.Contact.typename });
214
- space.db.add(view);
212
+ onCreateSpace: async ({ space }) => {
213
+ const { view, jsonSchema } = await View.makeFromDatabase({
214
+ db: space.db,
215
+ typename: TestSchema.Person.typename,
216
+ });
217
+ const table = Table.make({ view, jsonSchema });
218
+ space.db.add(table);
215
219
 
216
220
  const factory = createObjectFactory(space.db, faker as any);
217
221
  await factory([
218
- { type: Testing.Contact, count: 10 },
219
- // { type: Testing.Organization, count: 1 },
222
+ { type: TestSchema.Person, count: 10 },
223
+ // { type: TestSchema.Organization, count: 1 },
220
224
  ]);
221
225
  },
222
226
  }),
223
227
  ],
224
228
  parameters: {
225
229
  layout: 'fullscreen',
226
- translations,
230
+ translations: [...translations, ...formTranslations],
227
231
  },
228
232
  };
229
233
 
230
234
  const ContactWithArrayOfEmails = Schema.Struct({
231
- name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
235
+ name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
232
236
  emails: Schema.optional(
233
237
  Schema.Array(
234
238
  Schema.Struct({
@@ -238,7 +242,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
238
242
  ),
239
243
  ),
240
244
  }).pipe(
241
- EchoObject({
245
+ Type.object({
242
246
  typename: 'dxos.org/type/ContactWithArrayOfEmails',
243
247
  version: '0.1.0',
244
248
  }),
@@ -248,17 +252,21 @@ export const ArrayOfObjects: StoryObj = {
248
252
  render: DefaultStory,
249
253
  decorators: [
250
254
  withClientProvider({
251
- types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
255
+ types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
252
256
  createIdentity: true,
253
257
  createSpace: true,
254
- onCreateSpace: async ({ client, space }) => {
255
- const { view } = await Table.makeView({ client, space, typename: ContactWithArrayOfEmails.typename });
256
- space.db.add(view);
258
+ onCreateSpace: async ({ space }) => {
259
+ const { view, jsonSchema } = await View.makeFromDatabase({
260
+ db: space.db,
261
+ typename: ContactWithArrayOfEmails.typename,
262
+ });
263
+ const table = Table.make({ view, jsonSchema });
264
+ space.db.add(table);
257
265
 
258
266
  const factory = createObjectFactory(space.db, faker as any);
259
267
  await factory([
260
- // { type: Testing.Contact, count: 10 },
261
- // { type: Testing.Organization, count: 1 },
268
+ // { type: TestSchema.Person, count: 10 },
269
+ // { type: TestSchema.Organization, count: 1 },
262
270
  { type: ContactWithArrayOfEmails, count: 10 },
263
271
  ]);
264
272
  },
@@ -275,10 +283,10 @@ export const Tags: Meta<StoryProps> = {
275
283
  render: DefaultStory,
276
284
  decorators: [
277
285
  withClientProvider({
278
- types: [DataType.View, Table.Table],
286
+ types: [View.View, Table.Table],
279
287
  createIdentity: true,
280
288
  createSpace: true,
281
- onCreateSpace: async ({ client, space }) => {
289
+ onCreateSpace: async ({ space }) => {
282
290
  // Configure schema.
283
291
  const typename = 'example.com/SingleSelect';
284
292
  const selectOptions = [
@@ -294,25 +302,26 @@ export const Tags: Meta<StoryProps> = {
294
302
  const schema = getSchemaFromPropertyDefinitions(typename, [
295
303
  {
296
304
  name: 'single',
297
- format: FormatEnum.SingleSelect,
305
+ format: Format.TypeFormat.SingleSelect,
298
306
  config: { options: selectOptions },
299
307
  },
300
308
  {
301
309
  name: 'multiple',
302
- format: FormatEnum.MultiSelect,
310
+ format: Format.TypeFormat.MultiSelect,
303
311
  config: { options: selectOptions },
304
312
  },
305
313
  ]);
306
314
  const [storedSchema] = await space.db.schemaRegistry.register([schema]);
307
315
 
308
316
  // Initialize table.
309
- const { view } = await Table.makeView({ client, space, typename });
310
- space.db.add(view);
317
+ const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename });
318
+ const table = Table.make({ view, jsonSchema });
319
+ space.db.add(table);
311
320
 
312
321
  // Populate.
313
322
  Array.from({ length: 10 }).map(() => {
314
323
  return space.db.add(
315
- live(storedSchema, {
324
+ Obj.make(storedSchema, {
316
325
  single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
317
326
  multiple: faker.helpers.randomSubset(selectOptionIds),
318
327
  }),