@dxos/react-ui-table 0.8.4-main.c85a9c8dae → 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 (119) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/{chunk-DSR2MRZB.mjs → chunk-4URYOFDL.mjs} +10 -21
  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-PTHMYAAM.mjs → chunk-YDXPC7HA.mjs} +16 -72
  7. package/dist/lib/browser/chunk-YDXPC7HA.mjs.map +7 -0
  8. package/dist/lib/browser/index.mjs +207 -251
  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 +8 -6
  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 +2 -1
  16. package/dist/lib/node-esm/{chunk-GI72MQSG.mjs → chunk-2AN3QQ3D.mjs} +16 -72
  17. package/dist/lib/node-esm/chunk-2AN3QQ3D.mjs.map +7 -0
  18. package/dist/lib/node-esm/{chunk-HTZJSULI.mjs → chunk-B2SZYAEC.mjs} +10 -21
  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 +207 -251
  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 +8 -6
  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 +2 -1
  30. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/DynamicTable.d.ts +1 -2
  33. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +19 -21
  35. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/Table/Relations.stories.d.ts +82 -82
  37. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  39. package/dist/types/src/components/Table/Table.d.ts +20 -21
  40. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  41. package/dist/types/src/components/Table/Table.stories.d.ts +84 -84
  42. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  43. package/dist/types/src/components/Table/TableContent.d.ts +18 -0
  44. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  45. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  46. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  47. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
  48. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  49. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  50. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
  51. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  52. package/dist/types/src/components/index.d.ts +0 -1
  53. package/dist/types/src/components/index.d.ts.map +1 -1
  54. package/dist/types/src/components/testing.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  56. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  58. package/dist/types/src/index.d.ts +0 -2
  59. package/dist/types/src/index.d.ts.map +1 -1
  60. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  61. package/dist/types/src/model/selection-model.d.ts +1 -1
  62. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  63. package/dist/types/src/model/table-model.d.ts +4 -5
  64. package/dist/types/src/model/table-model.d.ts.map +1 -1
  65. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  66. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  67. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  68. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  69. package/dist/types/src/translations.d.ts +19 -21
  70. package/dist/types/src/translations.d.ts.map +1 -1
  71. package/dist/types/src/types/Table.d.ts +1 -7
  72. package/dist/types/src/types/Table.d.ts.map +1 -1
  73. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  74. package/dist/types/src/util/query-ast.d.ts.map +1 -1
  75. package/dist/types/src/util/schema.d.ts.map +1 -1
  76. package/dist/types/src/util/signals.d.ts.map +1 -1
  77. package/dist/types/src/util/sort.d.ts.map +1 -1
  78. package/dist/types/src/util/table-buttons.d.ts +20 -20
  79. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  80. package/dist/types/src/util/table-controls.d.ts +4 -4
  81. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  82. package/dist/types/src/util/tag.d.ts.map +1 -1
  83. package/dist/types/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +51 -60
  85. package/src/components/Table/ColumnActionsMenu.tsx +7 -6
  86. package/src/components/Table/DynamicTable.stories.tsx +15 -15
  87. package/src/components/Table/DynamicTable.tsx +6 -15
  88. package/src/components/Table/Relations.stories.tsx +72 -32
  89. package/src/components/Table/RowActionsMenu.tsx +3 -2
  90. package/src/components/Table/Table.stories.tsx +28 -31
  91. package/src/components/Table/Table.tsx +37 -427
  92. package/src/components/Table/TableContent.tsx +425 -0
  93. package/src/components/{TableToolbar → Table}/TableToolbar.tsx +34 -41
  94. package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -2
  95. package/src/components/TableCellEditor/FormCellEditor.tsx +3 -2
  96. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -11
  97. package/src/components/TableCellEditor/TableCellEditor.tsx +10 -8
  98. package/src/components/index.ts +0 -1
  99. package/src/components/testing.ts +10 -10
  100. package/src/index.ts +0 -4
  101. package/src/model/table-model.test.ts +1 -2
  102. package/src/model/table-model.ts +10 -11
  103. package/src/model/table-presentation.test.ts +1 -2
  104. package/src/model/table-presentation.ts +3 -5
  105. package/src/playwright/smoke.spec.ts +3 -3
  106. package/src/testing/useTestTableModel.ts +5 -5
  107. package/src/translations.ts +19 -21
  108. package/src/types/Table.ts +4 -21
  109. package/src/util/dynamic-table.test.ts +3 -3
  110. package/src/util/dynamic-table.ts +5 -6
  111. package/dist/lib/browser/chunk-DSR2MRZB.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +0 -7
  113. package/dist/lib/node-esm/chunk-GI72MQSG.mjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-HTZJSULI.mjs.map +0 -7
  115. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  116. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  117. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  118. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  119. package/src/components/TableToolbar/index.ts +0 -5
@@ -9,7 +9,7 @@ import { useEffect } from 'react';
9
9
  import { Format, Type } from '@dxos/echo';
10
10
  import { TypeEnum } from '@dxos/echo/internal';
11
11
  import { setValue } from '@dxos/effect';
12
- import { faker } from '@dxos/random';
12
+ import { random } from '@dxos/random';
13
13
  import { type ProjectionModel } from '@dxos/schema';
14
14
 
15
15
  export const TestSchema = Schema.Struct({
@@ -19,7 +19,7 @@ export const TestSchema = Schema.Struct({
19
19
  netWorth: Schema.optional(Schema.Number),
20
20
  }).pipe(
21
21
  Type.object({
22
- typename: 'example.com/type/Test',
22
+ typename: 'com.example.type.test',
23
23
  version: '0.1.0',
24
24
  }),
25
25
  );
@@ -37,10 +37,10 @@ export type TestItem = {
37
37
  export const createItemsAtom = (n: number) => {
38
38
  return Atom.make<{ data: TestItem[] }>({
39
39
  data: Array.from({ length: n }, () => ({
40
- name: faker.person.fullName(),
41
- age: faker.number.int({ min: 20, max: 70 }),
42
- active: faker.datatype.boolean(),
43
- netWorth: faker.number.int(),
40
+ name: random.person.fullName(),
41
+ age: random.number.int({ min: 20, max: 70 }),
42
+ active: random.datatype.boolean(),
43
+ netWorth: random.number.int(),
44
44
  })),
45
45
  }).pipe(Atom.keepAlive);
46
46
  };
@@ -50,10 +50,10 @@ export const createItemsAtom = (n: number) => {
50
50
  */
51
51
  export const createItems = (n: number): TestItem[] => {
52
52
  return Array.from({ length: n }, () => ({
53
- name: faker.person.fullName(),
54
- age: faker.number.int({ min: 20, max: 70 }),
55
- active: faker.datatype.boolean(),
56
- netWorth: faker.number.int(),
53
+ name: random.person.fullName(),
54
+ age: random.number.int({ min: 20, max: 70 }),
55
+ active: random.datatype.boolean(),
56
+ netWorth: random.number.int(),
57
57
  }));
58
58
  };
59
59
 
package/src/index.ts CHANGED
@@ -2,11 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { translations } from './translations';
6
-
7
5
  export * from './components';
8
6
  export * from './hooks';
9
7
  export * from './model';
10
8
  export * from './util';
11
-
12
- export { translations };
@@ -11,7 +11,6 @@ import { createEchoSchema } from '@dxos/echo/testing';
11
11
  import { ProjectionModel, ViewModel, createDirectChangeCallback } from '@dxos/schema';
12
12
 
13
13
  import { Table } from '../types';
14
-
15
14
  import {
16
15
  TableModel,
17
16
  type TableModelProps,
@@ -121,7 +120,7 @@ const Test = Schema.Struct({
121
120
  completed: Schema.Boolean,
122
121
  }).pipe(
123
122
  Type.object({
124
- typename: 'example.com/type/Test',
123
+ typename: 'com.example.type.test',
125
124
  version: '0.1.0',
126
125
  }),
127
126
  );
@@ -5,8 +5,7 @@
5
5
  import { Atom, type Registry } from '@effect-atom/atom-react';
6
6
 
7
7
  import { Resource } from '@dxos/context';
8
- import { type Database, Format, Obj, Order, Query, type QueryAST, Ref } from '@dxos/echo';
9
- import { type View } from '@dxos/echo';
8
+ import { type Database, Format, Obj, Order, Query, type QueryAST, Ref, type View } from '@dxos/echo';
10
9
  import { type JsonProp, type JsonSchemaType, type Mutable, toEffectSchema } from '@dxos/echo/internal';
11
10
  import { getSnapshot } from '@dxos/echo/internal';
12
11
  import { getValue, setValue } from '@dxos/effect';
@@ -38,7 +37,7 @@ export type FieldSortType = {
38
37
  import { type SelectionMode, SelectionModel } from './selection-model';
39
38
 
40
39
  /**
41
- * Callback type for wrapping mutations in Obj.change().
40
+ * Callback type for wrapping mutations in Obj.update().
42
41
  * Contains separate callbacks for table object and row mutations.
43
42
  */
44
43
  export type TableChangeCallback<T extends TableRow> = {
@@ -53,10 +52,10 @@ export type TableChangeCallback<T extends TableRow> = {
53
52
  * Use this when the table and rows are stored in the ECHO database.
54
53
  */
55
54
  export const createEchoChangeCallback = <T extends TableRow>(table: Table.Table): TableChangeCallback<T> => ({
56
- table: (mutate) => Obj.change(table, (mutableTable) => mutate(mutableTable as unknown as Table.Table)),
55
+ table: (mutate) => Obj.update(table, (table) => mutate(table as unknown as Table.Table)),
57
56
  row: (row, mutate) => {
58
57
  if (Obj.isObject(row)) {
59
- Obj.change(row, (mutableRow) => mutate(mutableRow as T));
58
+ Obj.update(row, (row) => mutate(row as T));
60
59
  } else {
61
60
  mutate(row);
62
61
  }
@@ -112,7 +111,7 @@ export type TableModelProps<T extends TableRow = TableRow> = {
112
111
  projection: ProjectionModel;
113
112
  db?: Database.Database;
114
113
  /**
115
- * Callbacks to wrap mutations in Obj.change().
114
+ * Callbacks to wrap mutations in Obj.update().
116
115
  * Use createEchoChangeCallback() for ECHO-backed objects or createDirectChangeCallback() for plain objects.
117
116
  */
118
117
  change?: TableChangeCallback<T>;
@@ -695,7 +694,7 @@ export class TableModel<T extends TableRow = TableRow> extends Resource {
695
694
  const snapshot = { ...getSnapshot(currentRow) };
696
695
  setValue(snapshot, field.path, transformedValue);
697
696
 
698
- const schema = Obj.getSchema(currentRow);
697
+ const schema = Obj.getSchema(currentRow as unknown as Obj.Unknown);
699
698
  invariant(schema);
700
699
 
701
700
  const validationResult = validateSchema(schema, snapshot);
@@ -894,14 +893,14 @@ export class TableModel<T extends TableRow = TableRow> extends Resource {
894
893
  if (field) {
895
894
  // Persist sort to view.query.ast
896
895
  const newQuery = baseQuery.orderBy(Order.property<any>(field.path as string, inMemorySort.direction));
897
- Obj.change(view, (v) => {
898
- v.query.ast = newQuery.ast as Mutable<typeof newQuery.ast>;
896
+ Obj.update(view, (view) => {
897
+ view.query.ast = newQuery.ast as Mutable<typeof newQuery.ast>;
899
898
  });
900
899
  }
901
900
  } else {
902
901
  // Clear sort from view.query.ast
903
- Obj.change(view, (v) => {
904
- v.query.ast = baseQuery.ast as Mutable<typeof baseQuery.ast>;
902
+ Obj.update(view, (view) => {
903
+ view.query.ast = baseQuery.ast as Mutable<typeof baseQuery.ast>;
905
904
  });
906
905
  }
907
906
 
@@ -11,7 +11,6 @@ import { createEchoSchema } from '@dxos/echo/testing';
11
11
  import { ProjectionModel, ViewModel, createDirectChangeCallback } from '@dxos/schema';
12
12
 
13
13
  import { Table } from '../types';
14
-
15
14
  import { TableModel, type TableModelProps } from './table-model';
16
15
  import { TablePresentation } from './table-presentation';
17
16
 
@@ -92,7 +91,7 @@ const Test = Schema.Struct({
92
91
  count: Schema.Number,
93
92
  }).pipe(
94
93
  Type.object({
95
- typename: 'example.com/type/Test',
94
+ typename: 'com.example.type.test',
96
95
  version: '0.1.0',
97
96
  }),
98
97
  );
@@ -5,8 +5,7 @@
5
5
  import { Atom, type Registry } from '@effect-atom/atom-react';
6
6
  import * as Predicate from 'effect/Predicate';
7
7
 
8
- import { Obj } from '@dxos/echo';
9
- import { type View } from '@dxos/echo';
8
+ import { Obj, type View } from '@dxos/echo';
10
9
  import { Format, TypeEnum, getValue } from '@dxos/echo/internal';
11
10
  import { cellClassesForFieldType, formatForDisplay } from '@dxos/react-ui-form';
12
11
  import {
@@ -20,7 +19,6 @@ import { VIEW_FIELD_LIMIT } from '@dxos/schema';
20
19
  import { mx } from '@dxos/ui-theme';
21
20
 
22
21
  import { tableButtons, tableControls } from '../util';
23
-
24
22
  import { type SelectionMode } from './selection-model';
25
23
  import { type TableModel, type TableRow } from './table-model';
26
24
 
@@ -474,8 +472,8 @@ export const cellClassesForRowSelection = (selected: boolean, selectionMode: Sel
474
472
 
475
473
  switch (selectionMode) {
476
474
  case 'single':
477
- return ['dx-grid__cell--no-focus-unfurl !bg-current-surface hover:bg-hover-surface cursor-pointer!'];
475
+ return ['dx-grid__cell--no-focus-unfurl bg-current-surface! hover:bg-hover-surface cursor-pointer!'];
478
476
  case 'multiple':
479
- return ['!bg-grid-cell-selected'];
477
+ return ['bg-grid-cell-selected!'];
480
478
  }
481
479
  };
@@ -5,7 +5,7 @@
5
5
  import { expect, test } from '@playwright/test';
6
6
 
7
7
  import { type DxGrid } from '@dxos/lit-grid';
8
- import { faker } from '@dxos/random';
8
+ import { random } from '@dxos/random';
9
9
  import { setupPage, storybookUrl } from '@dxos/test-utils/playwright';
10
10
 
11
11
  import { TableManager } from './TableManager';
@@ -13,7 +13,7 @@ import { TableManager } from './TableManager';
13
13
  const storyUrl = storybookUrl('ui-react-ui-table-table--default', 9004);
14
14
  const relationsStoryUrl = storybookUrl('ui-react-ui-table-relations--default', 9004);
15
15
 
16
- // NOTE(ZaymonFC): This test suite relies on the faker seed being set to 0 in the story.
16
+ // NOTE(ZaymonFC): This test suite relies on the random seed being set to 0 in the story.
17
17
  test.describe('Table', () => {
18
18
  test('Loads', async ({ browser, browserName }) => {
19
19
  test.skip(browserName === 'webkit');
@@ -310,7 +310,7 @@ test.describe('Table', () => {
310
310
  dxGridElement.scrollToColumn(6);
311
311
  });
312
312
 
313
- const nonRefContent = faker.lorem.words(3);
313
+ const nonRefContent = random.lorem.words(3);
314
314
  const nonRefCell = dxGrid.locator('[data-dx-grid-plane="grid"] [aria-rowindex="0"][aria-colindex="6"]');
315
315
  await nonRefCell.click();
316
316
  await page.keyboard.press('Enter');
@@ -5,12 +5,12 @@
5
5
  import { RegistryContext } from '@effect-atom/atom-react';
6
6
  import { type RefObject, useCallback, useContext, useMemo, useRef } from 'react';
7
7
 
8
- import { type Database, type Type } from '@dxos/echo';
8
+ import { type Database, Filter, type Type } from '@dxos/echo';
9
9
  import { isMutable } from '@dxos/echo/internal';
10
- import { faker } from '@dxos/random';
11
- import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
10
+ import { random } from '@dxos/random';
11
+ import { useQuery, useSchema } from '@dxos/react-client/echo';
12
12
  import { useClientStory } from '@dxos/react-client/testing';
13
- import { useGlobalFilteredObjects } from '@dxos/react-ui-searchlist';
13
+ import { useGlobalFilteredObjects } from '@dxos/react-ui-search';
14
14
  import { type ProjectionModel, getTypenameFromQuery } from '@dxos/schema';
15
15
 
16
16
  import { type TableController } from '../components';
@@ -18,7 +18,7 @@ import { useAddRow, useProjectionModel, useTableModel } from '../hooks';
18
18
  import { type TableModel, TablePresentation } from '../model';
19
19
  import { Table } from '../types';
20
20
 
21
- faker.seed(0); // NOTE(ZaymonFC): Required for smoke tests.
21
+ random.seed(0); // NOTE(ZaymonFC): Required for smoke tests.
22
22
 
23
23
  export type TestTableModel<T extends Type.AnyObj = Type.AnyObj> = {
24
24
  schema: T | undefined;
@@ -10,27 +10,25 @@ export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [translationKey]: {
13
- 'object placeholder': 'New table',
14
- 'create object label': 'Create table',
15
- 'table name placeholder': 'Table name',
16
- 'settings title': 'Table settings',
17
- 'table schema label': 'Type',
18
- 'new schema': 'New type',
19
- 'continue label': 'Continue',
20
- 'create stack section label': 'Create table',
21
- 'add row label': 'Add row',
22
- 'create comment': 'Create thread',
23
- 'column action sort descending': 'Sort Descending',
24
- 'column action sort ascending': 'Sort Ascending',
25
- 'column action clear sorting': 'Clear Sorting',
26
- 'column action settings': 'Column Settings',
27
- 'column action delete': 'Delete Column',
28
- 'delete row label': 'Delete row',
29
- 'bulk delete row label': 'Delete selected rows',
30
- 'column deleted label': 'Column deleted',
31
- 'new column button label': 'Create column',
32
- 'create new object label': 'Create new object “{{text}}”',
33
- 'save view label': 'Save changes to view',
13
+ 'object.placeholder': 'New table',
14
+ 'create-object.label': 'Create table',
15
+ 'table-name.placeholder': 'Table name',
16
+ 'settings.title': 'Table settings',
17
+ 'table-schema.label': 'Type',
18
+ 'continue.label': 'Continue',
19
+ 'create-stack-section.label': 'Create table',
20
+ 'add-row.label': 'Add row',
21
+ 'column-action-sort-descending.menu': 'Sort Descending',
22
+ 'column-action-sort-ascending.menu': 'Sort Ascending',
23
+ 'column-action-clear-sorting.menu': 'Clear Sorting',
24
+ 'column-action-settings.menu': 'Column Settings',
25
+ 'column-action-delete.menu': 'Delete Column',
26
+ 'delete-row.label': 'Delete row',
27
+ 'bulk-delete-row.label': 'Delete selected rows',
28
+ 'column-deleted.label': 'Column deleted',
29
+ 'new-column-button.label': 'Create column',
30
+ 'create-new-object.label': 'Create new object “{{text}}”',
31
+ 'save-view.label': 'Save changes to view',
34
32
  },
35
33
  },
36
34
  },
@@ -6,8 +6,7 @@ import * as Match from 'effect/Match';
6
6
  import * as Schema from 'effect/Schema';
7
7
  import * as SchemaAST from 'effect/SchemaAST';
8
8
 
9
- import { Annotation, JsonSchema, Obj, Ref, Type } from '@dxos/echo';
10
- import { View } from '@dxos/echo';
9
+ import { Annotation, JsonSchema, Obj, Ref, Type, View } from '@dxos/echo';
11
10
  import { FormInputAnnotation, type JsonPath, type JsonSchemaType, LabelAnnotation } from '@dxos/echo/internal';
12
11
  import { ViewAnnotation } from '@dxos/schema';
13
12
 
@@ -23,11 +22,11 @@ export const Table = Schema.Struct({
23
22
  }).pipe(Schema.mutable, FormInputAnnotation.set(false)),
24
23
  }).pipe(
25
24
  Type.object({
26
- typename: 'dxos.org/type/Table',
27
- version: '0.2.0',
25
+ typename: 'org.dxos.type.table',
26
+ version: '0.1.0',
28
27
  }),
29
28
  LabelAnnotation.set(['name']),
30
- ViewAnnotation.set(true),
29
+ ViewAnnotation.set(['view']),
31
30
  Annotation.IconAnnotation.set({
32
31
  icon: 'ph--table--regular',
33
32
  hue: 'green',
@@ -77,19 +76,3 @@ export const make = ({ name, sizes = {}, view, jsonSchema }: MakeProps): Table =
77
76
 
78
77
  return table;
79
78
  };
80
-
81
- //
82
- // V1
83
- //
84
-
85
- export const TableV1 = Schema.Struct({
86
- sizes: Schema.Record({
87
- key: Schema.String,
88
- value: Schema.Number,
89
- }).pipe(Schema.mutable),
90
- }).pipe(
91
- Type.object({
92
- typename: 'dxos.org/type/Table',
93
- version: '0.1.0',
94
- }),
95
- );
@@ -12,7 +12,7 @@ import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '.
12
12
  describe('makeDynamicTable', () => {
13
13
  /**
14
14
  * Base case: plain jsonSchema (not from Echo / JsonSchema.toJsonSchema). Does not exercise the path
15
- * where projection or schema are reactive, so this does not reproduce the Obj.change regression.
15
+ * where projection or schema are reactive, so this does not reproduce the Obj.update regression.
16
16
  * Confirms makeDynamicTable + setProperties (title) works with plain objects.
17
17
  */
18
18
  test('makeDynamicTable with plain jsonSchema and properties with title does not throw', () => {
@@ -44,12 +44,12 @@ describe('makeDynamicTable', () => {
44
44
 
45
45
  /**
46
46
  * Regression test for the path where jsonSchema comes from getBaseSchema(typename, properties).
47
- * That path uses Echo (ViewModel.make, JsonSchema.toJsonSchema); mutations must run inside Obj.change and on a
47
+ * That path uses Echo (ViewModel.make, JsonSchema.toJsonSchema); mutations must run inside Obj.update and on a
48
48
  * cloned schema. This test ensures that flow does not throw.
49
49
  */
50
50
  test('makeDynamicTable with jsonSchema from getBaseSchema(typename, properties) and properties with title does not throw', () => {
51
51
  const registry = Registry.make();
52
- const typename = 'example.com/type/DynamicTableTest';
52
+ const typename = 'com.example.type.dynamicTableTest';
53
53
  const properties: TablePropertyDefinition[] = [
54
54
  { name: 'id', format: Format.TypeFormat.String },
55
55
  { name: 'name', format: Format.TypeFormat.String, title: 'Name' },
@@ -5,8 +5,7 @@
5
5
  import { type Registry } from '@effect-atom/atom-react';
6
6
  import type * as Types from 'effect/Types';
7
7
 
8
- import { Filter, JsonSchema, Obj, Order, Query, type QueryAST, Ref, Type } from '@dxos/echo';
9
- import { type View } from '@dxos/echo';
8
+ import { Filter, JsonSchema, Obj, Order, Query, type QueryAST, Ref, Type, type View } from '@dxos/echo';
10
9
  import {
11
10
  ProjectionModel,
12
11
  type SchemaPropertyDefinition,
@@ -93,8 +92,8 @@ const setProperties = (
93
92
  const field = projection.getFields().find((field) => field.path === property.name);
94
93
  if (field) {
95
94
  if (property.size !== undefined) {
96
- Obj.change(table, (t) => {
97
- t.sizes[field.path] = property.size!;
95
+ Obj.update(table, (table) => {
96
+ table.sizes[field.path] = property.size!;
98
97
  });
99
98
  }
100
99
 
@@ -111,9 +110,9 @@ const setProperties = (
111
110
  const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
112
111
  // Use any type parameter since we're working with dynamic field paths
113
112
  const newQuery = currentQuery.orderBy(Order.property<any>(field.path as string, property.sort));
114
- Obj.change(view, (v) => {
113
+ Obj.update(view, (view) => {
115
114
  // Type assertion needed because Query AST types have some variance issues.
116
- v.query.ast = newQuery.ast as typeof v.query.ast;
115
+ view.query.ast = newQuery.ast as typeof view.query.ast;
117
116
  });
118
117
  }
119
118
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/Table.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation, JsonSchema, Obj, Ref, Type } from '@dxos/echo';\nimport { View } from '@dxos/echo';\nimport { FormInputAnnotation, type JsonPath, type JsonSchemaType, LabelAnnotation } from '@dxos/echo/internal';\nimport { ViewAnnotation } from '@dxos/schema';\n\nexport const Table = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n\n view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n sizes: Schema.Record({\n // TODO(wittjosiah): Should be JsonPath.\n key: Schema.String,\n value: Schema.Number,\n }).pipe(Schema.mutable, FormInputAnnotation.set(false)),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Table',\n version: '0.2.0',\n }),\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(true),\n Annotation.IconAnnotation.set({\n icon: 'ph--table--regular',\n hue: 'green',\n }),\n);\n\nexport interface Table extends Schema.Schema.Type<typeof Table> {}\n\ntype MakeProps = {\n name?: string;\n sizes?: Record<string, number>;\n view: View.View;\n /** Required to auto-size columns. */\n jsonSchema?: JsonSchemaType;\n};\n\n/**\n * Make a table as a view of a data set.\n */\nexport const make = ({ name, sizes = {}, view, jsonSchema }: MakeProps): Table => {\n const table = Obj.make(Table, { name, view: Ref.make(view), sizes } as Obj.MakeProps<typeof Table>);\n\n // Preset sizes.\n if (jsonSchema) {\n const schema = JsonSchema.toEffectSchema(jsonSchema);\n const properties = SchemaAST.getPropertySignatures(schema.ast);\n for (const property of properties) {\n const name = property.name.toString() as JsonPath;\n if (sizes?.[name]) {\n table.sizes[name] = sizes[name];\n continue;\n }\n\n Match.type<SchemaAST.AST>().pipe(\n Match.when({ _tag: 'BooleanKeyword' }, () => {\n table.sizes[name] = 100;\n }),\n Match.when({ _tag: 'NumberKeyword' }, () => {\n table.sizes[name] = 100;\n }),\n Match.orElse(() => {\n // Noop.\n }),\n )(property.type);\n }\n }\n\n return table;\n};\n\n//\n// V1\n//\n\nexport const TableV1 = Schema.Struct({\n sizes: Schema.Record({\n key: Schema.String,\n value: Schema.Number,\n }).pipe(Schema.mutable),\n}).pipe(\n Type.object({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\n"],
5
- "mappings": ";;;;;;;AAAA;;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAE3B,SAASC,YAAYC,YAAYC,KAAKC,KAAKC,YAAY;AACvD,SAASC,YAAY;AACrB,SAASC,qBAAyDC,uBAAuB;AACzF,SAASC,sBAAsB;AAExB,IAAMC,QAAeC,cAAO;EACjCC,MAAaC,cAAOC,KAAYC,eAAQ;EAExCC,MAAMC,IAAIA,IAAIC,KAAKA,IAAI,EAAEJ,KAAKK,oBAAoBC,IAAI,KAAA,CAAA;EAEtDC,OAAcC,cAAO;;IAEnBC,KAAYV;IACZW,OAAcC;EAChB,CAAA,EAAGX,KAAYY,gBAASP,oBAAoBC,IAAI,KAAA,CAAA;AAClD,CAAA,EAAGN,KACDa,KAAKC,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,gBAAgBX,IAAI;EAAC;CAAO,GAC5BY,eAAeZ,IAAI,IAAA,GACnBa,WAAWC,eAAed,IAAI;EAC5Be,MAAM;EACNC,KAAK;AACP,CAAA,CAAA;AAgBK,IAAMC,OAAO,CAAC,EAAEzB,MAAMS,QAAQ,CAAC,GAAGL,MAAMsB,WAAU,MAAa;AACpE,QAAMC,QAAQC,IAAIH,KAAK3B,OAAO;IAAEE;IAAMI,MAAMC,IAAIoB,KAAKrB,IAAAA;IAAOK;EAAM,CAAA;AAGlE,MAAIiB,YAAY;AACd,UAAMG,SAASC,WAAWC,eAAeL,UAAAA;AACzC,UAAMM,aAAuBC,gCAAsBJ,OAAOK,GAAG;AAC7D,eAAWC,YAAYH,YAAY;AACjC,YAAMhC,QAAOmC,SAASnC,KAAKoC,SAAQ;AACnC,UAAI3B,QAAQT,KAAAA,GAAO;AACjB2B,cAAMlB,MAAMT,KAAAA,IAAQS,MAAMT,KAAAA;AAC1B;MACF;AAEAqC,MAAMC,WAAI,EAAkBpC,KACpBqC,WAAK;QAAEC,MAAM;MAAiB,GAAG,MAAA;AACrCb,cAAMlB,MAAMT,KAAAA,IAAQ;MACtB,CAAA,GACMuC,WAAK;QAAEC,MAAM;MAAgB,GAAG,MAAA;AACpCb,cAAMlB,MAAMT,KAAAA,IAAQ;MACtB,CAAA,GACMyC,aAAO,MAAA;MAEb,CAAA,CAAA,EACAN,SAASG,IAAI;IACjB;EACF;AAEA,SAAOX;AACT;AAMO,IAAMe,UAAiB3C,cAAO;EACnCU,OAAcC,cAAO;IACnBC,KAAYV;IACZW,OAAcC;EAChB,CAAA,EAAGX,KAAYY,cAAO;AACxB,CAAA,EAAGZ,KACDa,KAAKC,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
- "names": ["Match", "Schema", "SchemaAST", "Annotation", "JsonSchema", "Obj", "Ref", "Type", "View", "FormInputAnnotation", "LabelAnnotation", "ViewAnnotation", "Table", "Struct", "name", "String", "pipe", "optional", "view", "Ref", "View", "FormInputAnnotation", "set", "sizes", "Record", "key", "value", "Number", "mutable", "Type", "object", "typename", "version", "LabelAnnotation", "ViewAnnotation", "Annotation", "IconAnnotation", "icon", "hue", "make", "jsonSchema", "table", "Obj", "schema", "JsonSchema", "toEffectSchema", "properties", "getPropertySignatures", "ast", "property", "toString", "Match", "type", "when", "_tag", "orElse", "TableV1"]
7
- }