@wavemaker-ai/react-runtime 1.0.0-rc.324 → 1.0.0-rc.328
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/components/basic/anchor/index.js +3 -0
- package/components/basic/icon/index.js +36 -5
- package/components/basic/iframe/index.js +18 -8
- package/components/basic/label/index.js +4 -3
- package/components/basic/search/index.d.ts +72 -3
- package/components/basic/search/index.js +75 -21
- package/components/basic/search/props.d.ts +4 -0
- package/components/common/WmAppIcon/index.js +11 -8
- package/components/common/WmAppIcon/props.d.ts +2 -0
- package/components/container/accordion/accordion-pane/index.d.ts +1 -0
- package/components/container/accordion/accordion-pane/index.js +7 -3
- package/components/container/accordion/accordion-pane/props.d.ts +1 -0
- package/components/container/index.js +18 -5
- package/components/container/layout-grid/grid-row/index.js +1 -1
- package/components/container/panel/components/panel-header/index.js +1 -3
- package/components/container/tabs/tab-pane/index.d.ts +1 -0
- package/components/container/tabs/tab-pane/index.js +2 -2
- package/components/container/tabs/tab-pane/props.d.ts +1 -0
- package/components/container/wizard/index.js +11 -10
- package/components/container/wizard/utils.js +1 -0
- package/components/data/form/base-form/hooks/useFormSubmission.d.ts +1 -1
- package/components/data/form/base-form/hooks/useFormSubmission.js +3 -1
- package/components/data/form/base-form/index.js +11 -14
- package/components/data/form/base-form/props.d.ts +3 -0
- package/components/data/form/dynamic-fields/WmxDynamicFormField.d.ts +11 -0
- package/components/data/form/dynamic-fields/WmxDynamicFormField.js +77 -0
- package/components/data/form/dynamic-fields/index.js +12 -1
- package/components/data/form/form-controller/withFormController.js +19 -16
- package/components/data/form/form-field/base-field.js +8 -5
- package/components/data/form/form-field/index.js +15 -8
- package/components/data/form/form-field/props.d.ts +1 -0
- package/components/data/list/components/ListItemWithTemplate.js +5 -2
- package/components/data/list/hooks/useListEffects.js +1 -1
- package/components/data/list/index.js +14 -5
- package/components/data/list/utils/constants.d.ts +0 -1
- package/components/data/list/utils/constants.js +0 -2
- package/components/data/table/components/RowCells.js +20 -4
- package/components/data/table/components/TableBody.js +5 -3
- package/components/data/table/components/TableHeader.js +14 -8
- package/components/data/table/components/TablePanelHeading.js +1 -1
- package/components/data/table/hooks/useDynamicColumns.js +1 -1
- package/components/data/table/hooks/useRowExpansion.js +41 -31
- package/components/data/table/hooks/useRowHandlers.d.ts +4 -2
- package/components/data/table/hooks/useRowHandlers.js +23 -12
- package/components/data/table/hooks/useRowSelection.d.ts +1 -1
- package/components/data/table/hooks/useRowSelection.js +80 -66
- package/components/data/table/hooks/useServerSideSorting.js +0 -1
- package/components/data/table/hooks/useTableColumns.js +16 -8
- package/components/data/table/hooks/useTableData.js +0 -1
- package/components/data/table/hooks/useTableEdit.js +0 -1
- package/components/data/table/hooks/useTableState.js +14 -2
- package/components/data/table/index.js +94 -61
- package/components/data/table/live-table/index.js +0 -1
- package/components/data/table/props.d.ts +8 -0
- package/components/data/table/utils/buildSelectionColumns.js +2 -4
- package/components/data/table/utils/columnBuilder.d.ts +16 -2
- package/components/data/table/utils/columnBuilder.js +14 -9
- package/components/data/table/utils/columnWidthDistribution.js +10 -0
- package/components/data/table/utils/constants.d.ts +0 -4
- package/components/data/table/utils/constants.js +0 -7
- package/components/data/table/utils/dynamic-columns.d.ts +1 -1
- package/components/data/table/utils/dynamic-columns.js +3 -8
- package/components/data/table/utils/expansionColumn.d.ts +23 -0
- package/components/data/table/utils/expansionColumn.js +56 -0
- package/components/data/table/utils/index.d.ts +23 -3
- package/components/data/table/utils/index.js +60 -20
- package/components/data/table/utils/selectionUtils.d.ts +5 -0
- package/components/data/table/utils/selectionUtils.js +5 -0
- package/components/dialogs/dialog/index.js +3 -2
- package/components/dialogs/dialog-header/index.js +1 -1
- package/components/dialogs/index.js +14 -2
- package/components/input/chips/index.js +29 -5
- package/components/input/color-picker/index.js +4 -6
- package/components/input/default/radioset/index.js +2 -1
- package/components/input/epoch/date/index.js +1 -1
- package/components/input/select/index.js +3 -5
- package/components/input/text/index.js +2 -2
- package/components/input/textarea/index.js +42 -17
- package/components/navbar/nav/index.js +10 -5
- package/components/navigation/breadcrumb/index.js +2 -1
- package/components/navigation/popover/index.js +24 -8
- package/components/page/index.js +1 -1
- package/components/page/page-content/index.js +30 -6
- package/components/page/page-content/props.d.ts +1 -0
- package/components/page/partial-container/index.js +2 -1
- package/components/prefab/index.js +3 -2
- package/components/prefab/props.d.ts +1 -0
- package/components/wmx/WmxRenderer.d.ts +8 -0
- package/components/wmx/WmxRenderer.js +57 -0
- package/context/WidgetProvider.js +2 -1
- package/core/appstore.js +1 -1
- package/core/proxy-service.d.ts +1 -0
- package/core/proxy-service.js +53 -2
- package/core/util/index.d.ts +0 -2
- package/core/util/index.js +3 -30
- package/higherOrder/BasePage.js +36 -54
- package/higherOrder/DataNav.js +4 -1
- package/higherOrder/withBaseWrapper.js +9 -7
- package/hooks/useHttp.js +4 -2
- package/hooks/useLayoutSize.js +1 -1
- package/package-lock.json +240 -607
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +2 -1
- package/runtime-dynamic/components/partial-content.js +4 -1
- package/runtime-dynamic/components/wmx-placeholder.d.ts +18 -0
- package/runtime-dynamic/components/wmx-placeholder.js +48 -0
- package/runtime-dynamic/factories/dynamic-component.js +26 -3
- package/runtime-dynamic/main.js +6 -0
- package/runtime-dynamic/services/compile-render.js +75 -12
- package/runtime-dynamic/services/css-scoping.d.ts +2 -0
- package/runtime-dynamic/services/css-scoping.js +39 -20
- package/store/slices/i18nSlice.d.ts +0 -1
- package/store/slices/i18nSlice.js +0 -2
- package/utils/custom-expression/parser.js +11 -8
- package/utils/layoutsize-util.js +12 -7
- package/utils/style-utils.d.ts +6 -0
- package/utils/style-utils.js +10 -0
- package/utils/transformedDataset-utils.d.ts +3 -3
- package/utils/transformedDataset-utils.js +1 -2
- package/utils/wmx.utils.d.ts +6 -0
- package/utils/wmx.utils.js +41 -0
- package/variables/crud-variable.js +1 -1
- package/variables/live-variable.js +1 -1
- package/variables/service-variable.js +6 -3
|
@@ -3,10 +3,19 @@ import {
|
|
|
3
3
|
isInteractiveElement,
|
|
4
4
|
getRowIdsFromDataset,
|
|
5
5
|
rowExistsInDataset,
|
|
6
|
-
selectionStateHelpers
|
|
6
|
+
selectionStateHelpers,
|
|
7
|
+
getWidgetForCallback
|
|
7
8
|
} from "../utils/selectionUtils";
|
|
8
9
|
import { saveTableState, getTableState } from "../utils/table-helpers";
|
|
9
10
|
import { cleanRowData, UNSUPPORTED_STATE_PERSISTENCE_TYPES } from "../utils";
|
|
11
|
+
const getRowFallbackId = (row) => row._wmTableRowId || String(row.id) || String(0);
|
|
12
|
+
const getSelectedIndices = (selectedIds, dataset) => selectedIds.reduce((indices, rowId) => {
|
|
13
|
+
const index = dataset.findIndex((row) => row._wmTableRowId === rowId || row.id === rowId);
|
|
14
|
+
if (index >= 0) {
|
|
15
|
+
indices.push(index);
|
|
16
|
+
}
|
|
17
|
+
return indices;
|
|
18
|
+
}, []);
|
|
10
19
|
const useRowSelection = ({
|
|
11
20
|
radioselect = false,
|
|
12
21
|
multiselect = false,
|
|
@@ -21,6 +30,8 @@ const useRowSelection = ({
|
|
|
21
30
|
onRowdeselect,
|
|
22
31
|
listener,
|
|
23
32
|
navigation = "Basic",
|
|
33
|
+
viewParent,
|
|
34
|
+
widgetRegistrationKey,
|
|
24
35
|
onSyncSelectedItems
|
|
25
36
|
}) => {
|
|
26
37
|
const datasetRef = useRef(internalDataset);
|
|
@@ -31,22 +42,36 @@ const useRowSelection = ({
|
|
|
31
42
|
const [updateTrigger, forceUpdate] = useState({});
|
|
32
43
|
const useMultiSelect = multiselect;
|
|
33
44
|
const useRadioSelect = radioselect && !multiselect;
|
|
34
|
-
const
|
|
45
|
+
const prevMultiselectRef = useRef(multiselect);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const prev = prevMultiselectRef.current;
|
|
48
|
+
prevMultiselectRef.current = multiselect;
|
|
49
|
+
if (prev === multiselect) return;
|
|
50
|
+
selectionStateHelpers.clearSelection(cellState);
|
|
51
|
+
forceUpdate({});
|
|
52
|
+
onSyncSelectedItems == null ? void 0 : onSyncSelectedItems([]);
|
|
53
|
+
if (statehandler && getTableCurrentState) {
|
|
54
|
+
saveTableState(name, statehandler, {});
|
|
55
|
+
}
|
|
56
|
+
}, [multiselect, cellState, onSyncSelectedItems, statehandler, name, getTableCurrentState]);
|
|
57
|
+
const applySelectionForMode = useCallback(
|
|
58
|
+
(rowIds) => {
|
|
59
|
+
if (rowIds.length === 0) return;
|
|
60
|
+
if (useMultiSelect) {
|
|
61
|
+
rowIds.forEach((rowId) => selectionStateHelpers.addToSelection(cellState, rowId));
|
|
62
|
+
} else {
|
|
63
|
+
selectionStateHelpers.setSelection(cellState, rowIds[0]);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[useMultiSelect, cellState]
|
|
67
|
+
);
|
|
35
68
|
const saveStateImmediate = useCallback(() => {
|
|
36
69
|
if (!statehandler || !getTableCurrentState) {
|
|
37
70
|
return;
|
|
38
71
|
}
|
|
39
72
|
const { currentPage, currentPageSize } = getTableCurrentState();
|
|
40
73
|
const selectedIds = selectionStateHelpers.getSelection(cellState);
|
|
41
|
-
const selectedIndices =
|
|
42
|
-
selectedIds.forEach((rowId) => {
|
|
43
|
-
const index = internalDataset.findIndex(
|
|
44
|
-
(row) => row._wmTableRowId === rowId || row.id === rowId
|
|
45
|
-
);
|
|
46
|
-
if (index >= 0) {
|
|
47
|
-
selectedIndices.push(index);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
74
|
+
const selectedIndices = getSelectedIndices(selectedIds, internalDataset);
|
|
50
75
|
const selectedItemsWithPage = selectedIndices.map((idx) => ({
|
|
51
76
|
page: currentPage,
|
|
52
77
|
index: idx
|
|
@@ -91,19 +116,35 @@ const useRowSelection = ({
|
|
|
91
116
|
internalDataset,
|
|
92
117
|
initialActualPageSize
|
|
93
118
|
]);
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
119
|
+
const widgetKey = widgetRegistrationKey != null ? widgetRegistrationKey : name;
|
|
120
|
+
const getWidgetRef = useCallback(
|
|
121
|
+
() => getWidgetForCallback(listener, viewParent, widgetKey),
|
|
122
|
+
[viewParent, widgetKey]
|
|
123
|
+
);
|
|
124
|
+
const syncSelectionToWidget = useCallback(
|
|
125
|
+
(selectedIds) => {
|
|
126
|
+
const ids = selectedIds != null ? selectedIds : selectionStateHelpers.getSelection(cellState);
|
|
127
|
+
onSyncSelectedItems == null ? void 0 : onSyncSelectedItems(ids);
|
|
128
|
+
},
|
|
129
|
+
[onSyncSelectedItems, cellState]
|
|
130
|
+
);
|
|
131
|
+
const commitSelectionChange = useCallback(
|
|
132
|
+
(syncIds) => {
|
|
133
|
+
forceUpdate({});
|
|
134
|
+
saveStateImmediate();
|
|
135
|
+
syncSelectionToWidget(syncIds);
|
|
136
|
+
},
|
|
137
|
+
[saveStateImmediate, syncSelectionToWidget]
|
|
138
|
+
);
|
|
98
139
|
const triggerSelectionCallback = useCallback(
|
|
99
140
|
(event, rowData, callback) => {
|
|
100
141
|
if (callback && rowData) {
|
|
101
|
-
|
|
142
|
+
const widget = getWidgetRef();
|
|
102
143
|
const cleanedRow = cleanRowData([rowData])[0];
|
|
103
|
-
callback(event,
|
|
144
|
+
callback(event, widget, cleanedRow);
|
|
104
145
|
}
|
|
105
146
|
},
|
|
106
|
-
[getWidgetRef
|
|
147
|
+
[getWidgetRef]
|
|
107
148
|
);
|
|
108
149
|
const handleRadioSelection = useCallback(
|
|
109
150
|
(rowId, rowData) => {
|
|
@@ -116,8 +157,7 @@ const useRowSelection = ({
|
|
|
116
157
|
);
|
|
117
158
|
}
|
|
118
159
|
selectionStateHelpers.setSelection(cellState, rowId);
|
|
119
|
-
|
|
120
|
-
saveStateImmediate();
|
|
160
|
+
commitSelectionChange();
|
|
121
161
|
if (previousRowData) {
|
|
122
162
|
triggerSelectionCallback(null, previousRowData, onRowdeselect);
|
|
123
163
|
}
|
|
@@ -125,7 +165,7 @@ const useRowSelection = ({
|
|
|
125
165
|
},
|
|
126
166
|
[
|
|
127
167
|
cellState,
|
|
128
|
-
|
|
168
|
+
commitSelectionChange,
|
|
129
169
|
onRowselect,
|
|
130
170
|
onRowdeselect,
|
|
131
171
|
internalDataset,
|
|
@@ -139,11 +179,10 @@ const useRowSelection = ({
|
|
|
139
179
|
} else {
|
|
140
180
|
selectionStateHelpers.removeFromSelection(cellState, rowId);
|
|
141
181
|
}
|
|
142
|
-
|
|
143
|
-
saveStateImmediate();
|
|
182
|
+
commitSelectionChange();
|
|
144
183
|
triggerSelectionCallback(null, rowData, isSelected ? onRowselect : onRowdeselect);
|
|
145
184
|
},
|
|
146
|
-
[cellState,
|
|
185
|
+
[cellState, commitSelectionChange, onRowselect, onRowdeselect, triggerSelectionCallback]
|
|
147
186
|
);
|
|
148
187
|
const handleSelectAll = useCallback(
|
|
149
188
|
(isSelected) => {
|
|
@@ -154,9 +193,7 @@ const useRowSelection = ({
|
|
|
154
193
|
} else {
|
|
155
194
|
selectionStateHelpers.clearSelection(cellState);
|
|
156
195
|
}
|
|
157
|
-
|
|
158
|
-
saveStateImmediate();
|
|
159
|
-
onSyncSelectedItems == null ? void 0 : onSyncSelectedItems(newIds);
|
|
196
|
+
commitSelectionChange(newIds);
|
|
160
197
|
const rows = datasetRef.current;
|
|
161
198
|
const callback = isSelected ? onRowselect : onRowdeselect;
|
|
162
199
|
if (callback && rows.length > 0) {
|
|
@@ -166,7 +203,7 @@ const useRowSelection = ({
|
|
|
166
203
|
});
|
|
167
204
|
}
|
|
168
205
|
},
|
|
169
|
-
[cellState,
|
|
206
|
+
[cellState, commitSelectionChange, onRowselect, onRowdeselect, getWidgetRef]
|
|
170
207
|
);
|
|
171
208
|
const handleRowSelectionClick = useCallback(
|
|
172
209
|
(event, rowId, rowData) => {
|
|
@@ -177,20 +214,18 @@ const useRowSelection = ({
|
|
|
177
214
|
const isCurrentlySelected = selectionStateHelpers.isRowSelected(cellState, rowId);
|
|
178
215
|
const willBeSelected = !isCurrentlySelected;
|
|
179
216
|
selectionStateHelpers.toggleSelection(cellState, rowId);
|
|
180
|
-
|
|
181
|
-
saveStateImmediate();
|
|
217
|
+
commitSelectionChange();
|
|
182
218
|
triggerSelectionCallback(event, rowData, willBeSelected ? onRowselect : onRowdeselect);
|
|
183
219
|
return true;
|
|
184
|
-
} else {
|
|
185
|
-
handleRadioSelection(rowId, rowData);
|
|
186
|
-
return true;
|
|
187
220
|
}
|
|
221
|
+
handleRadioSelection(rowId, rowData);
|
|
222
|
+
return true;
|
|
188
223
|
},
|
|
189
224
|
[
|
|
190
225
|
useMultiSelect,
|
|
191
226
|
handleRadioSelection,
|
|
192
227
|
cellState,
|
|
193
|
-
|
|
228
|
+
commitSelectionChange,
|
|
194
229
|
triggerSelectionCallback,
|
|
195
230
|
onRowselect,
|
|
196
231
|
onRowdeselect
|
|
@@ -202,26 +237,22 @@ const useRowSelection = ({
|
|
|
202
237
|
}
|
|
203
238
|
if (gridfirstrowselect && internalDataset.length > 0) {
|
|
204
239
|
const firstRowData = internalDataset[0];
|
|
205
|
-
const firstRowId =
|
|
240
|
+
const firstRowId = getRowFallbackId(firstRowData);
|
|
206
241
|
const currentSelection = selectionStateHelpers.getSelection(cellState);
|
|
207
242
|
if (currentSelection.length === 0) {
|
|
208
|
-
|
|
209
|
-
selectionStateHelpers.addToSelection(cellState, firstRowId);
|
|
210
|
-
} else {
|
|
211
|
-
selectionStateHelpers.setSelection(cellState, firstRowId);
|
|
212
|
-
}
|
|
243
|
+
applySelectionForMode([firstRowId]);
|
|
213
244
|
forceUpdate({});
|
|
214
245
|
initialSelectionDoneRef.current = true;
|
|
215
246
|
} else if (!useMultiSelect) {
|
|
216
247
|
const selectedId = currentSelection[0];
|
|
217
248
|
if (!rowExistsInDataset(selectedId, internalDataset)) {
|
|
218
|
-
|
|
249
|
+
applySelectionForMode([firstRowId]);
|
|
219
250
|
forceUpdate({});
|
|
220
251
|
initialSelectionDoneRef.current = true;
|
|
221
252
|
}
|
|
222
253
|
}
|
|
223
254
|
}
|
|
224
|
-
}, [gridfirstrowselect, internalDataset, useMultiSelect, cellState]);
|
|
255
|
+
}, [gridfirstrowselect, internalDataset, useMultiSelect, cellState, applySelectionForMode]);
|
|
225
256
|
useEffect(() => {
|
|
226
257
|
var _a;
|
|
227
258
|
if (!gridfirstrowselect || internalDataset.length === 0 || !initialSelectionDoneRef.current) {
|
|
@@ -239,12 +270,8 @@ const useRowSelection = ({
|
|
|
239
270
|
);
|
|
240
271
|
if (!hasSelectionInCurrentPage) {
|
|
241
272
|
const firstRowData = internalDataset[0];
|
|
242
|
-
const firstRowId =
|
|
243
|
-
|
|
244
|
-
selectionStateHelpers.addToSelection(cellState, firstRowId);
|
|
245
|
-
} else {
|
|
246
|
-
selectionStateHelpers.setSelection(cellState, firstRowId);
|
|
247
|
-
}
|
|
273
|
+
const firstRowId = getRowFallbackId(firstRowData);
|
|
274
|
+
applySelectionForMode([firstRowId]);
|
|
248
275
|
forceUpdate({});
|
|
249
276
|
if (onRowselect) {
|
|
250
277
|
triggerSelectionCallback(null, firstRowData, onRowselect);
|
|
@@ -259,7 +286,8 @@ const useRowSelection = ({
|
|
|
259
286
|
name,
|
|
260
287
|
statehandler,
|
|
261
288
|
onRowselect,
|
|
262
|
-
triggerSelectionCallback
|
|
289
|
+
triggerSelectionCallback,
|
|
290
|
+
applySelectionForMode
|
|
263
291
|
]);
|
|
264
292
|
const isRowSelected = useCallback(
|
|
265
293
|
(rowId) => {
|
|
@@ -302,23 +330,8 @@ const useRowSelection = ({
|
|
|
302
330
|
if (!isAlreadyRestored && expectedRowIds.length > 0) {
|
|
303
331
|
if (useMultiSelect) {
|
|
304
332
|
selectionStateHelpers.clearSelection(cellState);
|
|
305
|
-
currentPageSelections.forEach((index) => {
|
|
306
|
-
if (index >= 0 && index < internalDataset.length) {
|
|
307
|
-
const row = internalDataset[index];
|
|
308
|
-
if (row && row._wmTableRowId) {
|
|
309
|
-
selectionStateHelpers.addToSelection(cellState, row._wmTableRowId);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
} else {
|
|
314
|
-
const firstIndex = currentPageSelections[0];
|
|
315
|
-
if (firstIndex >= 0 && firstIndex < internalDataset.length) {
|
|
316
|
-
const row = internalDataset[firstIndex];
|
|
317
|
-
if (row && row._wmTableRowId) {
|
|
318
|
-
selectionStateHelpers.setSelection(cellState, row._wmTableRowId);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
333
|
}
|
|
334
|
+
applySelectionForMode(expectedRowIds);
|
|
322
335
|
forceUpdate({});
|
|
323
336
|
}
|
|
324
337
|
}
|
|
@@ -329,7 +342,8 @@ const useRowSelection = ({
|
|
|
329
342
|
navigation,
|
|
330
343
|
internalDataset,
|
|
331
344
|
cellState,
|
|
332
|
-
useMultiSelect
|
|
345
|
+
useMultiSelect,
|
|
346
|
+
applySelectionForMode
|
|
333
347
|
]);
|
|
334
348
|
return {
|
|
335
349
|
selectedRowIds,
|
|
@@ -39,7 +39,8 @@ import {
|
|
|
39
39
|
createRowIndexColumn,
|
|
40
40
|
createDataColumns,
|
|
41
41
|
createEditingActionButtons,
|
|
42
|
-
getActionColumnSize
|
|
42
|
+
getActionColumnSize,
|
|
43
|
+
ActionCell
|
|
43
44
|
} from "../utils/columnBuilder";
|
|
44
45
|
import { distributeColumnWidths } from "../utils/columnWidthDistribution";
|
|
45
46
|
import { useResponsiveColumns } from "./useResponsiveColumns";
|
|
@@ -210,11 +211,14 @@ const useTableColumns = ({
|
|
|
210
211
|
const shouldRenderEditableCell = (editmode === "inline" || editmode === "quickedit") && isEditingThisRow && !wmColumn.readonly;
|
|
211
212
|
return /* @__PURE__ */ jsx("span", { "data-col-identifier": wmColumn.field, children: shouldRenderEditableCell ? renderEditableCell(wmColumn, row.original, rowId) : renderDisplayCell(wmColumn, row.original, listener, cellState) });
|
|
212
213
|
},
|
|
213
|
-
[editmode, isRowEditing, renderEditableCell, cellState
|
|
214
|
+
[editmode, isRowEditing, renderEditableCell, cellState]
|
|
214
215
|
);
|
|
215
216
|
const filteredRowActions = useMemo(() => {
|
|
216
217
|
if (editmode === "quickedit") {
|
|
217
|
-
return filter(
|
|
218
|
+
return filter(
|
|
219
|
+
rowActions,
|
|
220
|
+
(action) => action.key === "deleterow" || action.action === "delete" || action.key === "updaterow"
|
|
221
|
+
);
|
|
218
222
|
}
|
|
219
223
|
return rowActions;
|
|
220
224
|
}, [rowActions, editmode]);
|
|
@@ -256,7 +260,6 @@ const useTableColumns = ({
|
|
|
256
260
|
saveEditing,
|
|
257
261
|
cancelEditing,
|
|
258
262
|
deleteRowAction,
|
|
259
|
-
listener,
|
|
260
263
|
selectionHandlers
|
|
261
264
|
]
|
|
262
265
|
);
|
|
@@ -277,13 +280,15 @@ const useTableColumns = ({
|
|
|
277
280
|
size: columnSize,
|
|
278
281
|
minSize,
|
|
279
282
|
enableResizing: true,
|
|
280
|
-
cell:
|
|
283
|
+
cell: ActionCell,
|
|
281
284
|
enableSorting: manualActionColumn.sortable !== false,
|
|
282
|
-
meta: __spreadValues({
|
|
285
|
+
meta: __spreadProps(__spreadValues({
|
|
283
286
|
textAlign: manualActionColumn.textalignment,
|
|
284
287
|
backgroundColor: manualActionColumn.backgroundcolor,
|
|
285
288
|
className: manualActionColumn.colClass
|
|
286
|
-
}, manualActionColumn.styles)
|
|
289
|
+
}, manualActionColumn.styles), {
|
|
290
|
+
_actions: { renderActionCell }
|
|
291
|
+
})
|
|
287
292
|
};
|
|
288
293
|
} else if (rowActions.length > 0 && (isDynamicTable || editmode !== "none")) {
|
|
289
294
|
return {
|
|
@@ -293,7 +298,10 @@ const useTableColumns = ({
|
|
|
293
298
|
minSize,
|
|
294
299
|
maxSize: size,
|
|
295
300
|
enableResizing: false,
|
|
296
|
-
cell:
|
|
301
|
+
cell: ActionCell,
|
|
302
|
+
meta: {
|
|
303
|
+
_actions: { renderActionCell }
|
|
304
|
+
}
|
|
297
305
|
};
|
|
298
306
|
}
|
|
299
307
|
return null;
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
1
|
+
import { useState, useCallback, useEffect, useRef } from "react";
|
|
2
2
|
const useTableState = ({
|
|
3
3
|
editMode = "none",
|
|
4
4
|
radioselect = false,
|
|
5
5
|
multiselect = false
|
|
6
6
|
}) => {
|
|
7
7
|
const [activeRowIds, setActiveRowIds] = useState([]);
|
|
8
|
+
const prevMultiselectRef = useRef(multiselect);
|
|
9
|
+
const prevRadioselectRef = useRef(radioselect);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const prevMultiselect = prevMultiselectRef.current;
|
|
12
|
+
const prevRadioselect = prevRadioselectRef.current;
|
|
13
|
+
prevMultiselectRef.current = multiselect;
|
|
14
|
+
prevRadioselectRef.current = radioselect;
|
|
15
|
+
if (prevMultiselect && !multiselect) {
|
|
16
|
+
setActiveRowIds([]);
|
|
17
|
+
} else if (prevRadioselect && !radioselect && !multiselect) {
|
|
18
|
+
setActiveRowIds([]);
|
|
19
|
+
}
|
|
20
|
+
}, [multiselect, radioselect]);
|
|
8
21
|
const handleRowActiveClick = useCallback(
|
|
9
22
|
(rowId, isSelectionHandled, isEditingOrAdding) => {
|
|
10
23
|
if (isEditingOrAdding) {
|
|
@@ -39,7 +52,6 @@ const useTableState = ({
|
|
|
39
52
|
setActiveRowIds([]);
|
|
40
53
|
}
|
|
41
54
|
}, []);
|
|
42
|
-
const activeRowId = activeRowIds && activeRowIds.length > 0 ? activeRowIds[0] : null;
|
|
43
55
|
return {
|
|
44
56
|
activeRowIds,
|
|
45
57
|
setActiveRow,
|