@dxos/react-ui-table 0.8.4-main.5ea62a8 → 0.8.4-main.60689f5b1c

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