@dxos/react-ui-table 0.8.4-main.f5c0578 → 0.8.4-main.fcfe5033a5

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 (162) hide show
  1. package/dist/lib/browser/chunk-BF54SSNL.mjs +70 -0
  2. package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-ZAOSIG3L.mjs → chunk-F7Y374KL.mjs} +739 -802
  4. package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +1208 -1158
  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 +34 -43
  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-ZOFFI3JJ.mjs → chunk-CCJ4LOVM.mjs} +739 -801
  12. package/dist/lib/node-esm/chunk-CCJ4LOVM.mjs.map +7 -0
  13. package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs +71 -0
  14. package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +1208 -1158
  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 +34 -43
  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 +35 -3
  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 +106 -5
  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 +21 -19
  33. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/Table.stories.d.ts +108 -5
  35. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/Table/TableContent.d.ts +17 -0
  37. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  38. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  39. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  40. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
  41. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +13 -9
  42. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  43. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +7 -14
  44. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  45. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +38 -5
  46. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  47. package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
  48. package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
  49. package/dist/types/src/components/index.d.ts +0 -1
  50. package/dist/types/src/components/index.d.ts.map +1 -1
  51. package/dist/types/src/components/testing.d.ts +23 -16
  52. package/dist/types/src/components/testing.d.ts.map +1 -1
  53. package/dist/types/src/hooks/index.d.ts +2 -1
  54. package/dist/types/src/hooks/index.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useAddRow.d.ts +6 -6
  56. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
  58. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
  59. package/dist/types/src/hooks/useTableModel.d.ts +9 -9
  60. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  61. package/dist/types/src/model/modal-controller.d.ts +5 -8
  62. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  63. package/dist/types/src/model/selection-model.d.ts +17 -8
  64. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  65. package/dist/types/src/model/table-model.d.ts +110 -29
  66. package/dist/types/src/model/table-model.d.ts.map +1 -1
  67. package/dist/types/src/model/table-presentation.d.ts +4 -2
  68. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  69. package/dist/types/src/playwright/TableManager.d.ts +2 -1
  70. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  71. package/dist/types/src/testing/useTestTableModel.d.ts +18 -34
  72. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  73. package/dist/types/src/translations.d.ts +21 -23
  74. package/dist/types/src/translations.d.ts.map +1 -1
  75. package/dist/types/src/types/Table.d.ts +26 -0
  76. package/dist/types/src/types/Table.d.ts.map +1 -0
  77. package/dist/types/src/types/index.d.ts +1 -1
  78. package/dist/types/src/types/index.d.ts.map +1 -1
  79. package/dist/types/src/util/dynamic-table.d.ts +14 -12
  80. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  81. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  82. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  83. package/dist/types/src/util/index.d.ts +2 -1
  84. package/dist/types/src/util/index.d.ts.map +1 -1
  85. package/dist/types/src/util/query-ast.d.ts +7 -0
  86. package/dist/types/src/util/query-ast.d.ts.map +1 -0
  87. package/dist/types/src/util/schema.d.ts +1 -1
  88. package/dist/types/src/util/schema.d.ts.map +1 -1
  89. package/dist/types/src/util/sort.d.ts +12 -0
  90. package/dist/types/src/util/sort.d.ts.map +1 -0
  91. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  92. package/dist/types/tsconfig.tsbuildinfo +1 -1
  93. package/package.json +58 -57
  94. package/src/components/Table/ColumnActionsMenu.tsx +15 -11
  95. package/src/components/Table/ColumnSettings.tsx +8 -9
  96. package/src/components/Table/DynamicTable.stories.tsx +36 -34
  97. package/src/components/Table/DynamicTable.tsx +33 -36
  98. package/src/components/Table/Relations.stories.tsx +180 -59
  99. package/src/components/Table/RowActionsMenu.tsx +24 -15
  100. package/src/components/Table/Table.stories.tsx +152 -129
  101. package/src/components/Table/Table.tsx +46 -391
  102. package/src/components/Table/TableContent.tsx +421 -0
  103. package/src/components/Table/TableToolbar.tsx +111 -0
  104. package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -5
  105. package/src/components/TableCellEditor/FormCellEditor.tsx +134 -40
  106. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +35 -72
  107. package/src/components/TableCellEditor/TableCellEditor.tsx +80 -224
  108. package/src/components/TableCellEditor/index.ts +1 -0
  109. package/src/components/index.ts +0 -1
  110. package/src/components/testing.ts +44 -18
  111. package/src/hooks/index.ts +2 -1
  112. package/src/hooks/useAddRow.ts +14 -14
  113. package/src/hooks/useProjectionModel.ts +39 -0
  114. package/src/hooks/useTableModel.ts +36 -34
  115. package/src/model/modal-controller.ts +23 -40
  116. package/src/model/selection-model.ts +75 -44
  117. package/src/model/table-model.test.ts +91 -56
  118. package/src/model/table-model.ts +447 -172
  119. package/src/model/table-presentation.test.ts +68 -58
  120. package/src/model/table-presentation.ts +97 -73
  121. package/src/playwright/TableManager.ts +13 -6
  122. package/src/playwright/playwright.config.ts +1 -1
  123. package/src/playwright/smoke.spec.ts +92 -46
  124. package/src/testing/useTestTableModel.ts +50 -40
  125. package/src/translations.ts +20 -22
  126. package/src/types/Table.ts +79 -0
  127. package/src/types/index.ts +1 -1
  128. package/src/util/dynamic-table.test.ts +70 -0
  129. package/src/util/dynamic-table.ts +45 -32
  130. package/src/util/index.ts +2 -1
  131. package/src/util/query-ast.ts +22 -0
  132. package/src/util/schema.ts +4 -4
  133. package/src/util/sort.ts +90 -0
  134. package/src/util/table-buttons.ts +3 -3
  135. package/src/util/table-controls.ts +2 -2
  136. package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
  137. package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
  138. package/dist/lib/browser/chunk-ZAOSIG3L.mjs.map +0 -7
  139. package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
  140. package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
  141. package/dist/lib/node-esm/chunk-ZOFFI3JJ.mjs.map +0 -7
  142. package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
  143. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
  144. package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
  145. package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
  146. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  147. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  148. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  149. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  150. package/dist/types/src/model/table-sorting.d.ts +0 -53
  151. package/dist/types/src/model/table-sorting.d.ts.map +0 -1
  152. package/dist/types/src/types/schema.d.ts +0 -8
  153. package/dist/types/src/types/schema.d.ts.map +0 -1
  154. package/dist/types/src/util/table.d.ts +0 -12
  155. package/dist/types/src/util/table.d.ts.map +0 -1
  156. package/src/components/Table/CreateRefPanel.tsx +0 -86
  157. package/src/components/TableCellEditor/extension.ts +0 -61
  158. package/src/components/TableToolbar/TableToolbar.tsx +0 -102
  159. package/src/components/TableToolbar/index.ts +0 -5
  160. package/src/model/table-sorting.ts +0 -216
  161. package/src/types/schema.ts +0 -16
  162. package/src/util/table.ts +0 -53
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-table",
3
- "version": "0.8.4-main.f5c0578",
3
+ "version": "0.8.4-main.fcfe5033a5",
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": {
@@ -53,72 +57,69 @@
53
57
  "src"
54
58
  ],
55
59
  "dependencies": {
56
- "@codemirror/autocomplete": "^6.18.1",
57
- "@codemirror/state": "^6.4.1",
58
- "@codemirror/view": "^6.34.1",
59
- "@fluentui/react-tabster": "^9.24.2",
60
- "@preact-signals/safe-react": "^0.9.0",
61
- "@preact/signals-core": "^1.9.0",
60
+ "@codemirror/autocomplete": "^6.19.0",
61
+ "@codemirror/state": "^6.5.2",
62
+ "@codemirror/view": "^6.38.4",
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
- "date-fns": "^3.3.1",
69
+ "date-fns": "^3.6.0",
67
70
  "lodash.orderby": "^4.6.0",
68
- "@dxos/debug": "0.8.4-main.f5c0578",
69
- "@dxos/context": "0.8.4-main.f5c0578",
70
- "@dxos/echo": "0.8.4-main.f5c0578",
71
- "@dxos/echo-db": "0.8.4-main.f5c0578",
72
- "@dxos/echo-schema": "0.8.4-main.f5c0578",
73
- "@dxos/effect": "0.8.4-main.f5c0578",
74
- "@dxos/invariant": "0.8.4-main.f5c0578",
75
- "@dxos/keys": "0.8.4-main.f5c0578",
76
- "@dxos/lit-grid": "0.8.4-main.f5c0578",
77
- "@dxos/live-object": "0.8.4-main.f5c0578",
78
- "@dxos/log": "0.8.4-main.f5c0578",
79
- "@dxos/plugin-search": "0.8.4-main.f5c0578",
80
- "@dxos/random": "0.8.4-main.f5c0578",
81
- "@dxos/react-client": "0.8.4-main.f5c0578",
82
- "@dxos/react-ui-editor": "0.8.4-main.f5c0578",
83
- "@dxos/react-ui-attention": "0.8.4-main.f5c0578",
84
- "@dxos/react-ui-form": "0.8.4-main.f5c0578",
85
- "@dxos/react-ui-grid": "0.8.4-main.f5c0578",
86
- "@dxos/react-ui-menu": "0.8.4-main.f5c0578",
87
- "@dxos/react-ui-searchlist": "0.8.4-main.f5c0578",
88
- "@dxos/react-ui-tag-picker": "0.8.4-main.f5c0578",
89
- "@dxos/react-ui-types": "0.8.4-main.f5c0578",
90
- "@dxos/react-ui-stack": "0.8.4-main.f5c0578",
91
- "@dxos/schema": "0.8.4-main.f5c0578",
92
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.f5c0578",
93
- "@dxos/util": "0.8.4-main.f5c0578"
71
+ "@dxos/context": "0.8.4-main.fcfe5033a5",
72
+ "@dxos/effect": "0.8.4-main.fcfe5033a5",
73
+ "@dxos/async": "0.8.4-main.fcfe5033a5",
74
+ "@dxos/debug": "0.8.4-main.fcfe5033a5",
75
+ "@dxos/echo-atom": "0.8.4-main.fcfe5033a5",
76
+ "@dxos/keys": "0.8.4-main.fcfe5033a5",
77
+ "@dxos/lit-grid": "0.8.4-main.fcfe5033a5",
78
+ "@dxos/invariant": "0.8.4-main.fcfe5033a5",
79
+ "@dxos/log": "0.8.4-main.fcfe5033a5",
80
+ "@dxos/random": "0.8.4-main.fcfe5033a5",
81
+ "@dxos/echo": "0.8.4-main.fcfe5033a5",
82
+ "@dxos/react-client": "0.8.4-main.fcfe5033a5",
83
+ "@dxos/react-ui-attention": "0.8.4-main.fcfe5033a5",
84
+ "@dxos/react-ui-components": "0.8.4-main.fcfe5033a5",
85
+ "@dxos/react-ui-editor": "0.8.4-main.fcfe5033a5",
86
+ "@dxos/react-ui-form": "0.8.4-main.fcfe5033a5",
87
+ "@dxos/react-ui-search": "0.8.4-main.fcfe5033a5",
88
+ "@dxos/react-ui-grid": "0.8.4-main.fcfe5033a5",
89
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.fcfe5033a5",
90
+ "@dxos/react-ui-menu": "0.8.4-main.fcfe5033a5",
91
+ "@dxos/schema": "0.8.4-main.fcfe5033a5",
92
+ "@dxos/types": "0.8.4-main.fcfe5033a5",
93
+ "@dxos/react-ui-stack": "0.8.4-main.fcfe5033a5",
94
+ "@dxos/ui-types": "0.8.4-main.fcfe5033a5",
95
+ "@dxos/util": "0.8.4-main.fcfe5033a5"
94
96
  },
95
97
  "devDependencies": {
96
- "@effect-rx/rx-react": "0.38.0",
97
- "@effect/platform": "0.90.2",
98
+ "@effect/platform": "0.94.4",
98
99
  "@types/lodash.orderby": "^4.6.9",
99
- "@types/react": "~18.2.0",
100
- "@types/react-dom": "~18.2.0",
101
- "effect": "3.17.7",
100
+ "@types/react": "~19.2.7",
101
+ "@types/react-dom": "~19.2.3",
102
+ "effect": "3.20.0",
102
103
  "fast-check": "^3.19.0",
103
- "react": "~18.2.0",
104
- "react-dom": "~18.2.0",
105
- "vite": "5.4.7",
106
- "@dxos/plugin-search": "0.8.4-main.f5c0578",
107
- "@dxos/random": "0.8.4-main.f5c0578",
108
- "@dxos/react-ui": "0.8.4-main.f5c0578",
109
- "@dxos/echo-signals": "0.8.4-main.f5c0578",
110
- "@dxos/react-ui-theme": "0.8.4-main.f5c0578",
111
- "@dxos/test-utils": "0.8.4-main.f5c0578",
112
- "@dxos/storybook-utils": "0.8.4-main.f5c0578"
104
+ "react": "~19.2.3",
105
+ "react-dom": "~19.2.3",
106
+ "vite": "^7.1.11",
107
+ "@dxos/lit-ui": "0.8.4-main.fcfe5033a5",
108
+ "@dxos/react-client": "0.8.4-main.fcfe5033a5",
109
+ "@dxos/random": "0.8.4-main.fcfe5033a5",
110
+ "@dxos/react-ui": "0.8.4-main.fcfe5033a5",
111
+ "@dxos/storybook-utils": "0.8.4-main.fcfe5033a5",
112
+ "@dxos/ui-theme": "0.8.4-main.fcfe5033a5",
113
+ "@dxos/test-utils": "0.8.4-main.fcfe5033a5"
113
114
  },
114
115
  "peerDependencies": {
115
- "@effect-rx/rx-react": "^0.34.1",
116
- "@effect/platform": "^0.80.12",
117
- "effect": "^3.13.3",
118
- "react": "~18.2.0",
119
- "react-dom": "~18.2.0",
120
- "@dxos/react-ui": "0.8.4-main.f5c0578",
121
- "@dxos/react-ui-theme": "0.8.4-main.f5c0578"
116
+ "@effect-atom/atom-react": "^0.5.0",
117
+ "@effect/platform": "0.94.4",
118
+ "effect": "3.20.0",
119
+ "react": "~19.2.3",
120
+ "react-dom": "~19.2.3",
121
+ "@dxos/react-ui": "0.8.4-main.fcfe5033a5",
122
+ "@dxos/ui-theme": "0.8.4-main.fcfe5033a5"
122
123
  },
123
124
  "publishConfig": {
124
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,32 +34,32 @@ 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
- {t('column action sort descending')}
39
+ {t('column-action-sort-descending.menu')}
36
40
  </DropdownMenu.Item>
37
41
  )}
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
- {t('column action sort ascending')}
47
+ {t('column-action-sort-ascending.menu')}
44
48
  </DropdownMenu.Item>
45
49
  )}
46
50
  {isCurrentColumnSorted && (
47
- <DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.sorting?.clearSort()}>
48
- {t('column action clear sorting')}
51
+ <DropdownMenu.Item data-testid='column-clear-sort' onClick={() => model.clearSort()}>
52
+ {t('column-action-clear-sorting.menu')}
49
53
  </DropdownMenu.Item>
50
54
  )}
51
55
  {model.getColumnCount() > 1 && model.features.schemaEditable && (
52
56
  <DropdownMenu.Item data-testid='column-delete' onClick={() => model.deleteColumn(state.fieldId)}>
53
- {t('column action delete')}
57
+ {t('column-action-delete.menu')}
54
58
  </DropdownMenu.Item>
55
59
  )}
56
60
  {model.features.schemaEditable && (
57
61
  <DropdownMenu.Item data-testid='column-settings' onClick={() => modals.openColumnSettings()}>
58
- {t('column action settings')}
62
+ {t('column-action-settings.menu')}
59
63
  </DropdownMenu.Item>
60
64
  )}
61
65
  </DropdownMenu.Viewport>
@@ -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}
@@ -2,42 +2,40 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import type * as Types from 'effect/Types';
8
7
  import React, { useMemo, useState } from 'react';
9
8
 
10
- import { Obj } from '@dxos/echo';
11
- import { FormatEnum, type JsonSchemaType } from '@dxos/echo-schema';
12
- import { faker } from '@dxos/random';
13
- import { useClient } from '@dxos/react-client';
9
+ import { type JsonSchema, Obj } from '@dxos/echo';
10
+ import { Format } from '@dxos/echo/internal';
11
+ import { random } from '@dxos/random';
14
12
  import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
15
- import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
13
+ import { useClientStory, withClientProvider } from '@dxos/react-client/testing';
14
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
16
15
  import { type SchemaPropertyDefinition } from '@dxos/schema';
17
- import { Testing } from '@dxos/schema/testing';
18
- import { withLayout, withTheme } from '@dxos/storybook-utils';
16
+ import { TestSchema } from '@dxos/schema/testing';
17
+ import { withRegistry } from '@dxos/storybook-utils';
19
18
 
20
19
  import { type TableFeatures } from '../../model';
21
20
  import { translations } from '../../translations';
22
-
23
21
  import { DynamicTable } from './DynamicTable';
24
22
 
25
- faker.seed(0);
23
+ random.seed(0);
26
24
 
27
25
  const useTestPropertiesAndObjects = () => {
28
26
  const properties = useMemo<SchemaPropertyDefinition[]>(
29
27
  () => [
30
- { name: 'name', format: FormatEnum.String },
31
- { name: 'age', format: FormatEnum.Number },
28
+ { name: 'name', format: Format.TypeFormat.String },
29
+ { name: 'age', format: Format.TypeFormat.Number },
32
30
  ],
33
31
  [],
34
32
  );
35
33
 
36
34
  const [rows] = useState<any[]>(
37
35
  Array.from({ length: 10 }, () => ({
38
- id: faker.string.uuid(),
39
- name: faker.person.fullName(),
40
- age: faker.number.int({ min: 18, max: 80 }),
36
+ id: random.string.uuid(),
37
+ name: random.person.fullName(),
38
+ age: random.number.int({ min: 18, max: 80 }),
41
39
  })),
42
40
  );
43
41
 
@@ -57,15 +55,20 @@ const DynamicTableStory = () => {
57
55
  // Story definitions.
58
56
  //
59
57
 
60
- const meta: Meta = {
58
+ const meta = {
61
59
  title: 'ui/react-ui-table/DynamicTable',
62
60
  component: DynamicTable,
63
- parameters: { translations },
64
- decorators: [withLayout({ fullscreen: true }), withTheme],
65
- };
61
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
62
+ parameters: {
63
+ layout: 'fullscreen',
64
+ translations,
65
+ },
66
+ } satisfies Meta<typeof DynamicTable>;
66
67
 
67
68
  export default meta;
68
69
 
70
+ type Story = StoryObj<typeof meta>;
71
+
69
72
  export const Default: StoryObj = {
70
73
  render: DynamicTableStory,
71
74
  };
@@ -98,7 +101,7 @@ export const WithClickToSelect: StoryObj = {
98
101
 
99
102
  export const WithJsonSchema: StoryObj = {
100
103
  render: () => {
101
- const schema = useMemo<JsonSchemaType>(
104
+ const schema = useMemo<Types.DeepMutable<JsonSchema.JsonSchema>>(
102
105
  () => ({
103
106
  type: 'object',
104
107
  properties: {
@@ -114,10 +117,10 @@ export const WithJsonSchema: StoryObj = {
114
117
 
115
118
  const [rows] = useState<any[]>(
116
119
  Array.from({ length: 15 }, () => ({
117
- name: faker.person.fullName(),
118
- age: faker.number.int({ min: 18, max: 80 }),
119
- email: faker.internet.email(),
120
- active: faker.datatype.boolean(),
120
+ name: random.person.fullName(),
121
+ age: random.number.int({ min: 18, max: 80 }),
122
+ email: random.internet.email(),
123
+ active: random.datatype.boolean(),
121
124
  })),
122
125
  );
123
126
 
@@ -127,10 +130,9 @@ export const WithJsonSchema: StoryObj = {
127
130
 
128
131
  export const WithEchoSchema: StoryObj = {
129
132
  render: () => {
130
- const client = useClient();
131
- const { space } = useClientProvider();
132
- const schema = useSchema(client, space, Testing.Contact.typename);
133
- 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());
134
136
  if (!schema) {
135
137
  return <div>Loading schema...</div>;
136
138
  }
@@ -139,15 +141,15 @@ export const WithEchoSchema: StoryObj = {
139
141
  },
140
142
  decorators: [
141
143
  withClientProvider({
142
- types: [Testing.Contact],
144
+ types: [TestSchema.Person],
143
145
  createIdentity: true,
144
146
  createSpace: true,
145
- onSpaceCreated: async ({ space }) => {
147
+ onCreateSpace: async ({ space }) => {
146
148
  Array.from({ length: 10 }).forEach(() => {
147
149
  space.db.add(
148
- Obj.make(Testing.Contact, {
149
- name: faker.person.fullName(),
150
- email: faker.internet.email(),
150
+ Obj.make(TestSchema.Person, {
151
+ name: random.person.fullName(),
152
+ email: random.internet.email(),
151
153
  }),
152
154
  );
153
155
  });
@@ -2,25 +2,28 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
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-schema';
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
-
16
19
  import { Table, type TableController } from './Table';
17
20
 
18
- type DynamicTableProps = ThemedClassName<{
21
+ export type DynamicTableProps<T extends Type.AnyEntity = Type.AnyEntity> = ThemedClassName<{
22
+ schema?: T;
19
23
  name?: string; // TODO(burdon): Remove?
20
24
  rows: any[];
21
25
  properties?: TablePropertyDefinition[];
22
- jsonSchema?: JsonSchemaType;
23
- schema?: Schema.Schema.AnyNoContext;
26
+ jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
24
27
  features?: Partial<TableFeatures>;
25
28
  rowActions?: TableRowAction[];
26
29
  onRowClick?: (row: any) => void;
@@ -32,28 +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.AnyEntity = Type.AnyEntity>({
36
39
  classNames,
37
- name = 'example.com/dynamic-table', // Rmove default or make random; this will lead to type collisions.
40
+ schema,
41
+ name = 'com.example.dynamic-table', // Remove default or make random; this will lead to type collisions.
38
42
  rows,
39
43
  properties,
40
- jsonSchema: _jsonSchema,
41
- schema,
44
+ jsonSchema: jsonSchemaProp,
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
- const { typename, jsonSchema } = useMemo(
49
- () => getBaseSchema({ typename: name, properties, jsonSchema: _jsonSchema, schema }),
50
- [name, properties, _jsonSchema, schema],
54
+ const { jsonSchema } = useMemo(
55
+ () => getBaseSchema({ typename: name, properties, jsonSchema: jsonSchemaProp, schema }),
56
+ [name, properties, jsonSchemaProp, schema],
51
57
  );
52
58
 
53
- const { projection, view } = useMemo(
54
- () => makeDynamicTable({ typename, jsonSchema, properties }),
55
- [typename, jsonSchema, properties],
56
- );
59
+ useEffect(() => {
60
+ setDynamicTable(makeDynamicTable({ registry, jsonSchema, properties }));
61
+ }, [registry, jsonSchema, properties]);
57
62
 
58
63
  const tableRef = useRef<TableController>(null);
59
64
  const handleCellUpdate = useCallback((cell: any) => {
@@ -75,9 +80,8 @@ export const DynamicTable = ({
75
80
 
76
81
  const model = useTableModel({
77
82
  rows,
78
- view,
79
- schema: jsonSchema,
80
- projection,
83
+ object: dynamicTable?.object,
84
+ projection: dynamicTable?.projection,
81
85
  features,
82
86
  rowActions,
83
87
  onCellUpdate: handleCellUpdate,
@@ -87,22 +91,15 @@ export const DynamicTable = ({
87
91
 
88
92
  const presentation = useMemo(() => {
89
93
  if (model) {
90
- return new TablePresentation(model);
94
+ return new TablePresentation(registry, model);
91
95
  }
92
- }, [model]);
96
+ }, [registry, model]);
93
97
 
94
- // TODO(burdon): Do we need the outer divs?
95
98
  return (
96
- <div role='none' className={mx('is-full bs-full grow grid', classNames)}>
97
- <div role='none' className='grid min-bs-0 overflow-hidden'>
98
- <Table.Root>
99
- <Table.Main
100
- ref={tableRef}
101
- model={model}
102
- presentation={presentation}
103
- ignoreAttention
104
- onRowClick={onRowClick}
105
- />
99
+ <div role='none' className={mx('dx-expander grid', classNames)}>
100
+ <div role='none' className='grid min-h-0 overflow-hidden'>
101
+ <Table.Root ref={tableRef}>
102
+ <Table.Content model={model} presentation={presentation} ignoreAttention onRowClick={onRowClick} />
106
103
  </Table.Root>
107
104
  </div>
108
105
  </div>