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