@dxos/react-ui-table 0.8.2-staging.7ac8446 → 0.8.2
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-U6LL2AVU.mjs +26 -0
- package/dist/lib/browser/chunk-U6LL2AVU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1115 -905
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-TGG6OZ54.cjs → chunk-CXDGXPM6.cjs} +12 -12
- package/dist/lib/node/chunk-CXDGXPM6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1113 -906
- package/dist/lib/node/index.cjs.map +4 -4
- 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-KKLP54L3.mjs → chunk-EFSM52KQ.mjs} +10 -10
- package/dist/lib/node-esm/chunk-EFSM52KQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1115 -905
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +3 -4
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +2 -0
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +1 -0
- 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/FormCellEditor.d.ts +13 -0
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +3 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/extension.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 +40 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.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/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +46 -45
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +4 -3
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/schema.d.ts +12 -0
- package/dist/types/src/util/schema.d.ts.map +1 -0
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +0 -14
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +2 -2
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/dist/types/src/util/tag.d.ts +11 -0
- package/dist/types/src/util/tag.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -34
- package/src/components/Table/CreateRefPanel.tsx +5 -5
- package/src/components/Table/DynamicTable.stories.tsx +4 -4
- package/src/components/Table/DynamicTable.tsx +4 -5
- package/src/components/Table/Table.stories.tsx +84 -50
- package/src/components/Table/Table.tsx +25 -28
- package/src/components/Table/relations.stories.tsx +38 -32
- package/src/components/TableCellEditor/FormCellEditor.tsx +94 -0
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +13 -11
- package/src/components/TableCellEditor/TableCellEditor.tsx +45 -4
- package/src/components/TableToolbar/TableToolbar.tsx +65 -35
- package/src/components/testing.ts +10 -9
- package/src/hooks/useTableModel.ts +6 -4
- package/src/model/modal-controller.ts +3 -3
- package/src/model/selection-model.ts +1 -1
- package/src/model/table-model.test.ts +7 -6
- package/src/model/table-model.ts +20 -3
- package/src/model/table-presentation.test.ts +7 -6
- package/src/model/table-presentation.ts +54 -10
- package/src/types/table.ts +16 -11
- package/src/util/dynamic-table.ts +9 -6
- package/src/util/index.ts +1 -0
- package/src/util/schema.ts +36 -0
- package/src/util/table-buttons.ts +1 -24
- package/src/util/table.ts +13 -16
- package/src/util/tag.ts +33 -0
- package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
- package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
- package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
- package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
- package/src/components/Table/RefPanel.tsx +0 -52
package/dist/lib/node/index.cjs
CHANGED
|
@@ -37,13 +37,14 @@ __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,
|
|
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
|
|
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,68 +63,88 @@ 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
|
-
var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
78
|
-
var import_react6 = __toESM(require("react"));
|
|
79
|
-
var import_react_ui6 = require("@dxos/react-ui");
|
|
80
83
|
var import_signals_core = require("@preact/signals-core");
|
|
81
84
|
var import_context = require("@dxos/context");
|
|
82
|
-
var
|
|
85
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
83
86
|
var import_invariant2 = require("@dxos/invariant");
|
|
84
87
|
var import_live_object = require("@dxos/live-object");
|
|
85
|
-
var
|
|
88
|
+
var import_react_ui_form3 = require("@dxos/react-ui-form");
|
|
86
89
|
var import_signals_core2 = require("@preact/signals-core");
|
|
87
90
|
var import_context2 = require("@dxos/context");
|
|
91
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
88
92
|
var import_live_object2 = require("@dxos/live-object");
|
|
89
93
|
var import_schema = require("@dxos/schema");
|
|
94
|
+
var import_effect2 = require("effect");
|
|
90
95
|
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
91
96
|
var import_react_client = require("@dxos/react-client");
|
|
92
97
|
var import_echo3 = require("@dxos/react-client/echo");
|
|
93
98
|
var import_schema2 = require("@dxos/schema");
|
|
99
|
+
var import_effect3 = require("effect");
|
|
100
|
+
var import_SchemaAST = require("effect/SchemaAST");
|
|
94
101
|
var import_signals_core3 = require("@preact/signals-core");
|
|
95
102
|
var import_lodash = __toESM(require("lodash.orderby"));
|
|
96
103
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
97
|
-
var
|
|
104
|
+
var import_react_ui_form4 = require("@dxos/react-ui-form");
|
|
98
105
|
var import_signals_core4 = require("@preact/signals-core");
|
|
99
106
|
var import_log = require("@dxos/log");
|
|
100
107
|
var import_signals_core5 = require("@preact/signals-core");
|
|
108
|
+
var import_Predicate = require("effect/Predicate");
|
|
101
109
|
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
102
|
-
var
|
|
110
|
+
var import_react_ui_form5 = require("@dxos/react-ui-form");
|
|
103
111
|
var import_react_ui_grid3 = require("@dxos/react-ui-grid");
|
|
104
112
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
105
113
|
var import_schema3 = require("@dxos/schema");
|
|
106
|
-
var
|
|
114
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
115
|
+
var import_react6 = __toESM(require("react"));
|
|
107
116
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
108
117
|
var import_invariant3 = require("@dxos/invariant");
|
|
109
|
-
var
|
|
118
|
+
var import_react_ui6 = require("@dxos/react-ui");
|
|
110
119
|
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
111
120
|
var import_react_ui_grid4 = require("@dxos/react-ui-grid");
|
|
112
121
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
122
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
123
|
+
var import_react7 = __toESM(require("react"));
|
|
124
|
+
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
125
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
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");
|
|
113
130
|
var import_autocomplete = require("@codemirror/autocomplete");
|
|
114
131
|
var import_view = require("@codemirror/view");
|
|
132
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
115
133
|
var import_react8 = __toESM(require("react"));
|
|
116
134
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
117
135
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
136
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
118
137
|
var import_signals_core6 = require("@preact/signals-core");
|
|
119
138
|
var import_react9 = require("react");
|
|
120
139
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
121
140
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
122
|
-
var
|
|
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");
|
|
123
144
|
var import_react10 = __toESM(require("react"));
|
|
124
145
|
var import_live_object3 = require("@dxos/live-object");
|
|
125
146
|
var import_react_ui_menu = require("@dxos/react-ui-menu");
|
|
147
|
+
var import_react_ui_menu2 = require("@dxos/react-ui-menu");
|
|
126
148
|
var translationKey = "table";
|
|
127
149
|
var translations_default = [
|
|
128
150
|
{
|
|
@@ -154,224 +176,211 @@ var translations_default = [
|
|
|
154
176
|
}
|
|
155
177
|
];
|
|
156
178
|
var ColumnActionsMenu = ({ model, modals }) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
}
|
|
186
213
|
};
|
|
187
214
|
var ColumnSettings = ({ model, modals, onNewColumn }) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
model?.projection,
|
|
202
|
-
state
|
|
203
|
-
]);
|
|
204
|
-
const existingField = (0, import_react3.useMemo)(() => {
|
|
205
|
-
if (state?.type === "columnSettings") {
|
|
206
|
-
const { mode } = state;
|
|
207
|
-
if (mode.type === "edit") {
|
|
208
|
-
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);
|
|
209
228
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
state,
|
|
229
|
-
newField
|
|
230
|
-
]);
|
|
231
|
-
if (!model?.view || !model.projection || !field) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
return /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Root, {
|
|
235
|
-
modal: false,
|
|
236
|
-
open: state?.type === "columnSettings"
|
|
237
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.VirtualTrigger, {
|
|
238
|
-
virtualRef: modals.trigger
|
|
239
|
-
}), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Content, {
|
|
240
|
-
classNames: "md:is-64"
|
|
241
|
-
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form.FieldEditor, {
|
|
242
|
-
view: model.view,
|
|
243
|
-
projection: model.projection,
|
|
244
|
-
field,
|
|
245
|
-
registry: space?.db.schemaRegistry,
|
|
246
|
-
onSave: handleSave,
|
|
247
|
-
onCancel: handleCancel
|
|
248
|
-
})), /* @__PURE__ */ import_react3.default.createElement(import_react_ui3.DropdownMenu.Arrow, null))));
|
|
249
|
-
};
|
|
250
|
-
var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
251
|
-
const { id: gridId } = (0, import_react_ui_grid2.useGridContext)("TableCellEditor", __gridScope);
|
|
252
|
-
const space = model?.space;
|
|
253
|
-
const state = modals.state.value;
|
|
254
|
-
const schema = (0, import_react4.useMemo)(() => {
|
|
255
|
-
if (!space || state?.type !== "createRefPanel") {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
const [schema2] = space.db.schemaRegistry.query({
|
|
259
|
-
typename: state.typename
|
|
260
|
-
}).runSync();
|
|
261
|
-
if (schema2) {
|
|
262
|
-
const omit = import_echo_schema2.S.omit("id");
|
|
263
|
-
return omit(schema2);
|
|
264
|
-
}
|
|
265
|
-
}, [
|
|
266
|
-
space,
|
|
267
|
-
state
|
|
268
|
-
]);
|
|
269
|
-
const handleSave = (0, import_react4.useCallback)((values) => {
|
|
270
|
-
if (!model || !space || state?.type !== "createRefPanel") {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
const [schema2] = space.db.schemaRegistry.query({
|
|
274
|
-
typename: state.typename
|
|
275
|
-
}).runSync();
|
|
276
|
-
if (schema2) {
|
|
277
|
-
const obj = space.db.add((0, import_echo2.create)(schema2, values));
|
|
278
|
-
state.onCreate?.(obj);
|
|
279
|
-
}
|
|
280
|
-
void modals.close();
|
|
281
|
-
}, [
|
|
282
|
-
modals,
|
|
283
|
-
space,
|
|
284
|
-
state
|
|
285
|
-
]);
|
|
286
|
-
const handleCancel = (0, import_react4.useCallback)(() => {
|
|
287
|
-
if (model) {
|
|
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)(() => {
|
|
288
247
|
modals.close();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Popover.Root, {
|
|
297
|
-
modal: false,
|
|
298
|
-
open: state?.type === "createRefPanel" && !!schema,
|
|
299
|
-
onOpenChange: (nextOpen) => {
|
|
300
|
-
if (model && !nextOpen) {
|
|
301
|
-
return 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);
|
|
302
254
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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();
|
|
321
280
|
}
|
|
322
281
|
};
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
modal: false,
|
|
333
|
-
open: state?.type === "refPanel" && !!targetObj && !!schema,
|
|
334
|
-
onOpenChange: (nextOpen) => {
|
|
335
|
-
if (!nextOpen) {
|
|
336
|
-
return modals.close();
|
|
282
|
+
var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
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;
|
|
337
291
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
+
}
|
|
348
352
|
};
|
|
349
353
|
var RowActionsMenu = ({ model, modals }) => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
"
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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
|
+
}
|
|
373
382
|
};
|
|
374
|
-
var
|
|
383
|
+
var getBaseSchema = ({ typename, properties, jsonSchema, schema }) => {
|
|
375
384
|
if (typename && properties) {
|
|
376
385
|
const schema2 = (0, import_schema.getSchemaFromPropertyDefinitions)(typename, properties);
|
|
377
386
|
return {
|
|
@@ -380,8 +389,8 @@ var getBaseSchems = ({ typename, properties, jsonSchema, schema }) => {
|
|
|
380
389
|
};
|
|
381
390
|
} else if (schema) {
|
|
382
391
|
return {
|
|
383
|
-
typename: schema
|
|
384
|
-
jsonSchema: schema
|
|
392
|
+
typename: (0, import_echo_schema3.getTypename)(schema),
|
|
393
|
+
jsonSchema: (0, import_echo_schema3.toJsonSchema)(schema)
|
|
385
394
|
};
|
|
386
395
|
} else if (typename && jsonSchema) {
|
|
387
396
|
return {
|
|
@@ -401,7 +410,7 @@ var makeDynamicTable = ({ typename, jsonSchema, properties }) => {
|
|
|
401
410
|
fields: properties.map((property) => property.name)
|
|
402
411
|
}
|
|
403
412
|
});
|
|
404
|
-
const table = (0, import_live_object2.
|
|
413
|
+
const table = (0, import_live_object2.live)(import_chunk_CXDGXPM6.TableType, {
|
|
405
414
|
name: "dynamic-table",
|
|
406
415
|
view: (0, import_live_object2.makeRef)(view)
|
|
407
416
|
});
|
|
@@ -450,8 +459,8 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
450
459
|
if (!schema) {
|
|
451
460
|
throw new Error(`Schema not found: ${typename}`);
|
|
452
461
|
}
|
|
453
|
-
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).
|
|
454
|
-
table.view =
|
|
462
|
+
const fields = (0, import_schema2.getSchemaProperties)(schema.ast).map((prop) => prop.name);
|
|
463
|
+
table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
|
|
455
464
|
// TODO(ZaymonFC): Don't hardcode name?
|
|
456
465
|
name: "View",
|
|
457
466
|
typename: schema.typename,
|
|
@@ -464,7 +473,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
464
473
|
ContactSchema
|
|
465
474
|
]);
|
|
466
475
|
const fields = ContactFields;
|
|
467
|
-
table.view =
|
|
476
|
+
table.view = import_echo_schema4.Ref.make((0, import_schema2.createView)({
|
|
468
477
|
name: "View",
|
|
469
478
|
typename: schema.typename,
|
|
470
479
|
jsonSchema: schema.jsonSchema,
|
|
@@ -472,7 +481,7 @@ var initializeTable = async ({ client, space, table, typename, initialRow = true
|
|
|
472
481
|
}));
|
|
473
482
|
createProjection(schema, table.view.target);
|
|
474
483
|
if (initialRow) {
|
|
475
|
-
space.db.add((0, import_echo3.
|
|
484
|
+
space.db.add((0, import_echo3.live)(schema, {}));
|
|
476
485
|
}
|
|
477
486
|
return schema;
|
|
478
487
|
}
|
|
@@ -481,13 +490,13 @@ var ContactSchema = (0, import_echo_schema4.TypedObject)({
|
|
|
481
490
|
typename: `example.com/type/${import_react_client.PublicKey.random().truncate()}`,
|
|
482
491
|
version: "0.1.0"
|
|
483
492
|
})({
|
|
484
|
-
name:
|
|
485
|
-
|
|
493
|
+
name: import_effect2.Schema.optional(import_effect2.Schema.String).annotations({
|
|
494
|
+
title: "Name"
|
|
486
495
|
}),
|
|
487
|
-
active:
|
|
488
|
-
email:
|
|
489
|
-
salary:
|
|
490
|
-
|
|
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"
|
|
491
500
|
})
|
|
492
501
|
});
|
|
493
502
|
var ContactFields = [
|
|
@@ -538,7 +547,7 @@ var BUTTON_IDENTIFIERS = {
|
|
|
538
547
|
var createButton = ({ attr, data, disabled = false, icon, testId, type = "primary" }) => {
|
|
539
548
|
const dataAttrs = Object.entries(data).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
540
549
|
const positionClass = type === "primary" ? "inline-end-2" : "inline-end-9";
|
|
541
|
-
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>`;
|
|
542
551
|
};
|
|
543
552
|
var addColumnButton = {
|
|
544
553
|
attr: BUTTON_IDENTIFIERS.newColumn,
|
|
@@ -574,26 +583,6 @@ var columnSettingsButton = {
|
|
|
574
583
|
fieldId: el.getAttribute("data-field-id")
|
|
575
584
|
})
|
|
576
585
|
};
|
|
577
|
-
var referencedCellButton = {
|
|
578
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
579
|
-
icon: "ph--link-simple-horizontal--regular",
|
|
580
|
-
render: ({ targetId, schemaId }) => {
|
|
581
|
-
return createButton({
|
|
582
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
583
|
-
icon: referencedCellButton.icon,
|
|
584
|
-
data: {
|
|
585
|
-
"data-target-id": targetId,
|
|
586
|
-
"data-schema-id": schemaId
|
|
587
|
-
},
|
|
588
|
-
testId: "table-ref-cell-button"
|
|
589
|
-
});
|
|
590
|
-
},
|
|
591
|
-
getData: (el) => ({
|
|
592
|
-
type: "referencedCell",
|
|
593
|
-
targetId: el.getAttribute("data-target-id"),
|
|
594
|
-
schemaId: el.getAttribute("data-schema-id")
|
|
595
|
-
})
|
|
596
|
-
};
|
|
597
586
|
var rowMenuButton = {
|
|
598
587
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
599
588
|
icon: "ph--dots-three--regular",
|
|
@@ -638,7 +627,6 @@ var sortButton = {
|
|
|
638
627
|
var tableButtons = {
|
|
639
628
|
addColumn: addColumnButton,
|
|
640
629
|
columnSettings: columnSettingsButton,
|
|
641
|
-
referencedCell: referencedCellButton,
|
|
642
630
|
rowMenu: rowMenuButton,
|
|
643
631
|
sort: sortButton
|
|
644
632
|
};
|
|
@@ -694,14 +682,20 @@ var tableControls = {
|
|
|
694
682
|
})
|
|
695
683
|
}
|
|
696
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
|
+
};
|
|
697
696
|
var SelectionModel = class extends import_context2.Resource {
|
|
698
697
|
constructor(_rows, _selectionMode, _onSelectionChanged) {
|
|
699
|
-
super()
|
|
700
|
-
this._rows = _rows;
|
|
701
|
-
this._selectionMode = _selectionMode;
|
|
702
|
-
this._onSelectionChanged = _onSelectionChanged;
|
|
703
|
-
this._selection = (0, import_signals_core2.signal)(/* @__PURE__ */ new Set());
|
|
704
|
-
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)(() => {
|
|
705
699
|
const rows = this._rows.value;
|
|
706
700
|
if (!rows) {
|
|
707
701
|
return /* @__PURE__ */ new Set();
|
|
@@ -710,27 +704,21 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
710
704
|
return new Set([
|
|
711
705
|
...this._selection.value
|
|
712
706
|
].filter((id) => validIds.has(id)));
|
|
713
|
-
})
|
|
714
|
-
this._hasSelection = (0, import_signals_core2.computed)(() => this._validSelectedIds.value.size > 0);
|
|
715
|
-
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)(() => {
|
|
716
708
|
const rows = this._rows.value;
|
|
717
709
|
if (rows.length === 0) {
|
|
718
710
|
return false;
|
|
719
711
|
}
|
|
720
712
|
return rows.every((row) => this._selection.value.has(row.id));
|
|
721
|
-
})
|
|
722
|
-
this.getSelectedRows = () => {
|
|
713
|
+
}), this.getSelectedRows = () => {
|
|
723
714
|
const selectedIds = this._validSelectedIds.value;
|
|
724
715
|
return this._rows.value.filter((row) => selectedIds.has(row.id));
|
|
725
|
-
}
|
|
726
|
-
this.isRowIndexSelected = (rowIndex) => {
|
|
716
|
+
}, this.isRowIndexSelected = (rowIndex) => {
|
|
727
717
|
const row = this._rows.value[rowIndex];
|
|
728
718
|
return this._selection.value.has(row.id);
|
|
729
|
-
}
|
|
730
|
-
this.isObjectSelected = (object) => {
|
|
719
|
+
}, this.isObjectSelected = (object) => {
|
|
731
720
|
return this._selection.value.has(object.id);
|
|
732
|
-
}
|
|
733
|
-
this.toggleSelectionForRowIndex = (rowIndex) => {
|
|
721
|
+
}, this.toggleSelectionForRowIndex = (rowIndex) => {
|
|
734
722
|
const row = this._rows.value[rowIndex];
|
|
735
723
|
const newSelection = new Set(this._selection.value);
|
|
736
724
|
if (newSelection.has(row.id)) {
|
|
@@ -742,8 +730,7 @@ var SelectionModel = class extends import_context2.Resource {
|
|
|
742
730
|
newSelection.add(row.id);
|
|
743
731
|
}
|
|
744
732
|
this._selection.value = newSelection;
|
|
745
|
-
}
|
|
746
|
-
this.setSelection = (mode) => {
|
|
733
|
+
}, this.setSelection = (mode) => {
|
|
747
734
|
switch (mode) {
|
|
748
735
|
case "all": {
|
|
749
736
|
this._selection.value = new Set(this._rows.value.map((row) => row.id));
|
|
@@ -931,13 +918,27 @@ var TableSorting = class {
|
|
|
931
918
|
const refValue = (0, import_echo_schema5.getValue)(value.target, field.referencePath);
|
|
932
919
|
return refValue;
|
|
933
920
|
}
|
|
934
|
-
return (0,
|
|
921
|
+
return (0, import_react_ui_form4.formatForDisplay)({
|
|
935
922
|
type,
|
|
936
923
|
format,
|
|
937
924
|
value
|
|
938
925
|
});
|
|
939
926
|
}
|
|
940
927
|
};
|
|
928
|
+
var TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
929
|
+
var extractTagIds = (value) => {
|
|
930
|
+
if (typeof value !== "string") {
|
|
931
|
+
return void 0;
|
|
932
|
+
}
|
|
933
|
+
const ids = [];
|
|
934
|
+
let match;
|
|
935
|
+
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
936
|
+
if (match[2]) {
|
|
937
|
+
ids.push(match[2]);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return ids.length > 0 ? ids : void 0;
|
|
941
|
+
};
|
|
941
942
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/model/table-model.ts";
|
|
942
943
|
var defaultFeatures = {
|
|
943
944
|
selection: {
|
|
@@ -1002,20 +1003,20 @@ var TableModel = class extends import_context.Resource {
|
|
|
1002
1003
|
}
|
|
1003
1004
|
const field = fields[col];
|
|
1004
1005
|
const dataIndex = this._sorting.getDataIndex(row);
|
|
1005
|
-
const value = (0,
|
|
1006
|
+
const value = (0, import_echo_schema2.getValue)(this._rows.value[dataIndex], field.path);
|
|
1006
1007
|
if (value == null) {
|
|
1007
1008
|
return "";
|
|
1008
1009
|
}
|
|
1009
1010
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
1010
1011
|
switch (props.format) {
|
|
1011
|
-
case
|
|
1012
|
+
case import_echo_schema2.FormatEnum.Ref: {
|
|
1012
1013
|
if (!field.referencePath) {
|
|
1013
1014
|
return "";
|
|
1014
1015
|
}
|
|
1015
|
-
return (0,
|
|
1016
|
+
return (0, import_echo_schema2.getValue)(value.target, field.referencePath);
|
|
1016
1017
|
}
|
|
1017
1018
|
default: {
|
|
1018
|
-
return (0,
|
|
1019
|
+
return (0, import_react_ui_form3.formatForEditing)({
|
|
1019
1020
|
type: props.type,
|
|
1020
1021
|
format: props.format,
|
|
1021
1022
|
value
|
|
@@ -1032,14 +1033,28 @@ var TableModel = class extends import_context.Resource {
|
|
|
1032
1033
|
const field = fields[col];
|
|
1033
1034
|
const { props } = this._projection.getFieldProjection(field.id);
|
|
1034
1035
|
switch (props.format) {
|
|
1035
|
-
case
|
|
1036
|
-
if ((0, import_live_object.
|
|
1037
|
-
(0,
|
|
1036
|
+
case import_echo_schema2.FormatEnum.Ref: {
|
|
1037
|
+
if ((0, import_live_object.isLiveObject)(value)) {
|
|
1038
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_live_object.makeRef)(value));
|
|
1039
|
+
}
|
|
1040
|
+
break;
|
|
1041
|
+
}
|
|
1042
|
+
case import_echo_schema2.FormatEnum.SingleSelect: {
|
|
1043
|
+
const ids = extractTagIds(value);
|
|
1044
|
+
if (ids && ids.length > 0) {
|
|
1045
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids[0]);
|
|
1046
|
+
}
|
|
1047
|
+
break;
|
|
1048
|
+
}
|
|
1049
|
+
case import_echo_schema2.FormatEnum.MultiSelect: {
|
|
1050
|
+
const ids = extractTagIds(value);
|
|
1051
|
+
if (ids) {
|
|
1052
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, ids);
|
|
1038
1053
|
}
|
|
1039
1054
|
break;
|
|
1040
1055
|
}
|
|
1041
1056
|
default: {
|
|
1042
|
-
(0,
|
|
1057
|
+
(0, import_echo_schema2.setValue)(this._rows.value[rowIdx], field.path, (0, import_react_ui_form3.parseValue)({
|
|
1043
1058
|
type: props.type,
|
|
1044
1059
|
format: props.format,
|
|
1045
1060
|
value
|
|
@@ -1058,7 +1073,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1058
1073
|
};
|
|
1059
1074
|
(0, import_invariant2.invariant)(!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === "single"), "Single selection is not compatible with editable tables.", {
|
|
1060
1075
|
F: __dxlog_file,
|
|
1061
|
-
L:
|
|
1076
|
+
L: 115,
|
|
1062
1077
|
S: this,
|
|
1063
1078
|
A: [
|
|
1064
1079
|
"!(this._features.dataEditable && this._features.selection.enabled && this._features.selection.mode === 'single')",
|
|
@@ -1118,7 +1133,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1118
1133
|
get columnMeta() {
|
|
1119
1134
|
(0, import_invariant2.invariant)(this._columnMeta, void 0, {
|
|
1120
1135
|
F: __dxlog_file,
|
|
1121
|
-
L:
|
|
1136
|
+
L: 184,
|
|
1122
1137
|
S: this,
|
|
1123
1138
|
A: [
|
|
1124
1139
|
"this._columnMeta",
|
|
@@ -1185,7 +1200,7 @@ var TableModel = class extends import_context.Resource {
|
|
|
1185
1200
|
for (let row = start.row; row <= end.row; row++) {
|
|
1186
1201
|
rowEffects.push((0, import_signals_core.effect)(() => {
|
|
1187
1202
|
const obj = this._sorting.sortedRows.value[row];
|
|
1188
|
-
this._view?.fields.forEach((field) => touch((0,
|
|
1203
|
+
this._view?.fields.forEach((field) => touch((0, import_echo_schema2.getValue)(obj, field.path)));
|
|
1189
1204
|
this._onCellUpdate?.({
|
|
1190
1205
|
row,
|
|
1191
1206
|
col: start.col,
|
|
@@ -1206,9 +1221,9 @@ var TableModel = class extends import_context.Resource {
|
|
|
1206
1221
|
const dataRow = this._sorting.getDataIndex(row);
|
|
1207
1222
|
const fields = this._view?.fields ?? [];
|
|
1208
1223
|
const field = fields[col];
|
|
1209
|
-
const value = (0,
|
|
1224
|
+
const value = (0, import_echo_schema2.getValue)(this._rows.value[dataRow], field.path);
|
|
1210
1225
|
const updatedValue = update(value);
|
|
1211
|
-
(0,
|
|
1226
|
+
(0, import_echo_schema2.setValue)(this._rows.value[dataRow], field.path, updatedValue);
|
|
1212
1227
|
}
|
|
1213
1228
|
//
|
|
1214
1229
|
// Column Operations
|
|
@@ -1394,6 +1409,9 @@ var TablePresentation = class {
|
|
|
1394
1409
|
if (value == null) {
|
|
1395
1410
|
return "";
|
|
1396
1411
|
}
|
|
1412
|
+
if (props.type === "array") {
|
|
1413
|
+
return "";
|
|
1414
|
+
}
|
|
1397
1415
|
switch (props.format) {
|
|
1398
1416
|
case import_echo_schema6.FormatEnum.Boolean:
|
|
1399
1417
|
case import_echo_schema6.FormatEnum.SingleSelect:
|
|
@@ -1407,7 +1425,7 @@ var TablePresentation = class {
|
|
|
1407
1425
|
return (0, import_echo_schema6.getValue)(value.target, field.referencePath);
|
|
1408
1426
|
}
|
|
1409
1427
|
default: {
|
|
1410
|
-
return (0,
|
|
1428
|
+
return (0, import_react_ui_form5.formatForDisplay)({
|
|
1411
1429
|
type: props.type,
|
|
1412
1430
|
format: props.format,
|
|
1413
1431
|
value
|
|
@@ -1417,7 +1435,7 @@ var TablePresentation = class {
|
|
|
1417
1435
|
}
|
|
1418
1436
|
};
|
|
1419
1437
|
const classes = [];
|
|
1420
|
-
const formatClasses = (0,
|
|
1438
|
+
const formatClasses = (0, import_react_ui_form5.cellClassesForFieldType)({
|
|
1421
1439
|
type: props.type,
|
|
1422
1440
|
format: props.format
|
|
1423
1441
|
});
|
|
@@ -1431,13 +1449,38 @@ var TablePresentation = class {
|
|
|
1431
1449
|
if (classes.length > 0) {
|
|
1432
1450
|
cell.className = (0, import_react_ui_theme2.mx)(classes.flat());
|
|
1433
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
|
+
}
|
|
1434
1479
|
if (props.format === import_echo_schema6.FormatEnum.Ref && props.referenceSchema) {
|
|
1435
1480
|
const targetObj = (0, import_echo_schema6.getValue)(obj, field.path)?.target;
|
|
1436
1481
|
if (targetObj) {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
schemaId: props.referenceSchema
|
|
1440
|
-
});
|
|
1482
|
+
const dxn = (0, import_echo_schema6.getDXN)(targetObj)?.toString();
|
|
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>`;
|
|
1441
1484
|
}
|
|
1442
1485
|
}
|
|
1443
1486
|
if (props.format === import_echo_schema6.FormatEnum.Boolean) {
|
|
@@ -1471,7 +1514,7 @@ var TablePresentation = class {
|
|
|
1471
1514
|
return null;
|
|
1472
1515
|
}).filter(Boolean).join(" ");
|
|
1473
1516
|
if (tags) {
|
|
1474
|
-
cell.accessoryHtml = tags
|
|
1517
|
+
cell.accessoryHtml = `<div role='none' class="flex flex-row gap-1">${tags}</div>`;
|
|
1475
1518
|
}
|
|
1476
1519
|
}
|
|
1477
1520
|
}
|
|
@@ -1516,7 +1559,7 @@ var TablePresentation = class {
|
|
|
1516
1559
|
fieldId: field.id
|
|
1517
1560
|
})}
|
|
1518
1561
|
`,
|
|
1519
|
-
className: "!bg-
|
|
1562
|
+
className: "!bg-toolbarSurface"
|
|
1520
1563
|
};
|
|
1521
1564
|
}
|
|
1522
1565
|
return cells;
|
|
@@ -1567,7 +1610,7 @@ var TablePresentation = class {
|
|
|
1567
1610
|
col: 0,
|
|
1568
1611
|
row: 0
|
|
1569
1612
|
})]: {
|
|
1570
|
-
className: "!bg-
|
|
1613
|
+
className: "!bg-toolbarSurface",
|
|
1571
1614
|
readonly: true,
|
|
1572
1615
|
value: ""
|
|
1573
1616
|
}
|
|
@@ -1583,7 +1626,7 @@ var TablePresentation = class {
|
|
|
1583
1626
|
header: true,
|
|
1584
1627
|
checked: this.model.selection.allRowsSeleted.value
|
|
1585
1628
|
}),
|
|
1586
|
-
className: "!bg-
|
|
1629
|
+
className: "!bg-toolbarSurface",
|
|
1587
1630
|
readonly: true,
|
|
1588
1631
|
value: ""
|
|
1589
1632
|
}
|
|
@@ -1598,7 +1641,7 @@ var TablePresentation = class {
|
|
|
1598
1641
|
accessoryHtml: this.model.features.schemaEditable ? tableButtons.addColumn.render({
|
|
1599
1642
|
disabled: (this.model.view?.fields?.length ?? 0) >= import_schema3.VIEW_FIELD_LIMIT
|
|
1600
1643
|
}) : void 0,
|
|
1601
|
-
className: "!bg-
|
|
1644
|
+
className: "!bg-toolbarSurface",
|
|
1602
1645
|
readonly: true,
|
|
1603
1646
|
value: ""
|
|
1604
1647
|
}
|
|
@@ -1627,6 +1670,97 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1627
1670
|
];
|
|
1628
1671
|
}
|
|
1629
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
|
+
};
|
|
1630
1764
|
var completion = ({ debug, onQuery, onMatch }) => {
|
|
1631
1765
|
return [
|
|
1632
1766
|
import_view.EditorView.theme({
|
|
@@ -1662,218 +1796,268 @@ var completion = ({ debug, onQuery, onMatch }) => {
|
|
|
1662
1796
|
})
|
|
1663
1797
|
];
|
|
1664
1798
|
};
|
|
1665
|
-
var
|
|
1799
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
|
|
1666
1800
|
var newValue = Symbol.for("newValue");
|
|
1667
1801
|
var createOption = (text) => ({
|
|
1668
1802
|
[newValue]: true,
|
|
1669
1803
|
text
|
|
1670
1804
|
});
|
|
1671
1805
|
var isCreateOption = (data) => typeof data === "object" && data[newValue];
|
|
1672
|
-
var
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
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
|
+
});
|
|
1679
1838
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
A: [
|
|
1688
|
-
"fieldProjection",
|
|
1689
|
-
""
|
|
1690
|
-
]
|
|
1839
|
+
return /* @__PURE__ */ import_react6.default.createElement(TableCellEditor, {
|
|
1840
|
+
model,
|
|
1841
|
+
modals,
|
|
1842
|
+
onEnter,
|
|
1843
|
+
onFocus,
|
|
1844
|
+
onQuery,
|
|
1845
|
+
__gridScope
|
|
1691
1846
|
});
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
const
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
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);
|
|
1723
1883
|
model.setCellData(cell, value);
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
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
|
+
}
|
|
1783
1965
|
}
|
|
1784
1966
|
}
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}
|
|
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);
|
|
1805
1989
|
}
|
|
1806
|
-
} else {
|
|
1807
|
-
handleEnter(data);
|
|
1808
1990
|
}
|
|
1809
1991
|
}
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1992
|
+
})
|
|
1993
|
+
]);
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1814
1996
|
}
|
|
1815
1997
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
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);
|
|
1839
2032
|
if (option) {
|
|
1840
|
-
|
|
1841
|
-
id,
|
|
2033
|
+
const tagItem = {
|
|
2034
|
+
id: value2,
|
|
1842
2035
|
label: option.title,
|
|
1843
2036
|
hue: option.color
|
|
1844
2037
|
};
|
|
2038
|
+
return (0, import_react_ui_tag_picker.createLinks)([
|
|
2039
|
+
tagItem
|
|
2040
|
+
]);
|
|
1845
2041
|
}
|
|
1846
|
-
return void 0;
|
|
1847
|
-
}).filter((item) => item !== void 0);
|
|
1848
|
-
return (0, import_react_ui_tag_picker.createLinks)(tagItems);
|
|
1849
|
-
} else {
|
|
1850
|
-
const option = options.find((o) => o.id === value2);
|
|
1851
|
-
if (option) {
|
|
1852
|
-
const tagItem = {
|
|
1853
|
-
id: value2,
|
|
1854
|
-
label: option.title,
|
|
1855
|
-
hue: option.color
|
|
1856
|
-
};
|
|
1857
|
-
return (0, import_react_ui_tag_picker.createLinks)([
|
|
1858
|
-
tagItem
|
|
1859
|
-
]);
|
|
1860
2042
|
}
|
|
1861
2043
|
}
|
|
2044
|
+
return "";
|
|
1862
2045
|
}
|
|
1863
|
-
|
|
2046
|
+
const value = model.getCellData(cell);
|
|
2047
|
+
return value !== void 0 ? String(value) : "";
|
|
1864
2048
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
}
|
|
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
|
+
}
|
|
1877
2061
|
};
|
|
1878
2062
|
var determineNavigationAxis = ({ key }) => {
|
|
1879
2063
|
switch (key) {
|
|
@@ -1899,422 +2083,438 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1899
2083
|
}
|
|
1900
2084
|
return shift ? -1 : 1;
|
|
1901
2085
|
};
|
|
1902
|
-
var
|
|
1903
|
-
var inlineEndLine = "[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-block-0 [&>.dx-grid]:after:-inline-end-px [&>.dx-grid]:after:is-px [&>.dx-grid]:after:bg-separator";
|
|
1904
|
-
var blockEndLine = "[&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-inline-0 [&>.dx-grid]:before:-block-end-px [&>.dx-grid]:before:bs-px [&>.dx-grid]:before:bg-separator";
|
|
2086
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1905
2087
|
var TableRoot = ({ children, role }) => {
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
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
|
+
}
|
|
1910
2097
|
};
|
|
1911
|
-
var TableMain = /* @__PURE__ */ (0, import_react.forwardRef)(({ model, presentation, ignoreAttention, onRowClick }, forwardedRef) => {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
]);
|
|
1935
|
-
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
1936
|
-
if (!presentation || !dxGrid) {
|
|
1937
|
-
return {};
|
|
1938
|
-
}
|
|
1939
|
-
return {
|
|
1940
|
-
update: (cell) => {
|
|
1941
|
-
if (cell) {
|
|
1942
|
-
dxGrid.updateIfWithinBounds(cell);
|
|
1943
|
-
} else {
|
|
1944
|
-
dxGrid.updateCells(true);
|
|
1945
|
-
dxGrid.requestUpdate();
|
|
1946
|
-
}
|
|
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;
|
|
1947
2121
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
const row = model?.getRowAt(rowIndex);
|
|
1958
|
-
row && onRowClick(row);
|
|
1959
|
-
}
|
|
1960
|
-
if (model?.features.selection.enabled && model?.selection.selectionMode === "single") {
|
|
1961
|
-
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 {};
|
|
1962
2131
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
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) {
|
|
1972
2158
|
return;
|
|
1973
2159
|
}
|
|
1974
|
-
|
|
1975
|
-
const
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
}
|
|
1981
|
-
case "columnSettings": {
|
|
1982
|
-
modals.showColumnMenu(data.fieldId);
|
|
1983
|
-
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;
|
|
1984
2166
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
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
|
+
}
|
|
1988
2186
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
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;
|
|
1992
2195
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
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
|
+
}
|
|
1996
2215
|
}
|
|
1997
2216
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
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) {
|
|
2005
2230
|
return;
|
|
2006
2231
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
}
|
|
2015
|
-
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
|
+
});
|
|
2016
2239
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
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);
|
|
2024
2257
|
break;
|
|
2025
2258
|
}
|
|
2026
2259
|
}
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
dxGrid.refocus(increment, delta);
|
|
2035
|
-
}
|
|
2036
|
-
}, [
|
|
2037
|
-
dxGrid
|
|
2038
|
-
]);
|
|
2039
|
-
const handleEnter = (0, import_react.useCallback)((cell) => {
|
|
2040
|
-
if (!model?.features.dataEditable) {
|
|
2041
|
-
return;
|
|
2042
|
-
}
|
|
2043
|
-
if (model && cell.row === model.getRowCount() - 1) {
|
|
2044
|
-
model.insertRow(cell.row);
|
|
2045
|
-
if (dxGrid) {
|
|
2046
|
-
requestAnimationFrame(() => {
|
|
2047
|
-
dxGrid?.scrollToRow(cell.row + 1);
|
|
2048
|
-
dxGrid?.refocus("row", 1);
|
|
2049
|
-
});
|
|
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);
|
|
2050
2267
|
}
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
if (!model?.features.dataEditable) {
|
|
2058
|
-
return;
|
|
2059
|
-
}
|
|
2060
|
-
const cell = (0, import_react_ui_grid.closestCell)(event.target);
|
|
2061
|
-
if (!model || !cell) {
|
|
2062
|
-
return;
|
|
2063
|
-
}
|
|
2064
|
-
switch (event.key) {
|
|
2065
|
-
case "Backspace":
|
|
2066
|
-
case "Delete": {
|
|
2067
|
-
model.setCellData(cell, void 0);
|
|
2068
|
-
break;
|
|
2268
|
+
}, [
|
|
2269
|
+
model
|
|
2270
|
+
]);
|
|
2271
|
+
const handleWheel = (0, import_react.useCallback)((event) => {
|
|
2272
|
+
if (!ignoreAttention && !hasAttention) {
|
|
2273
|
+
event.stopPropagation();
|
|
2069
2274
|
}
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
}
|
|
2119
|
-
return {
|
|
2120
|
-
label: value,
|
|
2121
|
-
data: obj
|
|
2122
|
-
};
|
|
2123
|
-
}).filter(import_util.isNotFalsy);
|
|
2124
|
-
return [
|
|
2125
|
-
...options,
|
|
2126
|
-
{
|
|
2127
|
-
label: t("create new object label", {
|
|
2128
|
-
text
|
|
2129
|
-
}),
|
|
2130
|
-
data: createOption(text)
|
|
2131
|
-
}
|
|
2132
|
-
];
|
|
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
|
+
}
|
|
2133
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
|
+
});
|
|
2134
2334
|
}
|
|
2135
|
-
return
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
})
|
|
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();
|
|
2145
2373
|
}
|
|
2146
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Root, {
|
|
2147
|
-
id: model.id ?? "table-grid"
|
|
2148
|
-
}, /* @__PURE__ */ import_react.default.createElement(TableCellEditor, {
|
|
2149
|
-
model,
|
|
2150
|
-
modals,
|
|
2151
|
-
onEnter: handleEnter,
|
|
2152
|
-
onFocus: handleFocus,
|
|
2153
|
-
onQuery: handleQuery
|
|
2154
|
-
}), /* @__PURE__ */ import_react.default.createElement(import_react_ui_grid.Grid.Content, {
|
|
2155
|
-
className: (0, import_react_ui_theme.mx)("[--dx-grid-base:var(--surface-bg)]", inlineEndLine, blockEndLine),
|
|
2156
|
-
frozen,
|
|
2157
|
-
// getCells={getCells}
|
|
2158
|
-
columns: model.columnMeta.value,
|
|
2159
|
-
limitRows: model.getRowCount() ?? 0,
|
|
2160
|
-
limitColumns: model.view?.fields?.length ?? 0,
|
|
2161
|
-
overscroll: "trap",
|
|
2162
|
-
onAxisResize: handleAxisResize,
|
|
2163
|
-
onClick: handleGridClick,
|
|
2164
|
-
onKeyDown: handleKeyDown,
|
|
2165
|
-
onWheelCapture: handleWheel,
|
|
2166
|
-
ref: setDxGrid
|
|
2167
|
-
}), /* @__PURE__ */ import_react.default.createElement(RowActionsMenu, {
|
|
2168
|
-
model,
|
|
2169
|
-
modals
|
|
2170
|
-
}), /* @__PURE__ */ import_react.default.createElement(ColumnActionsMenu, {
|
|
2171
|
-
model,
|
|
2172
|
-
modals
|
|
2173
|
-
}), /* @__PURE__ */ import_react.default.createElement(ColumnSettings, {
|
|
2174
|
-
model,
|
|
2175
|
-
modals,
|
|
2176
|
-
onNewColumn: handleNewColumn
|
|
2177
|
-
}), /* @__PURE__ */ import_react.default.createElement(CreateRefPanel, {
|
|
2178
|
-
model,
|
|
2179
|
-
modals
|
|
2180
|
-
}), /* @__PURE__ */ import_react.default.createElement(RefPanel, {
|
|
2181
|
-
model,
|
|
2182
|
-
modals
|
|
2183
|
-
}));
|
|
2184
2374
|
});
|
|
2185
2375
|
var Table = {
|
|
2186
2376
|
Root: TableRoot,
|
|
2187
2377
|
Main: TableMain
|
|
2188
2378
|
};
|
|
2189
2379
|
var useTableModel = ({ table, projection, rows, rowActions, features, onSelectionChanged, onRowAction, ...props }) => {
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
model2
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
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);
|
|
2206
2401
|
});
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
model
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
model
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
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
|
+
}
|
|
2253
2448
|
};
|
|
2254
2449
|
var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, properties, jsonSchema, schema, rowActions, onRowClick, onRowAction, ...props }) => {
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
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,
|
|
2258
2465
|
properties,
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
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
|
|
2265
2491
|
});
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
features,
|
|
2290
|
-
rowActions,
|
|
2291
|
-
onCellUpdate: handleCellUpdate,
|
|
2292
|
-
onRowOrderChange: handleRowOrderChange,
|
|
2293
|
-
onRowAction
|
|
2294
|
-
});
|
|
2295
|
-
const presentation = (0, import_react8.useMemo)(() => {
|
|
2296
|
-
if (model) {
|
|
2297
|
-
return new TablePresentation(model);
|
|
2298
|
-
}
|
|
2299
|
-
}, [
|
|
2300
|
-
model
|
|
2301
|
-
]);
|
|
2302
|
-
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2303
|
-
role: "none",
|
|
2304
|
-
className: (0, import_react_ui_theme3.mx)("is-full bs-full grow grid", classNames)
|
|
2305
|
-
}, /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
2306
|
-
role: "none",
|
|
2307
|
-
className: "grid min-bs-0 overflow-hidden"
|
|
2308
|
-
}, /* @__PURE__ */ import_react8.default.createElement(Table.Root, null, /* @__PURE__ */ import_react8.default.createElement(Table.Main, {
|
|
2309
|
-
ref: tableRef,
|
|
2310
|
-
model,
|
|
2311
|
-
presentation,
|
|
2312
|
-
ignoreAttention: true,
|
|
2313
|
-
onRowClick
|
|
2314
|
-
}))));
|
|
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
|
+
}
|
|
2315
2515
|
};
|
|
2316
|
-
var createTableToolbarActions = (state) => {
|
|
2317
|
-
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, {
|
|
2318
2518
|
type: "add-row",
|
|
2319
2519
|
icon: "ph--plus--regular",
|
|
2320
2520
|
label: [
|
|
@@ -2325,7 +2525,7 @@ var createTableToolbarActions = (state) => {
|
|
|
2325
2525
|
],
|
|
2326
2526
|
testId: "table.toolbar.add-row"
|
|
2327
2527
|
});
|
|
2328
|
-
const save = (0, import_react_ui_menu.createMenuAction)("save-view", {
|
|
2528
|
+
const save = (0, import_react_ui_menu.createMenuAction)("save-view", onSave, {
|
|
2329
2529
|
type: "save-view",
|
|
2330
2530
|
icon: "ph--floppy-disk--regular",
|
|
2331
2531
|
label: [
|
|
@@ -2336,49 +2536,55 @@ var createTableToolbarActions = (state) => {
|
|
|
2336
2536
|
],
|
|
2337
2537
|
testId: "table.toolbar.save-view",
|
|
2338
2538
|
iconOnly: false,
|
|
2339
|
-
hidden: !state.viewDirty
|
|
2539
|
+
hidden: get((0, import_react_ui_menu2.rxFromSignal)(() => !state.viewDirty))
|
|
2340
2540
|
});
|
|
2341
2541
|
const gap = (0, import_react_ui_menu.createGapSeparator)();
|
|
2342
|
-
const comment = (0, import_react_ui_menu.createMenuAction)("comment", {
|
|
2343
|
-
type: "comment",
|
|
2344
|
-
icon: "ph--chat-text--regular",
|
|
2345
|
-
label: [
|
|
2346
|
-
"create comment",
|
|
2347
|
-
{
|
|
2348
|
-
ns: translationKey
|
|
2349
|
-
}
|
|
2350
|
-
],
|
|
2351
|
-
testId: "table.toolbar.comment"
|
|
2352
|
-
});
|
|
2353
2542
|
const nodes = [
|
|
2354
2543
|
add,
|
|
2355
2544
|
save,
|
|
2356
|
-
...gap.nodes
|
|
2357
|
-
comment
|
|
2545
|
+
...gap.nodes
|
|
2358
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
|
+
}
|
|
2359
2556
|
return {
|
|
2360
2557
|
nodes,
|
|
2361
|
-
edges
|
|
2362
|
-
source: "root",
|
|
2363
|
-
target
|
|
2364
|
-
}))
|
|
2558
|
+
edges
|
|
2365
2559
|
};
|
|
2366
|
-
};
|
|
2367
|
-
var TableToolbar = ({ classNames, viewDirty, attendableId,
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
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
|
+
}
|
|
2382
2588
|
};
|
|
2383
2589
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2384
2590
|
0 && (module.exports = {
|
|
@@ -2395,9 +2601,10 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
2395
2601
|
TableToolbar,
|
|
2396
2602
|
TableType,
|
|
2397
2603
|
cellClassesForRowSelection,
|
|
2398
|
-
|
|
2604
|
+
getBaseSchema,
|
|
2399
2605
|
initializeTable,
|
|
2400
2606
|
makeDynamicTable,
|
|
2607
|
+
narrowSchema,
|
|
2401
2608
|
tableButtons,
|
|
2402
2609
|
tableControls,
|
|
2403
2610
|
touch,
|