@dxos/react-ui-table 0.8.4-main.72ec0f3 → 0.8.4-main.937b3ca

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 (129) hide show
  1. package/dist/lib/browser/{chunk-GS2UNGJK.mjs → chunk-MNZKOFMA.mjs} +633 -662
  2. package/dist/lib/browser/chunk-MNZKOFMA.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-OZBLY7XM.mjs +76 -0
  4. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1101 -973
  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 +29 -41
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types/index.mjs +3 -3
  11. package/dist/lib/node-esm/{chunk-TRR3C5NX.mjs → chunk-2ATAIIAO.mjs} +633 -661
  12. package/dist/lib/node-esm/chunk-2ATAIIAO.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs +77 -0
  14. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1101 -973
  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 +29 -41
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  20. package/dist/lib/node-esm/types/index.mjs +3 -3
  21. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
  22. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -2
  24. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/DynamicTable.d.ts +4 -5
  26. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +4 -18
  28. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  29. package/dist/types/src/components/Table/Relations.stories.d.ts +12 -8
  30. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/Table.d.ts +8 -8
  33. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/Table.stories.d.ts +71 -5
  35. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
  37. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +10 -12
  38. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  39. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -7
  40. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  41. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +4 -4
  42. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  43. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
  44. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  45. package/dist/types/src/components/testing.d.ts +22 -15
  46. package/dist/types/src/components/testing.d.ts.map +1 -1
  47. package/dist/types/src/hooks/index.d.ts +2 -1
  48. package/dist/types/src/hooks/index.d.ts.map +1 -1
  49. package/dist/types/src/hooks/useAddRow.d.ts +5 -6
  50. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  51. package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
  52. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
  53. package/dist/types/src/hooks/useTableModel.d.ts +8 -8
  54. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  55. package/dist/types/src/model/modal-controller.d.ts +5 -1
  56. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  57. package/dist/types/src/model/selection-model.d.ts +17 -8
  58. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  59. package/dist/types/src/model/table-model.d.ts +101 -22
  60. package/dist/types/src/model/table-model.d.ts.map +1 -1
  61. package/dist/types/src/model/table-presentation.d.ts +3 -1
  62. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  63. package/dist/types/src/playwright/TableManager.d.ts +1 -1
  64. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  65. package/dist/types/src/testing/useTestTableModel.d.ts +18 -15
  66. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  67. package/dist/types/src/translations.d.ts +4 -4
  68. package/dist/types/src/translations.d.ts.map +1 -1
  69. package/dist/types/src/types/Table.d.ts +31 -0
  70. package/dist/types/src/types/Table.d.ts.map +1 -0
  71. package/dist/types/src/types/index.d.ts +1 -1
  72. package/dist/types/src/types/index.d.ts.map +1 -1
  73. package/dist/types/src/util/dynamic-table.d.ts +13 -11
  74. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  75. package/dist/types/src/util/index.d.ts +2 -0
  76. package/dist/types/src/util/index.d.ts.map +1 -1
  77. package/dist/types/src/util/query-ast.d.ts +7 -0
  78. package/dist/types/src/util/query-ast.d.ts.map +1 -0
  79. package/dist/types/src/util/sort.d.ts +12 -0
  80. package/dist/types/src/util/sort.d.ts.map +1 -0
  81. package/dist/types/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +53 -54
  83. package/src/components/Table/ColumnActionsMenu.tsx +10 -6
  84. package/src/components/Table/ColumnSettings.tsx +6 -6
  85. package/src/components/Table/DynamicTable.stories.tsx +12 -13
  86. package/src/components/Table/DynamicTable.tsx +21 -14
  87. package/src/components/Table/Relations.stories.tsx +28 -33
  88. package/src/components/Table/RowActionsMenu.tsx +3 -2
  89. package/src/components/Table/Table.stories.tsx +65 -69
  90. package/src/components/Table/Table.tsx +335 -305
  91. package/src/components/TableCellEditor/CellValidationMessage.tsx +1 -1
  92. package/src/components/TableCellEditor/FormCellEditor.tsx +111 -134
  93. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +11 -8
  94. package/src/components/TableCellEditor/TableCellEditor.tsx +31 -31
  95. package/src/components/TableToolbar/TableToolbar.tsx +19 -13
  96. package/src/components/testing.ts +38 -12
  97. package/src/hooks/index.ts +2 -1
  98. package/src/hooks/useAddRow.ts +8 -10
  99. package/src/hooks/useProjectionModel.ts +40 -0
  100. package/src/hooks/useTableModel.ts +35 -33
  101. package/src/model/modal-controller.ts +23 -12
  102. package/src/model/selection-model.ts +75 -44
  103. package/src/model/table-model.test.ts +81 -53
  104. package/src/model/table-model.ts +422 -160
  105. package/src/model/table-presentation.test.ts +58 -48
  106. package/src/model/table-presentation.ts +31 -26
  107. package/src/playwright/TableManager.ts +5 -5
  108. package/src/playwright/playwright.config.ts +1 -1
  109. package/src/playwright/smoke.spec.ts +4 -3
  110. package/src/testing/useTestTableModel.ts +44 -37
  111. package/src/translations.ts +3 -3
  112. package/src/types/Table.ts +90 -0
  113. package/src/types/index.ts +1 -1
  114. package/src/util/dynamic-table.ts +36 -23
  115. package/src/util/index.ts +2 -0
  116. package/src/util/query-ast.ts +19 -0
  117. package/src/util/sort.ts +90 -0
  118. package/dist/lib/browser/chunk-2PFAPQL4.mjs +0 -66
  119. package/dist/lib/browser/chunk-2PFAPQL4.mjs.map +0 -7
  120. package/dist/lib/browser/chunk-GS2UNGJK.mjs.map +0 -7
  121. package/dist/lib/node-esm/chunk-6POOFFYF.mjs +0 -67
  122. package/dist/lib/node-esm/chunk-6POOFFYF.mjs.map +0 -7
  123. package/dist/lib/node-esm/chunk-TRR3C5NX.mjs.map +0 -7
  124. package/dist/types/src/model/table-sorting.d.ts +0 -52
  125. package/dist/types/src/model/table-sorting.d.ts.map +0 -1
  126. package/dist/types/src/types/schema.d.ts +0 -28
  127. package/dist/types/src/types/schema.d.ts.map +0 -1
  128. package/src/model/table-sorting.ts +0 -225
  129. package/src/types/schema.ts +0 -73
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-table",
3
- "version": "0.8.4-main.72ec0f3",
3
+ "version": "0.8.4-main.937b3ca",
4
4
  "description": "A table component.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  "./deprecated": {
@@ -56,71 +60,66 @@
56
60
  "@codemirror/autocomplete": "^6.19.0",
57
61
  "@codemirror/state": "^6.5.2",
58
62
  "@codemirror/view": "^6.38.4",
59
- "@fluentui/react-tabster": "^9.24.2",
60
- "@preact-signals/safe-react": "^0.9.0",
61
- "@preact/signals-core": "^1.12.1",
63
+ "@effect-atom/atom-react": "^0.4.6",
64
+ "@fluentui/react-tabster": "9.26.11",
62
65
  "@radix-ui/react-context": "1.1.1",
63
66
  "@radix-ui/react-primitive": "2.0.2",
64
67
  "@radix-ui/react-slot": "1.1.2",
65
68
  "@radix-ui/react-use-controllable-state": "1.1.0",
66
69
  "date-fns": "^3.3.1",
67
70
  "lodash.orderby": "^4.6.0",
68
- "@dxos/async": "0.8.4-main.72ec0f3",
69
- "@dxos/debug": "0.8.4-main.72ec0f3",
70
- "@dxos/echo": "0.8.4-main.72ec0f3",
71
- "@dxos/effect": "0.8.4-main.72ec0f3",
72
- "@dxos/invariant": "0.8.4-main.72ec0f3",
73
- "@dxos/lit-grid": "0.8.4-main.72ec0f3",
74
- "@dxos/echo-db": "0.8.4-main.72ec0f3",
75
- "@dxos/keys": "0.8.4-main.72ec0f3",
76
- "@dxos/live-object": "0.8.4-main.72ec0f3",
77
- "@dxos/log": "0.8.4-main.72ec0f3",
78
- "@dxos/plugin-search": "0.8.4-main.72ec0f3",
79
- "@dxos/react-client": "0.8.4-main.72ec0f3",
80
- "@dxos/random": "0.8.4-main.72ec0f3",
81
- "@dxos/react-ui-attention": "0.8.4-main.72ec0f3",
82
- "@dxos/react-ui-components": "0.8.4-main.72ec0f3",
83
- "@dxos/react-ui-editor": "0.8.4-main.72ec0f3",
84
- "@dxos/react-ui-form": "0.8.4-main.72ec0f3",
85
- "@dxos/react-ui-grid": "0.8.4-main.72ec0f3",
86
- "@dxos/react-ui-menu": "0.8.4-main.72ec0f3",
87
- "@dxos/react-ui-searchlist": "0.8.4-main.72ec0f3",
88
- "@dxos/react-ui-stack": "0.8.4-main.72ec0f3",
89
- "@dxos/context": "0.8.4-main.72ec0f3",
90
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.72ec0f3",
91
- "@dxos/react-ui-types": "0.8.4-main.72ec0f3",
92
- "@dxos/types": "0.8.4-main.72ec0f3",
93
- "@dxos/util": "0.8.4-main.72ec0f3",
94
- "@dxos/schema": "0.8.4-main.72ec0f3"
71
+ "@dxos/async": "0.8.4-main.937b3ca",
72
+ "@dxos/context": "0.8.4-main.937b3ca",
73
+ "@dxos/echo": "0.8.4-main.937b3ca",
74
+ "@dxos/debug": "0.8.4-main.937b3ca",
75
+ "@dxos/echo-atom": "0.8.4-main.937b3ca",
76
+ "@dxos/effect": "0.8.4-main.937b3ca",
77
+ "@dxos/invariant": "0.8.4-main.937b3ca",
78
+ "@dxos/lit-grid": "0.8.4-main.937b3ca",
79
+ "@dxos/log": "0.8.4-main.937b3ca",
80
+ "@dxos/keys": "0.8.4-main.937b3ca",
81
+ "@dxos/random": "0.8.4-main.937b3ca",
82
+ "@dxos/react-ui-attention": "0.8.4-main.937b3ca",
83
+ "@dxos/react-ui-components": "0.8.4-main.937b3ca",
84
+ "@dxos/react-client": "0.8.4-main.937b3ca",
85
+ "@dxos/react-ui-editor": "0.8.4-main.937b3ca",
86
+ "@dxos/react-ui-menu": "0.8.4-main.937b3ca",
87
+ "@dxos/react-ui-form": "0.8.4-main.937b3ca",
88
+ "@dxos/react-ui-searchlist": "0.8.4-main.937b3ca",
89
+ "@dxos/react-ui-stack": "0.8.4-main.937b3ca",
90
+ "@dxos/schema": "0.8.4-main.937b3ca",
91
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.937b3ca",
92
+ "@dxos/types": "0.8.4-main.937b3ca",
93
+ "@dxos/util": "0.8.4-main.937b3ca",
94
+ "@dxos/ui-types": "0.8.4-main.937b3ca",
95
+ "@dxos/react-ui-grid": "0.8.4-main.937b3ca"
95
96
  },
96
97
  "devDependencies": {
97
- "@effect-atom/atom-react": "^0.3.4",
98
- "@effect/platform": "0.92.1",
98
+ "@effect/platform": "0.93.6",
99
99
  "@types/lodash.orderby": "^4.6.9",
100
- "@types/react": "~19.2.2",
101
- "@types/react-dom": "~19.2.2",
102
- "effect": "3.18.3",
100
+ "@types/react": "~19.2.7",
101
+ "@types/react-dom": "~19.2.3",
102
+ "effect": "3.19.11",
103
103
  "fast-check": "^3.19.0",
104
- "react": "~19.2.0",
105
- "react-dom": "~19.2.0",
104
+ "react": "~19.2.3",
105
+ "react-dom": "~19.2.3",
106
106
  "vite": "7.1.9",
107
- "@dxos/echo-signals": "0.8.4-main.72ec0f3",
108
- "@dxos/lit-ui": "0.8.4-main.72ec0f3",
109
- "@dxos/plugin-search": "0.8.4-main.72ec0f3",
110
- "@dxos/random": "0.8.4-main.72ec0f3",
111
- "@dxos/react-ui": "0.8.4-main.72ec0f3",
112
- "@dxos/react-ui-theme": "0.8.4-main.72ec0f3",
113
- "@dxos/test-utils": "0.8.4-main.72ec0f3",
114
- "@dxos/storybook-utils": "0.8.4-main.72ec0f3"
107
+ "@dxos/lit-ui": "0.8.4-main.937b3ca",
108
+ "@dxos/random": "0.8.4-main.937b3ca",
109
+ "@dxos/react-ui": "0.8.4-main.937b3ca",
110
+ "@dxos/react-client": "0.8.4-main.937b3ca",
111
+ "@dxos/storybook-utils": "0.8.4-main.937b3ca",
112
+ "@dxos/ui-theme": "0.8.4-main.937b3ca",
113
+ "@dxos/test-utils": "0.8.4-main.937b3ca"
115
114
  },
116
115
  "peerDependencies": {
117
- "@effect-atom/atom-react": "^0.3.4",
118
- "@effect/platform": "^0.80.12",
119
- "effect": "^3.13.3",
120
- "react": "^19.0.0",
121
- "react-dom": "^19.0.0",
122
- "@dxos/react-ui": "0.8.4-main.72ec0f3",
123
- "@dxos/react-ui-theme": "0.8.4-main.72ec0f3"
116
+ "@effect-atom/atom-react": "^0.4.6",
117
+ "@effect/platform": "0.93.6",
118
+ "effect": "3.19.11",
119
+ "react": "~19.2.3",
120
+ "react-dom": "~19.2.3",
121
+ "@dxos/react-ui": "0.8.4-main.937b3ca",
122
+ "@dxos/ui-theme": "0.8.4-main.937b3ca"
124
123
  },
125
124
  "publishConfig": {
126
125
  "access": "public"
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { useAtomValue } from '@effect-atom/atom-react';
5
6
  import React from 'react';
6
7
 
7
8
  import { DropdownMenu, useTranslation } from '@dxos/react-ui';
@@ -9,16 +10,19 @@ import { DropdownMenu, useTranslation } from '@dxos/react-ui';
9
10
  import { type ModalController, type TableModel } from '../../model';
10
11
  import { translationKey } from '../../translations';
11
12
 
12
- type ColumnActionsMenuProps = { model: TableModel; modals: ModalController };
13
+ export type ColumnActionsMenuProps = {
14
+ model: TableModel;
15
+ modals: ModalController;
16
+ };
13
17
 
14
18
  export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) => {
15
19
  const { t } = useTranslation(translationKey);
16
- const state = modals.state.value;
20
+ const state = useAtomValue(modals.state);
17
21
  if (state?.type !== 'column') {
18
22
  return null;
19
23
  }
20
24
 
21
- const currentSort = model.sorting?.sorting;
25
+ const currentSort = model.getSorting();
22
26
  const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
23
27
 
24
28
  return (
@@ -30,7 +34,7 @@ export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) =>
30
34
  {(!isCurrentColumnSorted || currentSort?.direction === 'asc') && (
31
35
  <DropdownMenu.Item
32
36
  data-testid='column-sort-descending'
33
- onClick={() => model.sorting?.setSort(state.fieldId, 'desc')}
37
+ onClick={() => model.setSort(state.fieldId, 'desc')}
34
38
  >
35
39
  {t('column action sort descending')}
36
40
  </DropdownMenu.Item>
@@ -38,13 +42,13 @@ export const ColumnActionsMenu = ({ model, modals }: ColumnActionsMenuProps) =>
38
42
  {(!isCurrentColumnSorted || currentSort?.direction === 'desc') && (
39
43
  <DropdownMenu.Item
40
44
  data-testid='column-sort-ascending'
41
- onClick={() => model.sorting?.setSort(state.fieldId, 'asc')}
45
+ onClick={() => model.setSort(state.fieldId, 'asc')}
42
46
  >
43
47
  {t('column action sort ascending')}
44
48
  </DropdownMenu.Item>
45
49
  )}
46
50
  {isCurrentColumnSorted && (
47
- <DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.sorting?.clearSort()}>
51
+ <DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.clearSort()}>
48
52
  {t('column action clear sorting')}
49
53
  </DropdownMenu.Item>
50
54
  )}
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { useAtomValue } from '@effect-atom/atom-react';
5
6
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
7
 
7
- // TODO(burdon): Remove dependency on echo-db.
8
- import { type SchemaRegistry } from '@dxos/echo-db';
8
+ import { type SchemaRegistry } from '@dxos/echo';
9
9
  import { Popover } from '@dxos/react-ui';
10
10
  import { FieldEditor } from '@dxos/react-ui-form';
11
11
  import { type FieldType } from '@dxos/schema';
@@ -13,7 +13,7 @@ import { type FieldType } from '@dxos/schema';
13
13
  import { type ModalController, type TableModel } from '../../model';
14
14
 
15
15
  type ColumnSettingsProps = {
16
- registry?: SchemaRegistry;
16
+ registry?: SchemaRegistry.SchemaRegistry;
17
17
  model?: TableModel;
18
18
  modals: ModalController;
19
19
  onNewColumn: () => void;
@@ -21,7 +21,7 @@ type ColumnSettingsProps = {
21
21
 
22
22
  export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnSettingsProps) => {
23
23
  const [newField, setNewField] = useState<FieldType>();
24
- const state = modals.state.value;
24
+ const state = useAtomValue(modals.state);
25
25
 
26
26
  useEffect(() => {
27
27
  if (state?.type === 'columnSettings' && state.mode.type === 'create' && model?.projection) {
@@ -38,11 +38,11 @@ export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnS
38
38
  if (state?.type === 'columnSettings') {
39
39
  const { mode } = state;
40
40
  if (mode.type === 'edit') {
41
- return model?.projection?.fields.find((f) => f.id === mode.fieldId);
41
+ return model?.projection?.getFields().find((f) => f.id === mode.fieldId);
42
42
  }
43
43
  }
44
44
  return undefined;
45
- }, [model?.projection?.fields, state]);
45
+ }, [model?.projection, state]);
46
46
 
47
47
  const field = existingField ?? newField;
48
48
 
@@ -6,14 +6,14 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import React, { useMemo, useState } from 'react';
7
7
 
8
8
  import { Obj } from '@dxos/echo';
9
- import { FormatEnum, type JsonSchemaType } from '@dxos/echo/internal';
9
+ import { Format, type JsonSchemaType } from '@dxos/echo/internal';
10
10
  import { faker } from '@dxos/random';
11
- import { useClient } from '@dxos/react-client';
12
11
  import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
13
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
12
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
14
13
  import { withTheme } from '@dxos/react-ui/testing';
15
14
  import { type SchemaPropertyDefinition } from '@dxos/schema';
16
- import { Testing } from '@dxos/schema/testing';
15
+ import { TestSchema } from '@dxos/schema/testing';
16
+ import { withRegistry } from '@dxos/storybook-utils';
17
17
 
18
18
  import { type TableFeatures } from '../../model';
19
19
  import { translations } from '../../translations';
@@ -25,8 +25,8 @@ faker.seed(0);
25
25
  const useTestPropertiesAndObjects = () => {
26
26
  const properties = useMemo<SchemaPropertyDefinition[]>(
27
27
  () => [
28
- { name: 'name', format: FormatEnum.String },
29
- { name: 'age', format: FormatEnum.Number },
28
+ { name: 'name', format: Format.TypeFormat.String },
29
+ { name: 'age', format: Format.TypeFormat.Number },
30
30
  ],
31
31
  [],
32
32
  );
@@ -58,7 +58,7 @@ const DynamicTableStory = () => {
58
58
  const meta = {
59
59
  title: 'ui/react-ui-table/DynamicTable',
60
60
  component: DynamicTable,
61
- decorators: [withTheme],
61
+ decorators: [withTheme, withRegistry],
62
62
  parameters: {
63
63
  layout: 'fullscreen',
64
64
  translations,
@@ -130,10 +130,9 @@ export const WithJsonSchema: StoryObj = {
130
130
 
131
131
  export const WithEchoSchema: StoryObj = {
132
132
  render: () => {
133
- const client = useClient();
134
- const { space } = useClientProvider();
135
- const schema = useSchema(client, space, Testing.Person.typename);
136
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
133
+ const { space } = useClientStory();
134
+ const schema = useSchema(space?.db, TestSchema.Person.typename);
135
+ const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
137
136
  if (!schema) {
138
137
  return <div>Loading schema...</div>;
139
138
  }
@@ -142,13 +141,13 @@ export const WithEchoSchema: StoryObj = {
142
141
  },
143
142
  decorators: [
144
143
  withClientProvider({
145
- types: [Testing.Person],
144
+ types: [TestSchema.Person],
146
145
  createIdentity: true,
147
146
  createSpace: true,
148
147
  onCreateSpace: async ({ space }) => {
149
148
  Array.from({ length: 10 }).forEach(() => {
150
149
  space.db.add(
151
- Obj.make(Testing.Person, {
150
+ Obj.make(TestSchema.Person, {
152
151
  name: faker.person.fullName(),
153
152
  email: faker.internet.email(),
154
153
  }),
@@ -2,25 +2,28 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import type * as Schema from 'effect/Schema';
6
- import React, { useCallback, useMemo, useRef } from 'react';
5
+ import { RegistryContext } from '@effect-atom/atom-react';
6
+ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
7
7
 
8
+ import { type Type } from '@dxos/echo';
8
9
  import { type JsonSchemaType } from '@dxos/echo/internal';
9
10
  import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
10
- import { mx } from '@dxos/react-ui-theme';
11
+ import { type ProjectionModel } from '@dxos/schema';
12
+ import { mx } from '@dxos/ui-theme';
11
13
 
12
14
  import { useTableModel } from '../../hooks';
13
15
  import { type TableFeatures, TablePresentation, type TableRowAction } from '../../model';
16
+ import { type Table as TableType } from '../../types';
14
17
  import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '../../util';
15
18
 
16
19
  import { Table, type TableController } from './Table';
17
20
 
18
- type DynamicTableProps = ThemedClassName<{
21
+ export type DynamicTableProps<T extends Type.Entity.Any = Type.Entity.Any> = ThemedClassName<{
22
+ schema?: T;
19
23
  name?: string; // TODO(burdon): Remove?
20
24
  rows: any[];
21
25
  properties?: TablePropertyDefinition[];
22
26
  jsonSchema?: JsonSchemaType;
23
- schema?: Schema.Schema.AnyNoContext;
24
27
  features?: Partial<TableFeatures>;
25
28
  rowActions?: TableRowAction[];
26
29
  onRowClick?: (row: any) => void;
@@ -32,25 +35,30 @@ type DynamicTableProps = ThemedClassName<{
32
35
  */
33
36
  // TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
34
37
  // TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
35
- export const DynamicTable = ({
38
+ export const DynamicTable = <T extends Type.Entity.Any = Type.Entity.Any>({
36
39
  classNames,
40
+ schema,
37
41
  name = 'example.com/dynamic-table', // Rmove default or make random; this will lead to type collisions.
38
42
  rows,
39
43
  properties,
40
44
  jsonSchema: _jsonSchema,
41
- schema,
42
45
  rowActions,
43
46
  onRowClick,
44
47
  onRowAction,
45
48
  ...props
46
- }: DynamicTableProps) => {
49
+ }: DynamicTableProps<T>) => {
50
+ const registry = useContext(RegistryContext);
51
+ const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
52
+
47
53
  // TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
48
54
  const { jsonSchema } = useMemo(
49
55
  () => getBaseSchema({ typename: name, properties, jsonSchema: _jsonSchema, schema }),
50
56
  [name, properties, _jsonSchema, schema],
51
57
  );
52
58
 
53
- const { projection, view } = useMemo(() => makeDynamicTable({ jsonSchema, properties }), [jsonSchema, properties]);
59
+ useEffect(() => {
60
+ setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
61
+ }, [registry, jsonSchema, properties]);
54
62
 
55
63
  const tableRef = useRef<TableController>(null);
56
64
  const handleCellUpdate = useCallback((cell: any) => {
@@ -72,9 +80,8 @@ export const DynamicTable = ({
72
80
 
73
81
  const model = useTableModel({
74
82
  rows,
75
- view,
76
- schema: jsonSchema,
77
- projection,
83
+ object: dynamicTable?.object,
84
+ projection: dynamicTable?.projection,
78
85
  features,
79
86
  rowActions,
80
87
  onCellUpdate: handleCellUpdate,
@@ -84,9 +91,9 @@ export const DynamicTable = ({
84
91
 
85
92
  const presentation = useMemo(() => {
86
93
  if (model) {
87
- return new TablePresentation(model);
94
+ return new TablePresentation(registry, model);
88
95
  }
89
- }, [model]);
96
+ }, [registry, model]);
90
97
 
91
98
  // TODO(burdon): Do we need the outer divs?
92
99
  return (
@@ -2,26 +2,26 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { RegistryContext } from '@effect-atom/atom-react';
5
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import type * as Schema from 'effect/Schema';
7
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
8
8
  import { expect, userEvent, within } from 'storybook/test';
9
9
 
10
10
  import { Obj, Type } from '@dxos/echo';
11
- import { type JsonSchemaType } from '@dxos/echo/internal';
11
+ import { invariant } from '@dxos/invariant';
12
12
  import { type DxGrid } from '@dxos/lit-grid';
13
13
  import '@dxos/lit-ui/dx-tag-picker.pcss';
14
14
  import { faker } from '@dxos/random';
15
- import { useClient } from '@dxos/react-client';
16
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
15
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
17
16
  import { useAsyncEffect } from '@dxos/react-ui';
18
17
  import { withLayout, withTheme } from '@dxos/react-ui/testing';
19
18
  import { translations as formTranslations } from '@dxos/react-ui-form';
20
19
  import { View } from '@dxos/schema';
21
20
  import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
21
+ import { withRegistry } from '@dxos/storybook-utils';
22
22
  import { Organization, Person } from '@dxos/types';
23
23
 
24
- import { useTableModel } from '../../hooks';
24
+ import { useProjectionModel, useTableModel } from '../../hooks';
25
25
  import { type TableFeatures, TablePresentation, type TableRow } from '../../model';
26
26
  import { translations } from '../../translations';
27
27
  import { Table } from '../../types';
@@ -36,10 +36,9 @@ const generator: ValueGenerator = faker as any;
36
36
  // TODO(burdon): Reconcile schemas types and utils (see API PR).
37
37
  // TODO(burdon): Base type for T (with id); see ECHO API PR?
38
38
  const useTestModel = <S extends Type.Obj.Any>(schema: S, count: number) => {
39
- const client = useClient();
40
- const { space } = useClientProvider();
41
- const [view, setView] = useState<View.View>();
42
- const [jsonSchema, setJsonSchema] = useState<JsonSchemaType>();
39
+ const registry = useContext(RegistryContext);
40
+ const { space } = useClientStory();
41
+ const [object, setObject] = useState<Table.Table>();
43
42
 
44
43
  const features = useMemo<TableFeatures>(
45
44
  () => ({ schemaEditable: false, dataEditable: true, selection: { enabled: false } }),
@@ -51,18 +50,14 @@ const useTestModel = <S extends Type.Obj.Any>(schema: S, count: number) => {
51
50
  return;
52
51
  }
53
52
 
54
- const {
55
- jsonSchema,
56
- schema: effectSchema,
57
- view,
58
- } = await Table.makeView({ client, space, typename: Type.getTypename(schema) });
59
- setJsonSchema(jsonSchema);
60
- setView(view);
61
- space.db.add(view);
62
- await space.db.schemaRegistry.register([effectSchema]);
63
- }, [client, space, schema]);
53
+ const { view, jsonSchema } = await View.makeFromDatabase({ db: space.db, typename: Type.getTypename(schema) });
54
+ const object = Table.make({ view, jsonSchema });
55
+ setObject(object);
56
+ space.db.add(object);
57
+ }, [space, schema]);
64
58
 
65
- const model = useTableModel<TableRow>({ view, schema: jsonSchema, rows: [], features });
59
+ const projection = useProjectionModel(schema, object, registry);
60
+ const model = useTableModel<TableRow>({ object, projection, db: space?.db, features });
66
61
 
67
62
  useEffect(() => {
68
63
  if (!model || !space) {
@@ -80,21 +75,22 @@ const useTestModel = <S extends Type.Obj.Any>(schema: S, count: number) => {
80
75
  return;
81
76
  }
82
77
 
83
- return new TablePresentation(model);
84
- }, [model]);
78
+ return new TablePresentation(registry, model);
79
+ }, [registry, model]);
85
80
 
86
81
  return { model, presentation };
87
82
  };
88
83
 
89
84
  const DefaultStory = () => {
90
- const client = useClient();
91
85
  const { model: orgModel, presentation: orgPresentation } = useTestModel(Organization.Organization, 50);
92
86
  const { model: contactModel, presentation: contactPresentation } = useTestModel(Person.Person, 50);
93
- const { space } = useClientProvider();
87
+ const { space } = useClientStory();
94
88
 
95
89
  const handleCreate = useCallback(
96
- (schema: Schema.Schema.AnyNoContext, values: any) => {
97
- return client.spaces.default.db.add(Obj.make(schema, values));
90
+ (schema: Type.Entity.Any, values: any) => {
91
+ invariant(Type.isObjectSchema(schema));
92
+ invariant(space);
93
+ return space.db.add(Obj.make(schema, values));
98
94
  },
99
95
  [space],
100
96
  );
@@ -107,7 +103,6 @@ const DefaultStory = () => {
107
103
  schema={Organization.Organization}
108
104
  presentation={orgPresentation}
109
105
  onCreate={handleCreate}
110
- client={client}
111
106
  ignoreAttention
112
107
  testId='relations-0'
113
108
  />
@@ -118,7 +113,6 @@ const DefaultStory = () => {
118
113
  schema={Person.Person}
119
114
  presentation={contactPresentation}
120
115
  onCreate={handleCreate}
121
- client={client}
122
116
  ignoreAttention
123
117
  testId='relations-1'
124
118
  />
@@ -132,7 +126,8 @@ const meta = {
132
126
  render: DefaultStory,
133
127
  decorators: [
134
128
  withTheme,
135
- // TODO(thure): Shouldn’t `layout: 'fullscreen'` below make this unnecessary?
129
+ withRegistry,
130
+ // TODO(thure): Shouldn't `layout: 'fullscreen'` below make this unnecessary?
136
131
  withLayout({ classNames: 'fixed inset-0' }),
137
132
  withClientProvider({
138
133
  types: [View.View, Organization.Organization, Person.Person, Table.Table],
@@ -224,9 +219,9 @@ export const Default: Story = {
224
219
  const newOrgName = 'Salieri LLC';
225
220
  await userEvent.type(newSearchField, newOrgName);
226
221
 
227
- // Look for an option to select (should be the create new option)
228
- const newOption = await body.findAllByRole('option');
229
- await expect(newOption[0]).toBeVisible();
222
+ // Wait for the create option to appear (debounce is 200ms, allow time for render)
223
+ const createOption = await body.findByRole('option', undefined, { timeout: 500 });
224
+ await expect(createOption).toBeVisible();
230
225
 
231
226
  // Press Enter to select/create
232
227
  await userEvent.keyboard('{Enter}');
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { useAtomValue } from '@effect-atom/atom-react';
5
6
  import React from 'react';
6
7
 
7
8
  import { DropdownMenu, toLocalizedString, useTranslation } from '@dxos/react-ui';
@@ -13,8 +14,8 @@ type RowActionsMenuProps = { model: TableModel; modals: ModalController };
13
14
 
14
15
  export const RowActionsMenu = ({ model, modals }: RowActionsMenuProps) => {
15
16
  const { t } = useTranslation(translationKey);
16
- const hasSelection = model.selection.hasSelection.value;
17
- const state = modals.state.value;
17
+ const hasSelection = model.selection.hasSelection;
18
+ const state = useAtomValue(modals.state);
18
19
  if (state?.type !== 'row') {
19
20
  return null;
20
21
  }