@dxos/react-ui-table 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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