@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
@@ -37,13 +37,14 @@ __export(node_exports, {
37
37
  Table: () => Table,
38
38
  TableModel: () => TableModel,
39
39
  TablePresentation: () => TablePresentation,
40
- TableSchema: () => import_chunk_TGG6OZ54.TableSchema,
40
+ TableSchema: () => import_chunk_CXDGXPM6.TableSchema,
41
41
  TableToolbar: () => TableToolbar,
42
- TableType: () => import_chunk_TGG6OZ54.TableType,
42
+ TableType: () => import_chunk_CXDGXPM6.TableType,
43
43
  cellClassesForRowSelection: () => cellClassesForRowSelection,
44
- getBaseSchems: () => getBaseSchems,
44
+ getBaseSchema: () => getBaseSchema,
45
45
  initializeTable: () => initializeTable,
46
46
  makeDynamicTable: () => makeDynamicTable,
47
+ narrowSchema: () => narrowSchema,
47
48
  tableButtons: () => tableButtons,
48
49
  tableControls: () => tableControls,
49
50
  touch: () => touch,
@@ -51,7 +52,8 @@ __export(node_exports, {
51
52
  useTableModel: () => useTableModel
52
53
  });
53
54
  module.exports = __toCommonJS(node_exports);
54
- var import_chunk_TGG6OZ54 = require("./chunk-TGG6OZ54.cjs");
55
+ var import_chunk_CXDGXPM6 = require("./chunk-CXDGXPM6.cjs");
56
+ var import_tracking = require("@preact-signals/safe-react/tracking");
55
57
  var import_react = __toESM(require("react"));
56
58
  var import_echo_schema = require("@dxos/echo-schema");
57
59
  var import_invariant = require("@dxos/invariant");
@@ -61,33 +63,41 @@ var import_react_ui_attention = require("@dxos/react-ui-attention");
61
63
  var import_react_ui_grid = require("@dxos/react-ui-grid");
62
64
  var import_react_ui_theme = require("@dxos/react-ui-theme");
63
65
  var import_util = require("@dxos/util");
66
+ var import_tracking2 = require("@preact-signals/safe-react/tracking");
64
67
  var import_react2 = __toESM(require("react"));
65
68
  var import_react_ui2 = require("@dxos/react-ui");
69
+ var import_tracking3 = require("@preact-signals/safe-react/tracking");
66
70
  var import_react3 = __toESM(require("react"));
67
71
  var import_react_ui3 = require("@dxos/react-ui");
68
72
  var import_react_ui_form = require("@dxos/react-ui-form");
73
+ var import_tracking4 = require("@preact-signals/safe-react/tracking");
74
+ var import_effect = require("effect");
69
75
  var import_react4 = __toESM(require("react"));
70
- var import_echo_schema2 = require("@dxos/echo-schema");
71
76
  var import_echo2 = require("@dxos/react-client/echo");
72
77
  var import_react_ui4 = require("@dxos/react-ui");
73
78
  var import_react_ui_form2 = require("@dxos/react-ui-form");
74
79
  var import_react_ui_grid2 = require("@dxos/react-ui-grid");
80
+ var import_tracking5 = require("@preact-signals/safe-react/tracking");
75
81
  var import_react5 = __toESM(require("react"));
76
82
  var import_react_ui5 = require("@dxos/react-ui");
77
83
  var import_signals_core = require("@preact/signals-core");
78
84
  var import_context = require("@dxos/context");
79
- var import_echo_schema3 = require("@dxos/echo-schema");
85
+ var import_echo_schema2 = require("@dxos/echo-schema");
80
86
  var import_invariant2 = require("@dxos/invariant");
81
87
  var import_live_object = require("@dxos/live-object");
82
88
  var import_react_ui_form3 = require("@dxos/react-ui-form");
83
89
  var import_signals_core2 = require("@preact/signals-core");
84
90
  var import_context2 = require("@dxos/context");
91
+ var import_echo_schema3 = require("@dxos/echo-schema");
85
92
  var import_live_object2 = require("@dxos/live-object");
86
93
  var import_schema = require("@dxos/schema");
94
+ var import_effect2 = require("effect");
87
95
  var import_echo_schema4 = require("@dxos/echo-schema");
88
96
  var import_react_client = require("@dxos/react-client");
89
97
  var import_echo3 = require("@dxos/react-client/echo");
90
98
  var import_schema2 = require("@dxos/schema");
99
+ var import_effect3 = require("effect");
100
+ var import_SchemaAST = require("effect/SchemaAST");
91
101
  var import_signals_core3 = require("@preact/signals-core");
92
102
  var import_lodash = __toESM(require("lodash.orderby"));
93
103
  var import_echo_schema5 = require("@dxos/echo-schema");
@@ -95,11 +105,13 @@ var import_react_ui_form4 = require("@dxos/react-ui-form");
95
105
  var import_signals_core4 = require("@preact/signals-core");
96
106
  var import_log = require("@dxos/log");
97
107
  var import_signals_core5 = require("@preact/signals-core");
108
+ var import_Predicate = require("effect/Predicate");
98
109
  var import_echo_schema6 = require("@dxos/echo-schema");
99
110
  var import_react_ui_form5 = require("@dxos/react-ui-form");
100
111
  var import_react_ui_grid3 = require("@dxos/react-ui-grid");
101
112
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
102
113
  var import_schema3 = require("@dxos/schema");
114
+ var import_tracking6 = require("@preact-signals/safe-react/tracking");
103
115
  var import_react6 = __toESM(require("react"));
104
116
  var import_echo_schema7 = require("@dxos/echo-schema");
105
117
  var import_invariant3 = require("@dxos/invariant");
@@ -107,19 +119,32 @@ var import_react_ui6 = require("@dxos/react-ui");
107
119
  var import_react_ui_editor = require("@dxos/react-ui-editor");
108
120
  var import_react_ui_grid4 = require("@dxos/react-ui-grid");
109
121
  var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
110
- var import_autocomplete = require("@codemirror/autocomplete");
111
- var import_view = require("@codemirror/view");
122
+ var import_tracking7 = require("@preact-signals/safe-react/tracking");
112
123
  var import_react7 = __toESM(require("react"));
124
+ var import_echo_schema8 = require("@dxos/echo-schema");
125
+ var import_invariant4 = require("@dxos/invariant");
113
126
  var import_react_ui7 = require("@dxos/react-ui");
127
+ var import_react_ui_form6 = require("@dxos/react-ui-form");
128
+ var import_react_ui_grid5 = require("@dxos/react-ui-grid");
129
+ var import_util2 = require("@dxos/util");
130
+ var import_autocomplete = require("@codemirror/autocomplete");
131
+ var import_view = require("@codemirror/view");
132
+ var import_tracking8 = require("@preact-signals/safe-react/tracking");
133
+ var import_react8 = __toESM(require("react"));
134
+ var import_react_ui8 = require("@dxos/react-ui");
114
135
  var import_react_ui_theme3 = require("@dxos/react-ui-theme");
136
+ var import_tracking9 = require("@preact-signals/safe-react/tracking");
115
137
  var import_signals_core6 = require("@preact/signals-core");
116
- var import_react8 = require("react");
138
+ var import_react9 = require("react");
117
139
  var import_echo4 = require("@dxos/react-client/echo");
118
140
  var import_react_ui_attention2 = require("@dxos/react-ui-attention");
119
- var import_util2 = require("@dxos/util");
120
- var import_react9 = __toESM(require("react"));
141
+ var import_util3 = require("@dxos/util");
142
+ var import_tracking10 = require("@preact-signals/safe-react/tracking");
143
+ var import_rx_react = require("@effect-rx/rx-react");
144
+ var import_react10 = __toESM(require("react"));
121
145
  var import_live_object3 = require("@dxos/live-object");
122
146
  var import_react_ui_menu = require("@dxos/react-ui-menu");
147
+ var import_react_ui_menu2 = require("@dxos/react-ui-menu");
123
148
  var translationKey = "table";
124
149
  var translations_default = [
125
150
  {
@@ -151,191 +176,211 @@ var translations_default = [
151
176
  }
152
177
  ];
153
178
  var ColumnActionsMenu = ({ model, modals }) => {
154
- const { t } = (0, import_react_ui2.useTranslation)(translationKey);
155
- const state = modals.state.value;
156
- if (state?.type !== "column") {
157
- return null;
158
- }
159
- const currentSort = model.sorting?.sorting;
160
- const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
161
- return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Root, {
162
- modal: false,
163
- open: true,
164
- onOpenChange: modals.close
165
- }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.VirtualTrigger, {
166
- virtualRef: modals.trigger
167
- }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Content, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
168
- "data-testid": "column-sort-descending",
169
- onClick: () => model.sorting?.setSort(state.fieldId, "desc")
170
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
171
- "data-testid": "column-sort-ascending",
172
- onClick: () => model.sorting?.setSort(state.fieldId, "asc")
173
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
174
- "data-testid": "column-clear-sort",
175
- onClick: () => model.sorting?.clearSort()
176
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
177
- "data-testid": "column-delete",
178
- onClick: () => model.deleteColumn(state.fieldId)
179
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
180
- "data-testid": "column-settings",
181
- onClick: () => modals.openColumnSettings()
182
- }, t("column action settings"))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Arrow, null))));
179
+ var _effect = (0, import_tracking2.useSignals)();
180
+ try {
181
+ const { t } = (0, import_react_ui2.useTranslation)(translationKey);
182
+ const state = modals.state.value;
183
+ if (state?.type !== "column") {
184
+ return null;
185
+ }
186
+ const currentSort = model.sorting?.sorting;
187
+ const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
188
+ return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Root, {
189
+ modal: false,
190
+ open: true,
191
+ onOpenChange: modals.close
192
+ }, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.VirtualTrigger, {
193
+ virtualRef: modals.trigger
194
+ }), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Portal, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Content, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
195
+ "data-testid": "column-sort-descending",
196
+ onClick: () => model.sorting?.setSort(state.fieldId, "desc")
197
+ }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
198
+ "data-testid": "column-sort-ascending",
199
+ onClick: () => model.sorting?.setSort(state.fieldId, "asc")
200
+ }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
201
+ "data-testid": "column-clear-sort",
202
+ onClick: () => model.sorting?.clearSort()
203
+ }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
204
+ "data-testid": "column-delete",
205
+ onClick: () => model.deleteColumn(state.fieldId)
206
+ }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Item, {
207
+ "data-testid": "column-settings",
208
+ onClick: () => modals.openColumnSettings()
209
+ }, t("column action settings"))), /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.DropdownMenu.Arrow, null))));
210
+ } finally {
211
+ _effect.f();
212
+ }
183
213
  };
184
214
  var ColumnSettings = ({ model, modals, onNewColumn }) => {
185
- const [newField, setNewField] = (0, import_react3.useState)();
186
- const state = modals.state.value;
187
- const space = model?.space;
188
- (0, import_react3.useEffect)(() => {
189
- if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
190
- setNewField(model.projection.createFieldProjection());
191
- requestAnimationFrame(() => {
192
- onNewColumn();
193
- });
194
- } else {
195
- setNewField(void 0);
196
- }
197
- }, [
198
- model?.projection,
199
- state
200
- ]);
201
- const existingField = (0, import_react3.useMemo)(() => {
202
- if (state?.type === "columnSettings") {
203
- const { mode } = state;
204
- if (mode.type === "edit") {
205
- return model?.view?.fields.find((f) => f.id === mode.fieldId);
215
+ var _effect = (0, import_tracking3.useSignals)();
216
+ try {
217
+ const [newField, setNewField] = (0, import_react3.useState)();
218
+ const state = modals.state.value;
219
+ const space = model?.space;
220
+ (0, import_react3.useEffect)(() => {
221
+ if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
222
+ setNewField(model.projection.createFieldProjection());
223
+ requestAnimationFrame(() => {
224
+ onNewColumn();
225
+ });
226
+ } else {
227
+ setNewField(void 0);
206
228
  }
207
- }
208
- return void 0;
209
- }, [
210
- model?.view?.fields,
211
- state
212
- ]);
213
- const field = existingField ?? newField;
214
- const handleSave = (0, import_react3.useCallback)(() => {
215
- modals.close();
216
- }, [
217
- modals
218
- ]);
219
- const handleCancel = (0, import_react3.useCallback)(() => {
220
- if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
221
- model?.projection?.deleteFieldProjection(newField.id);
222
- }
223
- }, [
224
- model?.projection,
225
- state,
226
- newField
227
- ]);
228
- if (!model?.view || !model.projection || !field) {
229
- return null;
230
- }
231
- return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
232
- modal: false,
233
- open: state?.type === "columnSettings"
234
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.VirtualTrigger, {
235
- virtualRef: modals.trigger
236
- }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
237
- classNames: "md:is-64"
238
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
239
- view: model.view,
240
- projection: model.projection,
241
- field,
242
- registry: space?.db.schemaRegistry,
243
- onSave: handleSave,
244
- onCancel: handleCancel
245
- })), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Arrow, null))));
229
+ }, [
230
+ model?.projection,
231
+ state
232
+ ]);
233
+ const existingField = (0, import_react3.useMemo)(() => {
234
+ if (state?.type === "columnSettings") {
235
+ const { mode } = state;
236
+ if (mode.type === "edit") {
237
+ return model?.view?.fields.find((f) => f.id === mode.fieldId);
238
+ }
239
+ }
240
+ return void 0;
241
+ }, [
242
+ model?.view?.fields,
243
+ state
244
+ ]);
245
+ const field = existingField ?? newField;
246
+ const handleSave = (0, import_react3.useCallback)(() => {
247
+ modals.close();
248
+ }, [
249
+ modals
250
+ ]);
251
+ const handleCancel = (0, import_react3.useCallback)(() => {
252
+ if (state?.type === "columnSettings" && state.mode.type === "create" && newField) {
253
+ model?.projection?.deleteFieldProjection(newField.id);
254
+ }
255
+ }, [
256
+ model?.projection,
257
+ state,
258
+ newField
259
+ ]);
260
+ if (!model?.view || !model.projection || !field) {
261
+ return null;
262
+ }
263
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
264
+ modal: false,
265
+ open: state?.type === "columnSettings"
266
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.VirtualTrigger, {
267
+ virtualRef: modals.trigger
268
+ }), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
269
+ classNames: "md:is-64"
270
+ }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
271
+ view: model.view,
272
+ projection: model.projection,
273
+ field,
274
+ registry: space?.db.schemaRegistry,
275
+ onSave: handleSave,
276
+ onCancel: handleCancel
277
+ })), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Arrow, null))));
278
+ } finally {
279
+ _effect.f();
280
+ }
246
281
  };
247
282
  var CreateRefPanel = ({ model, modals, __gridScope }) => {
248
- const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
249
- const space = model?.space;
250
- const state = modals.state.value;
251
- const schema = (0, import_react4.useMemo)(() => {
252
- if (!space || state?.type !== "createRefPanel") {
253
- return;
254
- }
255
- const [schema2] = space.db.schemaRegistry.query({
256
- typename: state.typename
257
- }).runSync();
258
- if (schema2) {
259
- const omit = import_echo_schema2.S.omit("id");
260
- return omit(schema2);
261
- }
262
- }, [
263
- space,
264
- state
265
- ]);
266
- const handleSave = (0, import_react4.useCallback)((values) => {
267
- if (!model || !space || state?.type !== "createRefPanel") {
268
- return;
269
- }
270
- const [schema2] = space.db.schemaRegistry.query({
271
- typename: state.typename
272
- }).runSync();
273
- if (schema2) {
274
- const obj = space.db.add((0, import_echo2.live)(schema2, values));
275
- state.onCreate?.(obj);
276
- }
277
- void modals.close();
278
- }, [
279
- modals,
280
- space,
281
- state
282
- ]);
283
- const handleCancel = (0, import_react4.useCallback)(() => {
284
- if (model) {
285
- modals.close();
286
- }
287
- }, [
288
- modals
289
- ]);
290
- if (!model?.view || !model.projection) {
291
- return null;
292
- }
293
- return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
294
- modal: false,
295
- open: state?.type === "createRefPanel" && !!schema,
296
- onOpenChange: (nextOpen) => {
297
- if (model && !nextOpen) {
298
- return modals.close();
283
+ var _effect = (0, import_tracking4.useSignals)();
284
+ try {
285
+ const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
286
+ const space = model?.space;
287
+ const state = modals.state.value;
288
+ const schema = (0, import_react4.useMemo)(() => {
289
+ if (!space || state?.type !== "createRefPanel") {
290
+ return;
299
291
  }
300
- }
301
- }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.VirtualTrigger, {
302
- virtualRef: modals.trigger
303
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Content, {
304
- classNames: "md:is-64",
305
- "data-grid": gridId
306
- }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ import_react4.default.createElement(import_react_ui_form2.Form, {
307
- schema,
308
- values: state.initialValues ?? {},
309
- onSave: handleSave,
310
- onCancel: handleCancel
311
- }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
292
+ const [schema2] = space.db.schemaRegistry.query({
293
+ typename: state.typename
294
+ }).runSync();
295
+ if (schema2) {
296
+ const omit = import_effect.Schema.omit("id");
297
+ return omit(schema2);
298
+ }
299
+ }, [
300
+ space,
301
+ state
302
+ ]);
303
+ const handleSave = (0, import_react4.useCallback)((values) => {
304
+ if (!model || !space || state?.type !== "createRefPanel") {
305
+ return;
306
+ }
307
+ const [schema2] = space.db.schemaRegistry.query({
308
+ typename: state.typename
309
+ }).runSync();
310
+ if (schema2) {
311
+ const obj = space.db.add((0, import_echo2.live)(schema2, values));
312
+ state.onCreate?.(obj);
313
+ }
314
+ void modals.close();
315
+ }, [
316
+ modals,
317
+ space,
318
+ state
319
+ ]);
320
+ const handleCancel = (0, import_react4.useCallback)(() => {
321
+ if (model) {
322
+ modals.close();
323
+ }
324
+ }, [
325
+ modals
326
+ ]);
327
+ if (!model?.view || !model.projection) {
328
+ return null;
329
+ }
330
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
331
+ modal: false,
332
+ open: state?.type === "createRefPanel" && !!schema,
333
+ onOpenChange: (nextOpen) => {
334
+ if (model && !nextOpen) {
335
+ return modals.close();
336
+ }
337
+ }
338
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.VirtualTrigger, {
339
+ virtualRef: modals.trigger
340
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Content, {
341
+ classNames: "md:is-64",
342
+ "data-grid": gridId
343
+ }, state?.type === "createRefPanel" && schema && /* @__PURE__ */ import_react4.default.createElement(import_react_ui_form2.Form, {
344
+ schema,
345
+ values: state.initialValues ?? {},
346
+ onSave: handleSave,
347
+ onCancel: handleCancel
348
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Arrow, null))));
349
+ } finally {
350
+ _effect.f();
351
+ }
312
352
  };
313
353
  var RowActionsMenu = ({ model, modals }) => {
314
- const { t } = (0, import_react_ui5.useTranslation)(translationKey);
315
- const hasSelection = model.selection.hasSelection.value;
316
- const state = modals.state.value;
317
- if (state?.type !== "row") {
318
- return null;
319
- }
320
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Root, {
321
- modal: false,
322
- open: true,
323
- onOpenChange: modals.close
324
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.VirtualTrigger, {
325
- virtualRef: modals.trigger
326
- }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Content, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
327
- "data-testid": "row-menu-delete",
328
- onClick: () => model.deleteRow(state.rowIndex)
329
- }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
330
- key: action.id,
331
- "data-testid": `row-action-${action.id}`,
332
- onClick: () => {
333
- modals.close();
334
- model.handleRowAction(action.id, state.rowIndex);
335
- }
336
- }, t(action.translationKey)))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Arrow, null)));
354
+ var _effect = (0, import_tracking5.useSignals)();
355
+ try {
356
+ const { t } = (0, import_react_ui5.useTranslation)(translationKey);
357
+ const hasSelection = model.selection.hasSelection.value;
358
+ const state = modals.state.value;
359
+ if (state?.type !== "row") {
360
+ return null;
361
+ }
362
+ return /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Root, {
363
+ modal: false,
364
+ open: true,
365
+ onOpenChange: modals.close
366
+ }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.VirtualTrigger, {
367
+ virtualRef: modals.trigger
368
+ }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Content, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
369
+ "data-testid": "row-menu-delete",
370
+ onClick: () => model.deleteRow(state.rowIndex)
371
+ }, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Item, {
372
+ key: action.id,
373
+ "data-testid": `row-action-${action.id}`,
374
+ onClick: () => {
375
+ modals.close();
376
+ model.handleRowAction(action.id, state.rowIndex);
377
+ }
378
+ }, t(action.translationKey)))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.DropdownMenu.Arrow, null)));
379
+ } finally {
380
+ _effect.f();
381
+ }
337
382
  };
338
- var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
383
+ var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
339
384
  if (typename && properties) {
340
385
  const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
341
386
  return {
@@ -344,8 +389,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
344
389
  };
345
390
  } else if (schema) {
346
391
  return {
347
- typename: schema.typename,
348
- jsonSchema: schema.jsonSchema
392
+ typename: (0, import_echo_schema3.getTypename)(schema),
393
+ jsonSchema: (0, import_echo_schema3.toJsonSchema)(schema)
349
394
  };
350
395
  } else if (typename && jsonSchema) {
351
396
  return {
@@ -365,7 +410,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
365
410
  fields: properties.map((property) => property.name)
366
411
  }
367
412
  });
368
- const table = (0, import_live_object2.live)(import_chunk_TGG6OZ54.TableType, {
413
+ const table = (0, import_live_object2.live)(import_chunk_CXDGXPM6.TableType, {
369
414
  name: "dynamic-table",
370
415
  view: (0, import_live_object2.makeRef)(view)
371
416
  });
@@ -415,7 +460,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
415
460
  throw new Error(`Schema not found: ${typename}`);
416
461
  }
417
462
  const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
418
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
463
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
419
464
  // TODO(ZaymonFC): Don't hardcode name?
420
465
  name: "View",
421
466
  typename: schema.typename,
@@ -428,7 +473,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
428
473
  ContactSchema
429
474
  ]);
430
475
  const fields = ContactFields;
431
- table.view = (0, import_echo3.makeRef)((0, import_schema2.createView)({
476
+ table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
432
477
  name: "View",
433
478
  typename: schema.typename,
434
479
  jsonSchema: schema.jsonSchema,
@@ -445,13 +490,13 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
445
490
  typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
446
491
  version: "0.1.0"
447
492
  })({
448
- name: import_echo_schema4.S.optional(import_echo_schema4.S.String).annotations({
449
- [import_echo_schema4.AST.TitleAnnotationId]: "Name"
493
+ name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
494
+ title: "Name"
450
495
  }),
451
- active: import_echo_schema4.S.optional(import_echo_schema4.S.Boolean),
452
- email: import_echo_schema4.S.optional(import_echo_schema4.Format.Email),
453
- salary: import_echo_schema4.S.optional(import_echo_schema4.Format.Currency()).annotations({
454
- [import_echo_schema4.AST.TitleAnnotationId]: "Salary"
496
+ active: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
497
+ email: import_effect2.Schema.optional(import_echo_schema4.Format.Email),
498
+ salary: import_effect2.Schema.optional(import_echo_schema4.Format.Currency()).annotations({
499
+ title: "Salary"
455
500
  })
456
501
  });
457
502
  var ContactFields = [
@@ -502,7 +547,7 @@ var BUTTON_IDENTIFIERS = {
502
547
  var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
503
548
  const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
504
549
  const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
505
- 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>`;
550
+ 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>`;
506
551
  };
507
552
  var addColumnButton = {
508
553
  attr: BUTTON_IDENTIFIERS.newColumn,
@@ -637,14 +682,20 @@ var tableControls = {
637
682
  })
638
683
  }
639
684
  };
685
+ var narrowSchema = (schema, paths) => {
686
+ const ast = schema?.ast;
687
+ if ((0, import_SchemaAST.isTypeLiteral)(ast)) {
688
+ const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
689
+ if (propertySignatures.length > 0) {
690
+ const narrowType = new import_SchemaAST.TypeLiteral(propertySignatures, []);
691
+ return import_effect3.Schema.make(narrowType);
692
+ }
693
+ }
694
+ return void 0;
695
+ };
640
696
  var SelectionModel = class extends import_context2.Resource {
641
697
  constructor(_rows, _selectionMode, _onSelectionChanged) {
642
- super();
643
- this._rows = _rows;
644
- this._selectionMode = _selectionMode;
645
- this._onSelectionChanged = _onSelectionChanged;
646
- this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set());
647
- this._validSelectedIds = (0, import_signals_core2.computed)(() => {
698
+ super(), this._rows = _rows, this._selectionMode = _selectionMode, this._onSelectionChanged = _onSelectionChanged, this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set()), this._validSelectedIds = (0, import_signals_core2.computed)(() => {
648
699
  const rows = this._rows.value;
649
700
  if (!rows) {
650
701
  return /* @__PURE__ */ new Set();
@@ -653,27 +704,21 @@ var SelectionModel = class extends import_context2.Resource {
653
704
  return new Set([
654
705
  ...this._selection.value
655
706
  ].filter((id) => validIds.has(id)));
656
- });
657
- this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0);
658
- this._allSelected = (0, import_signals_core2.computed)(() => {
707
+ }), this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0), this._allSelected = (0, import_signals_core2.computed)(() => {
659
708
  const rows = this._rows.value;
660
709
  if (rows.length === 0) {
661
710
  return false;
662
711
  }
663
712
  return rows.every((row) => this._selection.value.has(row.id));
664
- });
665
- this.getSelectedRows = () => {
713
+ }), this.getSelectedRows = () => {
666
714
  const selectedIds = this._validSelectedIds.value;
667
715
  return this._rows.value.filter((row) => selectedIds.has(row.id));
668
- };
669
- this.isRowIndexSelected = (rowIndex) => {
716
+ }, this.isRowIndexSelected = (rowIndex) => {
670
717
  const row = this._rows.value[rowIndex];
671
718
  return this._selection.value.has(row.id);
672
- };
673
- this.isObjectSelected = (object) => {
719
+ }, this.isObjectSelected = (object) => {
674
720
  return this._selection.value.has(object.id);
675
- };
676
- this.toggleSelectionForRowIndex = (rowIndex) => {
721
+ }, this.toggleSelectionForRowIndex = (rowIndex) => {
677
722
  const row = this._rows.value[rowIndex];
678
723
  const newSelection = new Set(this._selection.value);
679
724
  if (newSelection.has(row.id)) {
@@ -685,8 +730,7 @@ var SelectionModel = class extends import_context2.Resource {
685
730
  newSelection.add(row.id);
686
731
  }
687
732
  this._selection.value = newSelection;
688
- };
689
- this.setSelection = (mode) => {
733
+ }, this.setSelection = (mode) => {
690
734
  switch (mode) {
691
735
  case "all": {
692
736
  this._selection.value = new Set(this._rows.value.map((row) => row.id));
@@ -959,17 +1003,17 @@ var TableModel = class extends import_context.Resource {
959
1003
  }
960
1004
  const field = fields[col];
961
1005
  const dataIndex = this._sorting.getDataIndex(row);
962
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataIndex], field.path);
1006
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataIndex], field.path);
963
1007
  if (value == null) {
964
1008
  return "";
965
1009
  }
966
1010
  const { props } = this._projection.getFieldProjection(field.id);
967
1011
  switch (props.format) {
968
- case import_echo_schema3.FormatEnum.Ref: {
1012
+ case import_echo_schema2.FormatEnum.Ref: {
969
1013
  if (!field.referencePath) {
970
1014
  return "";
971
1015
  }
972
- return (0, import_echo_schema3.getValue)(value.target, field.referencePath);
1016
+ return (0, import_echo_schema2.getValue)(value.target, field.referencePath);
973
1017
  }
974
1018
  default: {
975
1019
  return (0, import_react_ui_form3.formatForEditing)({
@@ -989,28 +1033,28 @@ var TableModel = class extends import_context.Resource {
989
1033
  const field = fields[col];
990
1034
  const { props } = this._projection.getFieldProjection(field.id);
991
1035
  switch (props.format) {
992
- case import_echo_schema3.FormatEnum.Ref: {
1036
+ case import_echo_schema2.FormatEnum.Ref: {
993
1037
  if ((0, import_live_object.isLiveObject)(value)) {
994
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
1038
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
995
1039
  }
996
1040
  break;
997
1041
  }
998
- case import_echo_schema3.FormatEnum.SingleSelect: {
1042
+ case import_echo_schema2.FormatEnum.SingleSelect: {
999
1043
  const ids = extractTagIds(value);
1000
1044
  if (ids && ids.length > 0) {
1001
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
1045
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
1002
1046
  }
1003
1047
  break;
1004
1048
  }
1005
- case import_echo_schema3.FormatEnum.MultiSelect: {
1049
+ case import_echo_schema2.FormatEnum.MultiSelect: {
1006
1050
  const ids = extractTagIds(value);
1007
1051
  if (ids) {
1008
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, ids);
1052
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
1009
1053
  }
1010
1054
  break;
1011
1055
  }
1012
1056
  default: {
1013
- (0, import_echo_schema3.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
1057
+ (0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
1014
1058
  type: props.type,
1015
1059
  format: props.format,
1016
1060
  value
@@ -1156,7 +1200,7 @@ var TableModel = class extends import_context.Resource {
1156
1200
  for (let row = start.row; row <= end.row; row++) {
1157
1201
  rowEffects.push((0, import_signals_core.effect)(() => {
1158
1202
  const obj = this._sorting.sortedRows.value[row];
1159
- this._view?.fields.forEach((field) => touch((0, import_echo_schema3.getValue)(obj, field.path)));
1203
+ this._view?.fields.forEach((field) => touch((0, import_echo_schema2.getValue)(obj, field.path)));
1160
1204
  this._onCellUpdate?.({
1161
1205
  row,
1162
1206
  col: start.col,
@@ -1177,9 +1221,9 @@ var TableModel = class extends import_context.Resource {
1177
1221
  const dataRow = this._sorting.getDataIndex(row);
1178
1222
  const fields = this._view?.fields ?? [];
1179
1223
  const field = fields[col];
1180
- const value = (0, import_echo_schema3.getValue)(this._rows.value[dataRow], field.path);
1224
+ const value = (0, import_echo_schema2.getValue)(this._rows.value[dataRow], field.path);
1181
1225
  const updatedValue = update(value);
1182
- (0, import_echo_schema3.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1226
+ (0, import_echo_schema2.setValue)(this._rows.value[dataRow], field.path, updatedValue);
1183
1227
  }
1184
1228
  //
1185
1229
  // Column Operations
@@ -1365,6 +1409,9 @@ var TablePresentation = class {
1365
1409
  if (value == null) {
1366
1410
  return "";
1367
1411
  }
1412
+ if (props.type === "array") {
1413
+ return "";
1414
+ }
1368
1415
  switch (props.format) {
1369
1416
  case import_echo_schema6.FormatEnum.Boolean:
1370
1417
  case import_echo_schema6.FormatEnum.SingleSelect:
@@ -1402,11 +1449,38 @@ var TablePresentation = class {
1402
1449
  if (classes.length > 0) {
1403
1450
  cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
1404
1451
  }
1452
+ if (props.type === import_echo_schema6.TypeEnum.Array) {
1453
+ const targetArray = (0, import_echo_schema6.getValue)(obj, field.path);
1454
+ if (targetArray && Array.isArray(targetArray)) {
1455
+ const getLabel = (value) => {
1456
+ if (!value) {
1457
+ return void 0;
1458
+ }
1459
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1460
+ return String(value);
1461
+ }
1462
+ if (Array.isArray(value)) {
1463
+ return "Array";
1464
+ }
1465
+ if (typeof value === "object" && value.name) {
1466
+ return value.name;
1467
+ }
1468
+ if (typeof value === "object" && value.value) {
1469
+ return `${value.value}`;
1470
+ }
1471
+ return "Object";
1472
+ };
1473
+ const tags = targetArray.map(getLabel).filter(import_Predicate.isNotNullable).map((title) => {
1474
+ return `<span class="dx-tag rounded-xl" data-hue="neutral">${title}</span>`;
1475
+ }).join("");
1476
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1 overflow-x-auto">${tags}</div>`;
1477
+ }
1478
+ }
1405
1479
  if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
1406
1480
  const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
1407
1481
  if (targetObj) {
1408
1482
  const dxn = (0, import_echo_schema6.getDXN)(targetObj)?.toString();
1409
- 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>`;
1483
+ 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>`;
1410
1484
  }
1411
1485
  }
1412
1486
  if (props.format === import_echo_schema6.FormatEnum.Boolean) {
@@ -1440,7 +1514,7 @@ var TablePresentation = class {
1440
1514
  return null;
1441
1515
  }).filter(Boolean).join(" ");
1442
1516
  if (tags) {
1443
- cell.accessoryHtml = tags;
1517
+ cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
1444
1518
  }
1445
1519
  }
1446
1520
  }
@@ -1485,7 +1559,7 @@ var TablePresentation = class {
1485
1559
  fieldId: field.id
1486
1560
  })}
1487
1561
  `,
1488
- className: "!bg-gridHeader"
1562
+ className: "!bg-toolbarSurface"
1489
1563
  };
1490
1564
  }
1491
1565
  return cells;
@@ -1536,7 +1610,7 @@ var TablePresentation = class {
1536
1610
  col: 0,
1537
1611
  row: 0
1538
1612
  })]: {
1539
- className: "!bg-gridHeader",
1613
+ className: "!bg-toolbarSurface",
1540
1614
  readonly: true,
1541
1615
  value: ""
1542
1616
  }
@@ -1552,7 +1626,7 @@ var TablePresentation = class {
1552
1626
  header: true,
1553
1627
  checked: this.model.selection.allRowsSeleted.value
1554
1628
  }),
1555
- className: "!bg-gridHeader",
1629
+ className: "!bg-toolbarSurface",
1556
1630
  readonly: true,
1557
1631
  value: ""
1558
1632
  }
@@ -1567,7 +1641,7 @@ var TablePresentation = class {
1567
1641
  accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
1568
1642
  disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
1569
1643
  }) : void 0,
1570
- className: "!bg-gridHeader",
1644
+ className: "!bg-toolbarSurface",
1571
1645
  readonly: true,
1572
1646
  value: ""
1573
1647
  }
@@ -1596,6 +1670,97 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
1596
1670
  ];
1597
1671
  }
1598
1672
  };
1673
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
1674
+ var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
1675
+ var _effect = (0, import_tracking7.useSignals)();
1676
+ try {
1677
+ const { editing, setEditing } = (0, import_react_ui_grid5.useGridContext)("ArrayEditor", __gridScope);
1678
+ const cellRef = (0, import_react7.useRef)(null);
1679
+ (0, import_react7.useEffect)(() => {
1680
+ if (editing && editing.cellElement) {
1681
+ cellRef.current = editing.cellElement;
1682
+ }
1683
+ }, [
1684
+ editing?.cellElement
1685
+ ]);
1686
+ const narrowedSchema = (0, import_react7.useMemo)(() => {
1687
+ if (!schema) {
1688
+ return void 0;
1689
+ }
1690
+ return narrowSchema(schema, [
1691
+ fieldProjection.field.path
1692
+ ]);
1693
+ }, [
1694
+ JSON.stringify(schema),
1695
+ fieldProjection.field.path
1696
+ ]);
1697
+ const originalRow = (0, import_react7.useMemo)(() => {
1698
+ if (model && editing) {
1699
+ const cell = (0, import_react_ui_grid5.parseCellIndex)(editing.index);
1700
+ const row = model.getRowAt(cell.row);
1701
+ (0, import_invariant4.invariant)(row, void 0, {
1702
+ F: __dxlog_file3,
1703
+ L: 47,
1704
+ S: void 0,
1705
+ A: [
1706
+ "row",
1707
+ ""
1708
+ ]
1709
+ });
1710
+ return row;
1711
+ }
1712
+ return void 0;
1713
+ }, [
1714
+ model,
1715
+ editing
1716
+ ]);
1717
+ const formValues = (0, import_react7.useMemo)(() => {
1718
+ if (originalRow) {
1719
+ return (0, import_echo_schema8.getSnapshot)(originalRow);
1720
+ }
1721
+ }, [
1722
+ originalRow
1723
+ ]);
1724
+ const handleSave = (0, import_react7.useCallback)((values) => {
1725
+ const path = fieldProjection.field.path;
1726
+ const value = (0, import_util2.getDeep)(values, [
1727
+ path
1728
+ ]);
1729
+ (0, import_util2.setDeep)(originalRow, [
1730
+ path
1731
+ ], value);
1732
+ setEditing(null);
1733
+ }, [
1734
+ fieldProjection.field.path,
1735
+ originalRow
1736
+ ]);
1737
+ const handleOpenChange = (0, import_react7.useCallback)((nextOpen) => {
1738
+ if (nextOpen === false) {
1739
+ setEditing(null);
1740
+ }
1741
+ }, [
1742
+ setEditing
1743
+ ]);
1744
+ if (!editing) {
1745
+ return null;
1746
+ }
1747
+ return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Root, {
1748
+ open: editing !== null,
1749
+ onOpenChange: handleOpenChange
1750
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.VirtualTrigger, {
1751
+ virtualRef: cellRef
1752
+ }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Content, {
1753
+ tabIndex: -1,
1754
+ classNames: "popover-card-width"
1755
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Popover.Arrow, null), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_form6.Form, {
1756
+ values: formValues,
1757
+ schema: narrowedSchema,
1758
+ onSave: handleSave
1759
+ })));
1760
+ } finally {
1761
+ _effect.f();
1762
+ }
1763
+ };
1599
1764
  var completion = ({ debug, onQuery, onMatch }) => {
1600
1765
  return [
1601
1766
  import_view.EditorView.theme({
@@ -1631,218 +1796,268 @@ var completion = ({ debug, onQuery, onMatch }) => {
1631
1796
  })
1632
1797
  ];
1633
1798
  };
1634
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1799
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
1635
1800
  var newValue = Symbol.for("newValue");
1636
1801
  var createOption = (text) => ({
1637
1802
  [newValue]: true,
1638
1803
  text
1639
1804
  });
1640
1805
  var isCreateOption = (data) => typeof data === "object" && data[newValue];
1641
- var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1642
- const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
1643
- const suppressNextBlur = (0, import_react6.useRef)(false);
1644
- const { themeMode } = (0, import_react_ui6.useThemeContext)();
1645
- const fieldProjection = (0, import_react6.useMemo)(() => {
1646
- if (!model || !editing) {
1647
- return;
1806
+ var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
1807
+ var _effect = (0, import_tracking6.useSignals)();
1808
+ try {
1809
+ const { editing } = (0, import_react_ui_grid4.useGridContext)("TableValueEditor", __gridScope);
1810
+ const fieldProjection = (0, import_react6.useMemo)(() => {
1811
+ if (!model || !editing) {
1812
+ return;
1813
+ }
1814
+ const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1815
+ const field = model.projection.view.fields[col];
1816
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1817
+ (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1818
+ F: __dxlog_file4,
1819
+ L: 73,
1820
+ S: void 0,
1821
+ A: [
1822
+ "fieldProjection",
1823
+ ""
1824
+ ]
1825
+ });
1826
+ return fieldProjection2;
1827
+ }, [
1828
+ model,
1829
+ editing
1830
+ ]);
1831
+ if (fieldProjection?.props.type === import_echo_schema7.TypeEnum.Array) {
1832
+ return /* @__PURE__ */ import_react6.default.createElement(FormCellEditor, {
1833
+ fieldProjection,
1834
+ model,
1835
+ schema,
1836
+ __gridScope
1837
+ });
1648
1838
  }
1649
- const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1650
- const field = model.projection.view.fields[col];
1651
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1652
- (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1653
- F: __dxlog_file3,
1654
- L: 71,
1655
- S: void 0,
1656
- A: [
1657
- "fieldProjection",
1658
- ""
1659
- ]
1839
+ return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
1840
+ model,
1841
+ modals,
1842
+ onEnter,
1843
+ onFocus,
1844
+ onQuery,
1845
+ __gridScope
1660
1846
  });
1661
- return fieldProjection2;
1662
- }, [
1663
- model,
1664
- editing
1665
- ]);
1666
- const handleEnter = (0, import_react6.useCallback)((value) => {
1667
- if (!model || !editing) {
1668
- return;
1669
- }
1670
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1671
- model.setCellData(cell, value);
1672
- onEnter?.(cell);
1673
- onFocus?.();
1674
- setEditing(null);
1675
- }, [
1676
- model,
1677
- editing,
1678
- onEnter,
1679
- onFocus,
1680
- setEditing
1681
- ]);
1682
- const handleBlur = (0, import_react6.useCallback)((value) => {
1683
- if (!model || !editing) {
1684
- return;
1685
- }
1686
- if (suppressNextBlur.current) {
1687
- suppressNextBlur.current = false;
1688
- return;
1689
- }
1690
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1691
- if (value !== void 0) {
1847
+ } finally {
1848
+ _effect.f();
1849
+ }
1850
+ };
1851
+ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
1852
+ var _effect = (0, import_tracking6.useSignals)();
1853
+ try {
1854
+ const { id: gridId, editing, setEditing } = (0, import_react_ui_grid4.useGridContext)("TableCellEditor", __gridScope);
1855
+ const suppressNextBlur = (0, import_react6.useRef)(false);
1856
+ const { themeMode } = (0, import_react_ui6.useThemeContext)();
1857
+ const fieldProjection = (0, import_react6.useMemo)(() => {
1858
+ if (!model || !editing) {
1859
+ return;
1860
+ }
1861
+ const { col } = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1862
+ const field = model.projection.view.fields[col];
1863
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
1864
+ (0, import_invariant3.invariant)(fieldProjection2, void 0, {
1865
+ F: __dxlog_file4,
1866
+ L: 114,
1867
+ S: void 0,
1868
+ A: [
1869
+ "fieldProjection",
1870
+ ""
1871
+ ]
1872
+ });
1873
+ return fieldProjection2;
1874
+ }, [
1875
+ model,
1876
+ editing
1877
+ ]);
1878
+ const handleEnter = (0, import_react6.useCallback)((value) => {
1879
+ if (!model || !editing) {
1880
+ return;
1881
+ }
1882
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1692
1883
  model.setCellData(cell, value);
1693
- }
1694
- }, [
1695
- model,
1696
- editing
1697
- ]);
1698
- const handleClose = (0, import_react6.useCallback)((value, event) => {
1699
- if (!model || !editing || !fieldProjection) {
1700
- return;
1701
- }
1702
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1703
- onEnter?.(cell);
1704
- if (event && onFocus) {
1705
- onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1706
- }
1707
- }, [
1708
- model,
1709
- editing,
1710
- onFocus,
1711
- onEnter,
1712
- fieldProjection
1713
- ]);
1714
- const extension = (0, import_react6.useMemo)(() => {
1715
- if (!fieldProjection) {
1716
- return [];
1717
- }
1718
- const extension2 = [
1719
- (0, import_react_ui_grid4.editorKeys)({
1720
- onClose: handleClose,
1721
- ...editing?.initialContent && {
1722
- onNav: handleClose
1723
- }
1724
- })
1725
- ];
1726
- const format = fieldProjection.props.format;
1727
- if (format === import_echo_schema7.FormatEnum.SingleSelect || format === import_echo_schema7.FormatEnum.MultiSelect) {
1728
- extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
1729
- themeMode
1730
- }));
1731
- const options = fieldProjection.props.options || [];
1732
- const mode = format === import_echo_schema7.FormatEnum.SingleSelect ? "single-select" : "multi-select";
1733
- extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
1734
- mode,
1735
- inGrid: true,
1736
- onSearch: (text, selectedIds) => {
1737
- return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1738
- id: option.id,
1739
- label: option.title,
1740
- hue: option.color
1741
- }));
1742
- },
1743
- onUpdate: (ids) => {
1744
- if (model && editing) {
1745
- if (ids.length === 0) {
1746
- return;
1747
- }
1748
- if (mode === "single-select") {
1749
- handleEnter(ids[0]);
1750
- } else {
1751
- handleEnter(ids);
1884
+ onEnter?.(cell);
1885
+ onFocus?.();
1886
+ setEditing(null);
1887
+ }, [
1888
+ model,
1889
+ editing,
1890
+ onEnter,
1891
+ onFocus,
1892
+ setEditing
1893
+ ]);
1894
+ const handleBlur = (0, import_react6.useCallback)((value) => {
1895
+ if (!model || !editing) {
1896
+ return;
1897
+ }
1898
+ if (suppressNextBlur.current) {
1899
+ suppressNextBlur.current = false;
1900
+ return;
1901
+ }
1902
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1903
+ if (value !== void 0) {
1904
+ model.setCellData(cell, value);
1905
+ }
1906
+ }, [
1907
+ model,
1908
+ editing
1909
+ ]);
1910
+ const handleClose = (0, import_react6.useCallback)((value, event) => {
1911
+ if (!model || !editing || !fieldProjection) {
1912
+ return;
1913
+ }
1914
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1915
+ onEnter?.(cell);
1916
+ if (event && onFocus) {
1917
+ onFocus(determineNavigationAxis(event), determineNavigationDelta(event));
1918
+ }
1919
+ }, [
1920
+ model,
1921
+ editing,
1922
+ onFocus,
1923
+ onEnter,
1924
+ fieldProjection
1925
+ ]);
1926
+ const extension = (0, import_react6.useMemo)(() => {
1927
+ if (!fieldProjection) {
1928
+ return [];
1929
+ }
1930
+ const extension2 = [
1931
+ (0, import_react_ui_grid4.editorKeys)({
1932
+ onClose: handleClose,
1933
+ ...editing?.initialContent && {
1934
+ onNav: handleClose
1935
+ }
1936
+ })
1937
+ ];
1938
+ const format = fieldProjection.props.format;
1939
+ if (format === import_echo_schema7.FormatEnum.SingleSelect || format === import_echo_schema7.FormatEnum.MultiSelect) {
1940
+ extension2.push((0, import_react_ui_editor.createMarkdownExtensions)({
1941
+ themeMode
1942
+ }));
1943
+ const options = fieldProjection.props.options || [];
1944
+ const mode = format === import_echo_schema7.FormatEnum.SingleSelect ? "single-select" : "multi-select";
1945
+ extension2.push((0, import_react_ui_tag_picker.tagPickerExtension)({
1946
+ mode,
1947
+ inGrid: true,
1948
+ onSearch: (text, selectedIds) => {
1949
+ return options.filter((option) => selectedIds.indexOf(option.id) === -1 && (text.length === 0 || option.title.toLowerCase().includes(text.toLowerCase()))).map((option) => ({
1950
+ id: option.id,
1951
+ label: option.title,
1952
+ hue: option.color
1953
+ }));
1954
+ },
1955
+ onUpdate: (ids) => {
1956
+ if (model && editing) {
1957
+ if (ids.length === 0) {
1958
+ return;
1959
+ }
1960
+ if (mode === "single-select") {
1961
+ handleEnter(ids[0]);
1962
+ } else {
1963
+ handleEnter(ids);
1964
+ }
1752
1965
  }
1753
1966
  }
1754
- }
1755
- }));
1756
- }
1757
- if (onQuery) {
1758
- switch (fieldProjection.props.format) {
1759
- case import_echo_schema7.FormatEnum.Ref: {
1760
- extension2.push([
1761
- completion({
1762
- onQuery: (text) => onQuery(fieldProjection, text),
1763
- onMatch: (data) => {
1764
- if (model && editing && modals) {
1765
- if (isCreateOption(data)) {
1766
- const { field, props } = fieldProjection;
1767
- if (props.referenceSchema) {
1768
- suppressNextBlur.current = true;
1769
- modals.openCreateRef(props.referenceSchema, document.querySelector((0, import_react_ui_grid4.cellQuery)(editing.index, gridId)), {
1770
- [field.referencePath]: data.text
1771
- }, (data2) => {
1772
- handleEnter(data2);
1773
- });
1967
+ }));
1968
+ }
1969
+ if (onQuery) {
1970
+ switch (fieldProjection.props.format) {
1971
+ case import_echo_schema7.FormatEnum.Ref: {
1972
+ extension2.push([
1973
+ completion({
1974
+ onQuery: (text) => onQuery(fieldProjection, text),
1975
+ onMatch: (data) => {
1976
+ if (model && editing && modals) {
1977
+ if (isCreateOption(data)) {
1978
+ const { field, props } = fieldProjection;
1979
+ if (props.referenceSchema) {
1980
+ suppressNextBlur.current = true;
1981
+ modals.openCreateRef(props.referenceSchema, document.querySelector((0, import_react_ui_grid4.cellQuery)(editing.index, gridId)), {
1982
+ [field.referencePath]: data.text
1983
+ }, (data2) => {
1984
+ handleEnter(data2);
1985
+ });
1986
+ }
1987
+ } else {
1988
+ handleEnter(data);
1774
1989
  }
1775
- } else {
1776
- handleEnter(data);
1777
1990
  }
1778
1991
  }
1779
- }
1780
- })
1781
- ]);
1782
- break;
1992
+ })
1993
+ ]);
1994
+ break;
1995
+ }
1783
1996
  }
1784
1997
  }
1785
- }
1786
- return extension2;
1787
- }, [
1788
- model,
1789
- modals,
1790
- editing,
1791
- fieldProjection,
1792
- handleClose,
1793
- themeMode
1794
- ]);
1795
- const getCellContent = (0, import_react6.useCallback)(() => {
1796
- if (model && editing) {
1797
- const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
1798
- const { col } = cell;
1799
- const field = model.projection.view.fields[col];
1800
- const fieldProjection2 = model.projection.getFieldProjection(field.id);
1801
- if (fieldProjection2?.props.format === import_echo_schema7.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema7.FormatEnum.MultiSelect) {
1802
- const value2 = model.getCellData(cell);
1803
- if (value2 !== void 0) {
1804
- const options = fieldProjection2.props.options || [];
1805
- if (fieldProjection2.props.format === import_echo_schema7.FormatEnum.MultiSelect && Array.isArray(value2)) {
1806
- const tagItems = value2.map((id) => {
1807
- const option = options.find((o) => o.id === id);
1998
+ return extension2;
1999
+ }, [
2000
+ model,
2001
+ modals,
2002
+ editing,
2003
+ fieldProjection,
2004
+ handleClose,
2005
+ themeMode
2006
+ ]);
2007
+ const getCellContent = (0, import_react6.useCallback)(() => {
2008
+ if (model && editing) {
2009
+ const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
2010
+ const { col } = cell;
2011
+ const field = model.projection.view.fields[col];
2012
+ const fieldProjection2 = model.projection.getFieldProjection(field.id);
2013
+ if (fieldProjection2?.props.format === import_echo_schema7.FormatEnum.SingleSelect || fieldProjection2?.props.format === import_echo_schema7.FormatEnum.MultiSelect) {
2014
+ const value2 = model.getCellData(cell);
2015
+ if (value2 !== void 0) {
2016
+ const options = fieldProjection2.props.options || [];
2017
+ if (fieldProjection2.props.format === import_echo_schema7.FormatEnum.MultiSelect && Array.isArray(value2)) {
2018
+ const tagItems = value2.map((id) => {
2019
+ const option = options.find((o) => o.id === id);
2020
+ if (option) {
2021
+ return {
2022
+ id,
2023
+ label: option.title,
2024
+ hue: option.color
2025
+ };
2026
+ }
2027
+ return void 0;
2028
+ }).filter((item) => item !== void 0);
2029
+ return (0, import_react_ui_tag_picker.createLinks)(tagItems);
2030
+ } else {
2031
+ const option = options.find((o) => o.id === value2);
1808
2032
  if (option) {
1809
- return {
1810
- id,
2033
+ const tagItem = {
2034
+ id: value2,
1811
2035
  label: option.title,
1812
2036
  hue: option.color
1813
2037
  };
2038
+ return (0, import_react_ui_tag_picker.createLinks)([
2039
+ tagItem
2040
+ ]);
1814
2041
  }
1815
- return void 0;
1816
- }).filter((item) => item !== void 0);
1817
- return (0, import_react_ui_tag_picker.createLinks)(tagItems);
1818
- } else {
1819
- const option = options.find((o) => o.id === value2);
1820
- if (option) {
1821
- const tagItem = {
1822
- id: value2,
1823
- label: option.title,
1824
- hue: option.color
1825
- };
1826
- return (0, import_react_ui_tag_picker.createLinks)([
1827
- tagItem
1828
- ]);
1829
2042
  }
1830
2043
  }
2044
+ return "";
1831
2045
  }
1832
- return "";
2046
+ const value = model.getCellData(cell);
2047
+ return value !== void 0 ? String(value) : "";
1833
2048
  }
1834
- const value = model.getCellData(cell);
1835
- return value !== void 0 ? String(value) : "";
1836
- }
1837
- }, [
1838
- model,
1839
- editing
1840
- ]);
1841
- return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_grid4.GridCellEditor, {
1842
- extension,
1843
- getCellContent,
1844
- onBlur: handleBlur
1845
- });
2049
+ }, [
2050
+ model,
2051
+ editing
2052
+ ]);
2053
+ return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_grid4.GridCellEditor, {
2054
+ extension,
2055
+ getCellContent,
2056
+ onBlur: handleBlur
2057
+ });
2058
+ } finally {
2059
+ _effect.f();
2060
+ }
1846
2061
  };
1847
2062
  var determineNavigationAxis = ({ key }) => {
1848
2063
  switch (key) {
@@ -1868,417 +2083,438 @@ var determineNavigationDelta = ({ key, shift }) => {
1868
2083
  }
1869
2084
  return shift ? -1 : 1;
1870
2085
  };
1871
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
2086
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
1872
2087
  var TableRoot = ({ children, role }) => {
1873
- return /* @__PURE__ */ import_react.default.createElement("div", {
1874
- role: "none",
1875
- className: (0, import_react_ui_theme.mx)("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]")
1876
- }, children);
2088
+ var _effect = (0, import_tracking.useSignals)();
2089
+ try {
2090
+ return /* @__PURE__ */ import_react.default.createElement("div", {
2091
+ role: "none",
2092
+ className: (0, import_react_ui_theme.mx)("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]")
2093
+ }, children);
2094
+ } finally {
2095
+ _effect.f();
2096
+ }
1877
2097
  };
1878
- var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
1879
- const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
1880
- const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
1881
- const { t } = (0, import_react_ui.useTranslation)(translationKey);
1882
- const modals = (0, import_react.useMemo)(() => new ModalController(), []);
1883
- const frozen = (0, import_react.useMemo)(() => {
1884
- const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
1885
- return {
1886
- frozenRowsStart: 1,
1887
- frozenColsStart: model?.features.selection.enabled ? 1 : 0,
1888
- frozenColsEnd: noActionColumn ? 0 : 1
1889
- };
1890
- }, [
1891
- model
1892
- ]);
1893
- const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
1894
- presentation
1895
- ]);
1896
- (0, import_react.useEffect)(() => {
1897
- if (!presentation || !dxGrid) {
1898
- return;
1899
- }
1900
- dxGrid.getCells = getCells;
1901
- }, [
1902
- presentation,
1903
- dxGrid,
1904
- getCells
1905
- ]);
1906
- (0, import_react.useImperativeHandle)(forwardedRef, () => {
1907
- if (!presentation || !dxGrid) {
1908
- return {};
1909
- }
1910
- return {
1911
- update: (cell) => {
1912
- if (cell) {
1913
- dxGrid.updateIfWithinBounds(cell);
1914
- } else {
1915
- dxGrid.updateCells(true);
1916
- dxGrid.requestUpdate();
1917
- }
2098
+ var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
2099
+ var _effect = (0, import_tracking.useSignals)();
2100
+ try {
2101
+ const [dxGrid, setDxGrid] = (0, import_react.useState)(null);
2102
+ const { hasAttention } = (0, import_react_ui_attention.useAttention)(model?.id ?? "table");
2103
+ const { t } = (0, import_react_ui.useTranslation)(translationKey);
2104
+ const modals = (0, import_react.useMemo)(() => new ModalController(), []);
2105
+ const frozen = (0, import_react.useMemo)(() => {
2106
+ const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
2107
+ return {
2108
+ frozenRowsStart: 1,
2109
+ frozenColsStart: model?.features.selection.enabled ? 1 : 0,
2110
+ frozenColsEnd: noActionColumn ? 0 : 1
2111
+ };
2112
+ }, [
2113
+ model
2114
+ ]);
2115
+ const getCells = (0, import_react.useCallback)((range, plane) => presentation?.getCells(range, plane) ?? {}, [
2116
+ presentation
2117
+ ]);
2118
+ (0, import_react.useEffect)(() => {
2119
+ if (!presentation || !dxGrid) {
2120
+ return;
1918
2121
  }
1919
- };
1920
- }, [
1921
- presentation,
1922
- dxGrid
1923
- ]);
1924
- const handleGridClick = (0, import_react.useCallback)((event) => {
1925
- const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
1926
- if (rowIndex != null) {
1927
- if (onRowClick) {
1928
- const row = model?.getRowAt(rowIndex);
1929
- row && onRowClick(row);
1930
- }
1931
- if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
1932
- model.selection.toggleSelectionForRowIndex(rowIndex);
2122
+ dxGrid.getCells = getCells;
2123
+ }, [
2124
+ presentation,
2125
+ dxGrid,
2126
+ getCells
2127
+ ]);
2128
+ (0, import_react.useImperativeHandle)(forwardedRef, () => {
2129
+ if (!presentation || !dxGrid) {
2130
+ return {};
1933
2131
  }
1934
- }
1935
- if (!modals) {
1936
- return;
1937
- }
1938
- const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
1939
- const tableButtonElement = event.target.closest(buttonSelector);
1940
- if (tableButtonElement) {
1941
- const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
1942
- if (!button) {
2132
+ return {
2133
+ update: (cell) => {
2134
+ if (cell) {
2135
+ dxGrid.updateIfWithinBounds(cell);
2136
+ } else {
2137
+ dxGrid.updateCells(true);
2138
+ dxGrid.requestUpdate();
2139
+ }
2140
+ }
2141
+ };
2142
+ }, [
2143
+ presentation,
2144
+ dxGrid
2145
+ ]);
2146
+ const handleGridClick = (0, import_react.useCallback)((event) => {
2147
+ const rowIndex = (0, import_util.safeParseInt)(event.target.ariaRowIndex ?? "");
2148
+ if (rowIndex != null) {
2149
+ if (onRowClick) {
2150
+ const row = model?.getRowAt(rowIndex);
2151
+ row && onRowClick(row);
2152
+ }
2153
+ if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
2154
+ model.selection.toggleSelectionForRowIndex(rowIndex);
2155
+ }
2156
+ }
2157
+ if (!modals) {
1943
2158
  return;
1944
2159
  }
1945
- modals.setTrigger(tableButtonElement);
1946
- const data = button.getData(tableButtonElement);
1947
- switch (data.type) {
1948
- case "rowMenu": {
1949
- modals.showRowMenu(data.rowIndex);
1950
- break;
2160
+ const buttonSelector = Object.values(tableButtons).map((button) => `button[${button.attr}]`).join(",");
2161
+ const tableButtonElement = event.target.closest(buttonSelector);
2162
+ if (tableButtonElement) {
2163
+ const button = Object.values(tableButtons).find((btn) => tableButtonElement.hasAttribute(btn.attr));
2164
+ if (!button) {
2165
+ return;
1951
2166
  }
1952
- case "columnSettings": {
1953
- modals.showColumnMenu(data.fieldId);
1954
- break;
2167
+ modals.setTrigger(tableButtonElement);
2168
+ const data = button.getData(tableButtonElement);
2169
+ switch (data.type) {
2170
+ case "rowMenu": {
2171
+ modals.showRowMenu(data.rowIndex);
2172
+ break;
2173
+ }
2174
+ case "columnSettings": {
2175
+ modals.showColumnMenu(data.fieldId);
2176
+ break;
2177
+ }
2178
+ case "newColumn": {
2179
+ modals.showColumnCreator();
2180
+ break;
2181
+ }
2182
+ case "sort": {
2183
+ model?.sorting?.toggleSort(data.fieldId);
2184
+ break;
2185
+ }
1955
2186
  }
1956
- case "newColumn": {
1957
- modals.showColumnCreator();
1958
- break;
2187
+ return;
2188
+ }
2189
+ const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
2190
+ const controlElement = event.target.closest(controlSelector);
2191
+ if (controlElement) {
2192
+ const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
2193
+ if (!control) {
2194
+ return;
1959
2195
  }
1960
- case "sort": {
1961
- model?.sorting?.toggleSort(data.fieldId);
1962
- break;
2196
+ const data = control.getData(controlElement);
2197
+ switch (data.type) {
2198
+ case "checkbox": {
2199
+ if (data.header) {
2200
+ model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
2201
+ } else {
2202
+ model?.selection.toggleSelectionForRowIndex(data.rowIndex);
2203
+ }
2204
+ break;
2205
+ }
2206
+ case "switch": {
2207
+ if (model) {
2208
+ model.updateCellData({
2209
+ row: data.rowIndex,
2210
+ col: data.colIndex
2211
+ }, (value) => !value);
2212
+ }
2213
+ break;
2214
+ }
1963
2215
  }
1964
2216
  }
1965
- return;
1966
- }
1967
- const controlSelector = Object.values(tableControls).map((control) => `input[${control.attr}]`).join(",");
1968
- const controlElement = event.target.closest(controlSelector);
1969
- if (controlElement) {
1970
- const control = Object.values(tableControls).find((ctrl) => controlElement.hasAttribute(ctrl.attr));
1971
- if (!control) {
2217
+ }, [
2218
+ model,
2219
+ modals
2220
+ ]);
2221
+ const handleFocus = (0, import_react.useCallback)((increment, delta) => {
2222
+ if (dxGrid) {
2223
+ dxGrid.refocus(increment, delta);
2224
+ }
2225
+ }, [
2226
+ dxGrid
2227
+ ]);
2228
+ const handleEnter = (0, import_react.useCallback)((cell) => {
2229
+ if (!model?.features.dataEditable) {
1972
2230
  return;
1973
2231
  }
1974
- const data = control.getData(controlElement);
1975
- switch (data.type) {
1976
- case "checkbox": {
1977
- if (data.header) {
1978
- model?.selection.setSelection(model.selection.allRowsSeleted.value ? "none" : "all");
1979
- } else {
1980
- model?.selection.toggleSelectionForRowIndex(data.rowIndex);
1981
- }
1982
- break;
2232
+ if (model && cell.row === model.getRowCount() - 1) {
2233
+ model.insertRow(cell.row);
2234
+ if (dxGrid) {
2235
+ requestAnimationFrame(() => {
2236
+ dxGrid?.scrollToRow(cell.row + 1);
2237
+ dxGrid?.refocus("row", 1);
2238
+ });
1983
2239
  }
1984
- case "switch": {
1985
- if (model) {
1986
- model.updateCellData({
1987
- row: data.rowIndex,
1988
- col: data.colIndex
1989
- }, (value) => !value);
1990
- }
2240
+ }
2241
+ }, [
2242
+ model,
2243
+ dxGrid
2244
+ ]);
2245
+ const handleKeyDown = (0, import_react.useCallback)((event) => {
2246
+ if (!model?.features.dataEditable) {
2247
+ return;
2248
+ }
2249
+ const cell = (0, import_react_ui_grid.closestCell)(event.target);
2250
+ if (!model || !cell) {
2251
+ return;
2252
+ }
2253
+ switch (event.key) {
2254
+ case "Backspace":
2255
+ case "Delete": {
2256
+ model.setCellData(cell, void 0);
1991
2257
  break;
1992
2258
  }
1993
2259
  }
1994
- }
1995
- }, [
1996
- model,
1997
- modals
1998
- ]);
1999
- const handleFocus = (0, import_react.useCallback)((increment, delta) => {
2000
- if (dxGrid) {
2001
- dxGrid.refocus(increment, delta);
2002
- }
2003
- }, [
2004
- dxGrid
2005
- ]);
2006
- const handleEnter = (0, import_react.useCallback)((cell) => {
2007
- if (!model?.features.dataEditable) {
2008
- return;
2009
- }
2010
- if (model && cell.row === model.getRowCount() - 1) {
2011
- model.insertRow(cell.row);
2012
- if (dxGrid) {
2013
- requestAnimationFrame(() => {
2014
- dxGrid?.scrollToRow(cell.row + 1);
2015
- dxGrid?.refocus("row", 1);
2016
- });
2260
+ }, [
2261
+ model
2262
+ ]);
2263
+ const handleAxisResize = (0, import_react.useCallback)((event) => {
2264
+ if (event.axis === "col") {
2265
+ const columnIndex = parseInt(event.index, 10);
2266
+ model?.setColumnWidth(columnIndex, event.size);
2017
2267
  }
2018
- }
2019
- }, [
2020
- model,
2021
- dxGrid
2022
- ]);
2023
- const handleKeyDown = (0, import_react.useCallback)((event) => {
2024
- if (!model?.features.dataEditable) {
2025
- return;
2026
- }
2027
- const cell = (0, import_react_ui_grid.closestCell)(event.target);
2028
- if (!model || !cell) {
2029
- return;
2030
- }
2031
- switch (event.key) {
2032
- case "Backspace":
2033
- case "Delete": {
2034
- model.setCellData(cell, void 0);
2035
- break;
2268
+ }, [
2269
+ model
2270
+ ]);
2271
+ const handleWheel = (0, import_react.useCallback)((event) => {
2272
+ if (!ignoreAttention && !hasAttention) {
2273
+ event.stopPropagation();
2036
2274
  }
2037
- }
2038
- }, [
2039
- model
2040
- ]);
2041
- const handleAxisResize = (0, import_react.useCallback)((event) => {
2042
- if (event.axis === "col") {
2043
- const columnIndex = parseInt(event.index, 10);
2044
- model?.setColumnWidth(columnIndex, event.size);
2045
- }
2046
- }, [
2047
- model
2048
- ]);
2049
- const handleWheel = (0, import_react.useCallback)((event) => {
2050
- if (!ignoreAttention && !hasAttention) {
2051
- event.stopPropagation();
2052
- }
2053
- }, [
2054
- hasAttention,
2055
- ignoreAttention
2056
- ]);
2057
- const handleNewColumn = (0, import_react.useCallback)(() => {
2058
- const columns = model?.getColumnCount();
2059
- if (dxGrid && columns) {
2060
- dxGrid.scrollToColumn(columns - 1);
2061
- }
2062
- }, [
2063
- model,
2064
- dxGrid
2065
- ]);
2066
- const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
2067
- if (model && props.referenceSchema && field.referencePath) {
2068
- const space = model.space;
2069
- (0, import_invariant.invariant)(space, void 0, {
2070
- F: __dxlog_file4,
2071
- L: 307,
2072
- S: void 0,
2073
- A: [
2074
- "space",
2075
- ""
2076
- ]
2077
- });
2078
- const schema = space.db.schemaRegistry.getSchema(props.referenceSchema);
2079
- if (schema) {
2080
- const { objects } = await space.db.query(import_echo.Filter.schema(schema)).run();
2081
- const options = objects.map((obj) => {
2082
- const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
2083
- if (!value || typeof value !== "string") {
2084
- return void 0;
2085
- }
2086
- return {
2087
- label: value,
2088
- data: obj
2089
- };
2090
- }).filter(import_util.isNotFalsy);
2091
- return [
2092
- ...options,
2093
- {
2094
- label: t("create new object label", {
2095
- text
2096
- }),
2097
- data: createOption(text)
2098
- }
2099
- ];
2275
+ }, [
2276
+ hasAttention,
2277
+ ignoreAttention
2278
+ ]);
2279
+ const handleNewColumn = (0, import_react.useCallback)(() => {
2280
+ const columns = model?.getColumnCount();
2281
+ if (dxGrid && columns) {
2282
+ dxGrid.scrollToColumn(columns - 1);
2283
+ }
2284
+ }, [
2285
+ model,
2286
+ dxGrid
2287
+ ]);
2288
+ const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
2289
+ if (model && props.referenceSchema && field.referencePath) {
2290
+ const space = model.space;
2291
+ (0, import_invariant.invariant)(space, void 0, {
2292
+ F: __dxlog_file5,
2293
+ L: 309,
2294
+ S: void 0,
2295
+ A: [
2296
+ "space",
2297
+ ""
2298
+ ]
2299
+ });
2300
+ const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
2301
+ if (schema2) {
2302
+ const { objects } = await space.db.query(import_echo.Filter.type(schema2)).run();
2303
+ const options = objects.map((obj) => {
2304
+ const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
2305
+ if (!value || typeof value !== "string") {
2306
+ return void 0;
2307
+ }
2308
+ return {
2309
+ label: value,
2310
+ data: obj
2311
+ };
2312
+ }).filter(import_util.isNotFalsy);
2313
+ return [
2314
+ ...options,
2315
+ {
2316
+ label: t("create new object label", {
2317
+ text
2318
+ }),
2319
+ data: createOption(text)
2320
+ }
2321
+ ];
2322
+ }
2100
2323
  }
2324
+ return [];
2325
+ }, [
2326
+ model,
2327
+ t
2328
+ ]);
2329
+ if (!model || !modals) {
2330
+ return /* @__PURE__ */ import_react.default.createElement("span", {
2331
+ role: "none",
2332
+ className: "attention-surface"
2333
+ });
2101
2334
  }
2102
- return [];
2103
- }, [
2104
- model,
2105
- t
2106
- ]);
2107
- if (!model || !modals) {
2108
- return /* @__PURE__ */ import_react.default.createElement("span", {
2109
- role: "none",
2110
- className: "attention-surface"
2111
- });
2335
+ return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
2336
+ id: model.id ?? "table-grid"
2337
+ }, /* @__PURE__ */ import_react.default.createElement(TableValueEditor, {
2338
+ model,
2339
+ modals,
2340
+ schema,
2341
+ onEnter: handleEnter,
2342
+ onFocus: handleFocus,
2343
+ onQuery: handleQuery
2344
+ }), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
2345
+ className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--baseSurface)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
2346
+ frozen,
2347
+ // getCells={getCells}
2348
+ columns: model.columnMeta.value,
2349
+ limitRows: model.getRowCount() ?? 0,
2350
+ limitColumns: model.view?.fields?.length ?? 0,
2351
+ overscroll: "trap",
2352
+ onAxisResize: handleAxisResize,
2353
+ onClick: handleGridClick,
2354
+ onKeyDown: handleKeyDown,
2355
+ onWheelCapture: handleWheel,
2356
+ ref: setDxGrid
2357
+ }), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
2358
+ model,
2359
+ modals
2360
+ }), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
2361
+ model,
2362
+ modals
2363
+ }), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
2364
+ model,
2365
+ modals,
2366
+ onNewColumn: handleNewColumn
2367
+ }), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
2368
+ model,
2369
+ modals
2370
+ }));
2371
+ } finally {
2372
+ _effect.f();
2112
2373
  }
2113
- return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
2114
- id: model.id ?? "table-grid"
2115
- }, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
2116
- model,
2117
- modals,
2118
- onEnter: handleEnter,
2119
- onFocus: handleFocus,
2120
- onQuery: handleQuery
2121
- }), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
2122
- className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
2123
- frozen,
2124
- // getCells={getCells}
2125
- columns: model.columnMeta.value,
2126
- limitRows: model.getRowCount() ?? 0,
2127
- limitColumns: model.view?.fields?.length ?? 0,
2128
- overscroll: "trap",
2129
- onAxisResize: handleAxisResize,
2130
- onClick: handleGridClick,
2131
- onKeyDown: handleKeyDown,
2132
- onWheelCapture: handleWheel,
2133
- ref: setDxGrid
2134
- }), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
2135
- model,
2136
- modals
2137
- }), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
2138
- model,
2139
- modals
2140
- }), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
2141
- model,
2142
- modals,
2143
- onNewColumn: handleNewColumn
2144
- }), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
2145
- model,
2146
- modals
2147
- }));
2148
2374
  });
2149
2375
  var Table = {
2150
2376
  Root: TableRoot,
2151
2377
  Main: TableMain
2152
2378
  };
2153
2379
  var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
2154
- const [model, setModel] = (0, import_react8.useState)();
2155
- (0, import_react8.useEffect)(() => {
2156
- if (!table || !projection) {
2157
- return;
2158
- }
2159
- let model2;
2160
- const t = setTimeout(async () => {
2161
- model2 = new TableModel({
2162
- id: (0, import_echo4.fullyQualifiedId)(table),
2163
- space: (0, import_echo4.getSpace)(table),
2164
- view: table.view?.target,
2165
- projection,
2166
- features,
2167
- rowActions,
2168
- onRowAction,
2169
- ...props
2380
+ var _effect = (0, import_tracking9.useSignals)();
2381
+ try {
2382
+ const [model, setModel] = (0, import_react9.useState)();
2383
+ (0, import_react9.useEffect)(() => {
2384
+ if (!table || !projection) {
2385
+ return;
2386
+ }
2387
+ let model2;
2388
+ const t = setTimeout(async () => {
2389
+ model2 = new TableModel({
2390
+ id: (0, import_echo4.fullyQualifiedId)(table),
2391
+ space: (0, import_echo4.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
- (0, import_react8.useEffect)(() => {
2186
- if (rows) {
2187
- model?.setRows(rows);
2188
- }
2189
- }, [
2190
- model,
2191
- rows
2192
- ]);
2193
- const { select, clear } = (0, import_react_ui_attention2.useSelectionActions)([
2194
- table?.id,
2195
- table?.view?.target?.query.typename
2196
- ].filter(import_util2.isNonNullable));
2197
- (0, import_react8.useEffect)(() => {
2198
- if (!model) {
2199
- return;
2200
- }
2201
- const unsubscribe = (0, import_signals_core6.effect)(() => {
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
+ (0, import_react9.useEffect)(() => {
2414
+ if (rows) {
2415
+ model?.setRows(rows);
2416
+ }
2417
+ }, [
2418
+ model,
2419
+ rows
2420
+ ]);
2421
+ const { multiSelect, clear } = (0, import_react_ui_attention2.useSelectionActions)([
2422
+ table?.id,
2423
+ table?.view?.target?.query.typename
2424
+ ].filter(import_util3.isNonNullable));
2425
+ (0, import_react9.useEffect)(() => {
2426
+ if (!model) {
2427
+ return;
2428
+ }
2429
+ const unsubscribe = (0, import_signals_core6.effect)(() => {
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
  var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
2219
- const { table, projection } = (0, import_react7.useMemo)(() => {
2220
- const props2 = getBaseSchems({
2221
- typename: name,
2450
+ var _effect = (0, import_tracking8.useSignals)();
2451
+ try {
2452
+ const { table, projection } = (0, import_react8.useMemo)(() => {
2453
+ const props2 = getBaseSchema({
2454
+ typename: name,
2455
+ properties,
2456
+ jsonSchema,
2457
+ schema
2458
+ });
2459
+ return makeDynamicTable({
2460
+ ...props2,
2461
+ properties
2462
+ });
2463
+ }, [
2464
+ name,
2222
2465
  properties,
2223
- jsonSchema,
2224
- schema
2225
- });
2226
- return makeDynamicTable({
2227
- ...props2,
2228
- properties
2466
+ schema,
2467
+ jsonSchema
2468
+ ]);
2469
+ const tableRef = (0, import_react8.useRef)(null);
2470
+ const handleCellUpdate = (0, import_react8.useCallback)((cell) => {
2471
+ tableRef.current?.update?.(cell);
2472
+ }, []);
2473
+ const handleRowOrderChange = (0, import_react8.useCallback)(() => {
2474
+ tableRef.current?.update?.();
2475
+ }, []);
2476
+ const features = (0, import_react_ui8.useDefaultValue)(props.features, () => ({
2477
+ selection: {
2478
+ enabled: false
2479
+ },
2480
+ dataEditable: false
2481
+ }));
2482
+ const model = useTableModel({
2483
+ table,
2484
+ rows,
2485
+ projection,
2486
+ features,
2487
+ rowActions,
2488
+ onCellUpdate: handleCellUpdate,
2489
+ onRowOrderChange: handleRowOrderChange,
2490
+ onRowAction
2229
2491
  });
2230
- }, [
2231
- name,
2232
- properties,
2233
- schema,
2234
- jsonSchema
2235
- ]);
2236
- const tableRef = (0, import_react7.useRef)(null);
2237
- const handleCellUpdate = (0, import_react7.useCallback)((cell) => {
2238
- tableRef.current?.update?.(cell);
2239
- }, []);
2240
- const handleRowOrderChange = (0, import_react7.useCallback)(() => {
2241
- tableRef.current?.update?.();
2242
- }, []);
2243
- const features = (0, import_react_ui7.useDefaultValue)(props.features, () => ({
2244
- selection: {
2245
- enabled: false
2246
- },
2247
- dataEditable: false
2248
- }));
2249
- const model = useTableModel({
2250
- table,
2251
- rows,
2252
- projection,
2253
- features,
2254
- rowActions,
2255
- onCellUpdate: handleCellUpdate,
2256
- onRowOrderChange: handleRowOrderChange,
2257
- onRowAction
2258
- });
2259
- const presentation = (0, import_react7.useMemo)(() => {
2260
- if (model) {
2261
- return new TablePresentation(model);
2262
- }
2263
- }, [
2264
- model
2265
- ]);
2266
- return /* @__PURE__ */ import_react7.default.createElement("div", {
2267
- role: "none",
2268
- className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
2269
- }, /* @__PURE__ */ import_react7.default.createElement("div", {
2270
- role: "none",
2271
- className: "grid min-bs-0 overflow-hidden"
2272
- }, /* @__PURE__ */ import_react7.default.createElement(Table.Root, null, /* @__PURE__ */ import_react7.default.createElement(Table.Main, {
2273
- ref: tableRef,
2274
- model,
2275
- presentation,
2276
- ignoreAttention: true,
2277
- onRowClick
2278
- }))));
2492
+ const presentation = (0, import_react8.useMemo)(() => {
2493
+ if (model) {
2494
+ return new TablePresentation(model);
2495
+ }
2496
+ }, [
2497
+ model
2498
+ ]);
2499
+ return /* @__PURE__ */ import_react8.default.createElement("div", {
2500
+ role: "none",
2501
+ className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
2502
+ }, /* @__PURE__ */ import_react8.default.createElement("div", {
2503
+ role: "none",
2504
+ className: "grid min-bs-0 overflow-hidden"
2505
+ }, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
2506
+ ref: tableRef,
2507
+ model,
2508
+ presentation,
2509
+ ignoreAttention: true,
2510
+ onRowClick
2511
+ }))));
2512
+ } finally {
2513
+ _effect.f();
2514
+ }
2279
2515
  };
2280
- var createTableToolbarActions = (state) => {
2281
- const add = (0, import_react_ui_menu.createMenuAction)("add-row", {
2516
+ var createTableToolbarActions = ({ state, onAdd, onSave, customActions }) => import_rx_react.Rx.make((get) => {
2517
+ const add = (0, import_react_ui_menu.createMenuAction)("add-row", onAdd, {
2282
2518
  type: "add-row",
2283
2519
  icon: "ph--plus--regular",
2284
2520
  label: [
@@ -2289,7 +2525,7 @@ var createTableToolbarActions = (state) => {
2289
2525
  ],
2290
2526
  testId: "table.toolbar.add-row"
2291
2527
  });
2292
- const save = (0, import_react_ui_menu.createMenuAction)("save-view", {
2528
+ const save = (0, import_react_ui_menu.createMenuAction)("save-view", onSave, {
2293
2529
  type: "save-view",
2294
2530
  icon: "ph--floppy-disk--regular",
2295
2531
  label: [
@@ -2300,49 +2536,55 @@ var createTableToolbarActions = (state) => {
2300
2536
  ],
2301
2537
  testId: "table.toolbar.save-view",
2302
2538
  iconOnly: false,
2303
- hidden: !state.viewDirty
2539
+ hidden: get((0, import_react_ui_menu2.rxFromSignal)(() => !state.viewDirty))
2304
2540
  });
2305
2541
  const gap = (0, import_react_ui_menu.createGapSeparator)();
2306
- const comment = (0, import_react_ui_menu.createMenuAction)("comment", {
2307
- type: "comment",
2308
- icon: "ph--chat-text--regular",
2309
- label: [
2310
- "create comment",
2311
- {
2312
- ns: translationKey
2313
- }
2314
- ],
2315
- testId: "table.toolbar.comment"
2316
- });
2317
2542
  const nodes = [
2318
2543
  add,
2319
2544
  save,
2320
- ...gap.nodes,
2321
- comment
2545
+ ...gap.nodes
2322
2546
  ];
2547
+ const edges = nodes.map(({ id: target }) => ({
2548
+ source: "root",
2549
+ target
2550
+ }));
2551
+ if (customActions) {
2552
+ const custom = get(customActions);
2553
+ nodes.push(...custom.nodes);
2554
+ edges.push(...custom.edges);
2555
+ }
2323
2556
  return {
2324
2557
  nodes,
2325
- edges: nodes.map(({ id: target }) => ({
2326
- source: "root",
2327
- target
2328
- }))
2558
+ edges
2329
2559
  };
2330
- };
2331
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2332
- const state = (0, import_react9.useMemo)(() => (0, import_live_object3.live)({
2333
- viewDirty
2334
- }), []);
2335
- const actionsCreator = (0, import_react9.useCallback)(() => createTableToolbarActions(state), [
2336
- state
2337
- ]);
2338
- const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
2339
- return /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.MenuProvider, {
2340
- ...menu,
2341
- attendableId,
2342
- onAction
2343
- }, /* @__PURE__ */ import_react9.default.createElement(import_react_ui_menu.ToolbarMenu, {
2344
- classNames
2345
- }));
2560
+ });
2561
+ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
2562
+ var _effect = (0, import_tracking10.useSignals)();
2563
+ try {
2564
+ const state = (0, import_react10.useMemo)(() => (0, import_live_object3.live)({
2565
+ viewDirty
2566
+ }), []);
2567
+ const actionsCreator = (0, import_react10.useMemo)(() => createTableToolbarActions({
2568
+ state,
2569
+ onAdd,
2570
+ onSave,
2571
+ customActions
2572
+ }), [
2573
+ state,
2574
+ onAdd,
2575
+ onSave,
2576
+ customActions
2577
+ ]);
2578
+ const menu = (0, import_react_ui_menu.useMenuActions)(actionsCreator);
2579
+ return /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.MenuProvider, {
2580
+ ...menu,
2581
+ attendableId
2582
+ }, /* @__PURE__ */ import_react10.default.createElement(import_react_ui_menu.ToolbarMenu, {
2583
+ classNames
2584
+ }));
2585
+ } finally {
2586
+ _effect.f();
2587
+ }
2346
2588
  };
2347
2589
  // Annotate the CommonJS export names for ESM import in node:
2348
2590
  0 && (module.exports = {
@@ -2359,9 +2601,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
2359
2601
  TableToolbar,
2360
2602
  TableType,
2361
2603
  cellClassesForRowSelection,
2362
- getBaseSchems,
2604
+ getBaseSchema,
2363
2605
  initializeTable,
2364
2606
  makeDynamicTable,
2607
+ narrowSchema,
2365
2608
  tableButtons,
2366
2609
  tableControls,
2367
2610
  touch,