@dxos/react-ui-table 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (136) hide show
  1. package/dist/lib/browser/chunk-DSR2MRZB.mjs +80 -0
  2. package/dist/lib/browser/chunk-DSR2MRZB.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-PTHMYAAM.mjs +1751 -0
  4. package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1160 -1024
  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 +30 -42
  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-GI72MQSG.mjs +1753 -0
  12. package/dist/lib/node-esm/chunk-GI72MQSG.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-HTZJSULI.mjs +81 -0
  14. package/dist/lib/node-esm/chunk-HTZJSULI.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1160 -1024
  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 +30 -42
  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 +7 -7
  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 -9
  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 +12 -12
  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 +5 -5
  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 +9 -9
  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 +105 -25
  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 +2 -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 +14 -11
  74. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  75. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  76. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  77. package/dist/types/src/util/index.d.ts +2 -0
  78. package/dist/types/src/util/index.d.ts.map +1 -1
  79. package/dist/types/src/util/query-ast.d.ts +7 -0
  80. package/dist/types/src/util/query-ast.d.ts.map +1 -0
  81. package/dist/types/src/util/sort.d.ts +12 -0
  82. package/dist/types/src/util/sort.d.ts.map +1 -0
  83. package/dist/types/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +54 -54
  85. package/src/components/Table/ColumnActionsMenu.tsx +10 -6
  86. package/src/components/Table/ColumnSettings.tsx +8 -9
  87. package/src/components/Table/DynamicTable.stories.tsx +16 -16
  88. package/src/components/Table/DynamicTable.tsx +29 -21
  89. package/src/components/Table/Relations.stories.tsx +52 -60
  90. package/src/components/Table/RowActionsMenu.tsx +24 -15
  91. package/src/components/Table/Table.stories.tsx +114 -96
  92. package/src/components/Table/Table.tsx +326 -300
  93. package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -5
  94. package/src/components/TableCellEditor/FormCellEditor.tsx +117 -134
  95. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +18 -13
  96. package/src/components/TableCellEditor/TableCellEditor.tsx +31 -31
  97. package/src/components/TableToolbar/TableToolbar.tsx +53 -37
  98. package/src/components/testing.ts +38 -12
  99. package/src/hooks/index.ts +2 -1
  100. package/src/hooks/useAddRow.ts +8 -10
  101. package/src/hooks/useProjectionModel.ts +39 -0
  102. package/src/hooks/useTableModel.ts +36 -34
  103. package/src/model/modal-controller.ts +23 -12
  104. package/src/model/selection-model.ts +75 -44
  105. package/src/model/table-model.test.ts +82 -54
  106. package/src/model/table-model.ts +436 -170
  107. package/src/model/table-presentation.test.ts +59 -49
  108. package/src/model/table-presentation.ts +43 -37
  109. package/src/playwright/TableManager.ts +13 -6
  110. package/src/playwright/playwright.config.ts +1 -1
  111. package/src/playwright/smoke.spec.ts +56 -10
  112. package/src/testing/useTestTableModel.ts +45 -38
  113. package/src/translations.ts +3 -3
  114. package/src/types/Table.ts +95 -0
  115. package/src/types/index.ts +1 -1
  116. package/src/util/dynamic-table.test.ts +70 -0
  117. package/src/util/dynamic-table.ts +41 -28
  118. package/src/util/index.ts +2 -0
  119. package/src/util/query-ast.ts +22 -0
  120. package/src/util/sort.ts +90 -0
  121. package/src/util/table-buttons.ts +1 -1
  122. package/src/util/table-controls.ts +2 -2
  123. package/dist/lib/browser/chunk-4K7JPALT.mjs +0 -66
  124. package/dist/lib/browser/chunk-4K7JPALT.mjs.map +0 -7
  125. package/dist/lib/browser/chunk-OZTXLZGM.mjs +0 -1804
  126. package/dist/lib/browser/chunk-OZTXLZGM.mjs.map +0 -7
  127. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs +0 -67
  128. package/dist/lib/node-esm/chunk-MK6OVUF6.mjs.map +0 -7
  129. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs +0 -1805
  130. package/dist/lib/node-esm/chunk-S56Z4V4X.mjs.map +0 -7
  131. package/dist/types/src/model/table-sorting.d.ts +0 -52
  132. package/dist/types/src/model/table-sorting.d.ts.map +0 -1
  133. package/dist/types/src/types/schema.d.ts +0 -28
  134. package/dist/types/src/types/schema.d.ts.map +0 -1
  135. package/src/model/table-sorting.ts +0 -225
  136. 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.c4373fc",
3
+ "version": "0.8.4-main.c85a9c8dae",
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,70 +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.5.0",
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.c4373fc",
69
- "@dxos/context": "0.8.4-main.c4373fc",
70
- "@dxos/debug": "0.8.4-main.c4373fc",
71
- "@dxos/echo-db": "0.8.4-main.c4373fc",
72
- "@dxos/invariant": "0.8.4-main.c4373fc",
73
- "@dxos/keys": "0.8.4-main.c4373fc",
74
- "@dxos/effect": "0.8.4-main.c4373fc",
75
- "@dxos/echo": "0.8.4-main.c4373fc",
76
- "@dxos/lit-grid": "0.8.4-main.c4373fc",
77
- "@dxos/live-object": "0.8.4-main.c4373fc",
78
- "@dxos/plugin-search": "0.8.4-main.c4373fc",
79
- "@dxos/log": "0.8.4-main.c4373fc",
80
- "@dxos/random": "0.8.4-main.c4373fc",
81
- "@dxos/react-ui-attention": "0.8.4-main.c4373fc",
82
- "@dxos/react-ui-editor": "0.8.4-main.c4373fc",
83
- "@dxos/react-ui-components": "0.8.4-main.c4373fc",
84
- "@dxos/react-ui-form": "0.8.4-main.c4373fc",
85
- "@dxos/react-client": "0.8.4-main.c4373fc",
86
- "@dxos/react-ui-grid": "0.8.4-main.c4373fc",
87
- "@dxos/react-ui-searchlist": "0.8.4-main.c4373fc",
88
- "@dxos/react-ui-menu": "0.8.4-main.c4373fc",
89
- "@dxos/react-ui-stack": "0.8.4-main.c4373fc",
90
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.c4373fc",
91
- "@dxos/react-ui-types": "0.8.4-main.c4373fc",
92
- "@dxos/schema": "0.8.4-main.c4373fc",
93
- "@dxos/util": "0.8.4-main.c4373fc"
71
+ "@dxos/async": "0.8.4-main.c85a9c8dae",
72
+ "@dxos/context": "0.8.4-main.c85a9c8dae",
73
+ "@dxos/effect": "0.8.4-main.c85a9c8dae",
74
+ "@dxos/debug": "0.8.4-main.c85a9c8dae",
75
+ "@dxos/echo-atom": "0.8.4-main.c85a9c8dae",
76
+ "@dxos/invariant": "0.8.4-main.c85a9c8dae",
77
+ "@dxos/keys": "0.8.4-main.c85a9c8dae",
78
+ "@dxos/log": "0.8.4-main.c85a9c8dae",
79
+ "@dxos/lit-grid": "0.8.4-main.c85a9c8dae",
80
+ "@dxos/random": "0.8.4-main.c85a9c8dae",
81
+ "@dxos/react-ui-attention": "0.8.4-main.c85a9c8dae",
82
+ "@dxos/react-client": "0.8.4-main.c85a9c8dae",
83
+ "@dxos/react-ui-editor": "0.8.4-main.c85a9c8dae",
84
+ "@dxos/react-ui-components": "0.8.4-main.c85a9c8dae",
85
+ "@dxos/echo": "0.8.4-main.c85a9c8dae",
86
+ "@dxos/react-ui-form": "0.8.4-main.c85a9c8dae",
87
+ "@dxos/react-ui-menu": "0.8.4-main.c85a9c8dae",
88
+ "@dxos/react-ui-searchlist": "0.8.4-main.c85a9c8dae",
89
+ "@dxos/react-ui-grid": "0.8.4-main.c85a9c8dae",
90
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.c85a9c8dae",
91
+ "@dxos/schema": "0.8.4-main.c85a9c8dae",
92
+ "@dxos/react-ui-stack": "0.8.4-main.c85a9c8dae",
93
+ "@dxos/util": "0.8.4-main.c85a9c8dae",
94
+ "@dxos/types": "0.8.4-main.c85a9c8dae",
95
+ "@dxos/ui-types": "0.8.4-main.c85a9c8dae"
94
96
  },
95
97
  "devDependencies": {
96
- "@effect-rx/rx-react": "0.42.4",
97
- "@effect/platform": "0.92.1",
98
+ "@effect/platform": "0.94.4",
98
99
  "@types/lodash.orderby": "^4.6.9",
99
- "@types/react": "~19.2.2",
100
- "@types/react-dom": "~19.2.1",
101
- "effect": "3.18.3",
100
+ "@types/react": "~19.2.7",
101
+ "@types/react-dom": "~19.2.3",
102
+ "effect": "3.19.16",
102
103
  "fast-check": "^3.19.0",
103
- "react": "~19.2.0",
104
- "react-dom": "~19.2.0",
105
- "vite": "7.1.9",
106
- "@dxos/lit-ui": "0.8.4-main.c4373fc",
107
- "@dxos/plugin-search": "0.8.4-main.c4373fc",
108
- "@dxos/random": "0.8.4-main.c4373fc",
109
- "@dxos/react-ui": "0.8.4-main.c4373fc",
110
- "@dxos/echo-signals": "0.8.4-main.c4373fc",
111
- "@dxos/react-ui-theme": "0.8.4-main.c4373fc",
112
- "@dxos/storybook-utils": "0.8.4-main.c4373fc",
113
- "@dxos/test-utils": "0.8.4-main.c4373fc"
104
+ "react": "~19.2.3",
105
+ "react-dom": "~19.2.3",
106
+ "vite": "^7.1.11",
107
+ "@dxos/random": "0.8.4-main.c85a9c8dae",
108
+ "@dxos/react-client": "0.8.4-main.c85a9c8dae",
109
+ "@dxos/lit-ui": "0.8.4-main.c85a9c8dae",
110
+ "@dxos/storybook-utils": "0.8.4-main.c85a9c8dae",
111
+ "@dxos/test-utils": "0.8.4-main.c85a9c8dae",
112
+ "@dxos/react-ui": "0.8.4-main.c85a9c8dae",
113
+ "@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
114
114
  },
115
115
  "peerDependencies": {
116
- "@effect-rx/rx-react": "^0.34.1",
117
- "@effect/platform": "^0.80.12",
118
- "effect": "^3.13.3",
119
- "react": "^19.0.0",
120
- "react-dom": "^19.0.0",
121
- "@dxos/react-ui": "0.8.4-main.c4373fc",
122
- "@dxos/react-ui-theme": "0.8.4-main.c4373fc"
116
+ "@effect-atom/atom-react": "^0.5.0",
117
+ "@effect/platform": "0.94.4",
118
+ "effect": "3.19.16",
119
+ "react": "~19.2.3",
120
+ "react-dom": "~19.2.3",
121
+ "@dxos/react-ui": "0.8.4-main.c85a9c8dae",
122
+ "@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
123
123
  },
124
124
  "publishConfig": {
125
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,26 +2,25 @@
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, type View } from '@dxos/echo';
9
9
  import { Popover } from '@dxos/react-ui';
10
10
  import { FieldEditor } from '@dxos/react-ui-form';
11
- import { type FieldType } from '@dxos/schema';
12
11
 
13
12
  import { type ModalController, type TableModel } from '../../model';
14
13
 
15
14
  type ColumnSettingsProps = {
16
- registry?: SchemaRegistry;
15
+ registry?: SchemaRegistry.SchemaRegistry;
17
16
  model?: TableModel;
18
17
  modals: ModalController;
19
18
  onNewColumn: () => void;
20
19
  };
21
20
 
22
21
  export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnSettingsProps) => {
23
- const [newField, setNewField] = useState<FieldType>();
24
- const state = modals.state.value;
22
+ const [newField, setNewField] = useState<View.FieldType>();
23
+ const state = useAtomValue(modals.state);
25
24
 
26
25
  useEffect(() => {
27
26
  if (state?.type === 'columnSettings' && state.mode.type === 'create' && model?.projection) {
@@ -38,11 +37,11 @@ export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnS
38
37
  if (state?.type === 'columnSettings') {
39
38
  const { mode } = state;
40
39
  if (mode.type === 'edit') {
41
- return model?.projection?.fields.find((f) => f.id === mode.fieldId);
40
+ return model?.projection?.getFields().find((f) => f.id === mode.fieldId);
42
41
  }
43
42
  }
44
43
  return undefined;
45
- }, [model?.projection?.fields, state]);
44
+ }, [model?.projection, state]);
46
45
 
47
46
  const field = existingField ?? newField;
48
47
 
@@ -64,7 +63,7 @@ export const ColumnSettings = ({ registry, model, modals, onNewColumn }: ColumnS
64
63
  <Popover.Root modal={false} open={state?.type === 'columnSettings'}>
65
64
  <Popover.VirtualTrigger virtualRef={modals.trigger} />
66
65
  <Popover.Portal>
67
- <Popover.Content classNames='md:is-64'>
66
+ <Popover.Content classNames='md:w-64'>
68
67
  <Popover.Viewport>
69
68
  <FieldEditor
70
69
  projection={model.projection}
@@ -3,17 +3,18 @@
3
3
  //
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import type * as Types from 'effect/Types';
6
7
  import React, { useMemo, useState } from 'react';
7
8
 
8
- import { Obj } from '@dxos/echo';
9
- import { FormatEnum, type JsonSchemaType } from '@dxos/echo/internal';
9
+ import { type JsonSchema, Obj } from '@dxos/echo';
10
+ import { Format } from '@dxos/echo/internal';
10
11
  import { faker } from '@dxos/random';
11
- import { useClient } from '@dxos/react-client';
12
12
  import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
13
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
14
- import { withTheme } from '@dxos/react-ui/testing';
13
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
14
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
15
15
  import { type SchemaPropertyDefinition } from '@dxos/schema';
16
- import { Testing } from '@dxos/schema/testing';
16
+ import { TestSchema } from '@dxos/schema/testing';
17
+ import { withRegistry } from '@dxos/storybook-utils';
17
18
 
18
19
  import { type TableFeatures } from '../../model';
19
20
  import { translations } from '../../translations';
@@ -25,8 +26,8 @@ faker.seed(0);
25
26
  const useTestPropertiesAndObjects = () => {
26
27
  const properties = useMemo<SchemaPropertyDefinition[]>(
27
28
  () => [
28
- { name: 'name', format: FormatEnum.String },
29
- { name: 'age', format: FormatEnum.Number },
29
+ { name: 'name', format: Format.TypeFormat.String },
30
+ { name: 'age', format: Format.TypeFormat.Number },
30
31
  ],
31
32
  [],
32
33
  );
@@ -58,7 +59,7 @@ const DynamicTableStory = () => {
58
59
  const meta = {
59
60
  title: 'ui/react-ui-table/DynamicTable',
60
61
  component: DynamicTable,
61
- decorators: [withTheme],
62
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
62
63
  parameters: {
63
64
  layout: 'fullscreen',
64
65
  translations,
@@ -101,7 +102,7 @@ export const WithClickToSelect: StoryObj = {
101
102
 
102
103
  export const WithJsonSchema: StoryObj = {
103
104
  render: () => {
104
- const schema = useMemo<JsonSchemaType>(
105
+ const schema = useMemo<Types.DeepMutable<JsonSchema.JsonSchema>>(
105
106
  () => ({
106
107
  type: 'object',
107
108
  properties: {
@@ -130,10 +131,9 @@ export const WithJsonSchema: StoryObj = {
130
131
 
131
132
  export const WithEchoSchema: StoryObj = {
132
133
  render: () => {
133
- const client = useClient();
134
- const { space } = useClientProvider();
135
- const schema = useSchema(client, space, Testing.Contact.typename);
136
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
134
+ const { space } = useClientStory();
135
+ const schema = useSchema(space?.db, TestSchema.Person.typename);
136
+ const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
137
137
  if (!schema) {
138
138
  return <div>Loading schema...</div>;
139
139
  }
@@ -142,13 +142,13 @@ export const WithEchoSchema: StoryObj = {
142
142
  },
143
143
  decorators: [
144
144
  withClientProvider({
145
- types: [Testing.Contact],
145
+ types: [TestSchema.Person],
146
146
  createIdentity: true,
147
147
  createSpace: true,
148
148
  onCreateSpace: async ({ space }) => {
149
149
  Array.from({ length: 10 }).forEach(() => {
150
150
  space.db.add(
151
- Obj.make(Testing.Contact, {
151
+ Obj.make(TestSchema.Person, {
152
152
  name: faker.person.fullName(),
153
153
  email: faker.internet.email(),
154
154
  }),
@@ -2,25 +2,29 @@
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 type * as Types from 'effect/Types';
7
+ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
7
8
 
8
- import { type JsonSchemaType } from '@dxos/echo/internal';
9
+ import { type Type } from '@dxos/echo';
10
+ import { type JsonSchema } from '@dxos/echo';
9
11
  import { type ThemedClassName, useDefaultValue } from '@dxos/react-ui';
10
- import { mx } from '@dxos/react-ui-theme';
12
+ import { type ProjectionModel } from '@dxos/schema';
13
+ import { mx } from '@dxos/ui-theme';
11
14
 
12
15
  import { useTableModel } from '../../hooks';
13
16
  import { type TableFeatures, TablePresentation, type TableRowAction } from '../../model';
17
+ import { type Table as TableType } from '../../types';
14
18
  import { type TablePropertyDefinition, getBaseSchema, makeDynamicTable } from '../../util';
15
19
 
16
20
  import { Table, type TableController } from './Table';
17
21
 
18
- type DynamicTableProps = ThemedClassName<{
22
+ export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = ThemedClassName<{
23
+ schema?: T;
19
24
  name?: string; // TODO(burdon): Remove?
20
25
  rows: any[];
21
26
  properties?: TablePropertyDefinition[];
22
- jsonSchema?: JsonSchemaType;
23
- schema?: Schema.Schema.AnyNoContext;
27
+ jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
24
28
  features?: Partial<TableFeatures>;
25
29
  rowActions?: TableRowAction[];
26
30
  onRowClick?: (row: any) => void;
@@ -32,25 +36,30 @@ type DynamicTableProps = ThemedClassName<{
32
36
  */
33
37
  // TODO(burdon): Instead of creating component variants, create helpers/hooks that normalize the props.
34
38
  // TODO(burdon): Warning: Cannot update a component (`DynamicTable`) while rendering a different component (`DynamicTable`).
35
- export const DynamicTable = ({
39
+ export const DynamicTable = <T extends Type.AnyEntity = Type.AnyEntity>({
36
40
  classNames,
41
+ schema,
37
42
  name = 'example.com/dynamic-table', // Rmove default or make random; this will lead to type collisions.
38
43
  rows,
39
44
  properties,
40
- jsonSchema: _jsonSchema,
41
- schema,
45
+ jsonSchema: jsonSchemaProp,
42
46
  rowActions,
43
47
  onRowClick,
44
48
  onRowAction,
45
49
  ...props
46
- }: DynamicTableProps) => {
50
+ }: DynamicTableProps<T>) => {
51
+ const registry = useContext(RegistryContext);
52
+ const [dynamicTable, setDynamicTable] = useState<{ object: TableType.Table; projection: ProjectionModel }>();
53
+
47
54
  // TODO(burdon): Remove variance from the props (should be normalized externally; possibly via hooks).
48
55
  const { jsonSchema } = useMemo(
49
- () => getBaseSchema({ typename: name, properties, jsonSchema: _jsonSchema, schema }),
50
- [name, properties, _jsonSchema, schema],
56
+ () => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp, schema }),
57
+ [name, properties, jsonSchemaProp, schema],
51
58
  );
52
59
 
53
- const { projection, view } = useMemo(() => makeDynamicTable({ jsonSchema, properties }), [jsonSchema, properties]);
60
+ useEffect(() => {
61
+ setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
62
+ }, [registry, jsonSchema, properties]);
54
63
 
55
64
  const tableRef = useRef<TableController>(null);
56
65
  const handleCellUpdate = useCallback((cell: any) => {
@@ -72,9 +81,8 @@ export const DynamicTable = ({
72
81
 
73
82
  const model = useTableModel({
74
83
  rows,
75
- view,
76
- schema: jsonSchema,
77
- projection,
84
+ object: dynamicTable?.object,
85
+ projection: dynamicTable?.projection,
78
86
  features,
79
87
  rowActions,
80
88
  onCellUpdate: handleCellUpdate,
@@ -84,14 +92,14 @@ export const DynamicTable = ({
84
92
 
85
93
  const presentation = useMemo(() => {
86
94
  if (model) {
87
- return new TablePresentation(model);
95
+ return new TablePresentation(registry, model);
88
96
  }
89
- }, [model]);
97
+ }, [registry, model]);
90
98
 
91
99
  // TODO(burdon): Do we need the outer divs?
92
100
  return (
93
- <div role='none' className={mx('is-full bs-full grow grid', classNames)}>
94
- <div role='none' className='grid min-bs-0 overflow-hidden'>
101
+ <div role='none' className={mx('w-full h-full grow grid', classNames)}>
102
+ <div role='none' className='grid min-h-0 overflow-hidden'>
95
103
  <Table.Root>
96
104
  <Table.Main
97
105
  ref={tableRef}