@dxos/react-ui-table 0.8.4-main.2e9d522 → 0.8.4-main.3eb6e50203

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