@dxos/react-ui-table 0.8.4-main.3eb6e50203 → 0.8.4-main.422d1c7879

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 (101) hide show
  1. package/dist/lib/browser/{chunk-OZBLY7XM.mjs → chunk-BF54SSNL.mjs} +12 -18
  2. package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-GTGYBRJA.mjs → chunk-G5EDJPD2.mjs} +31 -28
  4. package/dist/lib/browser/chunk-G5EDJPD2.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +204 -178
  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 +5 -5
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node-esm/{chunk-WNZSKIRF.mjs → chunk-SIRDIPHZ.mjs} +12 -18
  12. package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-DPNSZHU5.mjs → chunk-ZZ3SYTIL.mjs} +31 -28
  14. package/dist/lib/node-esm/chunk-ZZ3SYTIL.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +204 -178
  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 +5 -5
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/types/index.mjs +1 -1
  21. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/DynamicTable.d.ts +2 -2
  23. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  24. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +20 -22
  25. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Table/Relations.stories.d.ts +82 -82
  27. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.d.ts +20 -21
  29. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/Table.stories.d.ts +84 -84
  31. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/TableContent.d.ts +17 -0
  33. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  34. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  35. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  36. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -3
  37. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  38. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
  39. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  40. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
  41. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/index.d.ts +0 -1
  43. package/dist/types/src/components/index.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useAddRow.d.ts +1 -1
  45. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  46. package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
  47. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
  48. package/dist/types/src/model/table-model.d.ts +2 -1
  49. package/dist/types/src/model/table-model.d.ts.map +1 -1
  50. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  51. package/dist/types/src/testing/useTestTableModel.d.ts +2 -2
  52. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  53. package/dist/types/src/translations.d.ts +19 -21
  54. package/dist/types/src/translations.d.ts.map +1 -1
  55. package/dist/types/src/types/Table.d.ts +1 -6
  56. package/dist/types/src/types/Table.d.ts.map +1 -1
  57. package/dist/types/src/util/dynamic-table.d.ts +2 -2
  58. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  59. package/dist/types/src/util/query-ast.d.ts.map +1 -1
  60. package/dist/types/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +39 -52
  62. package/src/components/Table/ColumnActionsMenu.tsx +5 -5
  63. package/src/components/Table/ColumnSettings.tsx +3 -4
  64. package/src/components/Table/DynamicTable.stories.tsx +13 -14
  65. package/src/components/Table/DynamicTable.tsx +10 -18
  66. package/src/components/Table/Relations.stories.tsx +75 -32
  67. package/src/components/Table/Table.stories.tsx +54 -49
  68. package/src/components/Table/Table.tsx +41 -435
  69. package/src/components/Table/TableContent.tsx +421 -0
  70. package/src/components/{TableToolbar → Table}/TableToolbar.tsx +35 -42
  71. package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
  72. package/src/components/TableCellEditor/FormCellEditor.tsx +12 -6
  73. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -10
  74. package/src/components/TableCellEditor/TableCellEditor.tsx +12 -10
  75. package/src/components/index.ts +0 -1
  76. package/src/components/testing.ts +10 -10
  77. package/src/hooks/useAddRow.ts +1 -1
  78. package/src/hooks/useProjectionModel.ts +3 -3
  79. package/src/model/table-model.test.ts +5 -6
  80. package/src/model/table-model.ts +9 -8
  81. package/src/model/table-presentation.test.ts +5 -6
  82. package/src/model/table-presentation.ts +12 -12
  83. package/src/playwright/playwright.config.ts +1 -1
  84. package/src/playwright/smoke.spec.ts +3 -3
  85. package/src/testing/useTestTableModel.ts +5 -5
  86. package/src/translations.ts +19 -21
  87. package/src/types/Table.ts +11 -22
  88. package/src/util/dynamic-table.test.ts +3 -3
  89. package/src/util/dynamic-table.ts +11 -10
  90. package/src/util/query-ast.ts +3 -0
  91. package/src/util/table-buttons.ts +1 -1
  92. package/src/util/table-controls.ts +2 -2
  93. package/dist/lib/browser/chunk-GTGYBRJA.mjs.map +0 -7
  94. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
  95. package/dist/lib/node-esm/chunk-DPNSZHU5.mjs.map +0 -7
  96. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +0 -7
  97. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  98. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  99. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  100. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  101. package/src/components/TableToolbar/index.ts +0 -5
@@ -6,25 +6,24 @@ 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 { Annotation, type Database, Format, Obj, type QueryAST, Type } from '@dxos/echo';
9
+ import { Annotation, type Database, Format, Obj, type QueryAST, Ref, Type } from '@dxos/echo';
10
+ import { View } from '@dxos/echo';
10
11
  import { type Mutable, PropertyMetaAnnotationId } from '@dxos/echo/internal';
11
12
  import { invariant } from '@dxos/invariant';
12
- import { faker } from '@dxos/random';
13
+ import { random } from '@dxos/random';
13
14
  import { PublicKey } from '@dxos/react-client';
14
15
  import { withClientProvider } from '@dxos/react-client/testing';
15
- import { ScrollArea } from '@dxos/react-ui';
16
- import { withTheme } from '@dxos/react-ui/testing';
16
+ import { Panel, ScrollArea } from '@dxos/react-ui';
17
17
  import { ViewEditor, translations as formTranslations } from '@dxos/react-ui-form';
18
- import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
19
- import { View, getSchemaFromPropertyDefinitions, getTypenameFromQuery } from '@dxos/schema';
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';
20
21
  import { TestSchema, createObjectFactory } from '@dxos/schema/testing';
21
22
  import { withRegistry } from '@dxos/storybook-utils';
22
23
 
23
24
  import { useTestTableModel } from '../../testing';
24
25
  import { translations } from '../../translations';
25
26
  import { Table } from '../../types';
26
- import { TableToolbar } from '../TableToolbar';
27
-
28
27
  import { Table as TableComponent } from './Table';
29
28
 
30
29
  const Example = Schema.Struct({
@@ -48,11 +47,11 @@ const Example = Schema.Struct({
48
47
  }),
49
48
  ),
50
49
  description: Schema.optional(Schema.String).annotations({ title: 'Description' }),
51
- parent: Schema.optional(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example))).annotations({
50
+ parent: Schema.optional(Schema.suspend((): Ref.RefSchema<Example> => Ref.Ref(Example))).annotations({
52
51
  title: 'Parent',
53
52
  }),
54
53
  }).pipe(
55
- Type.object({ typename: `example.com/type/${PublicKey.random().truncate()}`, version: '0.1.0' }),
54
+ Type.object({ typename: `com.example.type.${PublicKey.random().truncate()}`, version: '0.1.0' }),
56
55
  Annotation.LabelAnnotation.set(['name']),
57
56
  );
58
57
  interface Example extends Schema.Schema.Type<typeof Example> {}
@@ -74,8 +73,8 @@ const StoryViewEditor = ({
74
73
  invariant(Type.isMutable(schema));
75
74
  schema.updateTypename(getTypenameFromQuery(newQuery));
76
75
  invariant(view);
77
- Obj.change(view, (v) => {
78
- v.query.ast = newQuery as Mutable<typeof newQuery>;
76
+ Obj.change(view, (view) => {
77
+ view.query.ast = newQuery as Mutable<typeof newQuery>;
79
78
  });
80
79
  },
81
80
  [schema, view],
@@ -119,44 +118,50 @@ const DefaultStory = () => {
119
118
 
120
119
  return (
121
120
  <div className='grow grid grid-cols-[1fr_350px]'>
122
- <div className='grid grid-rows-[min-content_1fr] min-bs-0 overflow-hidden'>
123
- <TableToolbar classNames='border-be border-subduedSeparator' onAdd={handleInsertRow} onSave={handleSaveView} />
124
- <TableComponent.Root>
125
- <TableComponent.Main
126
- ref={tableRef}
127
- schema={schema}
128
- model={model}
129
- presentation={presentation}
130
- onRowClick={handleRowClick}
131
- ignoreAttention
132
- />
133
- </TableComponent.Root>
134
- </div>
135
- <ScrollArea.Root orientation='vertical' classNames='bs-full border-l border-separator'>
121
+ <TableComponent.Root ref={tableRef}>
122
+ <Panel.Root>
123
+ <Panel.Toolbar asChild>
124
+ <TableComponent.Toolbar
125
+ classNames='border-b border-subdued-separator'
126
+ onAdd={handleInsertRow}
127
+ onSave={handleSaveView}
128
+ />
129
+ </Panel.Toolbar>
130
+ <Panel.Content asChild>
131
+ <TableComponent.Content
132
+ schema={schema}
133
+ model={model}
134
+ presentation={presentation}
135
+ onRowClick={handleRowClick}
136
+ ignoreAttention
137
+ />
138
+ </Panel.Content>
139
+ </Panel.Root>
140
+ </TableComponent.Root>
141
+ <ScrollArea.Root orientation='vertical' classNames='border-l border-separator'>
136
142
  <ScrollArea.Viewport>
137
143
  <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>
144
+ <JsonHighlighter data={{ view: table.view.target, schema }} classNames='text-xs' />
141
145
  </ScrollArea.Viewport>
142
146
  </ScrollArea.Root>
143
147
  </div>
144
148
  );
145
149
  };
146
150
 
147
- type StoryProps = { rows?: number };
151
+ type DefaultStoryProps = { rows?: number };
148
152
 
149
153
  //
150
154
  // Story definitions.
151
155
  //
152
156
 
153
- // TODO(burdon): Need super simple story.
157
+ // TODO(burdon): Need simpler story.
154
158
 
155
159
  const meta = {
156
160
  title: 'ui/react-ui-table/Table',
157
161
  render: DefaultStory,
158
162
  decorators: [
159
163
  withTheme(),
164
+ withLayout({ layout: 'fullscreen' }),
160
165
  withRegistry,
161
166
  withClientProvider({
162
167
  types: [View.View, Table.Table],
@@ -164,12 +169,12 @@ const meta = {
164
169
  createSpace: true,
165
170
  onCreateSpace: async ({ space }) => {
166
171
  const [schema] = await space.db.schemaRegistry.register([Example]);
167
- const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename: schema.typename });
172
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename: schema.typename });
168
173
  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'),
174
+ Obj.change(view, (view) => {
175
+ view.projection.fields = [
176
+ view.projection.fields.find((field) => field.path === 'name')!,
177
+ ...view.projection.fields.filter((field) => field.path !== 'name'),
173
178
  ];
174
179
  });
175
180
 
@@ -178,9 +183,9 @@ const meta = {
178
183
  Array.from({ length: 10 }).map(() => {
179
184
  return space.db.add(
180
185
  Obj.make(schema, {
181
- name: faker.lorem.sentence(),
182
- status: faker.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
183
- description: faker.lorem.paragraph(),
186
+ name: random.lorem.sentence(),
187
+ status: random.helpers.arrayElement(['todo', 'in-progress', 'done'] as const),
188
+ description: random.lorem.paragraph(),
184
189
  }),
185
190
  );
186
191
  });
@@ -210,14 +215,14 @@ export const StaticSchema: StoryObj = {
210
215
  createIdentity: true,
211
216
  createSpace: true,
212
217
  onCreateSpace: async ({ space }) => {
213
- const { view, jsonSchema } = await View.makeFromDatabase({
218
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({
214
219
  db: space.db,
215
220
  typename: TestSchema.Person.typename,
216
221
  });
217
222
  const table = Table.make({ view, jsonSchema });
218
223
  space.db.add(table);
219
224
 
220
- const factory = createObjectFactory(space.db, faker as any);
225
+ const factory = createObjectFactory(space.db, random as any);
221
226
  await factory([
222
227
  { type: TestSchema.Person, count: 10 },
223
228
  // { type: TestSchema.Organization, count: 1 },
@@ -243,7 +248,7 @@ const ContactWithArrayOfEmails = Schema.Struct({
243
248
  ),
244
249
  }).pipe(
245
250
  Type.object({
246
- typename: 'dxos.org/type/ContactWithArrayOfEmails',
251
+ typename: 'org.dxos.type.contactWithArrayOfEmails',
247
252
  version: '0.1.0',
248
253
  }),
249
254
  );
@@ -256,14 +261,14 @@ export const ArrayOfObjects: StoryObj = {
256
261
  createIdentity: true,
257
262
  createSpace: true,
258
263
  onCreateSpace: async ({ space }) => {
259
- const { view, jsonSchema } = await View.makeFromDatabase({
264
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({
260
265
  db: space.db,
261
266
  typename: ContactWithArrayOfEmails.typename,
262
267
  });
263
268
  const table = Table.make({ view, jsonSchema });
264
269
  space.db.add(table);
265
270
 
266
- const factory = createObjectFactory(space.db, faker as any);
271
+ const factory = createObjectFactory(space.db, random as any);
267
272
  await factory([
268
273
  // { type: TestSchema.Person, count: 10 },
269
274
  // { type: TestSchema.Organization, count: 1 },
@@ -278,7 +283,7 @@ export const ArrayOfObjects: StoryObj = {
278
283
  },
279
284
  };
280
285
 
281
- export const Tags: Meta<StoryProps> = {
286
+ export const Tags: Meta<DefaultStoryProps> = {
282
287
  title: 'ui/react-ui-table/Table',
283
288
  render: DefaultStory,
284
289
  decorators: [
@@ -288,7 +293,7 @@ export const Tags: Meta<StoryProps> = {
288
293
  createSpace: true,
289
294
  onCreateSpace: async ({ space }) => {
290
295
  // Configure schema.
291
- const typename = 'example.com/SingleSelect';
296
+ const typename = 'com.example.type.single-select';
292
297
  const selectOptions = [
293
298
  { id: 'one', title: 'One', color: 'emerald' },
294
299
  { id: 'two', title: 'Two', color: 'blue' },
@@ -314,7 +319,7 @@ export const Tags: Meta<StoryProps> = {
314
319
  const [storedSchema] = await space.db.schemaRegistry.register([schema]);
315
320
 
316
321
  // Initialize table.
317
- const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename });
322
+ const { view, jsonSchema } = await ViewModel.makeFromDatabase({ db: space.db, typename });
318
323
  const table = Table.make({ view, jsonSchema });
319
324
  space.db.add(table);
320
325
 
@@ -322,8 +327,8 @@ export const Tags: Meta<StoryProps> = {
322
327
  Array.from({ length: 10 }).map(() => {
323
328
  return space.db.add(
324
329
  Obj.make(storedSchema, {
325
- single: faker.helpers.arrayElement([...selectOptionIds, undefined]),
326
- multiple: faker.helpers.randomSubset(selectOptionIds),
330
+ single: random.helpers.arrayElement([...selectOptionIds, undefined]),
331
+ multiple: random.helpers.randomSubset(selectOptionIds),
327
332
  }),
328
333
  );
329
334
  });