@dxos/react-ui-table 0.8.2-main.f11618f → 0.8.2-staging.42af850

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 (87) hide show
  1. package/dist/lib/browser/chunk-U6LL2AVU.mjs +26 -0
  2. package/dist/lib/browser/chunk-U6LL2AVU.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1074 -828
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-TGG6OZ54.cjs → chunk-CXDGXPM6.cjs} +12 -12
  8. package/dist/lib/node/chunk-CXDGXPM6.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +1080 -837
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/types/index.cjs +3 -3
  13. package/dist/lib/node/types/index.cjs.map +1 -1
  14. package/dist/lib/node-esm/{chunk-KKLP54L3.mjs → chunk-EFSM52KQ.mjs} +10 -10
  15. package/dist/lib/node-esm/chunk-EFSM52KQ.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +1074 -828
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/types/index.mjs +1 -1
  20. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  21. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
  24. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  26. package/dist/types/src/components/Table/Table.d.ts +2 -0
  27. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.stories.d.ts +1 -0
  29. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  31. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +13 -0
  32. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -0
  33. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +3 -0
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -1
  37. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +6 -3
  38. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts +39 -39
  40. package/dist/types/src/components/testing.d.ts.map +1 -1
  41. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  42. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  43. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  44. package/dist/types/src/model/table-model.d.ts.map +1 -1
  45. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  46. package/dist/types/src/types/table.d.ts +46 -45
  47. package/dist/types/src/types/table.d.ts.map +1 -1
  48. package/dist/types/src/util/dynamic-table.d.ts +4 -3
  49. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  50. package/dist/types/src/util/index.d.ts +1 -0
  51. package/dist/types/src/util/index.d.ts.map +1 -1
  52. package/dist/types/src/util/schema.d.ts +12 -0
  53. package/dist/types/src/util/schema.d.ts.map +1 -0
  54. package/dist/types/src/util/signals.d.ts.map +1 -1
  55. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  56. package/dist/types/src/util/table.d.ts +2 -2
  57. package/dist/types/src/util/table.d.ts.map +1 -1
  58. package/dist/types/src/util/tag.d.ts.map +1 -1
  59. package/dist/types/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +41 -34
  61. package/src/components/Table/CreateRefPanel.tsx +3 -3
  62. package/src/components/Table/DynamicTable.stories.tsx +2 -2
  63. package/src/components/Table/DynamicTable.tsx +4 -5
  64. package/src/components/Table/Table.stories.tsx +76 -42
  65. package/src/components/Table/Table.tsx +8 -5
  66. package/src/components/Table/relations.stories.tsx +17 -20
  67. package/src/components/TableCellEditor/FormCellEditor.tsx +94 -0
  68. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -8
  69. package/src/components/TableCellEditor/TableCellEditor.tsx +45 -4
  70. package/src/components/TableToolbar/TableToolbar.tsx +63 -33
  71. package/src/components/testing.ts +7 -6
  72. package/src/hooks/useTableModel.ts +4 -2
  73. package/src/model/selection-model.ts +1 -1
  74. package/src/model/table-model.test.ts +4 -3
  75. package/src/model/table-model.ts +1 -1
  76. package/src/model/table-presentation.test.ts +4 -3
  77. package/src/model/table-presentation.ts +53 -7
  78. package/src/types/table.ts +16 -11
  79. package/src/util/dynamic-table.ts +7 -4
  80. package/src/util/index.ts +1 -0
  81. package/src/util/schema.ts +36 -0
  82. package/src/util/table-buttons.ts +1 -1
  83. package/src/util/table.ts +11 -10
  84. package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
  85. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
  86. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
  87. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TableSchema,
3
3
  TableType
4
- } from "./chunk-YWNRUF4J.mjs";
4
+ } from "./chunk-U6LL2AVU.mjs";
5
5
 
6
6
  // packages/ui/react-ui-table/src/translations.ts
7
7
  var translationKey = "table";
@@ -36,9 +36,10 @@ var translations_default = [
36
36
  ];
37
37
 
38
38
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
39
- import React6, { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState2, useMemo as useMemo4, useEffect as useEffect2 } from "react";
39
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
40
+ import React7, { forwardRef, useCallback as useCallback5, useImperativeHandle, useState as useState2, useMemo as useMemo5, useEffect as useEffect3 } from "react";
40
41
  import { getValue as getValue4 } from "@dxos/echo-schema";
41
- import { invariant as invariant3 } from "@dxos/invariant";
42
+ import { invariant as invariant4 } from "@dxos/invariant";
42
43
  import { Filter } from "@dxos/react-client/echo";
43
44
  import { useTranslation as useTranslation3 } from "@dxos/react-ui";
44
45
  import { useAttention } from "@dxos/react-ui-attention";
@@ -47,209 +48,233 @@ import { mx as mx2 } from "@dxos/react-ui-theme";
47
48
  import { isNotFalsy, safeParseInt } from "@dxos/util";
48
49
 
49
50
  // packages/ui/react-ui-table/src/components/Table/ColumnActionsMenu.tsx
51
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
50
52
  import React from "react";
51
53
  import { DropdownMenu, useTranslation } from "@dxos/react-ui";
52
54
  var ColumnActionsMenu = ({ model, modals }) => {
53
- const { t } = useTranslation(translationKey);
54
- const state = modals.state.value;
55
- if (state?.type !== "column") {
56
- return null;
57
- }
58
- const currentSort = model.sorting?.sorting;
59
- const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
60
- return /* @__PURE__ */ React.createElement(DropdownMenu.Root, {
61
- modal: false,
62
- open: true,
63
- onOpenChange: modals.close
64
- }, /* @__PURE__ */ React.createElement(DropdownMenu.VirtualTrigger, {
65
- virtualRef: modals.trigger
66
- }), /* @__PURE__ */ React.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
67
- "data-testid": "column-sort-descending",
68
- onClick: () => model.sorting?.setSort(state.fieldId, "desc")
69
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
70
- "data-testid": "column-sort-ascending",
71
- onClick: () => model.sorting?.setSort(state.fieldId, "asc")
72
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
73
- "data-testid": "column-clear-sort",
74
- onClick: () => model.sorting?.clearSort()
75
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
76
- "data-testid": "column-delete",
77
- onClick: () => model.deleteColumn(state.fieldId)
78
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
79
- "data-testid": "column-settings",
80
- onClick: () => modals.openColumnSettings()
81
- }, t("column action settings"))), /* @__PURE__ */ React.createElement(DropdownMenu.Arrow, null))));
55
+ var _effect = _useSignals();
56
+ try {
57
+ const { t } = useTranslation(translationKey);
58
+ const state = modals.state.value;
59
+ if (state?.type !== "column") {
60
+ return null;
61
+ }
62
+ const currentSort = model.sorting?.sorting;
63
+ const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
64
+ return /* @__PURE__ */ React.createElement(DropdownMenu.Root, {
65
+ modal: false,
66
+ open: true,
67
+ onOpenChange: modals.close
68
+ }, /* @__PURE__ */ React.createElement(DropdownMenu.VirtualTrigger, {
69
+ virtualRef: modals.trigger
70
+ }), /* @__PURE__ */ React.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
71
+ "data-testid": "column-sort-descending",
72
+ onClick: () => model.sorting?.setSort(state.fieldId, "desc")
73
+ }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
74
+ "data-testid": "column-sort-ascending",
75
+ onClick: () => model.sorting?.setSort(state.fieldId, "asc")
76
+ }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
77
+ "data-testid": "column-clear-sort",
78
+ onClick: () => model.sorting?.clearSort()
79
+ }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
80
+ "data-testid": "column-delete",
81
+ onClick: () => model.deleteColumn(state.fieldId)
82
+ }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React.createElement(DropdownMenu.Item, {
83
+ "data-testid": "column-settings",
84
+ onClick: () => modals.openColumnSettings()
85
+ }, t("column action settings"))), /* @__PURE__ */ React.createElement(DropdownMenu.Arrow, null))));
86
+ } finally {
87
+ _effect.f();
88
+ }
82
89
  };
83
90
 
84
91
  // packages/ui/react-ui-table/src/components/Table/ColumnSettings.tsx
92
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
85
93
  import React2, { useCallback, useEffect, useMemo, useState } from "react";
86
94
  import { DropdownMenu as DropdownMenu2 } from "@dxos/react-ui";
87
95
  import { FieldEditor } from "@dxos/react-ui-form";
88
96
  var ColumnSettings = ({ model, modals, onNewColumn }) => {
89
- const [newField, setNewField] = useState();
90
- const state = modals.state.value;
91
- const space = model?.space;
92
- useEffect(() => {
93
- if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
94
- setNewField(model.projection.createFieldProjection());
95
- requestAnimationFrame(() => {
96
- onNewColumn();
97
- });
98
- } else {
99
- setNewField(void 0);
100
- }
101
- }, [
102
- model?.projection,
103
- state
104
- ]);
105
- const existingField = useMemo(() => {
106
- if (state?.type === "columnSettings") {
107
- const { mode } = state;
108
- if (mode.type === "edit") {
109
- return model?.view?.fields.find((f) => f.id === mode.fieldId);
97
+ var _effect = _useSignals2();
98
+ try {
99
+ const [newField, setNewField] = useState();
100
+ const state = modals.state.value;
101
+ const space = model?.space;
102
+ useEffect(() => {
103
+ if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
104
+ setNewField(model.projection.createFieldProjection());
105
+ requestAnimationFrame(() => {
106
+ onNewColumn();
107
+ });
108
+ } else {
109
+ setNewField(void 0);
110
110
  }
111
- }
112
- return void 0;
113
- }, [
114
- model?.view?.fields,
115
- state
116
- ]);
117
- const field = existingField ?? newField;
118
- const handleSave = useCallback(() => {
119
- modals.close();
120
- }, [
121
- modals
122
- ]);
123
- const handleCancel = useCallback(() => {
124
- if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
125
- model?.projection?.deleteFieldProjection(newField.id);
126
- }
127
- }, [
128
- model?.projection,
129
- state,
130
- newField
131
- ]);
132
- if (!model?.view || !model.projection || !field) {
133
- return null;
134
- }
135
- return /* @__PURE__ */ React2.createElement(DropdownMenu2.Root, {
136
- modal: false,
137
- open: state?.type === "columnSettings"
138
- }, /* @__PURE__ */ React2.createElement(DropdownMenu2.VirtualTrigger, {
139
- virtualRef: modals.trigger
140
- }), /* @__PURE__ */ React2.createElement(DropdownMenu2.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu2.Content, {
141
- classNames: "md:is-64"
142
- }, /* @__PURE__ */ React2.createElement(DropdownMenu2.Viewport, null, /* @__PURE__ */ React2.createElement(FieldEditor, {
143
- view: model.view,
144
- projection: model.projection,
145
- field,
146
- registry: space?.db.schemaRegistry,
147
- onSave: handleSave,
148
- onCancel: handleCancel
149
- })), /* @__PURE__ */ React2.createElement(DropdownMenu2.Arrow, null))));
111
+ }, [
112
+ model?.projection,
113
+ state
114
+ ]);
115
+ const existingField = useMemo(() => {
116
+ if (state?.type === "columnSettings") {
117
+ const { mode } = state;
118
+ if (mode.type === "edit") {
119
+ return model?.view?.fields.find((f) => f.id === mode.fieldId);
120
+ }
121
+ }
122
+ return void 0;
123
+ }, [
124
+ model?.view?.fields,
125
+ state
126
+ ]);
127
+ const field = existingField ?? newField;
128
+ const handleSave = useCallback(() => {
129
+ modals.close();
130
+ }, [
131
+ modals
132
+ ]);
133
+ const handleCancel = useCallback(() => {
134
+ if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
135
+ model?.projection?.deleteFieldProjection(newField.id);
136
+ }
137
+ }, [
138
+ model?.projection,
139
+ state,
140
+ newField
141
+ ]);
142
+ if (!model?.view || !model.projection || !field) {
143
+ return null;
144
+ }
145
+ return /* @__PURE__ */ React2.createElement(DropdownMenu2.Root, {
146
+ modal: false,
147
+ open: state?.type === "columnSettings"
148
+ }, /* @__PURE__ */ React2.createElement(DropdownMenu2.VirtualTrigger, {
149
+ virtualRef: modals.trigger
150
+ }), /* @__PURE__ */ React2.createElement(DropdownMenu2.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu2.Content, {
151
+ classNames: "md:is-64"
152
+ }, /* @__PURE__ */ React2.createElement(DropdownMenu2.Viewport, null, /* @__PURE__ */ React2.createElement(FieldEditor, {
153
+ view: model.view,
154
+ projection: model.projection,
155
+ field,
156
+ registry: space?.db.schemaRegistry,
157
+ onSave: handleSave,
158
+ onCancel: handleCancel
159
+ })), /* @__PURE__ */ React2.createElement(DropdownMenu2.Arrow, null))));
160
+ } finally {
161
+ _effect.f();
162
+ }
150
163
  };
151
164
 
152
165
  // packages/ui/react-ui-table/src/components/Table/CreateRefPanel.tsx
166
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
167
+ import { Schema } from "effect";
153
168
  import React3, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
154
- import { S } from "@dxos/echo-schema";
155
169
  import { live } from "@dxos/react-client/echo";
156
170
  import { Popover } from "@dxos/react-ui";
157
171
  import { Form } from "@dxos/react-ui-form";
158
172
  import { useGridContext } from "@dxos/react-ui-grid";
159
173
  var CreateRefPanel = ({ model, modals, __gridScope }) => {
160
- const { id: gridId } = useGridContext("TableCellEditor", __gridScope);
161
- const space = model?.space;
162
- const state = modals.state.value;
163
- const schema = useMemo2(() => {
164
- if (!space || state?.type !== "createRefPanel") {
165
- return;
166
- }
167
- const [schema2] = space.db.schemaRegistry.query({
168
- typename: state.typename
169
- }).runSync();
170
- if (schema2) {
171
- const omit = S.omit("id");
172
- return omit(schema2);
173
- }
174
- }, [
175
- space,
176
- state
177
- ]);
178
- const handleSave = useCallback2((values) => {
179
- if (!model || !space || state?.type !== "createRefPanel") {
180
- return;
181
- }
182
- const [schema2] = space.db.schemaRegistry.query({
183
- typename: state.typename
184
- }).runSync();
185
- if (schema2) {
186
- const obj = space.db.add(live(schema2, values));
187
- state.onCreate?.(obj);
188
- }
189
- void modals.close();
190
- }, [
191
- modals,
192
- space,
193
- state
194
- ]);
195
- const handleCancel = useCallback2(() => {
196
- if (model) {
197
- modals.close();
198
- }
199
- }, [
200
- modals
201
- ]);
202
- if (!model?.view || !model.projection) {
203
- return null;
204
- }
205
- return /* @__PURE__ */ React3.createElement(Popover.Root, {
206
- modal: false,
207
- open: state?.type === "createRefPanel" && !!schema,
208
- onOpenChange: (nextOpen) => {
209
- if (model && !nextOpen) {
210
- return modals.close();
174
+ var _effect = _useSignals3();
175
+ try {
176
+ const { id: gridId } = useGridContext("TableCellEditor", __gridScope);
177
+ const space = model?.space;
178
+ const state = modals.state.value;
179
+ const schema = useMemo2(() => {
180
+ if (!space || state?.type !== "createRefPanel") {
181
+ return;
211
182
  }
212
- }
213
- }, /* @__PURE__ */ React3.createElement(Popover.VirtualTrigger, {
214
- virtualRef: modals.trigger
215
- }), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
216
- classNames: "md:is-64",
217
- "data-grid": gridId
218
- }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ React3.createElement(Form, {
219
- schema,
220
- values: state.initialValues ?? {},
221
- onSave: handleSave,
222
- onCancel: handleCancel
223
- }), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
183
+ const [schema2] = space.db.schemaRegistry.query({
184
+ typename: state.typename
185
+ }).runSync();
186
+ if (schema2) {
187
+ const omit = Schema.omit("id");
188
+ return omit(schema2);
189
+ }
190
+ }, [
191
+ space,
192
+ state
193
+ ]);
194
+ const handleSave = useCallback2((values) => {
195
+ if (!model || !space || state?.type !== "createRefPanel") {
196
+ return;
197
+ }
198
+ const [schema2] = space.db.schemaRegistry.query({
199
+ typename: state.typename
200
+ }).runSync();
201
+ if (schema2) {
202
+ const obj = space.db.add(live(schema2, values));
203
+ state.onCreate?.(obj);
204
+ }
205
+ void modals.close();
206
+ }, [
207
+ modals,
208
+ space,
209
+ state
210
+ ]);
211
+ const handleCancel = useCallback2(() => {
212
+ if (model) {
213
+ modals.close();
214
+ }
215
+ }, [
216
+ modals
217
+ ]);
218
+ if (!model?.view || !model.projection) {
219
+ return null;
220
+ }
221
+ return /* @__PURE__ */ React3.createElement(Popover.Root, {
222
+ modal: false,
223
+ open: state?.type === "createRefPanel" && !!schema,
224
+ onOpenChange: (nextOpen) => {
225
+ if (model && !nextOpen) {
226
+ return modals.close();
227
+ }
228
+ }
229
+ }, /* @__PURE__ */ React3.createElement(Popover.VirtualTrigger, {
230
+ virtualRef: modals.trigger
231
+ }), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
232
+ classNames: "md:is-64",
233
+ "data-grid": gridId
234
+ }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ React3.createElement(Form, {
235
+ schema,
236
+ values: state.initialValues ?? {},
237
+ onSave: handleSave,
238
+ onCancel: handleCancel
239
+ }), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
240
+ } finally {
241
+ _effect.f();
242
+ }
224
243
  };
225
244
 
226
245
  // packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
246
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
227
247
  import React4 from "react";
228
248
  import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
229
249
  var RowActionsMenu = ({ model, modals }) => {
230
- const { t } = useTranslation2(translationKey);
231
- const hasSelection = model.selection.hasSelection.value;
232
- const state = modals.state.value;
233
- if (state?.type !== "row") {
234
- return null;
235
- }
236
- return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
237
- modal: false,
238
- open: true,
239
- onOpenChange: modals.close
240
- }, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
241
- virtualRef: modals.trigger
242
- }), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
243
- "data-testid": "row-menu-delete",
244
- onClick: () => model.deleteRow(state.rowIndex)
245
- }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
246
- key: action.id,
247
- "data-testid": `row-action-${action.id}`,
248
- onClick: () => {
249
- modals.close();
250
- model.handleRowAction(action.id, state.rowIndex);
251
- }
252
- }, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
250
+ var _effect = _useSignals4();
251
+ try {
252
+ const { t } = useTranslation2(translationKey);
253
+ const hasSelection = model.selection.hasSelection.value;
254
+ const state = modals.state.value;
255
+ if (state?.type !== "row") {
256
+ return null;
257
+ }
258
+ return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
259
+ modal: false,
260
+ open: true,
261
+ onOpenChange: modals.close
262
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
263
+ virtualRef: modals.trigger
264
+ }), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
265
+ "data-testid": "row-menu-delete",
266
+ onClick: () => model.deleteRow(state.rowIndex)
267
+ }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
268
+ key: action.id,
269
+ "data-testid": `row-action-${action.id}`,
270
+ onClick: () => {
271
+ modals.close();
272
+ model.handleRowAction(action.id, state.rowIndex);
273
+ }
274
+ }, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
275
+ } finally {
276
+ _effect.f();
277
+ }
253
278
  };
254
279
 
255
280
  // packages/ui/react-ui-table/src/model/table-model.ts
@@ -257,7 +282,7 @@ import { computed as computed3, effect as effect2, signal as signal3 } from "@pr
257
282
  import { Resource as Resource2 } from "@dxos/context";
258
283
  import { FormatEnum as FormatEnum3, getValue as getValue2, setValue } from "@dxos/echo-schema";
259
284
  import { invariant } from "@dxos/invariant";
260
- import { isLiveObject, makeRef as makeRef3 } from "@dxos/live-object";
285
+ import { isLiveObject, makeRef as makeRef2 } from "@dxos/live-object";
261
286
  import { formatForEditing, parseValue } from "@dxos/react-ui-form";
262
287
 
263
288
  // packages/ui/react-ui-table/src/model/selection-model.ts
@@ -265,9 +290,10 @@ import { computed, effect, signal } from "@preact/signals-core";
265
290
  import { Resource } from "@dxos/context";
266
291
 
267
292
  // packages/ui/react-ui-table/src/util/dynamic-table.ts
293
+ import { getTypename, toJsonSchema } from "@dxos/echo-schema";
268
294
  import { live as live2, makeRef } from "@dxos/live-object";
269
295
  import { createView, getSchemaFromPropertyDefinitions, ViewProjection } from "@dxos/schema";
270
- var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
296
+ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
271
297
  if (typename && properties) {
272
298
  const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
273
299
  return {
@@ -276,8 +302,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
276
302
  };
277
303
  } else if (schema) {
278
304
  return {
279
- typename: schema.typename,
280
- jsonSchema: schema.jsonSchema
305
+ typename: getTypename(schema),
306
+ jsonSchema: toJsonSchema(schema)
281
307
  };
282
308
  } else if (typename && jsonSchema) {
283
309
  return {
@@ -344,9 +370,10 @@ var setProperties = (view, projection, properties) => {
344
370
  var touch = (value) => value;
345
371
 
346
372
  // packages/ui/react-ui-table/src/util/table.ts
347
- import { AST, Format, FormatEnum, S as S2, TypedObject, TypeEnum } from "@dxos/echo-schema";
373
+ import { Schema as Schema2 } from "effect";
374
+ import { Format, FormatEnum, Ref, TypedObject, TypeEnum } from "@dxos/echo-schema";
348
375
  import { PublicKey } from "@dxos/react-client";
349
- import { live as live3, makeRef as makeRef2 } from "@dxos/react-client/echo";
376
+ import { live as live3 } from "@dxos/react-client/echo";
350
377
  import { createFieldId, createView as createView2, getSchemaProperties, ViewProjection as ViewProjection2 } from "@dxos/schema";
351
378
  var initializeTable = async ({ client, space, table, typename, initialRow = true }) => {
352
379
  if (typename) {
@@ -355,7 +382,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
355
382
  throw new Error(`Schema not found: ${typename}`);
356
383
  }
357
384
  const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
358
- table.view = makeRef2(createView2({
385
+ table.view = Ref.make(createView2({
359
386
  // TODO(ZaymonFC): Don't hardcode name?
360
387
  name: "View",
361
388
  typename: schema.typename,
@@ -368,7 +395,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
368
395
  ContactSchema
369
396
  ]);
370
397
  const fields = ContactFields;
371
- table.view = makeRef2(createView2({
398
+ table.view = Ref.make(createView2({
372
399
  name: "View",
373
400
  typename: schema.typename,
374
401
  jsonSchema: schema.jsonSchema,
@@ -385,13 +412,13 @@ var ContactSchema = TypedObject({
385
412
  typename: `example.com/type/${PublicKey.random().truncate()}`,
386
413
  version: "0.1.0"
387
414
  })({
388
- name: S2.optional(S2.String).annotations({
389
- [AST.TitleAnnotationId]: "Name"
415
+ name: Schema2.optional(Schema2.String).annotations({
416
+ title: "Name"
390
417
  }),
391
- active: S2.optional(S2.Boolean),
392
- email: S2.optional(Format.Email),
393
- salary: S2.optional(Format.Currency()).annotations({
394
- [AST.TitleAnnotationId]: "Salary"
418
+ active: Schema2.optional(Schema2.Boolean),
419
+ email: Schema2.optional(Format.Email),
420
+ salary: Schema2.optional(Format.Currency()).annotations({
421
+ title: "Salary"
395
422
  })
396
423
  });
397
424
  var ContactFields = [
@@ -444,7 +471,7 @@ var BUTTON_IDENTIFIERS = {
444
471
  var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
445
472
  const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
446
473
  const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
447
- return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
474
+ return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? "disabled" : ""}><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
448
475
  };
449
476
  var addColumnButton = {
450
477
  attr: BUTTON_IDENTIFIERS.newColumn,
@@ -582,15 +609,25 @@ var tableControls = {
582
609
  }
583
610
  };
584
611
 
612
+ // packages/ui/react-ui-table/src/util/schema.ts
613
+ import { Schema as Schema3 } from "effect";
614
+ import { isTypeLiteral, TypeLiteral } from "effect/SchemaAST";
615
+ var narrowSchema = (schema, paths) => {
616
+ const ast = schema?.ast;
617
+ if (isTypeLiteral(ast)) {
618
+ const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
619
+ if (propertySignatures.length > 0) {
620
+ const narrowType = new TypeLiteral(propertySignatures, []);
621
+ return Schema3.make(narrowType);
622
+ }
623
+ }
624
+ return void 0;
625
+ };
626
+
585
627
  // packages/ui/react-ui-table/src/model/selection-model.ts
586
628
  var SelectionModel = class extends Resource {
587
629
  constructor(_rows, _selectionMode, _onSelectionChanged) {
588
- super();
589
- this._rows = _rows;
590
- this._selectionMode = _selectionMode;
591
- this._onSelectionChanged = _onSelectionChanged;
592
- this._selection = signal(/* @__PURE__ */ new Set());
593
- this._validSelectedIds = computed(() => {
630
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._onSelectionChanged = _onSelectionChanged, this._selection = signal(/* @__PURE__ */ new Set()), this._validSelectedIds = computed(() => {
594
631
  const rows = this._rows.value;
595
632
  if (!rows) {
596
633
  return /* @__PURE__ */ new Set();
@@ -599,27 +636,21 @@ var SelectionModel = class extends Resource {
599
636
  return new Set([
600
637
  ...this._selection.value
601
638
  ].filter((id) => validIds.has(id)));
602
- });
603
- this._hasSelection = computed(() => this._validSelectedIds.value.size > 0);
604
- this._allSelected = computed(() => {
639
+ }), this._hasSelection = computed(() => this._validSelectedIds.value.size > 0), this._allSelected = computed(() => {
605
640
  const rows = this._rows.value;
606
641
  if (rows.length === 0) {
607
642
  return false;
608
643
  }
609
644
  return rows.every((row) => this._selection.value.has(row.id));
610
- });
611
- this.getSelectedRows = () => {
645
+ }), this.getSelectedRows = () => {
612
646
  const selectedIds = this._validSelectedIds.value;
613
647
  return this._rows.value.filter((row) => selectedIds.has(row.id));
614
- };
615
- this.isRowIndexSelected = (rowIndex) => {
648
+ }, this.isRowIndexSelected = (rowIndex) => {
616
649
  const row = this._rows.value[rowIndex];
617
650
  return this._selection.value.has(row.id);
618
- };
619
- this.isObjectSelected = (object) => {
651
+ }, this.isObjectSelected = (object) => {
620
652
  return this._selection.value.has(object.id);
621
- };
622
- this.toggleSelectionForRowIndex = (rowIndex) => {
653
+ }, this.toggleSelectionForRowIndex = (rowIndex) => {
623
654
  const row = this._rows.value[rowIndex];
624
655
  const newSelection = new Set(this._selection.value);
625
656
  if (newSelection.has(row.id)) {
@@ -631,8 +662,7 @@ var SelectionModel = class extends Resource {
631
662
  newSelection.add(row.id);
632
663
  }
633
664
  this._selection.value = newSelection;
634
- };
635
- this.setSelection = (mode) => {
665
+ }, this.setSelection = (mode) => {
636
666
  switch (mode) {
637
667
  case "all": {
638
668
  this._selection.value = new Set(this._rows.value.map((row) => row.id));
@@ -950,7 +980,7 @@ var TableModel = class extends Resource2 {
950
980
  switch (props.format) {
951
981
  case FormatEnum3.Ref: {
952
982
  if (isLiveObject(value)) {
953
- setValue(this._rows.value[rowIdx], field.path, makeRef3(value));
983
+ setValue(this._rows.value[rowIdx], field.path, makeRef2(value));
954
984
  }
955
985
  break;
956
986
  }
@@ -1274,7 +1304,8 @@ var ModalController = class {
1274
1304
 
1275
1305
  // packages/ui/react-ui-table/src/model/table-presentation.ts
1276
1306
  import { signal as signal5 } from "@preact/signals-core";
1277
- import { FormatEnum as FormatEnum4, getDXN, getValue as getValue3 } from "@dxos/echo-schema";
1307
+ import { isNotNullable } from "effect/Predicate";
1308
+ import { FormatEnum as FormatEnum4, getDXN, getValue as getValue3, TypeEnum as TypeEnum3 } from "@dxos/echo-schema";
1278
1309
  import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
1279
1310
  import { toPlaneCellIndex } from "@dxos/react-ui-grid";
1280
1311
  import { mx } from "@dxos/react-ui-theme";
@@ -1336,6 +1367,9 @@ var TablePresentation = class {
1336
1367
  if (value == null) {
1337
1368
  return "";
1338
1369
  }
1370
+ if (props.type === "array") {
1371
+ return "";
1372
+ }
1339
1373
  switch (props.format) {
1340
1374
  case FormatEnum4.Boolean:
1341
1375
  case FormatEnum4.SingleSelect:
@@ -1373,11 +1407,38 @@ var TablePresentation = class {
1373
1407
  if (classes.length > 0) {
1374
1408
  cell.className = mx(classes.flat());
1375
1409
  }
1410
+ if (props.type === TypeEnum3.Array) {
1411
+ const targetArray = getValue3(obj, field.path);
1412
+ if (targetArray && Array.isArray(targetArray)) {
1413
+ const getLabel = (value) => {
1414
+ if (!value) {
1415
+ return void 0;
1416
+ }
1417
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1418
+ return String(value);
1419
+ }
1420
+ if (Array.isArray(value)) {
1421
+ return "Array";
1422
+ }
1423
+ if (typeof value === "object" && value.name) {
1424
+ return value.name;
1425
+ }
1426
+ if (typeof value === "object" && value.value) {
1427
+ return `${value.value}`;
1428
+ }
1429
+ return "Object";
1430
+ };
1431
+ const tags = targetArray.map(getLabel).filter(isNotNullable).map((title) => {
1432
+ return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
1433
+ }).join("");
1434
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
1435
+ }
1436
+ }
1376
1437
  if (props.format === FormatEnum4.Ref && props.referenceSchema) {
1377
1438
  const targetObj = getValue3(obj, field.path)?.target;
1378
1439
  if (targetObj) {
1379
1440
  const dxn = getDXN(targetObj)?.toString();
1380
- cell.accessoryHtml = `<dx-ref-tag ref=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
1441
+ cell.accessoryHtml = `<dx-ref-tag refId=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
1381
1442
  }
1382
1443
  }
1383
1444
  if (props.format === FormatEnum4.Boolean) {
@@ -1411,7 +1472,7 @@ var TablePresentation = class {
1411
1472
  return null;
1412
1473
  }).filter(Boolean).join(" ");
1413
1474
  if (tags) {
1414
- cell.accessoryHtml = tags;
1475
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
1415
1476
  }
1416
1477
  }
1417
1478
  }
@@ -1456,7 +1517,7 @@ var TablePresentation = class {
1456
1517
  fieldId: field.id
1457
1518
  })}
1458
1519
  `,
1459
- className: "!bg-gridHeader"
1520
+ className: "!bg-toolbarSurface"
1460
1521
  };
1461
1522
  }
1462
1523
  return cells;
@@ -1507,7 +1568,7 @@ var TablePresentation = class {
1507
1568
  col: 0,
1508
1569
  row: 0
1509
1570
  })]: {
1510
- className: "!bg-gridHeader",
1571
+ className: "!bg-toolbarSurface",
1511
1572
  readonly: true,
1512
1573
  value: ""
1513
1574
  }
@@ -1523,7 +1584,7 @@ var TablePresentation = class {
1523
1584
  header: true,
1524
1585
  checked: this.model.selection.allRowsSeleted.value
1525
1586
  }),
1526
- className: "!bg-gridHeader",
1587
+ className: "!bg-toolbarSurface",
1527
1588
  readonly: true,
1528
1589
  value: ""
1529
1590
  }
@@ -1538,7 +1599,7 @@ var TablePresentation = class {
1538
1599
  accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
1539
1600
  disabled: (this.model.view?.fields?.length ?? 0) >= VIEW_FIELD_LIMIT
1540
1601
  }) : void 0,
1541
- className: "!bg-gridHeader",
1602
+ className: "!bg-toolbarSurface",
1542
1603
  readonly: true,
1543
1604
  value: ""
1544
1605
  }
@@ -1569,14 +1630,116 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1569
1630
  };
1570
1631
 
1571
1632
  // packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
1572
- import React5, { useCallback as useCallback3, useMemo as useMemo3, useRef } from "react";
1573
- import { FormatEnum as FormatEnum5 } from "@dxos/echo-schema";
1574
- import { invariant as invariant2 } from "@dxos/invariant";
1633
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1634
+ import React6, { useCallback as useCallback4, useMemo as useMemo4, useRef as useRef2 } from "react";
1635
+ import { FormatEnum as FormatEnum5, TypeEnum as TypeEnum4 } from "@dxos/echo-schema";
1636
+ import { invariant as invariant3 } from "@dxos/invariant";
1575
1637
  import { useThemeContext } from "@dxos/react-ui";
1576
1638
  import { createMarkdownExtensions } from "@dxos/react-ui-editor";
1577
- import { cellQuery, editorKeys, parseCellIndex, useGridContext as useGridContext2, GridCellEditor } from "@dxos/react-ui-grid";
1639
+ import { cellQuery, editorKeys, parseCellIndex as parseCellIndex2, useGridContext as useGridContext3, GridCellEditor } from "@dxos/react-ui-grid";
1578
1640
  import { tagPickerExtension, createLinks } from "@dxos/react-ui-tag-picker";
1579
1641
 
1642
+ // packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx
1643
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1644
+ import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef } from "react";
1645
+ import { getSnapshot } from "@dxos/echo-schema";
1646
+ import { invariant as invariant2 } from "@dxos/invariant";
1647
+ import { Popover as Popover2 } from "@dxos/react-ui";
1648
+ import { Form as Form2 } from "@dxos/react-ui-form";
1649
+ import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
1650
+ import { getDeep, setDeep } from "@dxos/util";
1651
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1652
+ var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1653
+ var _effect = _useSignals5();
1654
+ try {
1655
+ const { editing, setEditing } = useGridContext2("ArrayEditor", __gridScope);
1656
+ const cellRef = useRef(null);
1657
+ useEffect2(() => {
1658
+ if (editing && editing.cellElement) {
1659
+ cellRef.current = editing.cellElement;
1660
+ }
1661
+ }, [
1662
+ editing?.cellElement
1663
+ ]);
1664
+ const narrowedSchema = useMemo3(() => {
1665
+ if (!schema) {
1666
+ return void 0;
1667
+ }
1668
+ return narrowSchema(schema, [
1669
+ fieldProjection.field.path
1670
+ ]);
1671
+ }, [
1672
+ JSON.stringify(schema),
1673
+ fieldProjection.field.path
1674
+ ]);
1675
+ const originalRow = useMemo3(() => {
1676
+ if (model && editing) {
1677
+ const cell = parseCellIndex(editing.index);
1678
+ const row = model.getRowAt(cell.row);
1679
+ invariant2(row, void 0, {
1680
+ F: __dxlog_file3,
1681
+ L: 47,
1682
+ S: void 0,
1683
+ A: [
1684
+ "row",
1685
+ ""
1686
+ ]
1687
+ });
1688
+ return row;
1689
+ }
1690
+ return void 0;
1691
+ }, [
1692
+ model,
1693
+ editing
1694
+ ]);
1695
+ const formValues = useMemo3(() => {
1696
+ if (originalRow) {
1697
+ return getSnapshot(originalRow);
1698
+ }
1699
+ }, [
1700
+ originalRow
1701
+ ]);
1702
+ const handleSave = useCallback3((values) => {
1703
+ const path = fieldProjection.field.path;
1704
+ const value = getDeep(values, [
1705
+ path
1706
+ ]);
1707
+ setDeep(originalRow, [
1708
+ path
1709
+ ], value);
1710
+ setEditing(null);
1711
+ }, [
1712
+ fieldProjection.field.path,
1713
+ originalRow
1714
+ ]);
1715
+ const handleOpenChange = useCallback3((nextOpen) => {
1716
+ if (nextOpen === false) {
1717
+ setEditing(null);
1718
+ }
1719
+ }, [
1720
+ setEditing
1721
+ ]);
1722
+ if (!editing) {
1723
+ return null;
1724
+ }
1725
+ return /* @__PURE__ */ React5.createElement(Popover2.Root, {
1726
+ open: editing !== null,
1727
+ onOpenChange: handleOpenChange
1728
+ }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
1729
+ virtualRef: cellRef
1730
+ }), /* @__PURE__ */ React5.createElement(Popover2.Content, {
1731
+ tabIndex: -1,
1732
+ classNames: "popover-card-width"
1733
+ }, /* @__PURE__ */ React5.createElement(Popover2.Arrow, null), /* @__PURE__ */ React5.createElement(Form2, {
1734
+ values: formValues,
1735
+ schema: narrowedSchema,
1736
+ onSave: handleSave
1737
+ })));
1738
+ } finally {
1739
+ _effect.f();
1740
+ }
1741
+ };
1742
+
1580
1743
  // packages/ui/react-ui-table/src/components/TableCellEditor/extension.ts
1581
1744
  import { autocompletion, pickedCompletion } from "@codemirror/autocomplete";
1582
1745
  import { EditorView } from "@codemirror/view";
@@ -1617,218 +1780,268 @@ var completion = ({ debug, onQuery, onMatch }) => {
1617
1780
  };
1618
1781
 
1619
1782
  // packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
1620
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1783
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1621
1784
  var newValue = Symbol.for("newValue");
1622
1785
  var createOption = (text) => ({
1623
1786
  [newValue]: true,
1624
1787
  text
1625
1788
  });
1626
1789
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1627
- var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1628
- const { id: gridId, editing, setEditing } = useGridContext2("TableCellEditor", __gridScope);
1629
- const suppressNextBlur = useRef(false);
1630
- const { themeMode } = useThemeContext();
1631
- const fieldProjection = useMemo3(() => {
1632
- if (!model || !editing) {
1633
- return;
1790
+ var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1791
+ var _effect = _useSignals6();
1792
+ try {
1793
+ const { editing } = useGridContext3("TableValueEditor", __gridScope);
1794
+ const fieldProjection = useMemo4(() => {
1795
+ if (!model || !editing) {
1796
+ return;
1797
+ }
1798
+ const { col } = parseCellIndex2(editing.index);
1799
+ const field = model.projection.view.fields[col];
1800
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1801
+ invariant3(fieldProjection2, void 0, {
1802
+ F: __dxlog_file4,
1803
+ L: 73,
1804
+ S: void 0,
1805
+ A: [
1806
+ "fieldProjection",
1807
+ ""
1808
+ ]
1809
+ });
1810
+ return fieldProjection2;
1811
+ }, [
1812
+ model,
1813
+ editing
1814
+ ]);
1815
+ if (fieldProjection?.props.type === TypeEnum4.Array) {
1816
+ return /* @__PURE__ */ React6.createElement(FormCellEditor, {
1817
+ fieldProjection,
1818
+ model,
1819
+ schema,
1820
+ __gridScope
1821
+ });
1634
1822
  }
1635
- const { col } = parseCellIndex(editing.index);
1636
- const field = model.projection.view.fields[col];
1637
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1638
- invariant2(fieldProjection2, void 0, {
1639
- F: __dxlog_file3,
1640
- L: 71,
1641
- S: void 0,
1642
- A: [
1643
- "fieldProjection",
1644
- ""
1645
- ]
1823
+ return /* @__PURE__ */ React6.createElement(TableCellEditor, {
1824
+ model,
1825
+ modals,
1826
+ onEnter,
1827
+ onFocus,
1828
+ onQuery,
1829
+ __gridScope
1646
1830
  });
1647
- return fieldProjection2;
1648
- }, [
1649
- model,
1650
- editing
1651
- ]);
1652
- const handleEnter = useCallback3((value) => {
1653
- if (!model || !editing) {
1654
- return;
1655
- }
1656
- const cell = parseCellIndex(editing.index);
1657
- model.setCellData(cell, value);
1658
- onEnter?.(cell);
1659
- onFocus?.();
1660
- setEditing(null);
1661
- }, [
1662
- model,
1663
- editing,
1664
- onEnter,
1665
- onFocus,
1666
- setEditing
1667
- ]);
1668
- const handleBlur = useCallback3((value) => {
1669
- if (!model || !editing) {
1670
- return;
1671
- }
1672
- if (suppressNextBlur.current) {
1673
- suppressNextBlur.current = false;
1674
- return;
1675
- }
1676
- const cell = parseCellIndex(editing.index);
1677
- if (value !== void 0) {
1831
+ } finally {
1832
+ _effect.f();
1833
+ }
1834
+ };
1835
+ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1836
+ var _effect = _useSignals6();
1837
+ try {
1838
+ const { id: gridId, editing, setEditing } = useGridContext3("TableCellEditor", __gridScope);
1839
+ const suppressNextBlur = useRef2(false);
1840
+ const { themeMode } = useThemeContext();
1841
+ const fieldProjection = useMemo4(() => {
1842
+ if (!model || !editing) {
1843
+ return;
1844
+ }
1845
+ const { col } = parseCellIndex2(editing.index);
1846
+ const field = model.projection.view.fields[col];
1847
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1848
+ invariant3(fieldProjection2, void 0, {
1849
+ F: __dxlog_file4,
1850
+ L: 114,
1851
+ S: void 0,
1852
+ A: [
1853
+ "fieldProjection",
1854
+ ""
1855
+ ]
1856
+ });
1857
+ return fieldProjection2;
1858
+ }, [
1859
+ model,
1860
+ editing
1861
+ ]);
1862
+ const handleEnter = useCallback4((value) => {
1863
+ if (!model || !editing) {
1864
+ return;
1865
+ }
1866
+ const cell = parseCellIndex2(editing.index);
1678
1867
  model.setCellData(cell, value);
1679
- }
1680
- }, [
1681
- model,
1682
- editing
1683
- ]);
1684
- const handleClose = useCallback3((value, event) => {
1685
- if (!model || !editing || !fieldProjection) {
1686
- return;
1687
- }
1688
- const cell = parseCellIndex(editing.index);
1689
- onEnter?.(cell);
1690
- if (event && onFocus) {
1691
- onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1692
- }
1693
- }, [
1694
- model,
1695
- editing,
1696
- onFocus,
1697
- onEnter,
1698
- fieldProjection
1699
- ]);
1700
- const extension = useMemo3(() => {
1701
- if (!fieldProjection) {
1702
- return [];
1703
- }
1704
- const extension2 = [
1705
- editorKeys({
1706
- onClose: handleClose,
1707
- ...editing?.initialContent && {
1708
- onNav: handleClose
1709
- }
1710
- })
1711
- ];
1712
- const format = fieldProjection.props.format;
1713
- if (format === FormatEnum5.SingleSelect || format === FormatEnum5.MultiSelect) {
1714
- extension2.push(createMarkdownExtensions({
1715
- themeMode
1716
- }));
1717
- const options = fieldProjection.props.options || [];
1718
- const mode = format === FormatEnum5.SingleSelect ? "single-select" : "multi-select";
1719
- extension2.push(tagPickerExtension({
1720
- mode,
1721
- inGrid: true,
1722
- onSearch: (text, selectedIds) => {
1723
- return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1724
- id: option.id,
1725
- label: option.title,
1726
- hue: option.color
1727
- }));
1728
- },
1729
- onUpdate: (ids) => {
1730
- if (model && editing) {
1731
- if (ids.length === 0) {
1732
- return;
1733
- }
1734
- if (mode === "single-select") {
1735
- handleEnter(ids[0]);
1736
- } else {
1737
- handleEnter(ids);
1868
+ onEnter?.(cell);
1869
+ onFocus?.();
1870
+ setEditing(null);
1871
+ }, [
1872
+ model,
1873
+ editing,
1874
+ onEnter,
1875
+ onFocus,
1876
+ setEditing
1877
+ ]);
1878
+ const handleBlur = useCallback4((value) => {
1879
+ if (!model || !editing) {
1880
+ return;
1881
+ }
1882
+ if (suppressNextBlur.current) {
1883
+ suppressNextBlur.current = false;
1884
+ return;
1885
+ }
1886
+ const cell = parseCellIndex2(editing.index);
1887
+ if (value !== void 0) {
1888
+ model.setCellData(cell, value);
1889
+ }
1890
+ }, [
1891
+ model,
1892
+ editing
1893
+ ]);
1894
+ const handleClose = useCallback4((value, event) => {
1895
+ if (!model || !editing || !fieldProjection) {
1896
+ return;
1897
+ }
1898
+ const cell = parseCellIndex2(editing.index);
1899
+ onEnter?.(cell);
1900
+ if (event && onFocus) {
1901
+ onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1902
+ }
1903
+ }, [
1904
+ model,
1905
+ editing,
1906
+ onFocus,
1907
+ onEnter,
1908
+ fieldProjection
1909
+ ]);
1910
+ const extension = useMemo4(() => {
1911
+ if (!fieldProjection) {
1912
+ return [];
1913
+ }
1914
+ const extension2 = [
1915
+ editorKeys({
1916
+ onClose: handleClose,
1917
+ ...editing?.initialContent && {
1918
+ onNav: handleClose
1919
+ }
1920
+ })
1921
+ ];
1922
+ const format = fieldProjection.props.format;
1923
+ if (format === FormatEnum5.SingleSelect || format === FormatEnum5.MultiSelect) {
1924
+ extension2.push(createMarkdownExtensions({
1925
+ themeMode
1926
+ }));
1927
+ const options = fieldProjection.props.options || [];
1928
+ const mode = format === FormatEnum5.SingleSelect ? "single-select" : "multi-select";
1929
+ extension2.push(tagPickerExtension({
1930
+ mode,
1931
+ inGrid: true,
1932
+ onSearch: (text, selectedIds) => {
1933
+ return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1934
+ id: option.id,
1935
+ label: option.title,
1936
+ hue: option.color
1937
+ }));
1938
+ },
1939
+ onUpdate: (ids) => {
1940
+ if (model && editing) {
1941
+ if (ids.length === 0) {
1942
+ return;
1943
+ }
1944
+ if (mode === "single-select") {
1945
+ handleEnter(ids[0]);
1946
+ } else {
1947
+ handleEnter(ids);
1948
+ }
1738
1949
  }
1739
1950
  }
1740
- }
1741
- }));
1742
- }
1743
- if (onQuery) {
1744
- switch (fieldProjection.props.format) {
1745
- case FormatEnum5.Ref: {
1746
- extension2.push([
1747
- completion({
1748
- onQuery: (text) => onQuery(fieldProjection, text),
1749
- onMatch: (data) => {
1750
- if (model && editing && modals) {
1751
- if (isCreateOption(data)) {
1752
- const { field, props } = fieldProjection;
1753
- if (props.referenceSchema) {
1754
- suppressNextBlur.current = true;
1755
- modals.openCreateRef(props.referenceSchema, document.querySelector(cellQuery(editing.index, gridId)), {
1756
- [field.referencePath]: data.text
1757
- }, (data2) => {
1758
- handleEnter(data2);
1759
- });
1951
+ }));
1952
+ }
1953
+ if (onQuery) {
1954
+ switch (fieldProjection.props.format) {
1955
+ case FormatEnum5.Ref: {
1956
+ extension2.push([
1957
+ completion({
1958
+ onQuery: (text) => onQuery(fieldProjection, text),
1959
+ onMatch: (data) => {
1960
+ if (model && editing && modals) {
1961
+ if (isCreateOption(data)) {
1962
+ const { field, props } = fieldProjection;
1963
+ if (props.referenceSchema) {
1964
+ suppressNextBlur.current = true;
1965
+ modals.openCreateRef(props.referenceSchema, document.querySelector(cellQuery(editing.index, gridId)), {
1966
+ [field.referencePath]: data.text
1967
+ }, (data2) => {
1968
+ handleEnter(data2);
1969
+ });
1970
+ }
1971
+ } else {
1972
+ handleEnter(data);
1760
1973
  }
1761
- } else {
1762
- handleEnter(data);
1763
1974
  }
1764
1975
  }
1765
- }
1766
- })
1767
- ]);
1768
- break;
1976
+ })
1977
+ ]);
1978
+ break;
1979
+ }
1769
1980
  }
1770
1981
  }
1771
- }
1772
- return extension2;
1773
- }, [
1774
- model,
1775
- modals,
1776
- editing,
1777
- fieldProjection,
1778
- handleClose,
1779
- themeMode
1780
- ]);
1781
- const getCellContent = useCallback3(() => {
1782
- if (model && editing) {
1783
- const cell = parseCellIndex(editing.index);
1784
- const { col } = cell;
1785
- const field = model.projection.view.fields[col];
1786
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1787
- if (fieldProjection2?.props.format === FormatEnum5.SingleSelect || fieldProjection2?.props.format === FormatEnum5.MultiSelect) {
1788
- const value2 = model.getCellData(cell);
1789
- if (value2 !== void 0) {
1790
- const options = fieldProjection2.props.options || [];
1791
- if (fieldProjection2.props.format === FormatEnum5.MultiSelect && Array.isArray(value2)) {
1792
- const tagItems = value2.map((id) => {
1793
- const option = options.find((o) => o.id === id);
1982
+ return extension2;
1983
+ }, [
1984
+ model,
1985
+ modals,
1986
+ editing,
1987
+ fieldProjection,
1988
+ handleClose,
1989
+ themeMode
1990
+ ]);
1991
+ const getCellContent = useCallback4(() => {
1992
+ if (model && editing) {
1993
+ const cell = parseCellIndex2(editing.index);
1994
+ const { col } = cell;
1995
+ const field = model.projection.view.fields[col];
1996
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1997
+ if (fieldProjection2?.props.format === FormatEnum5.SingleSelect || fieldProjection2?.props.format === FormatEnum5.MultiSelect) {
1998
+ const value2 = model.getCellData(cell);
1999
+ if (value2 !== void 0) {
2000
+ const options = fieldProjection2.props.options || [];
2001
+ if (fieldProjection2.props.format === FormatEnum5.MultiSelect && Array.isArray(value2)) {
2002
+ const tagItems = value2.map((id) => {
2003
+ const option = options.find((o) => o.id === id);
2004
+ if (option) {
2005
+ return {
2006
+ id,
2007
+ label: option.title,
2008
+ hue: option.color
2009
+ };
2010
+ }
2011
+ return void 0;
2012
+ }).filter((item) => item !== void 0);
2013
+ return createLinks(tagItems);
2014
+ } else {
2015
+ const option = options.find((o) => o.id === value2);
1794
2016
  if (option) {
1795
- return {
1796
- id,
2017
+ const tagItem = {
2018
+ id: value2,
1797
2019
  label: option.title,
1798
2020
  hue: option.color
1799
2021
  };
2022
+ return createLinks([
2023
+ tagItem
2024
+ ]);
1800
2025
  }
1801
- return void 0;
1802
- }).filter((item) => item !== void 0);
1803
- return createLinks(tagItems);
1804
- } else {
1805
- const option = options.find((o) => o.id === value2);
1806
- if (option) {
1807
- const tagItem = {
1808
- id: value2,
1809
- label: option.title,
1810
- hue: option.color
1811
- };
1812
- return createLinks([
1813
- tagItem
1814
- ]);
1815
2026
  }
1816
2027
  }
2028
+ return "";
1817
2029
  }
1818
- return "";
2030
+ const value = model.getCellData(cell);
2031
+ return value !== void 0 ? String(value) : "";
1819
2032
  }
1820
- const value = model.getCellData(cell);
1821
- return value !== void 0 ? String(value) : "";
1822
- }
1823
- }, [
1824
- model,
1825
- editing
1826
- ]);
1827
- return /* @__PURE__ */ React5.createElement(GridCellEditor, {
1828
- extension,
1829
- getCellContent,
1830
- onBlur: handleBlur
1831
- });
2033
+ }, [
2034
+ model,
2035
+ editing
2036
+ ]);
2037
+ return /* @__PURE__ */ React6.createElement(GridCellEditor, {
2038
+ extension,
2039
+ getCellContent,
2040
+ onBlur: handleBlur
2041
+ });
2042
+ } finally {
2043
+ _effect.f();
2044
+ }
1832
2045
  };
1833
2046
  var determineNavigationAxis = ({ key }) => {
1834
2047
  switch (key) {
@@ -1856,283 +2069,294 @@ var determineNavigationDelta = ({ key, shift }) => {
1856
2069
  };
1857
2070
 
1858
2071
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
1859
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
2072
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1860
2073
  var TableRoot = ({ children, role }) => {
1861
- return /* @__PURE__ */ React6.createElement("div", {
1862
- role: "none",
1863
- className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
1864
- }, children);
2074
+ var _effect = _useSignals7();
2075
+ try {
2076
+ return /* @__PURE__ */ React7.createElement("div", {
2077
+ role: "none",
2078
+ className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
2079
+ }, children);
2080
+ } finally {
2081
+ _effect.f();
2082
+ }
1865
2083
  };
1866
- var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
1867
- const [dxGrid, setDxGrid] = useState2(null);
1868
- const { hasAttention } = useAttention(model?.id ?? "table");
1869
- const { t } = useTranslation3(translationKey);
1870
- const modals = useMemo4(() => new ModalController(), []);
1871
- const frozen = useMemo4(() => {
1872
- const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
1873
- return {
1874
- frozenRowsStart: 1,
1875
- frozenColsStart: model?.features.selection.enabled ? 1 : 0,
1876
- frozenColsEnd: noActionColumn ? 0 : 1
1877
- };
1878
- }, [
1879
- model
1880
- ]);
1881
- const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
1882
- presentation
1883
- ]);
1884
- useEffect2(() => {
1885
- if (!presentation || !dxGrid) {
1886
- return;
1887
- }
1888
- dxGrid.getCells = getCells;
1889
- }, [
1890
- presentation,
1891
- dxGrid,
1892
- getCells
1893
- ]);
1894
- useImperativeHandle(forwardedRef, () => {
1895
- if (!presentation || !dxGrid) {
1896
- return {};
1897
- }
1898
- return {
1899
- update: (cell) => {
1900
- if (cell) {
1901
- dxGrid.updateIfWithinBounds(cell);
1902
- } else {
1903
- dxGrid.updateCells(true);
1904
- dxGrid.requestUpdate();
1905
- }
2084
+ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
2085
+ var _effect = _useSignals7();
2086
+ try {
2087
+ const [dxGrid, setDxGrid] = useState2(null);
2088
+ const { hasAttention } = useAttention(model?.id ?? "table");
2089
+ const { t } = useTranslation3(translationKey);
2090
+ const modals = useMemo5(() => new ModalController(), []);
2091
+ const frozen = useMemo5(() => {
2092
+ const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
2093
+ return {
2094
+ frozenRowsStart: 1,
2095
+ frozenColsStart: model?.features.selection.enabled ? 1 : 0,
2096
+ frozenColsEnd: noActionColumn ? 0 : 1
2097
+ };
2098
+ }, [
2099
+ model
2100
+ ]);
2101
+ const getCells = useCallback5((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2102
+ presentation
2103
+ ]);
2104
+ useEffect3(() => {
2105
+ if (!presentation || !dxGrid) {
2106
+ return;
1906
2107
  }
1907
- };
1908
- }, [
1909
- presentation,
1910
- dxGrid
1911
- ]);
1912
- const handleGridClick = useCallback4((event) => {
1913
- const rowIndex = safeParseInt(event.target.ariaRowIndex ?? "");
1914
- if (rowIndex != null) {
1915
- if (onRowClick) {
1916
- const row = model?.getRowAt(rowIndex);
1917
- row && onRowClick(row);
1918
- }
1919
- if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
1920
- model.selection.toggleSelectionForRowIndex(rowIndex);
2108
+ dxGrid.getCells = getCells;
2109
+ }, [
2110
+ presentation,
2111
+ dxGrid,
2112
+ getCells
2113
+ ]);
2114
+ useImperativeHandle(forwardedRef, () => {
2115
+ if (!presentation || !dxGrid) {
2116
+ return {};
1921
2117
  }
1922
- }
1923
- if (!modals) {
1924
- return;
1925
- }
1926
- const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
1927
- const tableButtonElement = event.target.closest(buttonSelector);
1928
- if (tableButtonElement) {
1929
- const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
1930
- if (!button) {
2118
+ return {
2119
+ update: (cell) => {
2120
+ if (cell) {
2121
+ dxGrid.updateIfWithinBounds(cell);
2122
+ } else {
2123
+ dxGrid.updateCells(true);
2124
+ dxGrid.requestUpdate();
2125
+ }
2126
+ }
2127
+ };
2128
+ }, [
2129
+ presentation,
2130
+ dxGrid
2131
+ ]);
2132
+ const handleGridClick = useCallback5((event) => {
2133
+ const rowIndex = safeParseInt(event.target.ariaRowIndex ?? "");
2134
+ if (rowIndex != null) {
2135
+ if (onRowClick) {
2136
+ const row = model?.getRowAt(rowIndex);
2137
+ row && onRowClick(row);
2138
+ }
2139
+ if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
2140
+ model.selection.toggleSelectionForRowIndex(rowIndex);
2141
+ }
2142
+ }
2143
+ if (!modals) {
1931
2144
  return;
1932
2145
  }
1933
- modals.setTrigger(tableButtonElement);
1934
- const data = button.getData(tableButtonElement);
1935
- switch (data.type) {
1936
- case "rowMenu": {
1937
- modals.showRowMenu(data.rowIndex);
1938
- break;
2146
+ const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
2147
+ const tableButtonElement = event.target.closest(buttonSelector);
2148
+ if (tableButtonElement) {
2149
+ const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
2150
+ if (!button) {
2151
+ return;
1939
2152
  }
1940
- case "columnSettings": {
1941
- modals.showColumnMenu(data.fieldId);
1942
- break;
2153
+ modals.setTrigger(tableButtonElement);
2154
+ const data = button.getData(tableButtonElement);
2155
+ switch (data.type) {
2156
+ case "rowMenu": {
2157
+ modals.showRowMenu(data.rowIndex);
2158
+ break;
2159
+ }
2160
+ case "columnSettings": {
2161
+ modals.showColumnMenu(data.fieldId);
2162
+ break;
2163
+ }
2164
+ case "newColumn": {
2165
+ modals.showColumnCreator();
2166
+ break;
2167
+ }
2168
+ case "sort": {
2169
+ model?.sorting?.toggleSort(data.fieldId);
2170
+ break;
2171
+ }
1943
2172
  }
1944
- case "newColumn": {
1945
- modals.showColumnCreator();
1946
- break;
2173
+ return;
2174
+ }
2175
+ const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2176
+ const controlElement = event.target.closest(controlSelector);
2177
+ if (controlElement) {
2178
+ const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2179
+ if (!control) {
2180
+ return;
1947
2181
  }
1948
- case "sort": {
1949
- model?.sorting?.toggleSort(data.fieldId);
1950
- break;
2182
+ const data = control.getData(controlElement);
2183
+ switch (data.type) {
2184
+ case "checkbox": {
2185
+ if (data.header) {
2186
+ model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2187
+ } else {
2188
+ model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2189
+ }
2190
+ break;
2191
+ }
2192
+ case "switch": {
2193
+ if (model) {
2194
+ model.updateCellData({
2195
+ row: data.rowIndex,
2196
+ col: data.colIndex
2197
+ }, (value) => !value);
2198
+ }
2199
+ break;
2200
+ }
1951
2201
  }
1952
2202
  }
1953
- return;
1954
- }
1955
- const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
1956
- const controlElement = event.target.closest(controlSelector);
1957
- if (controlElement) {
1958
- const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
1959
- if (!control) {
2203
+ }, [
2204
+ model,
2205
+ modals
2206
+ ]);
2207
+ const handleFocus = useCallback5((increment, delta) => {
2208
+ if (dxGrid) {
2209
+ dxGrid.refocus(increment, delta);
2210
+ }
2211
+ }, [
2212
+ dxGrid
2213
+ ]);
2214
+ const handleEnter = useCallback5((cell) => {
2215
+ if (!model?.features.dataEditable) {
1960
2216
  return;
1961
2217
  }
1962
- const data = control.getData(controlElement);
1963
- switch (data.type) {
1964
- case "checkbox": {
1965
- if (data.header) {
1966
- model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
1967
- } else {
1968
- model?.selection.toggleSelectionForRowIndex(data.rowIndex);
1969
- }
1970
- break;
2218
+ if (model && cell.row === model.getRowCount() - 1) {
2219
+ model.insertRow(cell.row);
2220
+ if (dxGrid) {
2221
+ requestAnimationFrame(() => {
2222
+ dxGrid?.scrollToRow(cell.row + 1);
2223
+ dxGrid?.refocus("row", 1);
2224
+ });
1971
2225
  }
1972
- case "switch": {
1973
- if (model) {
1974
- model.updateCellData({
1975
- row: data.rowIndex,
1976
- col: data.colIndex
1977
- }, (value) => !value);
1978
- }
2226
+ }
2227
+ }, [
2228
+ model,
2229
+ dxGrid
2230
+ ]);
2231
+ const handleKeyDown = useCallback5((event) => {
2232
+ if (!model?.features.dataEditable) {
2233
+ return;
2234
+ }
2235
+ const cell = closestCell(event.target);
2236
+ if (!model || !cell) {
2237
+ return;
2238
+ }
2239
+ switch (event.key) {
2240
+ case "Backspace":
2241
+ case "Delete": {
2242
+ model.setCellData(cell, void 0);
1979
2243
  break;
1980
2244
  }
1981
2245
  }
1982
- }
1983
- }, [
1984
- model,
1985
- modals
1986
- ]);
1987
- const handleFocus = useCallback4((increment, delta) => {
1988
- if (dxGrid) {
1989
- dxGrid.refocus(increment, delta);
1990
- }
1991
- }, [
1992
- dxGrid
1993
- ]);
1994
- const handleEnter = useCallback4((cell) => {
1995
- if (!model?.features.dataEditable) {
1996
- return;
1997
- }
1998
- if (model && cell.row === model.getRowCount() - 1) {
1999
- model.insertRow(cell.row);
2000
- if (dxGrid) {
2001
- requestAnimationFrame(() => {
2002
- dxGrid?.scrollToRow(cell.row + 1);
2003
- dxGrid?.refocus("row", 1);
2004
- });
2246
+ }, [
2247
+ model
2248
+ ]);
2249
+ const handleAxisResize = useCallback5((event) => {
2250
+ if (event.axis === "col") {
2251
+ const columnIndex = parseInt(event.index, 10);
2252
+ model?.setColumnWidth(columnIndex, event.size);
2005
2253
  }
2006
- }
2007
- }, [
2008
- model,
2009
- dxGrid
2010
- ]);
2011
- const handleKeyDown = useCallback4((event) => {
2012
- if (!model?.features.dataEditable) {
2013
- return;
2014
- }
2015
- const cell = closestCell(event.target);
2016
- if (!model || !cell) {
2017
- return;
2018
- }
2019
- switch (event.key) {
2020
- case "Backspace":
2021
- case "Delete": {
2022
- model.setCellData(cell, void 0);
2023
- break;
2254
+ }, [
2255
+ model
2256
+ ]);
2257
+ const handleWheel = useCallback5((event) => {
2258
+ if (!ignoreAttention && !hasAttention) {
2259
+ event.stopPropagation();
2024
2260
  }
2025
- }
2026
- }, [
2027
- model
2028
- ]);
2029
- const handleAxisResize = useCallback4((event) => {
2030
- if (event.axis === "col") {
2031
- const columnIndex = parseInt(event.index, 10);
2032
- model?.setColumnWidth(columnIndex, event.size);
2033
- }
2034
- }, [
2035
- model
2036
- ]);
2037
- const handleWheel = useCallback4((event) => {
2038
- if (!ignoreAttention && !hasAttention) {
2039
- event.stopPropagation();
2040
- }
2041
- }, [
2042
- hasAttention,
2043
- ignoreAttention
2044
- ]);
2045
- const handleNewColumn = useCallback4(() => {
2046
- const columns = model?.getColumnCount();
2047
- if (dxGrid && columns) {
2048
- dxGrid.scrollToColumn(columns - 1);
2049
- }
2050
- }, [
2051
- model,
2052
- dxGrid
2053
- ]);
2054
- const handleQuery = useCallback4(async ({ field, props }, text) => {
2055
- if (model && props.referenceSchema && field.referencePath) {
2056
- const space = model.space;
2057
- invariant3(space, void 0, {
2058
- F: __dxlog_file4,
2059
- L: 307,
2060
- S: void 0,
2061
- A: [
2062
- "space",
2063
- ""
2064
- ]
2065
- });
2066
- const schema = space.db.schemaRegistry.getSchema(props.referenceSchema);
2067
- if (schema) {
2068
- const { objects } = await space.db.query(Filter.schema(schema)).run();
2069
- const options = objects.map((obj) => {
2070
- const value = getValue4(obj, field.referencePath);
2071
- if (!value || typeof value !== "string") {
2072
- return void 0;
2073
- }
2074
- return {
2075
- label: value,
2076
- data: obj
2077
- };
2078
- }).filter(isNotFalsy);
2079
- return [
2080
- ...options,
2081
- {
2082
- label: t("create new object label", {
2083
- text
2084
- }),
2085
- data: createOption(text)
2086
- }
2087
- ];
2261
+ }, [
2262
+ hasAttention,
2263
+ ignoreAttention
2264
+ ]);
2265
+ const handleNewColumn = useCallback5(() => {
2266
+ const columns = model?.getColumnCount();
2267
+ if (dxGrid && columns) {
2268
+ dxGrid.scrollToColumn(columns - 1);
2269
+ }
2270
+ }, [
2271
+ model,
2272
+ dxGrid
2273
+ ]);
2274
+ const handleQuery = useCallback5(async ({ field, props }, text) => {
2275
+ if (model && props.referenceSchema && field.referencePath) {
2276
+ const space = model.space;
2277
+ invariant4(space, void 0, {
2278
+ F: __dxlog_file5,
2279
+ L: 309,
2280
+ S: void 0,
2281
+ A: [
2282
+ "space",
2283
+ ""
2284
+ ]
2285
+ });
2286
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2287
+ if (schema2) {
2288
+ const { objects } = await space.db.query(Filter.type(schema2)).run();
2289
+ const options = objects.map((obj) => {
2290
+ const value = getValue4(obj, field.referencePath);
2291
+ if (!value || typeof value !== "string") {
2292
+ return void 0;
2293
+ }
2294
+ return {
2295
+ label: value,
2296
+ data: obj
2297
+ };
2298
+ }).filter(isNotFalsy);
2299
+ return [
2300
+ ...options,
2301
+ {
2302
+ label: t("create new object label", {
2303
+ text
2304
+ }),
2305
+ data: createOption(text)
2306
+ }
2307
+ ];
2308
+ }
2088
2309
  }
2310
+ return [];
2311
+ }, [
2312
+ model,
2313
+ t
2314
+ ]);
2315
+ if (!model || !modals) {
2316
+ return /* @__PURE__ */ React7.createElement("span", {
2317
+ role: "none",
2318
+ className: "attention-surface"
2319
+ });
2089
2320
  }
2090
- return [];
2091
- }, [
2092
- model,
2093
- t
2094
- ]);
2095
- if (!model || !modals) {
2096
- return /* @__PURE__ */ React6.createElement("span", {
2097
- role: "none",
2098
- className: "attention-surface"
2099
- });
2321
+ return /* @__PURE__ */ React7.createElement(Grid.Root, {
2322
+ id: model.id ?? "table-grid"
2323
+ }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
2324
+ model,
2325
+ modals,
2326
+ schema,
2327
+ onEnter: handleEnter,
2328
+ onFocus: handleFocus,
2329
+ onQuery: handleQuery
2330
+ }), /* @__PURE__ */ React7.createElement(Grid.Content, {
2331
+ className: mx2("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
2332
+ frozen,
2333
+ // getCells={getCells}
2334
+ columns: model.columnMeta.value,
2335
+ limitRows: model.getRowCount() ?? 0,
2336
+ limitColumns: model.view?.fields?.length ?? 0,
2337
+ overscroll: "trap",
2338
+ onAxisResize: handleAxisResize,
2339
+ onClick: handleGridClick,
2340
+ onKeyDown: handleKeyDown,
2341
+ onWheelCapture: handleWheel,
2342
+ ref: setDxGrid
2343
+ }), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
2344
+ model,
2345
+ modals
2346
+ }), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
2347
+ model,
2348
+ modals
2349
+ }), /* @__PURE__ */ React7.createElement(ColumnSettings, {
2350
+ model,
2351
+ modals,
2352
+ onNewColumn: handleNewColumn
2353
+ }), /* @__PURE__ */ React7.createElement(CreateRefPanel, {
2354
+ model,
2355
+ modals
2356
+ }));
2357
+ } finally {
2358
+ _effect.f();
2100
2359
  }
2101
- return /* @__PURE__ */ React6.createElement(Grid.Root, {
2102
- id: model.id ?? "table-grid"
2103
- }, /* @__PURE__ */ React6.createElement(TableCellEditor, {
2104
- model,
2105
- modals,
2106
- onEnter: handleEnter,
2107
- onFocus: handleFocus,
2108
- onQuery: handleQuery
2109
- }), /* @__PURE__ */ React6.createElement(Grid.Content, {
2110
- className: mx2("[--dx-grid-base:var(--surface-bg)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
2111
- frozen,
2112
- // getCells={getCells}
2113
- columns: model.columnMeta.value,
2114
- limitRows: model.getRowCount() ?? 0,
2115
- limitColumns: model.view?.fields?.length ?? 0,
2116
- overscroll: "trap",
2117
- onAxisResize: handleAxisResize,
2118
- onClick: handleGridClick,
2119
- onKeyDown: handleKeyDown,
2120
- onWheelCapture: handleWheel,
2121
- ref: setDxGrid
2122
- }), /* @__PURE__ */ React6.createElement(RowActionsMenu, {
2123
- model,
2124
- modals
2125
- }), /* @__PURE__ */ React6.createElement(ColumnActionsMenu, {
2126
- model,
2127
- modals
2128
- }), /* @__PURE__ */ React6.createElement(ColumnSettings, {
2129
- model,
2130
- modals,
2131
- onNewColumn: handleNewColumn
2132
- }), /* @__PURE__ */ React6.createElement(CreateRefPanel, {
2133
- model,
2134
- modals
2135
- }));
2136
2360
  });
2137
2361
  var Table = {
2138
2362
  Root: TableRoot,
@@ -2140,152 +2364,167 @@ var Table = {
2140
2364
  };
2141
2365
 
2142
2366
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2143
- import React7, { useRef as useRef2, useMemo as useMemo5, useCallback as useCallback5 } from "react";
2367
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
2368
+ import React8, { useRef as useRef3, useMemo as useMemo6, useCallback as useCallback6 } from "react";
2144
2369
  import { useDefaultValue } from "@dxos/react-ui";
2145
2370
  import { mx as mx3 } from "@dxos/react-ui-theme";
2146
2371
 
2147
2372
  // packages/ui/react-ui-table/src/hooks/useTableModel.ts
2373
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
2148
2374
  import { effect as effect3 } from "@preact/signals-core";
2149
- import { useEffect as useEffect3, useState as useState3 } from "react";
2375
+ import { useEffect as useEffect4, useState as useState3 } from "react";
2150
2376
  import { fullyQualifiedId, getSpace } from "@dxos/react-client/echo";
2151
2377
  import { useSelectionActions } from "@dxos/react-ui-attention";
2152
2378
  import { isNonNullable } from "@dxos/util";
2153
2379
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2154
- const [model, setModel] = useState3();
2155
- useEffect3(() => {
2156
- if (!table || !projection) {
2157
- return;
2158
- }
2159
- let model2;
2160
- const t = setTimeout(async () => {
2161
- model2 = new TableModel({
2162
- id: fullyQualifiedId(table),
2163
- space: getSpace(table),
2164
- view: table.view?.target,
2165
- projection,
2166
- features,
2167
- rowActions,
2168
- onRowAction,
2169
- ...props
2380
+ var _effect = _useSignals8();
2381
+ try {
2382
+ const [model, setModel] = useState3();
2383
+ useEffect4(() => {
2384
+ if (!table || !projection) {
2385
+ return;
2386
+ }
2387
+ let model2;
2388
+ const t = setTimeout(async () => {
2389
+ model2 = new TableModel({
2390
+ id: fullyQualifiedId(table),
2391
+ space: getSpace(table),
2392
+ view: table.view?.target,
2393
+ projection,
2394
+ features,
2395
+ rowActions,
2396
+ onRowAction,
2397
+ ...props
2398
+ });
2399
+ await model2.open();
2400
+ setModel(model2);
2170
2401
  });
2171
- await model2.open();
2172
- setModel(model2);
2173
- });
2174
- return () => {
2175
- clearTimeout(t);
2176
- void model2?.close();
2177
- };
2178
- }, [
2179
- table,
2180
- projection,
2181
- table?.view?.target,
2182
- features,
2183
- rowActions
2184
- ]);
2185
- useEffect3(() => {
2186
- if (rows) {
2187
- model?.setRows(rows);
2188
- }
2189
- }, [
2190
- model,
2191
- rows
2192
- ]);
2193
- const { select, clear } = useSelectionActions([
2194
- table?.id,
2195
- table?.view?.target?.query.typename
2196
- ].filter(isNonNullable));
2197
- useEffect3(() => {
2198
- if (!model) {
2199
- return;
2200
- }
2201
- const unsubscribe = effect3(() => {
2202
- const selectedItems = [
2203
- ...model.selection.selection.value
2204
- ];
2205
- select(selectedItems);
2206
- onSelectionChanged?.(selectedItems);
2207
- });
2208
- return () => {
2209
- clear();
2210
- unsubscribe();
2211
- };
2212
- }, [
2213
- model,
2214
- onSelectionChanged
2215
- ]);
2216
- return model;
2402
+ return () => {
2403
+ clearTimeout(t);
2404
+ void model2?.close();
2405
+ };
2406
+ }, [
2407
+ table,
2408
+ projection,
2409
+ table?.view?.target,
2410
+ features,
2411
+ rowActions
2412
+ ]);
2413
+ useEffect4(() => {
2414
+ if (rows) {
2415
+ model?.setRows(rows);
2416
+ }
2417
+ }, [
2418
+ model,
2419
+ rows
2420
+ ]);
2421
+ const { multiSelect, clear } = useSelectionActions([
2422
+ table?.id,
2423
+ table?.view?.target?.query.typename
2424
+ ].filter(isNonNullable));
2425
+ useEffect4(() => {
2426
+ if (!model) {
2427
+ return;
2428
+ }
2429
+ const unsubscribe = effect3(() => {
2430
+ const selectedItems = [
2431
+ ...model.selection.selection.value
2432
+ ];
2433
+ multiSelect(selectedItems);
2434
+ onSelectionChanged?.(selectedItems);
2435
+ });
2436
+ return () => {
2437
+ clear();
2438
+ unsubscribe();
2439
+ };
2440
+ }, [
2441
+ model,
2442
+ onSelectionChanged
2443
+ ]);
2444
+ return model;
2445
+ } finally {
2446
+ _effect.f();
2447
+ }
2217
2448
  };
2218
2449
 
2219
2450
  // packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
2220
2451
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2221
- const { table, projection } = useMemo5(() => {
2222
- const props2 = getBaseSchems({
2223
- typename: name,
2452
+ var _effect = _useSignals9();
2453
+ try {
2454
+ const { table, projection } = useMemo6(() => {
2455
+ const props2 = getBaseSchema({
2456
+ typename: name,
2457
+ properties,
2458
+ jsonSchema,
2459
+ schema
2460
+ });
2461
+ return makeDynamicTable({
2462
+ ...props2,
2463
+ properties
2464
+ });
2465
+ }, [
2466
+ name,
2224
2467
  properties,
2225
- jsonSchema,
2226
- schema
2227
- });
2228
- return makeDynamicTable({
2229
- ...props2,
2230
- properties
2468
+ schema,
2469
+ jsonSchema
2470
+ ]);
2471
+ const tableRef = useRef3(null);
2472
+ const handleCellUpdate = useCallback6((cell) => {
2473
+ tableRef.current?.update?.(cell);
2474
+ }, []);
2475
+ const handleRowOrderChange = useCallback6(() => {
2476
+ tableRef.current?.update?.();
2477
+ }, []);
2478
+ const features = useDefaultValue(props.features, () => ({
2479
+ selection: {
2480
+ enabled: false
2481
+ },
2482
+ dataEditable: false
2483
+ }));
2484
+ const model = useTableModel({
2485
+ table,
2486
+ rows,
2487
+ projection,
2488
+ features,
2489
+ rowActions,
2490
+ onCellUpdate: handleCellUpdate,
2491
+ onRowOrderChange: handleRowOrderChange,
2492
+ onRowAction
2231
2493
  });
2232
- }, [
2233
- name,
2234
- properties,
2235
- schema,
2236
- jsonSchema
2237
- ]);
2238
- const tableRef = useRef2(null);
2239
- const handleCellUpdate = useCallback5((cell) => {
2240
- tableRef.current?.update?.(cell);
2241
- }, []);
2242
- const handleRowOrderChange = useCallback5(() => {
2243
- tableRef.current?.update?.();
2244
- }, []);
2245
- const features = useDefaultValue(props.features, () => ({
2246
- selection: {
2247
- enabled: false
2248
- },
2249
- dataEditable: false
2250
- }));
2251
- const model = useTableModel({
2252
- table,
2253
- rows,
2254
- projection,
2255
- features,
2256
- rowActions,
2257
- onCellUpdate: handleCellUpdate,
2258
- onRowOrderChange: handleRowOrderChange,
2259
- onRowAction
2260
- });
2261
- const presentation = useMemo5(() => {
2262
- if (model) {
2263
- return new TablePresentation(model);
2264
- }
2265
- }, [
2266
- model
2267
- ]);
2268
- return /* @__PURE__ */ React7.createElement("div", {
2269
- role: "none",
2270
- className: mx3("is-full bs-full grow grid", classNames)
2271
- }, /* @__PURE__ */ React7.createElement("div", {
2272
- role: "none",
2273
- className: "grid min-bs-0 overflow-hidden"
2274
- }, /* @__PURE__ */ React7.createElement(Table.Root, null, /* @__PURE__ */ React7.createElement(Table.Main, {
2275
- ref: tableRef,
2276
- model,
2277
- presentation,
2278
- ignoreAttention: true,
2279
- onRowClick
2280
- }))));
2494
+ const presentation = useMemo6(() => {
2495
+ if (model) {
2496
+ return new TablePresentation(model);
2497
+ }
2498
+ }, [
2499
+ model
2500
+ ]);
2501
+ return /* @__PURE__ */ React8.createElement("div", {
2502
+ role: "none",
2503
+ className: mx3("is-full bs-full grow grid", classNames)
2504
+ }, /* @__PURE__ */ React8.createElement("div", {
2505
+ role: "none",
2506
+ className: "grid min-bs-0 overflow-hidden"
2507
+ }, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
2508
+ ref: tableRef,
2509
+ model,
2510
+ presentation,
2511
+ ignoreAttention: true,
2512
+ onRowClick
2513
+ }))));
2514
+ } finally {
2515
+ _effect.f();
2516
+ }
2281
2517
  };
2282
2518
 
2283
2519
  // packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
2284
- import React8, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
2520
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
2521
+ import { Rx } from "@effect-rx/rx-react";
2522
+ import React9, { useMemo as useMemo7 } from "react";
2285
2523
  import { live as live4 } from "@dxos/live-object";
2286
2524
  import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
2287
- var createTableToolbarActions = (state) => {
2288
- const add = createMenuAction("add-row", {
2525
+ import { rxFromSignal } from "@dxos/react-ui-menu";
2526
+ var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => Rx.make((get) => {
2527
+ const add = createMenuAction("add-row", onAdd, {
2289
2528
  type: "add-row",
2290
2529
  icon: "ph--plus--regular",
2291
2530
  label: [
@@ -2296,7 +2535,7 @@ var createTableToolbarActions = (state) => {
2296
2535
  ],
2297
2536
  testId: "table.toolbar.add-row"
2298
2537
  });
2299
- const save = createMenuAction("save-view", {
2538
+ const save = createMenuAction("save-view", onSave, {
2300
2539
  type: "save-view",
2301
2540
  icon: "ph--floppy-disk--regular",
2302
2541
  label: [
@@ -2307,49 +2546,55 @@ var createTableToolbarActions = (state) => {
2307
2546
  ],
2308
2547
  testId: "table.toolbar.save-view",
2309
2548
  iconOnly: false,
2310
- hidden: !state.viewDirty
2549
+ hidden: get(rxFromSignal(() => !state.viewDirty))
2311
2550
  });
2312
2551
  const gap = createGapSeparator();
2313
- const comment = createMenuAction("comment", {
2314
- type: "comment",
2315
- icon: "ph--chat-text--regular",
2316
- label: [
2317
- "create comment",
2318
- {
2319
- ns: translationKey
2320
- }
2321
- ],
2322
- testId: "table.toolbar.comment"
2323
- });
2324
2552
  const nodes = [
2325
2553
  add,
2326
2554
  save,
2327
- ...gap.nodes,
2328
- comment
2555
+ ...gap.nodes
2329
2556
  ];
2557
+ const edges = nodes.map(({ id: target }) => ({
2558
+ source: "root",
2559
+ target
2560
+ }));
2561
+ if (customActions) {
2562
+ const custom = get(customActions);
2563
+ nodes.push(...custom.nodes);
2564
+ edges.push(...custom.edges);
2565
+ }
2330
2566
  return {
2331
2567
  nodes,
2332
- edges: nodes.map(({ id: target }) => ({
2333
- source: "root",
2334
- target
2335
- }))
2568
+ edges
2336
2569
  };
2337
- };
2338
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2339
- const state = useMemo6(() => live4({
2340
- viewDirty
2341
- }), []);
2342
- const actionsCreator = useCallback6(() => createTableToolbarActions(state), [
2343
- state
2344
- ]);
2345
- const menu = useMenuActions(actionsCreator);
2346
- return /* @__PURE__ */ React8.createElement(MenuProvider, {
2347
- ...menu,
2348
- attendableId,
2349
- onAction
2350
- }, /* @__PURE__ */ React8.createElement(ToolbarMenu, {
2351
- classNames
2352
- }));
2570
+ });
2571
+ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
2572
+ var _effect = _useSignals10();
2573
+ try {
2574
+ const state = useMemo7(() => live4({
2575
+ viewDirty
2576
+ }), []);
2577
+ const actionsCreator = useMemo7(() => createTableToolbarActions({
2578
+ state,
2579
+ onAdd,
2580
+ onSave,
2581
+ customActions
2582
+ }), [
2583
+ state,
2584
+ onAdd,
2585
+ onSave,
2586
+ customActions
2587
+ ]);
2588
+ const menu = useMenuActions(actionsCreator);
2589
+ return /* @__PURE__ */ React9.createElement(MenuProvider, {
2590
+ ...menu,
2591
+ attendableId
2592
+ }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
2593
+ classNames
2594
+ }));
2595
+ } finally {
2596
+ _effect.f();
2597
+ }
2353
2598
  };
2354
2599
  export {
2355
2600
  BUTTON_IDENTIFIERS,
@@ -2365,9 +2610,10 @@ export {
2365
2610
  TableToolbar,
2366
2611
  TableType,
2367
2612
  cellClassesForRowSelection,
2368
- getBaseSchems,
2613
+ getBaseSchema,
2369
2614
  initializeTable,
2370
2615
  makeDynamicTable,
2616
+ narrowSchema,
2371
2617
  tableButtons,
2372
2618
  tableControls,
2373
2619
  touch,