@dxos/react-ui-table 0.8.4-main.c4373fc → 0.8.4-main.d05539e30a

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 (169) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/chunk-4URYOFDL.mjs +69 -0
  3. package/dist/lib/browser/chunk-4URYOFDL.mjs.map +7 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-YDXPC7HA.mjs +1695 -0
  7. package/dist/lib/browser/chunk-YDXPC7HA.mjs.map +7 -0
  8. package/dist/lib/browser/index.mjs +1136 -1044
  9. package/dist/lib/browser/index.mjs.map +4 -4
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/testing/index.mjs +35 -45
  12. package/dist/lib/browser/testing/index.mjs.map +3 -3
  13. package/dist/lib/browser/translations.mjs +36 -0
  14. package/dist/lib/browser/translations.mjs.map +7 -0
  15. package/dist/lib/browser/types/index.mjs +4 -3
  16. package/dist/lib/node-esm/chunk-2AN3QQ3D.mjs +1697 -0
  17. package/dist/lib/node-esm/chunk-2AN3QQ3D.mjs.map +7 -0
  18. package/dist/lib/node-esm/chunk-B2SZYAEC.mjs +70 -0
  19. package/dist/lib/node-esm/chunk-B2SZYAEC.mjs.map +7 -0
  20. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  21. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  22. package/dist/lib/node-esm/index.mjs +1136 -1044
  23. package/dist/lib/node-esm/index.mjs.map +4 -4
  24. package/dist/lib/node-esm/meta.json +1 -1
  25. package/dist/lib/node-esm/testing/index.mjs +35 -45
  26. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  27. package/dist/lib/node-esm/translations.mjs +37 -0
  28. package/dist/lib/node-esm/translations.mjs.map +7 -0
  29. package/dist/lib/node-esm/types/index.mjs +4 -3
  30. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
  31. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -2
  33. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/DynamicTable.d.ts +6 -7
  35. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  36. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +21 -37
  37. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/Table/Relations.stories.d.ts +84 -81
  39. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  40. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  41. package/dist/types/src/components/Table/Table.d.ts +20 -21
  42. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  43. package/dist/types/src/components/Table/Table.stories.d.ts +92 -26
  44. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  45. package/dist/types/src/components/Table/TableContent.d.ts +18 -0
  46. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  47. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  48. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  49. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
  50. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
  51. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +10 -12
  52. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  53. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -7
  54. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  55. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +24 -26
  56. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  57. package/dist/types/src/components/index.d.ts +0 -1
  58. package/dist/types/src/components/index.d.ts.map +1 -1
  59. package/dist/types/src/components/testing.d.ts +22 -15
  60. package/dist/types/src/components/testing.d.ts.map +1 -1
  61. package/dist/types/src/hooks/index.d.ts +2 -1
  62. package/dist/types/src/hooks/index.d.ts.map +1 -1
  63. package/dist/types/src/hooks/useAddRow.d.ts +5 -6
  64. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  65. package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
  66. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
  67. package/dist/types/src/hooks/useTableModel.d.ts +9 -9
  68. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  69. package/dist/types/src/index.d.ts +0 -2
  70. package/dist/types/src/index.d.ts.map +1 -1
  71. package/dist/types/src/model/modal-controller.d.ts +5 -1
  72. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  73. package/dist/types/src/model/selection-model.d.ts +18 -9
  74. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  75. package/dist/types/src/model/table-model.d.ts +104 -25
  76. package/dist/types/src/model/table-model.d.ts.map +1 -1
  77. package/dist/types/src/model/table-presentation.d.ts +3 -1
  78. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  79. package/dist/types/src/playwright/TableManager.d.ts +2 -1
  80. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  81. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  82. package/dist/types/src/testing/useTestTableModel.d.ts +18 -15
  83. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  84. package/dist/types/src/translations.d.ts +21 -23
  85. package/dist/types/src/translations.d.ts.map +1 -1
  86. package/dist/types/src/types/Table.d.ts +25 -0
  87. package/dist/types/src/types/Table.d.ts.map +1 -0
  88. package/dist/types/src/types/index.d.ts +1 -1
  89. package/dist/types/src/types/index.d.ts.map +1 -1
  90. package/dist/types/src/util/dynamic-table.d.ts +14 -11
  91. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  92. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  93. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  94. package/dist/types/src/util/index.d.ts +2 -0
  95. package/dist/types/src/util/index.d.ts.map +1 -1
  96. package/dist/types/src/util/query-ast.d.ts +7 -0
  97. package/dist/types/src/util/query-ast.d.ts.map +1 -0
  98. package/dist/types/src/util/schema.d.ts.map +1 -1
  99. package/dist/types/src/util/signals.d.ts.map +1 -1
  100. package/dist/types/src/util/sort.d.ts +12 -0
  101. package/dist/types/src/util/sort.d.ts.map +1 -0
  102. package/dist/types/src/util/table-buttons.d.ts +20 -20
  103. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  104. package/dist/types/src/util/table-controls.d.ts +4 -4
  105. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  106. package/dist/types/src/util/tag.d.ts.map +1 -1
  107. package/dist/types/tsconfig.tsbuildinfo +1 -1
  108. package/package.json +67 -76
  109. package/src/components/Table/ColumnActionsMenu.tsx +17 -12
  110. package/src/components/Table/ColumnSettings.tsx +8 -9
  111. package/src/components/Table/DynamicTable.stories.tsx +30 -30
  112. package/src/components/Table/DynamicTable.tsx +31 -32
  113. package/src/components/Table/Relations.stories.tsx +113 -81
  114. package/src/components/Table/RowActionsMenu.tsx +27 -17
  115. package/src/components/Table/Table.stories.tsx +125 -110
  116. package/src/components/Table/Table.tsx +43 -407
  117. package/src/components/Table/TableContent.tsx +425 -0
  118. package/src/components/Table/TableToolbar.tsx +111 -0
  119. package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -6
  120. package/src/components/TableCellEditor/FormCellEditor.tsx +119 -135
  121. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +26 -22
  122. package/src/components/TableCellEditor/TableCellEditor.tsx +35 -33
  123. package/src/components/index.ts +0 -1
  124. package/src/components/testing.ts +43 -17
  125. package/src/hooks/index.ts +2 -1
  126. package/src/hooks/useAddRow.ts +8 -10
  127. package/src/hooks/useProjectionModel.ts +39 -0
  128. package/src/hooks/useTableModel.ts +36 -34
  129. package/src/index.ts +0 -4
  130. package/src/model/modal-controller.ts +23 -12
  131. package/src/model/selection-model.ts +75 -44
  132. package/src/model/table-model.test.ts +82 -55
  133. package/src/model/table-model.ts +435 -170
  134. package/src/model/table-presentation.test.ts +59 -50
  135. package/src/model/table-presentation.ts +43 -39
  136. package/src/playwright/TableManager.ts +13 -6
  137. package/src/playwright/playwright.config.ts +1 -1
  138. package/src/playwright/smoke.spec.ts +59 -13
  139. package/src/testing/useTestTableModel.ts +49 -42
  140. package/src/translations.ts +20 -22
  141. package/src/types/Table.ts +78 -0
  142. package/src/types/index.ts +1 -1
  143. package/src/util/dynamic-table.test.ts +70 -0
  144. package/src/util/dynamic-table.ts +40 -28
  145. package/src/util/index.ts +2 -0
  146. package/src/util/query-ast.ts +22 -0
  147. package/src/util/sort.ts +90 -0
  148. package/src/util/table-buttons.ts +1 -1
  149. package/src/util/table-controls.ts +2 -2
  150. package/dist/lib/browser/chunk-4K7JPALT.mjs +0 -66
  151. package/dist/lib/browser/chunk-4K7JPALT.mjs.map +0 -7
  152. package/dist/lib/browser/chunk-OZTXLZGM.mjs +0 -1804
  153. package/dist/lib/browser/chunk-OZTXLZGM.mjs.map +0 -7
  154. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs +0 -67
  155. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +0 -7
  156. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs +0 -1805
  157. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs.map +0 -7
  158. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  159. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  160. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  161. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  162. package/dist/types/src/model/table-sorting.d.ts +0 -52
  163. package/dist/types/src/model/table-sorting.d.ts.map +0 -1
  164. package/dist/types/src/types/schema.d.ts +0 -28
  165. package/dist/types/src/types/schema.d.ts.map +0 -1
  166. package/src/components/TableToolbar/TableToolbar.tsx +0 -102
  167. package/src/components/TableToolbar/index.ts +0 -5
  168. package/src/model/table-sorting.ts +0 -225
  169. package/src/types/schema.ts +0 -73
@@ -6,41 +6,34 @@ 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 { Filter, Obj, Query, 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, Ref, Type, View } from '@dxos/echo';
10
+ import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
19
11
  import { invariant } from '@dxos/invariant';
20
- import { faker } from '@dxos/random';
12
+ import { random } 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
- import { withTheme } from '@dxos/react-ui/testing';
15
+ import { Panel, ScrollArea } from '@dxos/react-ui';
25
16
  import { ViewEditor } from '@dxos/react-ui-form';
26
- import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
27
- import { DataType, getSchemaFromPropertyDefinitions } from '@dxos/schema';
28
- import { Testing, createObjectFactory } from '@dxos/schema/testing';
17
+ import { translations as formTranslations } from '@dxos/react-ui-form/translations';
18
+ import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
19
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
20
+ import { ViewModel, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
21
+ import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
22
+ import { withRegistry } from '@dxos/storybook-utils';
23
+
24
+ import { translations } from '#translations';
29
25
 
30
26
  import { useTestTableModel } from '../../testing';
31
- import { translations } from '../../translations';
32
27
  import { Table } from '../../types';
33
- import { TableToolbar } from '../TableToolbar';
34
-
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,33 +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((): Ref.RefSchema<Example> => Ref.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: `com.example.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(
79
- (typename: string) => {
72
+ (newQuery: QueryAST.Query) => {
80
73
  invariant(schema);
81
74
  invariant(Type.isMutable(schema));
82
- schema.updateTypename(typename);
75
+ schema.updateTypename(getTypenameFromQuery(newQuery));
83
76
  invariant(view);
84
- view.query.ast = Query.select(Filter.typename(typename)).ast;
77
+ Obj.update(view, (view) => {
78
+ view.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,81 +101,92 @@ 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
 
126
120
  return (
127
121
  <div className='grow grid grid-cols-[1fr_350px]'>
128
- <div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
129
- <TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
130
- <TableComponent.Root>
131
- <TableComponent.Main
132
- ref={tableRef}
133
- model={model}
134
- presentation={presentation}
135
- schema={schema}
136
- client={client}
137
- ignoreAttention
138
- />
139
- </TableComponent.Root>
140
- </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>
122
+ <TableComponent.Root ref={tableRef}>
123
+ <Panel.Root>
124
+ <Panel.Toolbar asChild>
125
+ <TableComponent.Toolbar
126
+ classNames='border-b border-subdued-separator'
127
+ onAdd={handleInsertRow}
128
+ onSave={handleSaveView}
129
+ />
130
+ </Panel.Toolbar>
131
+ <Panel.Content asChild>
132
+ <TableComponent.Content
133
+ schema={schema}
134
+ model={model}
135
+ presentation={presentation}
136
+ onRowClick={handleRowClick}
137
+ ignoreAttention
138
+ />
139
+ </Panel.Content>
140
+ </Panel.Root>
141
+ </TableComponent.Root>
142
+ <ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
143
+ <ScrollArea.Viewport>
144
+ <StoryViewEditor view={table.view.target} schema={schema} db={db} handleDeleteColumn={handleDeleteColumn} />
145
+ <JsonHighlighter data={{ view: table.view.target, schema }} classNames='text-xs' />
146
+ </ScrollArea.Viewport>
147
+ </ScrollArea.Root>
147
148
  </div>
148
149
  );
149
150
  };
150
151
 
151
- type StoryProps = { rows?: number };
152
+ type DefaultStoryProps = { rows?: number };
152
153
 
153
154
  //
154
155
  // Story definitions.
155
156
  //
156
157
 
157
- // TODO(burdon): Need super simple story.
158
+ // TODO(burdon): Need simpler story.
158
159
 
159
160
  const meta = {
160
161
  title: 'ui/react-ui-table/Table',
161
162
  render: DefaultStory,
162
163
  decorators: [
163
- withTheme,
164
+ withTheme(),
165
+ withLayout({ layout: 'fullscreen' }),
166
+ withRegistry,
164
167
  withClientProvider({
165
- types: [DataType.View, Table.Table],
168
+ types: [View.View, Table.Table],
166
169
  createIdentity: true,
167
170
  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
- ];
171
+ onCreateSpace: async ({ space }) => {
172
+ const [schema] = await space.db.schemaRegistry.register([Example]);
173
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
174
+ const table = Table.make({ view, jsonSchema });
175
+ Obj.update(view, (view) => {
176
+ view.projection.fields = [
177
+ view.projection.fields.find((field) => field.path === 'name')!,
178
+ ...view.projection.fields.filter((field) => field.path !== 'name'),
179
+ ];
180
+ });
175
181
 
176
- space.db.add(view);
182
+ space.db.add(table);
177
183
 
178
184
  Array.from({ length: 10 }).map(() => {
179
185
  return space.db.add(
180
186
  Obj.make(schema, {
181
- name: faker.lorem.sentence(),
182
- status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
183
- description: faker.lorem.paragraph(),
187
+ name: random.lorem.sentence(),
188
+ status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
189
+ description: random.lorem.paragraph(),
184
190
  }),
185
191
  );
186
192
  });
@@ -192,7 +198,7 @@ const meta = {
192
198
  controls: {
193
199
  disable: true,
194
200
  },
195
- translations,
201
+ translations: [...translations, ...formTranslations],
196
202
  },
197
203
  } satisfies Meta<typeof TableComponent>;
198
204
 
@@ -206,29 +212,33 @@ export const StaticSchema: StoryObj = {
206
212
  render: DefaultStory,
207
213
  decorators: [
208
214
  withClientProvider({
209
- types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization],
215
+ types: [View.View, Table.Table],
210
216
  createIdentity: true,
211
217
  createSpace: true,
212
- onCreateSpace: async ({ client, space }) => {
213
- const { view } = await Table.makeView({ client, space, typename: Testing.Contact.typename });
214
- space.db.add(view);
218
+ onCreateSpace: async ({ space }) => {
219
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({
220
+ db: space.db,
221
+ typename: TestSchema.Person.typename,
222
+ });
223
+ const table = Table.make({ view, jsonSchema });
224
+ space.db.add(table);
215
225
 
216
- const factory = createObjectFactory(space.db, faker as any);
226
+ const factory = createObjectFactory(space.db, random as any);
217
227
  await factory([
218
- { type: Testing.Contact, count: 10 },
219
- // { type: Testing.Organization, count: 1 },
228
+ { type: TestSchema.Person, count: 10 },
229
+ // { type: TestSchema.Organization, count: 1 },
220
230
  ]);
221
231
  },
222
232
  }),
223
233
  ],
224
234
  parameters: {
225
235
  layout: 'fullscreen',
226
- translations,
236
+ translations: [...translations, ...formTranslations],
227
237
  },
228
238
  };
229
239
 
230
240
  const ContactWithArrayOfEmails = Schema.Struct({
231
- name: Schema.String.pipe(GeneratorAnnotation.set('person.fullName')),
241
+ name: Schema.String.pipe(Annotation.GeneratorAnnotation.set('person.fullName')),
232
242
  emails: Schema.optional(
233
243
  Schema.Array(
234
244
  Schema.Struct({
@@ -238,8 +248,8 @@ const ContactWithArrayOfEmails = Schema.Struct({
238
248
  ),
239
249
  ),
240
250
  }).pipe(
241
- EchoObject({
242
- typename: 'dxos.org/type/ContactWithArrayOfEmails',
251
+ Type.object({
252
+ typename: 'org.dxos.type.contactWithArrayOfEmails',
243
253
  version: '0.1.0',
244
254
  }),
245
255
  );
@@ -248,17 +258,21 @@ export const ArrayOfObjects: StoryObj = {
248
258
  render: DefaultStory,
249
259
  decorators: [
250
260
  withClientProvider({
251
- types: [DataType.View, Table.Table, Testing.Contact, Testing.Organization, ContactWithArrayOfEmails],
261
+ types: [View.View, Table.Table, TestSchema.Person, TestSchema.Organization, ContactWithArrayOfEmails],
252
262
  createIdentity: true,
253
263
  createSpace: true,
254
- onCreateSpace: async ({ client, space }) => {
255
- const { view } = await Table.makeView({ client, space, typename: ContactWithArrayOfEmails.typename });
256
- space.db.add(view);
264
+ onCreateSpace: async ({ space }) => {
265
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({
266
+ db: space.db,
267
+ typename: ContactWithArrayOfEmails.typename,
268
+ });
269
+ const table = Table.make({ view, jsonSchema });
270
+ space.db.add(table);
257
271
 
258
- const factory = createObjectFactory(space.db, faker as any);
272
+ const factory = createObjectFactory(space.db, random as any);
259
273
  await factory([
260
- // { type: Testing.Contact, count: 10 },
261
- // { type: Testing.Organization, count: 1 },
274
+ // { type: TestSchema.Person, count: 10 },
275
+ // { type: TestSchema.Organization, count: 1 },
262
276
  { type: ContactWithArrayOfEmails, count: 10 },
263
277
  ]);
264
278
  },
@@ -270,17 +284,17 @@ export const ArrayOfObjects: StoryObj = {
270
284
  },
271
285
  };
272
286
 
273
- export const Tags: Meta<StoryProps> = {
287
+ export const Tags: Meta<DefaultStoryProps> = {
274
288
  title: 'ui/react-ui-table/Table',
275
289
  render: DefaultStory,
276
290
  decorators: [
277
291
  withClientProvider({
278
- types: [DataType.View, Table.Table],
292
+ types: [View.View, Table.Table],
279
293
  createIdentity: true,
280
294
  createSpace: true,
281
- onCreateSpace: async ({ client, space }) => {
295
+ onCreateSpace: async ({ space }) => {
282
296
  // Configure schema.
283
- const typename = 'example.com/SingleSelect';
297
+ const typename = 'com.example.type.single-select';
284
298
  const selectOptions = [
285
299
  { id: 'one', title: 'One', color: 'emerald' },
286
300
  { id: 'two', title: 'Two', color: 'blue' },
@@ -294,27 +308,28 @@ export const Tags: Meta<StoryProps> = {
294
308
  const schema = getSchemaFromPropertyDefinitions(typename, [
295
309
  {
296
310
  name: 'single',
297
- format: FormatEnum.SingleSelect,
311
+ format: Format.TypeFormat.SingleSelect,
298
312
  config: { options: selectOptions },
299
313
  },
300
314
  {
301
315
  name: 'multiple',
302
- format: FormatEnum.MultiSelect,
316
+ format: Format.TypeFormat.MultiSelect,
303
317
  config: { options: selectOptions },
304
318
  },
305
319
  ]);
306
320
  const [storedSchema] = await space.db.schemaRegistry.register([schema]);
307
321
 
308
322
  // Initialize table.
309
- const { view } = await Table.makeView({ client, space, typename });
310
- space.db.add(view);
323
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
324
+ const table = Table.make({ view, jsonSchema });
325
+ space.db.add(table);
311
326
 
312
327
  // Populate.
313
328
  Array.from({ length: 10 }).map(() => {
314
329
  return space.db.add(
315
- live(storedSchema, {
316
- single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
317
- multiple: faker.helpers.randomSubset(selectOptionIds),
330
+ Obj.make(storedSchema, {
331
+ single: random.helpers.arrayElement([...selectOptionIds, undefined]),
332
+ multiple: random.helpers.randomSubset(selectOptionIds),
318
333
  }),
319
334
  );
320
335
  });