@dxos/react-ui-table 0.8.2-main.fbd8ed0 → 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.
- package/dist/lib/browser/{chunk-PFFO5LYM.mjs → chunk-U6LL2AVU.mjs} +5 -6
- package/dist/lib/browser/chunk-U6LL2AVU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +972 -911
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-VREQOYRW.cjs → chunk-CXDGXPM6.cjs} +7 -8
- package/dist/lib/node/chunk-CXDGXPM6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +973 -912
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-34JG3SDI.mjs → chunk-EFSM52KQ.mjs} +5 -6
- package/dist/lib/node-esm/chunk-EFSM52KQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +972 -911
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +6 -3
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +4 -4
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -2
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +41 -35
- package/src/components/Table/Table.stories.tsx +16 -28
- package/src/components/Table/relations.stories.tsx +1 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +2 -2
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +2 -1
- package/src/components/TableToolbar/TableToolbar.tsx +62 -31
- package/src/hooks/useTableModel.ts +4 -2
- package/src/model/selection-model.ts +1 -1
- package/src/model/table-model.ts +1 -1
- package/src/model/table-presentation.ts +1 -1
- package/src/types/table.ts +2 -5
- package/src/util/table-buttons.ts +1 -1
- package/src/util/table.ts +3 -3
- package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +0 -7
- package/dist/lib/node/chunk-VREQOYRW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -37,9 +37,9 @@ __export(node_exports, {
|
|
|
37
37
|
Table: () => Table,
|
|
38
38
|
TableModel: () => TableModel,
|
|
39
39
|
TablePresentation: () => TablePresentation,
|
|
40
|
-
TableSchema: () =>
|
|
40
|
+
TableSchema: () => import_chunk_CXDGXPM6.TableSchema,
|
|
41
41
|
TableToolbar: () => TableToolbar,
|
|
42
|
-
TableType: () =>
|
|
42
|
+
TableType: () => import_chunk_CXDGXPM6.TableType,
|
|
43
43
|
cellClassesForRowSelection: () => cellClassesForRowSelection,
|
|
44
44
|
getBaseSchema: () => getBaseSchema,
|
|
45
45
|
initializeTable: () => initializeTable,
|
|
@@ -52,7 +52,8 @@ __export(node_exports, {
|
|
|
52
52
|
useTableModel: () => useTableModel
|
|
53
53
|
});
|
|
54
54
|
module.exports = __toCommonJS(node_exports);
|
|
55
|
-
var
|
|
55
|
+
var import_chunk_CXDGXPM6 = require("./chunk-CXDGXPM6.cjs");
|
|
56
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
56
57
|
var import_react = __toESM(require("react"));
|
|
57
58
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
58
59
|
var import_invariant = require("@dxos/invariant");
|
|
@@ -62,17 +63,21 @@ var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
|
62
63
|
var import_react_ui_grid = require("@dxos/react-ui-grid");
|
|
63
64
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
64
65
|
var import_util = require("@dxos/util");
|
|
66
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
65
67
|
var import_react2 = __toESM(require("react"));
|
|
66
68
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
69
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
67
70
|
var import_react3 = __toESM(require("react"));
|
|
68
71
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
69
72
|
var import_react_ui_form = require("@dxos/react-ui-form");
|
|
73
|
+
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
70
74
|
var import_effect = require("effect");
|
|
71
75
|
var import_react4 = __toESM(require("react"));
|
|
72
76
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
73
77
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
74
78
|
var import_react_ui_form2 = require("@dxos/react-ui-form");
|
|
75
79
|
var import_react_ui_grid2 = require("@dxos/react-ui-grid");
|
|
80
|
+
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
76
81
|
var import_react5 = __toESM(require("react"));
|
|
77
82
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
78
83
|
var import_signals_core = require("@preact/signals-core");
|
|
@@ -106,6 +111,7 @@ var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
|
106
111
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
107
112
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
108
113
|
var import_schema3 = require("@dxos/schema");
|
|
114
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
109
115
|
var import_react6 = __toESM(require("react"));
|
|
110
116
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
111
117
|
var import_invariant3 = require("@dxos/invariant");
|
|
@@ -113,6 +119,7 @@ var import_react_ui6 = require("@dxos/react-ui");
|
|
|
113
119
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
114
120
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
115
121
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
122
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
116
123
|
var import_react7 = __toESM(require("react"));
|
|
117
124
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
118
125
|
var import_invariant4 = require("@dxos/invariant");
|
|
@@ -122,17 +129,22 @@ var import_react_ui_grid5 = require("@dxos/react-ui-grid");
|
|
|
122
129
|
var import_util2 = require("@dxos/util");
|
|
123
130
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
124
131
|
var import_view = require("@codemirror/view");
|
|
132
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
125
133
|
var import_react8 = __toESM(require("react"));
|
|
126
134
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
127
135
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
136
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
128
137
|
var import_signals_core6 = require("@preact/signals-core");
|
|
129
138
|
var import_react9 = require("react");
|
|
130
139
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
131
140
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
132
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");
|
|
133
144
|
var import_react10 = __toESM(require("react"));
|
|
134
145
|
var import_live_object3 = require("@dxos/live-object");
|
|
135
146
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
147
|
+
var import_react_ui_menu2 = require("@dxos/react-ui-menu");
|
|
136
148
|
var translationKey = "table";
|
|
137
149
|
var translations_default = [
|
|
138
150
|
{
|
|
@@ -164,189 +176,209 @@ var translations_default = [
|
|
|
164
176
|
}
|
|
165
177
|
];
|
|
166
178
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
}
|
|
196
213
|
};
|
|
197
214
|
var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
model?.projection,
|
|
212
|
-
state
|
|
213
|
-
]);
|
|
214
|
-
const existingField = (0, import_react3.useMemo)(() => {
|
|
215
|
-
if (state?.type === "columnSettings") {
|
|
216
|
-
const { mode } = state;
|
|
217
|
-
if (mode.type === "edit") {
|
|
218
|
-
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);
|
|
219
228
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
+
}
|
|
259
281
|
};
|
|
260
282
|
var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
typename: state.typename
|
|
270
|
-
}).runSync();
|
|
271
|
-
if (schema2) {
|
|
272
|
-
const omit = import_effect.Schema.omit("id");
|
|
273
|
-
return omit(schema2);
|
|
274
|
-
}
|
|
275
|
-
}, [
|
|
276
|
-
space,
|
|
277
|
-
state
|
|
278
|
-
]);
|
|
279
|
-
const handleSave = (0, import_react4.useCallback)((values) => {
|
|
280
|
-
if (!model || !space || state?.type !== "createRefPanel") {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
const [schema2] = space.db.schemaRegistry.query({
|
|
284
|
-
typename: state.typename
|
|
285
|
-
}).runSync();
|
|
286
|
-
if (schema2) {
|
|
287
|
-
const obj = space.db.add((0, import_echo2.live)(schema2, values));
|
|
288
|
-
state.onCreate?.(obj);
|
|
289
|
-
}
|
|
290
|
-
void modals.close();
|
|
291
|
-
}, [
|
|
292
|
-
modals,
|
|
293
|
-
space,
|
|
294
|
-
state
|
|
295
|
-
]);
|
|
296
|
-
const handleCancel = (0, import_react4.useCallback)(() => {
|
|
297
|
-
if (model) {
|
|
298
|
-
modals.close();
|
|
299
|
-
}
|
|
300
|
-
}, [
|
|
301
|
-
modals
|
|
302
|
-
]);
|
|
303
|
-
if (!model?.view || !model.projection) {
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
|
|
307
|
-
modal: false,
|
|
308
|
-
open: state?.type === "createRefPanel" && !!schema,
|
|
309
|
-
onOpenChange: (nextOpen) => {
|
|
310
|
-
if (model && !nextOpen) {
|
|
311
|
-
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;
|
|
312
291
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
+
}
|
|
325
352
|
};
|
|
326
353
|
var RowActionsMenu = ({ model, modals }) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
"
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
+
}
|
|
350
382
|
};
|
|
351
383
|
var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
|
|
352
384
|
if (typename && properties) {
|
|
@@ -378,7 +410,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
378
410
|
fields: properties.map((property) => property.name)
|
|
379
411
|
}
|
|
380
412
|
});
|
|
381
|
-
const table = (0, import_live_object2.live)(
|
|
413
|
+
const table = (0, import_live_object2.live)(import_chunk_CXDGXPM6.TableType, {
|
|
382
414
|
name: "dynamic-table",
|
|
383
415
|
view: (0, import_live_object2.makeRef)(view)
|
|
384
416
|
});
|
|
@@ -459,12 +491,12 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
|
|
|
459
491
|
version: "0.1.0"
|
|
460
492
|
})({
|
|
461
493
|
name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
|
|
462
|
-
|
|
494
|
+
title: "Name"
|
|
463
495
|
}),
|
|
464
496
|
active: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
465
497
|
email: import_effect2.Schema.optional(import_echo_schema4.Format.Email),
|
|
466
498
|
salary: import_effect2.Schema.optional(import_echo_schema4.Format.Currency()).annotations({
|
|
467
|
-
|
|
499
|
+
title: "Salary"
|
|
468
500
|
})
|
|
469
501
|
});
|
|
470
502
|
var ContactFields = [
|
|
@@ -515,7 +547,7 @@ var BUTTON_IDENTIFIERS = {
|
|
|
515
547
|
var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
|
|
516
548
|
const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
517
549
|
const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
|
|
518
|
-
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>`;
|
|
519
551
|
};
|
|
520
552
|
var addColumnButton = {
|
|
521
553
|
attr: BUTTON_IDENTIFIERS.newColumn,
|
|
@@ -663,12 +695,7 @@ var narrowSchema = (schema, paths) => {
|
|
|
663
695
|
};
|
|
664
696
|
var SelectionModel = class extends import_context2.Resource {
|
|
665
697
|
constructor(_rows, _selectionMode, _onSelectionChanged) {
|
|
666
|
-
super()
|
|
667
|
-
this._rows = _rows;
|
|
668
|
-
this._selectionMode = _selectionMode;
|
|
669
|
-
this._onSelectionChanged = _onSelectionChanged;
|
|
670
|
-
this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set());
|
|
671
|
-
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)(() => {
|
|
672
699
|
const rows = this._rows.value;
|
|
673
700
|
if (!rows) {
|
|
674
701
|
return /* @__PURE__ */ new Set();
|
|
@@ -677,27 +704,21 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
677
704
|
return new Set([
|
|
678
705
|
...this._selection.value
|
|
679
706
|
].filter((id) => validIds.has(id)));
|
|
680
|
-
})
|
|
681
|
-
this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0);
|
|
682
|
-
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)(() => {
|
|
683
708
|
const rows = this._rows.value;
|
|
684
709
|
if (rows.length === 0) {
|
|
685
710
|
return false;
|
|
686
711
|
}
|
|
687
712
|
return rows.every((row) => this._selection.value.has(row.id));
|
|
688
|
-
})
|
|
689
|
-
this.getSelectedRows = () => {
|
|
713
|
+
}), this.getSelectedRows = () => {
|
|
690
714
|
const selectedIds = this._validSelectedIds.value;
|
|
691
715
|
return this._rows.value.filter((row) => selectedIds.has(row.id));
|
|
692
|
-
}
|
|
693
|
-
this.isRowIndexSelected = (rowIndex) => {
|
|
716
|
+
}, this.isRowIndexSelected = (rowIndex) => {
|
|
694
717
|
const row = this._rows.value[rowIndex];
|
|
695
718
|
return this._selection.value.has(row.id);
|
|
696
|
-
}
|
|
697
|
-
this.isObjectSelected = (object) => {
|
|
719
|
+
}, this.isObjectSelected = (object) => {
|
|
698
720
|
return this._selection.value.has(object.id);
|
|
699
|
-
}
|
|
700
|
-
this.toggleSelectionForRowIndex = (rowIndex) => {
|
|
721
|
+
}, this.toggleSelectionForRowIndex = (rowIndex) => {
|
|
701
722
|
const row = this._rows.value[rowIndex];
|
|
702
723
|
const newSelection = new Set(this._selection.value);
|
|
703
724
|
if (newSelection.has(row.id)) {
|
|
@@ -709,8 +730,7 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
709
730
|
newSelection.add(row.id);
|
|
710
731
|
}
|
|
711
732
|
this._selection.value = newSelection;
|
|
712
|
-
}
|
|
713
|
-
this.setSelection = (mode) => {
|
|
733
|
+
}, this.setSelection = (mode) => {
|
|
714
734
|
switch (mode) {
|
|
715
735
|
case "all": {
|
|
716
736
|
this._selection.value = new Set(this._rows.value.map((row) => row.id));
|
|
@@ -1460,7 +1480,7 @@ var TablePresentation = class {
|
|
|
1460
1480
|
const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
|
|
1461
1481
|
if (targetObj) {
|
|
1462
1482
|
const dxn = (0, import_echo_schema6.getDXN)(targetObj)?.toString();
|
|
1463
|
-
cell.accessoryHtml = `<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>`;
|
|
1464
1484
|
}
|
|
1465
1485
|
}
|
|
1466
1486
|
if (props.format === import_echo_schema6.FormatEnum.Boolean) {
|
|
@@ -1652,89 +1672,94 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1652
1672
|
};
|
|
1653
1673
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
|
|
1654
1674
|
var FormCellEditor = ({ fieldProjection, model, schema, __gridScope }) => {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
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),
|
|
1669
1695
|
fieldProjection.field.path
|
|
1670
1696
|
]);
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
return (0, import_echo_schema8.getSnapshot)(originalRow);
|
|
1698
|
-
}
|
|
1699
|
-
}, [
|
|
1700
|
-
originalRow
|
|
1701
|
-
]);
|
|
1702
|
-
const handleSave = (0, import_react7.useCallback)((values) => {
|
|
1703
|
-
const path = fieldProjection.field.path;
|
|
1704
|
-
const value = (0, import_util2.getDeep)(values, [
|
|
1705
|
-
path
|
|
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
|
|
1706
1723
|
]);
|
|
1707
|
-
(0,
|
|
1708
|
-
path
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const handleOpenChange = (0, import_react7.useCallback)((nextOpen) => {
|
|
1716
|
-
if (nextOpen === false) {
|
|
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);
|
|
1717
1732
|
setEditing(null);
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
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
|
+
}
|
|
1738
1763
|
};
|
|
1739
1764
|
var completion = ({ debug, onQuery, onMatch }) => {
|
|
1740
1765
|
return [
|
|
@@ -1779,250 +1804,260 @@ var createOption = (text) => ({
|
|
|
1779
1804
|
});
|
|
1780
1805
|
var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
1781
1806
|
var TableValueEditor = ({ model, modals, schema, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
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
|
+
});
|
|
1786
1838
|
}
|
|
1787
|
-
|
|
1788
|
-
const field = model.projection.view.fields[col];
|
|
1789
|
-
const fieldProjection2 = model.projection.getFieldProjection(field.id);
|
|
1790
|
-
(0, import_invariant3.invariant)(fieldProjection2, void 0, {
|
|
1791
|
-
F: __dxlog_file4,
|
|
1792
|
-
L: 73,
|
|
1793
|
-
S: void 0,
|
|
1794
|
-
A: [
|
|
1795
|
-
"fieldProjection",
|
|
1796
|
-
""
|
|
1797
|
-
]
|
|
1798
|
-
});
|
|
1799
|
-
return fieldProjection2;
|
|
1800
|
-
}, [
|
|
1801
|
-
model,
|
|
1802
|
-
editing
|
|
1803
|
-
]);
|
|
1804
|
-
if (fieldProjection?.props.type === import_echo_schema7.TypeEnum.Array) {
|
|
1805
|
-
return /* @__PURE__ */ import_react6.default.createElement(FormCellEditor, {
|
|
1806
|
-
fieldProjection,
|
|
1839
|
+
return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
|
|
1807
1840
|
model,
|
|
1808
|
-
|
|
1841
|
+
modals,
|
|
1842
|
+
onEnter,
|
|
1843
|
+
onFocus,
|
|
1844
|
+
onQuery,
|
|
1809
1845
|
__gridScope
|
|
1810
1846
|
});
|
|
1847
|
+
} finally {
|
|
1848
|
+
_effect.f();
|
|
1811
1849
|
}
|
|
1812
|
-
return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
|
|
1813
|
-
model,
|
|
1814
|
-
modals,
|
|
1815
|
-
onEnter,
|
|
1816
|
-
onFocus,
|
|
1817
|
-
onQuery,
|
|
1818
|
-
__gridScope
|
|
1819
|
-
});
|
|
1820
1850
|
};
|
|
1821
1851
|
var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }) => {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
onFocus?.();
|
|
1854
|
-
setEditing(null);
|
|
1855
|
-
}, [
|
|
1856
|
-
model,
|
|
1857
|
-
editing,
|
|
1858
|
-
onEnter,
|
|
1859
|
-
onFocus,
|
|
1860
|
-
setEditing
|
|
1861
|
-
]);
|
|
1862
|
-
const handleBlur = (0, import_react6.useCallback)((value) => {
|
|
1863
|
-
if (!model || !editing) {
|
|
1864
|
-
return;
|
|
1865
|
-
}
|
|
1866
|
-
if (suppressNextBlur.current) {
|
|
1867
|
-
suppressNextBlur.current = false;
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
const cell = (0, import_react_ui_grid4.parseCellIndex)(editing.index);
|
|
1871
|
-
if (value !== void 0) {
|
|
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);
|
|
1872
1883
|
model.setCellData(cell, value);
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
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
|
+
}
|
|
1932
1965
|
}
|
|
1933
1966
|
}
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
}
|
|
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);
|
|
1954
1989
|
}
|
|
1955
|
-
} else {
|
|
1956
|
-
handleEnter(data);
|
|
1957
1990
|
}
|
|
1958
1991
|
}
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1992
|
+
})
|
|
1993
|
+
]);
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1963
1996
|
}
|
|
1964
1997
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
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);
|
|
1988
2032
|
if (option) {
|
|
1989
|
-
|
|
1990
|
-
id,
|
|
2033
|
+
const tagItem = {
|
|
2034
|
+
id: value2,
|
|
1991
2035
|
label: option.title,
|
|
1992
2036
|
hue: option.color
|
|
1993
2037
|
};
|
|
2038
|
+
return (0, import_react_ui_tag_picker.createLinks)([
|
|
2039
|
+
tagItem
|
|
2040
|
+
]);
|
|
1994
2041
|
}
|
|
1995
|
-
return void 0;
|
|
1996
|
-
}).filter((item) => item !== void 0);
|
|
1997
|
-
return (0, import_react_ui_tag_picker.createLinks)(tagItems);
|
|
1998
|
-
} else {
|
|
1999
|
-
const option = options.find((o) => o.id === value2);
|
|
2000
|
-
if (option) {
|
|
2001
|
-
const tagItem = {
|
|
2002
|
-
id: value2,
|
|
2003
|
-
label: option.title,
|
|
2004
|
-
hue: option.color
|
|
2005
|
-
};
|
|
2006
|
-
return (0, import_react_ui_tag_picker.createLinks)([
|
|
2007
|
-
tagItem
|
|
2008
|
-
]);
|
|
2009
2042
|
}
|
|
2010
2043
|
}
|
|
2044
|
+
return "";
|
|
2011
2045
|
}
|
|
2012
|
-
|
|
2046
|
+
const value = model.getCellData(cell);
|
|
2047
|
+
return value !== void 0 ? String(value) : "";
|
|
2013
2048
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
}
|
|
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
|
+
}
|
|
2026
2061
|
};
|
|
2027
2062
|
var determineNavigationAxis = ({ key }) => {
|
|
2028
2063
|
switch (key) {
|
|
@@ -2050,416 +2085,436 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
2050
2085
|
};
|
|
2051
2086
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
2052
2087
|
var TableRoot = ({ children, role }) => {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
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
|
+
}
|
|
2057
2097
|
};
|
|
2058
2098
|
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, schema, onRowClick }, forwardedRef) => {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
}, [
|
|
2082
|
-
presentation,
|
|
2083
|
-
dxGrid,
|
|
2084
|
-
getCells
|
|
2085
|
-
]);
|
|
2086
|
-
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
2087
|
-
if (!presentation || !dxGrid) {
|
|
2088
|
-
return {};
|
|
2089
|
-
}
|
|
2090
|
-
return {
|
|
2091
|
-
update: (cell) => {
|
|
2092
|
-
if (cell) {
|
|
2093
|
-
dxGrid.updateIfWithinBounds(cell);
|
|
2094
|
-
} else {
|
|
2095
|
-
dxGrid.updateCells(true);
|
|
2096
|
-
dxGrid.requestUpdate();
|
|
2097
|
-
}
|
|
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;
|
|
2098
2121
|
}
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
const row = model?.getRowAt(rowIndex);
|
|
2109
|
-
row && onRowClick(row);
|
|
2110
|
-
}
|
|
2111
|
-
if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
|
|
2112
|
-
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 {};
|
|
2113
2131
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
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) {
|
|
2123
2158
|
return;
|
|
2124
2159
|
}
|
|
2125
|
-
|
|
2126
|
-
const
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
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;
|
|
2131
2166
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
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
|
+
}
|
|
2135
2186
|
}
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
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;
|
|
2139
2195
|
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
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
|
+
}
|
|
2143
2215
|
}
|
|
2144
2216
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
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) {
|
|
2152
2230
|
return;
|
|
2153
2231
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
}
|
|
2162
|
-
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
|
+
});
|
|
2163
2239
|
}
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
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);
|
|
2171
2257
|
break;
|
|
2172
2258
|
}
|
|
2173
2259
|
}
|
|
2174
|
-
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
dxGrid.refocus(increment, delta);
|
|
2182
|
-
}
|
|
2183
|
-
}, [
|
|
2184
|
-
dxGrid
|
|
2185
|
-
]);
|
|
2186
|
-
const handleEnter = (0, import_react.useCallback)((cell) => {
|
|
2187
|
-
if (!model?.features.dataEditable) {
|
|
2188
|
-
return;
|
|
2189
|
-
}
|
|
2190
|
-
if (model && cell.row === model.getRowCount() - 1) {
|
|
2191
|
-
model.insertRow(cell.row);
|
|
2192
|
-
if (dxGrid) {
|
|
2193
|
-
requestAnimationFrame(() => {
|
|
2194
|
-
dxGrid?.scrollToRow(cell.row + 1);
|
|
2195
|
-
dxGrid?.refocus("row", 1);
|
|
2196
|
-
});
|
|
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);
|
|
2197
2267
|
}
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
if (!model?.features.dataEditable) {
|
|
2205
|
-
return;
|
|
2206
|
-
}
|
|
2207
|
-
const cell = (0, import_react_ui_grid.closestCell)(event.target);
|
|
2208
|
-
if (!model || !cell) {
|
|
2209
|
-
return;
|
|
2210
|
-
}
|
|
2211
|
-
switch (event.key) {
|
|
2212
|
-
case "Backspace":
|
|
2213
|
-
case "Delete": {
|
|
2214
|
-
model.setCellData(cell, void 0);
|
|
2215
|
-
break;
|
|
2268
|
+
}, [
|
|
2269
|
+
model
|
|
2270
|
+
]);
|
|
2271
|
+
const handleWheel = (0, import_react.useCallback)((event) => {
|
|
2272
|
+
if (!ignoreAttention && !hasAttention) {
|
|
2273
|
+
event.stopPropagation();
|
|
2216
2274
|
}
|
|
2217
|
-
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
}
|
|
2226
|
-
}, [
|
|
2227
|
-
model
|
|
2228
|
-
]);
|
|
2229
|
-
const handleWheel = (0, import_react.useCallback)((event) => {
|
|
2230
|
-
if (!ignoreAttention && !hasAttention) {
|
|
2231
|
-
event.stopPropagation();
|
|
2232
|
-
}
|
|
2233
|
-
}, [
|
|
2234
|
-
hasAttention,
|
|
2235
|
-
ignoreAttention
|
|
2236
|
-
]);
|
|
2237
|
-
const handleNewColumn = (0, import_react.useCallback)(() => {
|
|
2238
|
-
const columns = model?.getColumnCount();
|
|
2239
|
-
if (dxGrid && columns) {
|
|
2240
|
-
dxGrid.scrollToColumn(columns - 1);
|
|
2241
|
-
}
|
|
2242
|
-
}, [
|
|
2243
|
-
model,
|
|
2244
|
-
dxGrid
|
|
2245
|
-
]);
|
|
2246
|
-
const handleQuery = (0, import_react.useCallback)(async ({ field, props }, text) => {
|
|
2247
|
-
if (model && props.referenceSchema && field.referencePath) {
|
|
2248
|
-
const space = model.space;
|
|
2249
|
-
(0, import_invariant.invariant)(space, void 0, {
|
|
2250
|
-
F: __dxlog_file5,
|
|
2251
|
-
L: 309,
|
|
2252
|
-
S: void 0,
|
|
2253
|
-
A: [
|
|
2254
|
-
"space",
|
|
2255
|
-
""
|
|
2256
|
-
]
|
|
2257
|
-
});
|
|
2258
|
-
const schema2 = space.db.schemaRegistry.getSchema(props.referenceSchema);
|
|
2259
|
-
if (schema2) {
|
|
2260
|
-
const { objects } = await space.db.query(import_echo.Filter.type(schema2)).run();
|
|
2261
|
-
const options = objects.map((obj) => {
|
|
2262
|
-
const value = (0, import_echo_schema.getValue)(obj, field.referencePath);
|
|
2263
|
-
if (!value || typeof value !== "string") {
|
|
2264
|
-
return void 0;
|
|
2265
|
-
}
|
|
2266
|
-
return {
|
|
2267
|
-
label: value,
|
|
2268
|
-
data: obj
|
|
2269
|
-
};
|
|
2270
|
-
}).filter(import_util.isNotFalsy);
|
|
2271
|
-
return [
|
|
2272
|
-
...options,
|
|
2273
|
-
{
|
|
2274
|
-
label: t("create new object label", {
|
|
2275
|
-
text
|
|
2276
|
-
}),
|
|
2277
|
-
data: createOption(text)
|
|
2278
|
-
}
|
|
2279
|
-
];
|
|
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);
|
|
2280
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
|
+
}
|
|
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
|
+
});
|
|
2281
2334
|
}
|
|
2282
|
-
return
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
})
|
|
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();
|
|
2292
2373
|
}
|
|
2293
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
2294
|
-
id: model.id ?? "table-grid"
|
|
2295
|
-
}, /* @__PURE__ */ import_react.default.createElement(TableValueEditor, {
|
|
2296
|
-
model,
|
|
2297
|
-
modals,
|
|
2298
|
-
schema,
|
|
2299
|
-
onEnter: handleEnter,
|
|
2300
|
-
onFocus: handleFocus,
|
|
2301
|
-
onQuery: handleQuery
|
|
2302
|
-
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
2303
|
-
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--baseSurface)]", import_react_ui_grid.gridSeparatorInlineEnd, import_react_ui_grid.gridSeparatorBlockEnd),
|
|
2304
|
-
frozen,
|
|
2305
|
-
// getCells={getCells}
|
|
2306
|
-
columns: model.columnMeta.value,
|
|
2307
|
-
limitRows: model.getRowCount() ?? 0,
|
|
2308
|
-
limitColumns: model.view?.fields?.length ?? 0,
|
|
2309
|
-
overscroll: "trap",
|
|
2310
|
-
onAxisResize: handleAxisResize,
|
|
2311
|
-
onClick: handleGridClick,
|
|
2312
|
-
onKeyDown: handleKeyDown,
|
|
2313
|
-
onWheelCapture: handleWheel,
|
|
2314
|
-
ref: setDxGrid
|
|
2315
|
-
}), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
|
|
2316
|
-
model,
|
|
2317
|
-
modals
|
|
2318
|
-
}), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
|
|
2319
|
-
model,
|
|
2320
|
-
modals
|
|
2321
|
-
}), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
|
|
2322
|
-
model,
|
|
2323
|
-
modals,
|
|
2324
|
-
onNewColumn: handleNewColumn
|
|
2325
|
-
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
2326
|
-
model,
|
|
2327
|
-
modals
|
|
2328
|
-
}));
|
|
2329
2374
|
});
|
|
2330
2375
|
var Table = {
|
|
2331
2376
|
Root: TableRoot,
|
|
2332
2377
|
Main: TableMain
|
|
2333
2378
|
};
|
|
2334
2379
|
var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
model2
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
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);
|
|
2351
2401
|
});
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
model
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
model
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
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
|
+
}
|
|
2398
2448
|
};
|
|
2399
2449
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
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,
|
|
2403
2465
|
properties,
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
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
|
|
2410
2491
|
});
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
features,
|
|
2435
|
-
rowActions,
|
|
2436
|
-
onCellUpdate: handleCellUpdate,
|
|
2437
|
-
onRowOrderChange: handleRowOrderChange,
|
|
2438
|
-
onRowAction
|
|
2439
|
-
});
|
|
2440
|
-
const presentation = (0, import_react8.useMemo)(() => {
|
|
2441
|
-
if (model) {
|
|
2442
|
-
return new TablePresentation(model);
|
|
2443
|
-
}
|
|
2444
|
-
}, [
|
|
2445
|
-
model
|
|
2446
|
-
]);
|
|
2447
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2448
|
-
role: "none",
|
|
2449
|
-
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2450
|
-
}, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2451
|
-
role: "none",
|
|
2452
|
-
className: "grid min-bs-0 overflow-hidden"
|
|
2453
|
-
}, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
|
|
2454
|
-
ref: tableRef,
|
|
2455
|
-
model,
|
|
2456
|
-
presentation,
|
|
2457
|
-
ignoreAttention: true,
|
|
2458
|
-
onRowClick
|
|
2459
|
-
}))));
|
|
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
|
+
}
|
|
2460
2515
|
};
|
|
2461
|
-
var createTableToolbarActions = (state,
|
|
2462
|
-
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, {
|
|
2463
2518
|
type: "add-row",
|
|
2464
2519
|
icon: "ph--plus--regular",
|
|
2465
2520
|
label: [
|
|
@@ -2470,7 +2525,7 @@ var createTableToolbarActions = (state, onAction) => {
|
|
|
2470
2525
|
],
|
|
2471
2526
|
testId: "table.toolbar.add-row"
|
|
2472
2527
|
});
|
|
2473
|
-
const save = (0, import_react_ui_menu.createMenuAction)("save-view",
|
|
2528
|
+
const save = (0, import_react_ui_menu.createMenuAction)("save-view", onSave, {
|
|
2474
2529
|
type: "save-view",
|
|
2475
2530
|
icon: "ph--floppy-disk--regular",
|
|
2476
2531
|
label: [
|
|
@@ -2481,49 +2536,55 @@ var createTableToolbarActions = (state, onAction) => {
|
|
|
2481
2536
|
],
|
|
2482
2537
|
testId: "table.toolbar.save-view",
|
|
2483
2538
|
iconOnly: false,
|
|
2484
|
-
hidden: !state.viewDirty
|
|
2539
|
+
hidden: get((0, import_react_ui_menu2.rxFromSignal)(() => !state.viewDirty))
|
|
2485
2540
|
});
|
|
2486
2541
|
const gap = (0, import_react_ui_menu.createGapSeparator)();
|
|
2487
|
-
const comment = (0, import_react_ui_menu.createMenuAction)("comment", () => onAction(comment), {
|
|
2488
|
-
type: "comment",
|
|
2489
|
-
icon: "ph--chat-text--regular",
|
|
2490
|
-
label: [
|
|
2491
|
-
"create comment",
|
|
2492
|
-
{
|
|
2493
|
-
ns: translationKey
|
|
2494
|
-
}
|
|
2495
|
-
],
|
|
2496
|
-
testId: "table.toolbar.comment"
|
|
2497
|
-
});
|
|
2498
2542
|
const nodes = [
|
|
2499
2543
|
add,
|
|
2500
2544
|
save,
|
|
2501
|
-
...gap.nodes
|
|
2502
|
-
comment
|
|
2545
|
+
...gap.nodes
|
|
2503
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
|
+
}
|
|
2504
2556
|
return {
|
|
2505
2557
|
nodes,
|
|
2506
|
-
edges
|
|
2507
|
-
source: "root",
|
|
2508
|
-
target
|
|
2509
|
-
}))
|
|
2558
|
+
edges
|
|
2510
2559
|
};
|
|
2511
|
-
};
|
|
2512
|
-
var TableToolbar = ({ classNames, viewDirty, attendableId,
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
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
|
+
}
|
|
2527
2588
|
};
|
|
2528
2589
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2529
2590
|
0 && (module.exports = {
|