@dxos/react-ui-table 0.8.3 → 0.8.4-main.1f223c7

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 (148) hide show
  1. package/dist/lib/browser/chunk-63UUF4IG.mjs +66 -0
  2. package/dist/lib/browser/chunk-63UUF4IG.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-BBXDTWCX.mjs +1822 -0
  4. package/dist/lib/browser/chunk-BBXDTWCX.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +814 -2152
  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 +124 -0
  9. package/dist/lib/browser/testing/index.mjs.map +7 -0
  10. package/dist/lib/browser/types/index.mjs +3 -5
  11. package/dist/lib/node-esm/chunk-K734DJB7.mjs +67 -0
  12. package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs +1823 -0
  14. package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +814 -2152
  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 +125 -0
  19. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  20. package/dist/lib/node-esm/types/index.mjs +3 -5
  21. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -1
  22. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/ColumnSettings.d.ts +4 -2
  24. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/CreateRefPanel.d.ts +1 -1
  26. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/DynamicTable.d.ts +1 -1
  28. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  29. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +50 -2
  30. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/Relations.stories.d.ts +44 -0
  32. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
  34. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  35. package/dist/types/src/components/Table/Table.d.ts +3 -2
  36. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  37. package/dist/types/src/components/Table/Table.stories.d.ts +42 -3
  38. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  39. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +2 -1
  40. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
  41. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +8 -3
  42. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  43. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +9 -15
  44. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  45. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -3
  46. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  47. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  48. package/dist/types/src/components/testing.d.ts +3 -40
  49. package/dist/types/src/components/testing.d.ts.map +1 -1
  50. package/dist/types/src/hooks/index.d.ts +1 -0
  51. package/dist/types/src/hooks/index.d.ts.map +1 -1
  52. package/dist/types/src/hooks/useAddRow.d.ts +14 -0
  53. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -0
  54. package/dist/types/src/hooks/useTableModel.d.ts +8 -7
  55. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  56. package/dist/types/src/index.d.ts +1 -2
  57. package/dist/types/src/index.d.ts.map +1 -1
  58. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  59. package/dist/types/src/model/selection-model.d.ts +2 -1
  60. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  61. package/dist/types/src/model/table-model.d.ts +59 -21
  62. package/dist/types/src/model/table-model.d.ts.map +1 -1
  63. package/dist/types/src/model/table-presentation.d.ts +10 -1
  64. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  65. package/dist/types/src/model/table-sorting.d.ts +3 -4
  66. package/dist/types/src/model/table-sorting.d.ts.map +1 -1
  67. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  68. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  69. package/dist/types/src/testing/index.d.ts +2 -0
  70. package/dist/types/src/testing/index.d.ts.map +1 -0
  71. package/dist/types/src/testing/useTestTableModel.d.ts +22 -0
  72. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -0
  73. package/dist/types/src/translations.d.ts +5 -6
  74. package/dist/types/src/translations.d.ts.map +1 -1
  75. package/dist/types/src/types/index.d.ts +1 -1
  76. package/dist/types/src/types/index.d.ts.map +1 -1
  77. package/dist/types/src/types/schema.d.ts +28 -0
  78. package/dist/types/src/types/schema.d.ts.map +1 -0
  79. package/dist/types/src/util/dynamic-table.d.ts +4 -5
  80. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  81. package/dist/types/src/util/index.d.ts +0 -1
  82. package/dist/types/src/util/index.d.ts.map +1 -1
  83. package/dist/types/src/util/table-buttons.d.ts +15 -1
  84. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  85. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  86. package/dist/types/tsconfig.tsbuildinfo +1 -1
  87. package/package.json +57 -44
  88. package/src/components/Table/ColumnActionsMenu.tsx +1 -1
  89. package/src/components/Table/ColumnSettings.tsx +15 -11
  90. package/src/components/Table/CreateRefPanel.tsx +30 -11
  91. package/src/components/Table/DynamicTable.stories.tsx +8 -5
  92. package/src/components/Table/DynamicTable.tsx +17 -10
  93. package/src/components/Table/{relations.stories.tsx → Relations.stories.tsx} +56 -47
  94. package/src/components/Table/RowActionsMenu.tsx +3 -3
  95. package/src/components/Table/Table.stories.tsx +126 -159
  96. package/src/components/Table/Table.tsx +167 -123
  97. package/src/components/TableCellEditor/CellValidationMessage.tsx +7 -2
  98. package/src/components/TableCellEditor/FormCellEditor.tsx +158 -48
  99. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +31 -47
  100. package/src/components/TableCellEditor/TableCellEditor.tsx +106 -111
  101. package/src/components/TableToolbar/TableToolbar.tsx +2 -2
  102. package/src/components/testing.ts +7 -24
  103. package/src/hooks/index.ts +1 -0
  104. package/src/hooks/useAddRow.ts +38 -0
  105. package/src/hooks/useTableModel.ts +21 -17
  106. package/src/index.ts +1 -2
  107. package/src/model/modal-controller.ts +1 -1
  108. package/src/model/selection-model.ts +6 -3
  109. package/src/model/table-model.test.ts +12 -9
  110. package/src/model/table-model.ts +288 -88
  111. package/src/model/table-presentation.test.ts +12 -8
  112. package/src/model/table-presentation.ts +263 -138
  113. package/src/model/table-sorting.ts +22 -13
  114. package/src/playwright/playwright.config.ts +17 -0
  115. package/src/playwright/smoke.spec.ts +137 -44
  116. package/src/testing/index.ts +5 -0
  117. package/src/testing/useTestTableModel.ts +124 -0
  118. package/src/translations.ts +7 -5
  119. package/src/types/index.ts +2 -2
  120. package/src/types/schema.ts +73 -0
  121. package/src/util/dynamic-table.ts +24 -21
  122. package/src/util/index.ts +0 -1
  123. package/src/util/schema.ts +1 -1
  124. package/src/util/table-buttons.ts +28 -4
  125. package/src/util/table-controls.ts +4 -1
  126. package/dist/lib/browser/chunk-TL7CKQQV.mjs +0 -27
  127. package/dist/lib/browser/chunk-TL7CKQQV.mjs.map +0 -7
  128. package/dist/lib/node/chunk-O2VPBNS5.cjs +0 -50
  129. package/dist/lib/node/chunk-O2VPBNS5.cjs.map +0 -7
  130. package/dist/lib/node/index.cjs +0 -2739
  131. package/dist/lib/node/index.cjs.map +0 -7
  132. package/dist/lib/node/meta.json +0 -1
  133. package/dist/lib/node/types/index.cjs +0 -31
  134. package/dist/lib/node/types/index.cjs.map +0 -7
  135. package/dist/lib/node-esm/chunk-GBT6GD4G.mjs +0 -29
  136. package/dist/lib/node-esm/chunk-GBT6GD4G.mjs.map +0 -7
  137. package/dist/types/src/components/Table/relations.stories.d.ts +0 -9
  138. package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
  139. package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
  140. package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
  141. package/dist/types/src/types/table.d.ts +0 -56
  142. package/dist/types/src/types/table.d.ts.map +0 -1
  143. package/dist/types/src/util/table.d.ts +0 -14
  144. package/dist/types/src/util/table.d.ts.map +0 -1
  145. package/src/components/TableCellEditor/extension.ts +0 -61
  146. package/src/playwright/playwright.config.cts +0 -18
  147. package/src/types/table.ts +0 -27
  148. package/src/util/table.ts +0 -127
@@ -4,150 +4,90 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { type StoryObj, type Meta } from '@storybook/react';
7
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
8
  import { Schema } from 'effect';
9
- import React, { useCallback, useMemo, useRef } from 'react';
10
-
11
- import { Obj, Type } from '@dxos/echo';
12
- import { FormatEnum, isMutable, toJsonSchema, EchoObject, GeneratorAnnotation } from '@dxos/echo-schema';
9
+ import React, { useCallback } from 'react';
10
+
11
+ import { Filter, Obj, Query, Type } from '@dxos/echo';
12
+ import {
13
+ EchoObject,
14
+ FormatAnnotation,
15
+ FormatEnum,
16
+ GeneratorAnnotation,
17
+ LabelAnnotation,
18
+ PropertyMetaAnnotationId,
19
+ } from '@dxos/echo-schema';
13
20
  import { invariant } from '@dxos/invariant';
14
- import { useGlobalFilteredObjects } from '@dxos/plugin-search';
15
21
  import { faker } from '@dxos/random';
16
- import { useClient } from '@dxos/react-client';
17
- import { Filter, useQuery, useSchema, live } from '@dxos/react-client/echo';
18
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
22
+ import { PublicKey } from '@dxos/react-client';
23
+ import { type Space, live } from '@dxos/react-client/echo';
24
+ import { withClientProvider } from '@dxos/react-client/testing';
19
25
  import { ViewEditor } from '@dxos/react-ui-form';
20
26
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
21
- import { getSchemaFromPropertyDefinitions, ViewProjection, ViewType } from '@dxos/schema';
27
+ import { DataType, getSchemaFromPropertyDefinitions } from '@dxos/schema';
22
28
  import { Testing, createObjectFactory } from '@dxos/schema/testing';
23
29
  import { withLayout, withTheme } from '@dxos/storybook-utils';
24
30
 
25
- import { Table, type TableController } from './Table';
26
- import { useTableModel } from '../../hooks';
27
- import { TablePresentation } from '../../model';
28
- import translations from '../../translations';
29
- import { TableType } from '../../types';
30
- import { initializeTable } from '../../util';
31
+ import { useTestTableModel } from '../../testing';
32
+ import { translations } from '../../translations';
33
+ import { Table } from '../../types';
31
34
  import { TableToolbar } from '../TableToolbar';
32
35
 
33
- faker.seed(0); // NOTE(ZaymonFC): Required for smoke tests.
34
-
35
- /**
36
- * Custom hook to create and manage a test table model for storybook demonstrations.
37
- * Provides table data, schema, and handlers for table operations.
38
- */
39
- const useTestTableModel = () => {
40
- const client = useClient();
41
- const { space } = useClientProvider();
42
-
43
- const filter = useMemo(() => Filter.type(TableType), []);
44
- const tables = useQuery(space, filter);
45
- const table = useMemo(() => tables.at(0), [tables]);
46
- const schema = useSchema(client, space, table?.view?.target?.query.typename);
47
-
48
- const projection = useMemo(() => {
49
- if (schema && table?.view?.target) {
50
- return new ViewProjection(toJsonSchema(schema), table.view.target);
51
- }
52
- }, [schema, table?.view?.target]);
53
-
54
- const features = useMemo(
55
- () => ({
56
- selection: { enabled: true, mode: 'multiple' as const },
57
- dataEditable: true,
58
- schemaEditable: schema && isMutable(schema),
59
- }),
60
- [schema],
61
- );
62
-
63
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
64
- const filteredObjects = useGlobalFilteredObjects(objects);
65
-
66
- const tableRef = useRef<TableController>(null);
67
- const handleCellUpdate = useCallback((cell: any) => {
68
- tableRef.current?.update?.(cell);
69
- }, []);
70
-
71
- const handleRowOrderChange = useCallback(() => {
72
- tableRef.current?.update?.();
73
- }, []);
74
-
75
- const handleInsertRow = useCallback(() => {
76
- if (space && schema) {
77
- space.db.add(live(schema, {}));
78
- }
79
- }, [space, schema]);
80
-
81
- const handleDeleteRows = useCallback(
82
- (_: number, objects: any[]) => {
83
- for (const object of objects) {
84
- space?.db.remove(object);
85
- }
86
- },
87
- [space],
88
- );
89
-
90
- const handleDeleteColumn = useCallback(
91
- (fieldId: string) => {
92
- if (projection) {
93
- projection.deleteFieldProjection(fieldId);
94
- }
95
- },
96
- [projection],
97
- );
98
-
99
- const model = useTableModel({
100
- table,
101
- projection,
102
- features,
103
- rows: filteredObjects,
104
- onInsertRow: handleInsertRow,
105
- onDeleteRows: handleDeleteRows,
106
- onDeleteColumn: handleDeleteColumn,
107
- onCellUpdate: handleCellUpdate,
108
- onRowOrderChange: handleRowOrderChange,
109
- });
110
-
111
- const handleSaveView = useCallback(() => {
112
- model?.saveView();
113
- }, [model]);
114
-
115
- const presentation = useMemo(() => {
116
- if (model) {
117
- return new TablePresentation(model);
118
- }
119
- }, [model]);
120
-
121
- return {
122
- schema,
123
- table,
124
- tableRef,
125
- model,
126
- presentation,
127
- space,
128
- client,
129
- handleInsertRow,
130
- handleSaveView,
131
- handleDeleteRows,
132
- handleDeleteColumn,
133
- };
134
- };
135
-
136
- const StoryViewEditor = () => {
137
- const { table, space, schema, handleDeleteColumn } = useTestTableModel();
138
-
139
- const handleTypenameChanged = useCallback(
36
+ import { Table as TableComponent } from './Table';
37
+
38
+ const TestSchema = Schema.Struct({
39
+ // TODO(wittjosiah): Should be title. Currently name to work with default label.
40
+ name: Schema.optional(Schema.String).annotations({ title: 'Title' }),
41
+ urgent: Schema.optional(Schema.Boolean).annotations({ title: 'Urgent' }),
42
+ status: Schema.optional(
43
+ Schema.Literal('todo', 'in-progress', 'done')
44
+ .pipe(FormatAnnotation.set(FormatEnum.SingleSelect))
45
+ .annotations({
46
+ title: 'Status',
47
+ [PropertyMetaAnnotationId]: {
48
+ singleSelect: {
49
+ options: [
50
+ { id: 'todo', title: 'Todo', color: 'indigo' },
51
+ { id: 'in-progress', title: 'In Progress', color: 'purple' },
52
+ { id: 'done', title: 'Done', color: 'amber' },
53
+ ],
54
+ },
55
+ },
56
+ }),
57
+ ),
58
+ description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
59
+ parent: Schema.optional(Schema.suspend((): Type.Ref<TestSchema> => Type.Ref(TestSchema))).annotations({
60
+ title: 'Parent',
61
+ }),
62
+ }).pipe(
63
+ Type.Obj({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
64
+ LabelAnnotation.set(['name']),
65
+ );
66
+ interface TestSchema extends Schema.Schema.Type<typeof TestSchema> {}
67
+
68
+ const StoryViewEditor = ({
69
+ view,
70
+ schema,
71
+ space,
72
+ handleDeleteColumn,
73
+ }: {
74
+ view?: DataType.View;
75
+ schema?: Schema.Schema.AnyNoContext;
76
+ space?: Space;
77
+ handleDeleteColumn: (fieldId: string) => void;
78
+ }) => {
79
+ const handleQueryChanged = useCallback(
140
80
  (typename: string) => {
141
81
  invariant(schema);
142
82
  invariant(Type.isMutable(schema));
143
83
  schema.updateTypename(typename);
144
- invariant(table?.view?.target);
145
- table.view.target.query.typename = typename;
84
+ invariant(view);
85
+ view.query = Query.select(Filter.typename(typename)).ast;
146
86
  },
147
- [schema, table?.view?.target],
87
+ [schema, view],
148
88
  );
149
89
 
150
- if (!table || !schema || !table.view?.target) {
90
+ if (!view || !schema) {
151
91
  return null;
152
92
  }
153
93
 
@@ -155,8 +95,8 @@ const StoryViewEditor = () => {
155
95
  <ViewEditor
156
96
  registry={space?.db.schemaRegistry}
157
97
  schema={schema}
158
- view={table.view.target!}
159
- onTypenameChanged={handleTypenameChanged}
98
+ view={view}
99
+ onQueryChanged={handleQueryChanged}
160
100
  onDelete={handleDeleteColumn}
161
101
  />
162
102
  );
@@ -167,9 +107,20 @@ const StoryViewEditor = () => {
167
107
  //
168
108
 
169
109
  const DefaultStory = () => {
170
- const { schema, table, tableRef, model, presentation, client, handleInsertRow, handleSaveView } = useTestTableModel();
110
+ const {
111
+ space,
112
+ schema,
113
+ view,
114
+ tableRef,
115
+ model,
116
+ presentation,
117
+ client,
118
+ handleInsertRow,
119
+ handleSaveView,
120
+ handleDeleteColumn,
121
+ } = useTestTableModel();
171
122
 
172
- if (!schema || !table) {
123
+ if (!schema || !view) {
173
124
  return <div />;
174
125
  }
175
126
 
@@ -177,8 +128,8 @@ const DefaultStory = () => {
177
128
  <div className='grow grid grid-cols-[1fr_350px]'>
178
129
  <div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
179
130
  <TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
180
- <Table.Root>
181
- <Table.Main
131
+ <TableComponent.Root>
132
+ <TableComponent.Main
182
133
  ref={tableRef}
183
134
  model={model}
184
135
  presentation={presentation}
@@ -186,12 +137,12 @@ const DefaultStory = () => {
186
137
  client={client}
187
138
  ignoreAttention
188
139
  />
189
- </Table.Root>
140
+ </TableComponent.Root>
190
141
  </div>
191
142
  <div className='flex flex-col h-full border-l border-separator overflow-y-auto'>
192
- <StoryViewEditor />
193
- <SyntaxHighlighter language='json' className='w-full text-xs'>
194
- {JSON.stringify({ view: table.view?.target, schema }, null, 2)}
143
+ <StoryViewEditor view={view} schema={schema} space={space} handleDeleteColumn={handleDeleteColumn} />
144
+ <SyntaxHighlighter language='json' className='text-xs'>
145
+ {JSON.stringify({ view, schema }, null, 2)}
195
146
  </SyntaxHighlighter>
196
147
  </div>
197
148
  </div>
@@ -206,53 +157,69 @@ type StoryProps = { rows?: number };
206
157
 
207
158
  // TODO(burdon): Need super simple story.
208
159
 
209
- const meta: Meta<StoryProps> = {
160
+ const meta = {
210
161
  title: 'ui/react-ui-table/Table',
211
162
  render: DefaultStory,
212
- parameters: { translations, controls: { disable: true } },
163
+ parameters: {
164
+ translations,
165
+ layout: 'fullscreen',
166
+ controls: {
167
+ disable: true,
168
+ },
169
+ },
213
170
  decorators: [
171
+ withTheme,
172
+ withLayout({ fullscreen: true }),
214
173
  withClientProvider({
215
- types: [TableType, ViewType],
174
+ types: [DataType.View, Table.Table],
216
175
  createIdentity: true,
217
176
  createSpace: true,
218
177
  onSpaceCreated: async ({ client, space }) => {
219
- const table = space.db.add(Obj.make(TableType, {}));
220
- const schema = await initializeTable({ client, space, table, initialRow: false });
178
+ const [schema] = await space.db.schemaRegistry.register([TestSchema]);
179
+ const { view } = await Table.makeView({ client, space, typename: schema.typename });
180
+ view.projection.fields = [
181
+ view.projection.fields.find((field) => field.path === 'name')!,
182
+ ...view.projection.fields.filter((field) => field.path !== 'name'),
183
+ ];
184
+
185
+ space.db.add(view);
186
+
221
187
  Array.from({ length: 10 }).map(() => {
222
188
  return space.db.add(
223
- live(schema, {
224
- name: faker.person.fullName(),
189
+ Obj.make(schema, {
190
+ name: faker.lorem.sentence(),
191
+ status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
192
+ description: faker.lorem.paragraph(),
225
193
  }),
226
194
  );
227
195
  });
228
196
  },
229
197
  }),
230
- withLayout({ fullscreen: true }),
231
- withTheme,
232
198
  ],
233
- };
199
+ } satisfies Meta<typeof TableComponent>;
234
200
 
235
201
  export default meta;
236
202
 
237
- export const Default = {};
203
+ type Story = StoryObj<typeof meta>;
204
+
205
+ export const Default: Story = {};
238
206
 
239
207
  export const StaticSchema: StoryObj = {
240
208
  render: DefaultStory,
241
209
  parameters: { translations },
242
210
  decorators: [
243
211
  withClientProvider({
244
- types: [TableType, ViewType, Testing.Contact, Testing.Organization],
212
+ types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization],
245
213
  createIdentity: true,
246
214
  createSpace: true,
247
215
  onSpaceCreated: async ({ client, space }) => {
248
- const table = space.db.add(Obj.make(TableType, {}));
249
- await initializeTable({ client, space, table, typename: Testing.Organization.typename });
216
+ const { view } = await Table.makeView({ client, space, typename: Testing.Contact.typename });
217
+ space.db.add(view);
250
218
 
251
219
  const factory = createObjectFactory(space.db, faker as any);
252
220
  await factory([
253
- // { type: Testing.Contact, count: 10 },
221
+ { type: Testing.Contact, count: 10 },
254
222
  // { type: Testing.Organization, count: 1 },
255
- { type: ContactWithArrayOfEmails, count: 10 },
256
223
  ]);
257
224
  },
258
225
  }),
@@ -283,12 +250,12 @@ export const ArrayOfObjects: StoryObj = {
283
250
  parameters: { translations },
284
251
  decorators: [
285
252
  withClientProvider({
286
- types: [TableType, ViewType, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
253
+ types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
287
254
  createIdentity: true,
288
255
  createSpace: true,
289
256
  onSpaceCreated: async ({ client, space }) => {
290
- const table = space.db.add(Obj.make(TableType, {}));
291
- await initializeTable({ client, space, table, typename: ContactWithArrayOfEmails.typename });
257
+ const { view } = await Table.makeView({ client, space, typename: ContactWithArrayOfEmails.typename });
258
+ space.db.add(view);
292
259
 
293
260
  const factory = createObjectFactory(space.db, faker as any);
294
261
  await factory([
@@ -309,7 +276,7 @@ export const Tags: Meta<StoryProps> = {
309
276
  parameters: { translations },
310
277
  decorators: [
311
278
  withClientProvider({
312
- types: [TableType, ViewType],
279
+ types: [DataType.View, Table.Table],
313
280
  createIdentity: true,
314
281
  createSpace: true,
315
282
  onSpaceCreated: async ({ client, space }) => {
@@ -340,8 +307,8 @@ export const Tags: Meta<StoryProps> = {
340
307
  const [storedSchema] = await space.db.schemaRegistry.register([schema]);
341
308
 
342
309
  // Initialize table.
343
- const table = space.db.add(Obj.make(TableType, {}));
344
- await initializeTable({ client, space, table, initialRow: false, typename });
310
+ const { view } = await Table.makeView({ client, space, typename });
311
+ space.db.add(view);
345
312
 
346
313
  // Populate.
347
314
  Array.from({ length: 10 }).map(() => {