@wavemaker/react-runtime 11.14.2-rc.6311 → 11.15.0-1.246
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/actions/base-action.js +5 -7
- package/actions/login-action.js +7 -8
- package/actions/logout-action.js +5 -7
- package/actions/navigation-action.js +73 -18
- package/actions/notification-action.js +22 -8
- package/actions/timer-action.js +13 -15
- package/actions/toast.js +4 -2
- package/actions/toast.service.js +1 -2
- package/components/advanced/carousel/index.js +1 -1
- package/components/advanced/carousel/template.js +1 -1
- package/components/basic/anchor/index.js +31 -11
- package/components/basic/html/index.js +115 -24
- package/components/basic/icon/index.js +2 -1
- package/components/basic/iframe/index.js +2 -1
- package/components/basic/label/index.js +12 -9
- package/components/basic/message/index.js +12 -3
- package/components/basic/picture/index.js +11 -4
- package/components/basic/progress-bar/index.js +4 -1
- package/components/basic/progress-circle/index.js +34 -28
- package/components/basic/progress-circle/props.js +10 -2
- package/components/basic/richtexteditor/index.js +95 -94
- package/components/basic/search/index.js +401 -156
- package/components/basic/search/providers.js +126 -61
- package/components/basic/spinner/index.js +2 -1
- package/components/basic/tree/index.js +34 -34
- package/components/basic/tree/utils.js +10 -4
- package/components/chart/components/barColumnChart/index.js +36 -33
- package/components/chart/components/bubbleChart/index.js +35 -25
- package/components/chart/components/chartLegend/utils.js +2 -1
- package/components/chart/components/cumulativeLineChart/index.js +30 -26
- package/components/chart/components/lineAreaChart/index.js +50 -32
- package/components/chart/components/pieDonutChart/index.js +13 -4
- package/components/chart/hooks/useXAxisConfig.js +15 -8
- package/components/chart/index.js +223 -53
- package/components/chart/utils.js +12 -1
- package/components/constants.js +5 -2
- package/components/container/accordion/accordion-pane/index.js +17 -12
- package/components/container/accordion/index.js +9 -4
- package/components/container/alignment-utils.js +56 -1
- package/components/container/index.js +49 -20
- package/components/container/panel/components/panel-header/index.js +3 -4
- package/components/container/panel/index.js +15 -10
- package/components/container/repeat-template/index.js +33 -0
- package/components/container/tabs/index.js +83 -14
- package/components/container/tabs/tab-pane/index.js +33 -10
- package/components/container/tabs/utils.js +51 -0
- package/components/container/wizard/components/StepComponents.js +2 -1
- package/components/container/wizard/components/WizardStep.js +2 -1
- package/components/container/wizard/index.js +64 -35
- package/components/container/wizard/utils.js +46 -1
- package/components/container/wizard/wizard-step/index.js +11 -1
- package/components/data/card/card-content/index.js +1 -1
- package/components/data/form/base-form/index.js +985 -183
- package/components/data/form/base-form/props.js +3 -1
- package/components/data/form/base-form/utils.js +159 -1
- package/components/data/form/dynamic-fields/constant.js +53 -0
- package/components/data/form/dynamic-fields/index.js +10 -45
- package/components/data/form/dynamic-fields/utils.js +37 -2
- package/components/data/form/form-action/index.js +5 -4
- package/components/data/form/form-context.js +5 -1
- package/components/data/form/form-controller/utils.js +84 -0
- package/components/data/form/form-controller/validation-contrustor.js +402 -189
- package/components/data/form/form-controller/withFormController.js +191 -52
- package/components/data/form/form-field/base-field.js +67 -45
- package/components/data/form/form-field/index.js +28 -5
- package/components/data/form/form-header/index.js +3 -4
- package/components/data/form/index.js +20 -1
- package/components/data/list/components/ListDND.js +2 -1
- package/components/data/list/components/ListItem.js +6 -2
- package/components/data/list/components/ListItemWithTemplate.js +46 -2
- package/components/data/list/components/ListItems.js +17 -26
- package/components/data/list/components/ListPagination.js +3 -3
- package/components/data/list/components/StandardListItems.js +3 -4
- package/components/data/list/hooks/useListEffects.js +55 -14
- package/components/data/list/hooks/useListEventHandlers.js +3 -1
- package/components/data/list/hooks/useListState.js +3 -1
- package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
- package/components/data/list/index.js +74 -55
- package/components/data/list/utils/list-helpers.js +73 -35
- package/components/data/list/utils/list-widget-methods.js +138 -95
- package/components/data/live-filter/index.js +26 -15
- package/components/data/live-form/index.js +51 -18
- package/components/data/live-form/props.js +1 -1
- package/components/data/pagination/components/BasicPagination.js +71 -16
- package/components/data/pagination/components/PageSizeSelector.js +8 -3
- package/components/data/pagination/components/TotalRecords.js +1 -5
- package/components/data/pagination/hooks/usePagination.js +349 -66
- package/components/data/pagination/index.js +137 -19
- package/components/data/table/components/AddNewRow.js +5 -1
- package/components/data/table/components/EditableCell.js +2 -2
- package/components/data/table/components/RowCells.js +64 -0
- package/components/data/table/components/RowExpansionButton.js +2 -2
- package/components/data/table/components/SummaryCell.js +111 -0
- package/components/data/table/components/SummaryRow.js +54 -0
- package/components/data/table/components/SummaryRowFooter.js +46 -0
- package/components/data/table/components/TableBody.js +61 -59
- package/components/data/table/components/TableDataRow.js +109 -0
- package/components/data/table/components/TableFilters.js +225 -121
- package/components/data/table/components/TableHeader.js +291 -23
- package/components/data/table/components/TablePanelHeading.js +139 -8
- package/components/data/table/components/index.js +22 -1
- package/components/data/table/hooks/use-edited-rows.js +141 -0
- package/components/data/table/hooks/useCellState.js +5 -12
- package/components/data/table/hooks/useFormWidget.js +58 -52
- package/components/data/table/hooks/usePaginationState.js +45 -24
- package/components/data/table/hooks/usePanelStructure.js +4 -4
- package/components/data/table/hooks/useRowHandlers.js +39 -5
- package/components/data/table/hooks/useRowSelection.js +244 -50
- package/components/data/table/hooks/useServerSideSorting.js +81 -37
- package/components/data/table/hooks/useTableColumns.js +211 -118
- package/components/data/table/hooks/useTableData.js +54 -9
- package/components/data/table/hooks/useTableEdit.js +272 -97
- package/components/data/table/hooks/useTableEffects.js +31 -13
- package/components/data/table/hooks/useTableFilter.js +1 -1
- package/components/data/table/hooks/useTableInitialization.js +23 -22
- package/components/data/table/hooks/useTableState.js +11 -5
- package/components/data/table/hooks/useTableStateManager.js +140 -65
- package/components/data/table/index.js +637 -274
- package/components/data/table/live-table/index.js +54 -22
- package/components/data/table/table-action/index.js +1 -1
- package/components/data/table/table-group/index.js +26 -0
- package/components/data/table/table-row-action/index.js +32 -18
- package/components/data/table/utils/buildSelectionColumns.js +12 -21
- package/components/data/table/utils/columnBuilder.js +29 -14
- package/components/data/table/utils/columnProxy.js +68 -1
- package/components/data/table/utils/constants.js +6 -2
- package/components/data/table/utils/crud-handlers.js +68 -63
- package/components/data/table/utils/groupHeaderUtils.js +102 -0
- package/components/data/table/utils/index.js +210 -21
- package/components/data/table/utils/renderDisplayCell.js +6 -6
- package/components/data/table/utils/selectionUtils.js +25 -26
- package/components/data/table/utils/validation.js +1 -0
- package/components/data/utils/filter-field-util.js +3 -3
- package/components/dialogs/alert-dialog/index.js +1 -1
- package/components/dialogs/confirm-dialog/index.js +1 -1
- package/components/dialogs/dialog/index.js +4 -1
- package/components/dialogs/dialog-content/index.js +3 -1
- package/components/dialogs/dialog-header/index.js +2 -2
- package/components/dialogs/iframe-dialog/index.js +11 -5
- package/components/dialogs/index.js +1 -1
- package/components/dialogs/login-dialog/index.js +1 -1
- package/components/dialogs/page-dialog/index.js +1 -1
- package/components/form/button/index.js +33 -7
- package/components/input/calendar/index.js +18 -6
- package/components/input/chips/index.js +99 -28
- package/components/input/chips/utils.js +34 -4
- package/components/input/color-picker/index.js +74 -25
- package/components/input/composite/index.js +3 -3
- package/components/input/currency/index.js +35 -49
- package/components/input/default/checkbox/index.js +23 -28
- package/components/input/default/checkboxset/index.js +38 -18
- package/components/input/default/checkboxset/utils.js +30 -0
- package/components/input/default/radioset/index.js +36 -39
- package/components/input/default/switch/index.js +30 -13
- package/components/input/epoch/date/index.js +130 -69
- package/components/input/epoch/date/utils.js +94 -1
- package/components/input/epoch/datetime/index.js +72 -22
- package/components/input/epoch/datetime/utils.js +49 -10
- package/components/input/epoch/time/index.js +68 -19
- package/components/input/epoch/time/utils.js +62 -14
- package/components/input/fileupload/Utils.js +12 -7
- package/components/input/fileupload/components/MultiUpload.js +2 -6
- package/components/input/fileupload/components/SingleUpload.js +3 -7
- package/components/input/fileupload/index.js +6 -10
- package/components/input/fileupload/useFileUpload.js +16 -5
- package/components/input/number/index.js +158 -43
- package/components/input/rating/index.js +90 -7
- package/components/input/select/index.js +209 -72
- package/components/input/slider/index.js +84 -26
- package/components/input/text/index.js +38 -18
- package/components/input/text/util.js +283 -130
- package/components/input/textarea/index.js +13 -10
- package/components/input/upload/index.js +124 -0
- package/components/input/upload/props.js +5 -0
- package/components/input/util/index.js +11 -0
- package/components/navbar/index.js +51 -3
- package/components/navbar/nav/index.js +46 -16
- package/components/navbar/nav-item/index.js +11 -5
- package/components/navigation/menu/components/ListItems.js +3 -0
- package/components/navigation/menu/constants.js +2 -1
- package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
- package/components/navigation/menu/index.js +326 -188
- package/components/navigation/menu/utils/action-task.js +14 -0
- package/components/navigation/menu/utils/role-filter.js +76 -0
- package/components/navigation/popover/index.js +105 -32
- package/components/page/partial-container/index.js +34 -5
- package/components/prefab/index.js +2 -4
- package/context/PrefabContext.js +10 -6
- package/context/WidgetProvider.js +30 -31
- package/core/app.service.js +1 -1
- package/core/constants/events.js +57 -1
- package/core/dialog.service.js +1 -2
- package/core/event-notifier.js +1 -2
- package/core/formatter/array-formatters.js +33 -0
- package/core/formatter/date-formatters.js +2 -4
- package/core/formatter/index.js +2 -1
- package/core/formatter/number-formatters.js +5 -10
- package/core/formatter/security-formatters.js +2 -4
- package/core/formatter/string-formatters.js +3 -6
- package/core/proxy-service.js +85 -13
- package/core/script-registry.js +108 -48
- package/core/util/common.js +4 -4
- package/core/util/compare.js +30 -0
- package/core/util/dom.js +8 -8
- package/core/util/index.js +16 -6
- package/core/util/safe-is-equal.js +156 -0
- package/core/util/security.js +1 -2
- package/core/util/utils.js +16 -7
- package/higherOrder/BaseApp.js +108 -65
- package/higherOrder/BaseDateTime.js +31 -13
- package/higherOrder/BasePage.js +268 -144
- package/higherOrder/BasePartial.js +1 -1
- package/higherOrder/BasePrefab.js +33 -15
- package/higherOrder/DataNav.js +99 -16
- package/higherOrder/helper.js +41 -3
- package/higherOrder/withBaseWrapper.js +41 -28
- package/hooks/useAuth.js +11 -5
- package/hooks/useHttp.js +280 -94
- package/mui-config/theme-provider.js +1 -1
- package/mui-config/theme.js +1 -1
- package/package-lock.json +840 -740
- package/package.json +8 -8
- package/store/bindActions/i18nActions.js +18 -0
- package/store/index.js +3 -1
- package/store/slices/appConfigSlice.js +2 -2
- package/store/slices/authSlice.js +31 -28
- package/store/slices/i18nSlice.js +2 -2
- package/store/slices/navigationSlice.js +35 -0
- package/store/viewport.service.js +255 -0
- package/utils/attr.js +35 -0
- package/utils/dataset-util.js +1 -2
- package/utils/form-state.util.js +43 -12
- package/utils/form-utils.js +47 -2
- package/utils/format-util.js +28 -13
- package/utils/page-params-util.js +33 -1
- package/utils/state-persistance.js +72 -13
- package/utils/transformedDataset-utils.js +35 -24
- package/variables/base-variable.js +12 -14
- package/variables/crud-variable.js +225 -0
- package/variables/live-variable.js +56 -20
- package/variables/metadata.service.js +123 -0
- package/variables/model-variable.js +21 -15
- package/variables/service-variable.js +88 -83
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.useTableEdit = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
14
|
var _lodashEs = require("lodash-es");
|
|
@@ -16,6 +18,8 @@ var _utils = require("../utils");
|
|
|
16
18
|
var _useEditingState2 = require("./useEditingState");
|
|
17
19
|
var _validation = require("../utils/validation");
|
|
18
20
|
var _crudHandlers = require("../utils/crud-handlers");
|
|
21
|
+
var _useEditedRows = require("./use-edited-rows");
|
|
22
|
+
var _formContext = require("@wavemaker/react-runtime/components/data/form/form-context");
|
|
19
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
20
24
|
var __jsx = _react["default"].createElement;
|
|
21
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -40,6 +44,12 @@ var MODE_CONFIGS = {
|
|
|
40
44
|
hasKeyboardNavigation: false,
|
|
41
45
|
cancelsAddNewRowOnEdit: false
|
|
42
46
|
},
|
|
47
|
+
form: {
|
|
48
|
+
showNewRowFormByDefault: false,
|
|
49
|
+
startEditOnRowClick: false,
|
|
50
|
+
hasKeyboardNavigation: false,
|
|
51
|
+
cancelsAddNewRowOnEdit: false
|
|
52
|
+
},
|
|
43
53
|
none: {
|
|
44
54
|
showNewRowFormByDefault: false,
|
|
45
55
|
startEditOnRowClick: false,
|
|
@@ -87,7 +97,12 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
87
97
|
onRowinsert = _ref.onRowinsert,
|
|
88
98
|
onRowupdate = _ref.onRowupdate,
|
|
89
99
|
tableRef = _ref.tableRef,
|
|
90
|
-
isServerSidePagination = _ref.isServerSidePagination
|
|
100
|
+
isServerSidePagination = _ref.isServerSidePagination,
|
|
101
|
+
tableName = _ref.tableName;
|
|
102
|
+
var updateCell = (0, _useEditedRows.useUpdateEditedCell)();
|
|
103
|
+
var _useEditedRowsContext = (0, _useEditedRows.useEditedRowsContext)(),
|
|
104
|
+
getEdits = _useEditedRowsContext.getEdits,
|
|
105
|
+
removeRowEdits = _useEditedRowsContext.removeRowEdits;
|
|
91
106
|
// Use the editing state hook
|
|
92
107
|
var _useEditingState = (0, _useEditingState2.useEditingState)(),
|
|
93
108
|
editingRowId = _useEditingState.editingRowId,
|
|
@@ -102,9 +117,12 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
102
117
|
isRowEditing = _useEditingState.isRowEditing;
|
|
103
118
|
|
|
104
119
|
// Validation refs
|
|
120
|
+
var formContext = (0, _formContext.useFormContext)();
|
|
121
|
+
var updateFormData = formContext === null || formContext === void 0 ? void 0 : formContext.updateFormData;
|
|
105
122
|
var fieldRefs = (0, _react.useRef)({});
|
|
106
123
|
var fieldValidationErrorsRef = (0, _react.useRef)({});
|
|
107
124
|
var cellUpdateCallbacksRef = (0, _react.useRef)({});
|
|
125
|
+
var originalRowDataRef = (0, _react.useRef)({});
|
|
108
126
|
var validationState = {
|
|
109
127
|
fieldRefs: fieldRefs,
|
|
110
128
|
fieldValidationErrors: fieldValidationErrorsRef,
|
|
@@ -130,6 +148,7 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
130
148
|
console.warn("Editing is not enabled. Set editmode to enable this feature.");
|
|
131
149
|
return;
|
|
132
150
|
}
|
|
151
|
+
originalRowDataRef.current = _objectSpread({}, rowData);
|
|
133
152
|
|
|
134
153
|
// Cancel add new row if configured for this mode
|
|
135
154
|
if (config.cancelsAddNewRowOnEdit && isAddingNewRow) {
|
|
@@ -139,120 +158,241 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
139
158
|
// Reset editing data and start fresh
|
|
140
159
|
resetEditingData();
|
|
141
160
|
setEditingRowId(rowId);
|
|
142
|
-
|
|
161
|
+
|
|
162
|
+
// Initialize with existing edits if available
|
|
163
|
+
var existingEdits = getEdits(rowId) || {};
|
|
164
|
+
editingRowDataRef.current = _objectSpread(_objectSpread({}, rowData), existingEdits);
|
|
143
165
|
resetValidationState(editMode === "quickedit" ? "all" : undefined);
|
|
144
166
|
incrementSessionKey();
|
|
145
|
-
}, [editMode, config.cancelsAddNewRowOnEdit, isAddingNewRow, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, resetEditingData]);
|
|
167
|
+
}, [editMode, config.cancelsAddNewRowOnEdit, isAddingNewRow, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, resetEditingData, getEdits]);
|
|
146
168
|
|
|
147
169
|
// Cancel editing function
|
|
148
170
|
var cancelEditing = (0, _react.useCallback)(function () {
|
|
171
|
+
// Clear persisted edits for this row if we are cancelling
|
|
172
|
+
if (editingRowId) {
|
|
173
|
+
removeRowEdits(editingRowId);
|
|
174
|
+
// Also clear cellState if it exists
|
|
175
|
+
if (cellState) {
|
|
176
|
+
// Note: cellState doesn't have a clearRow method exposed easily here without path iteration.
|
|
177
|
+
// But removeRowEdits handles the EditedRowsContext which drives the view.
|
|
178
|
+
// Ideally we should clear cellState too, but let's focus on the visual consistency first.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
149
181
|
setEditingRowId(null);
|
|
150
182
|
|
|
151
|
-
// For inline mode, also cancel add new row
|
|
183
|
+
// For inline mode, also cancel add new row and clear refs
|
|
152
184
|
if (editMode === "inline") {
|
|
153
185
|
setIsAddingNewRow(false);
|
|
186
|
+
// Clear the editing data ref to ensure no old values persist
|
|
187
|
+
editingRowDataRef.current = {};
|
|
154
188
|
}
|
|
155
189
|
resetEditingData();
|
|
156
190
|
|
|
157
191
|
// Reset validation based on mode
|
|
158
192
|
resetValidationState(editMode === "quickedit" ? "all" : undefined);
|
|
159
193
|
incrementSessionKey();
|
|
160
|
-
}, [editMode, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, resetEditingData]);
|
|
194
|
+
}, [editMode, editingRowId, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, resetEditingData, removeRowEdits, cellState]);
|
|
161
195
|
|
|
162
196
|
// Generic save function that works for both edit modes
|
|
163
|
-
var saveEditingInternal = (0, _react.useCallback)(function (
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
197
|
+
var saveEditingInternal = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
198
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(rowId, isNewRow, rowDataRef, onSaveSuccess) {
|
|
199
|
+
var currentRowId, activeElement, editableCellContainer, fieldName, inputValue, currentEditingData, originalData, hasChanges, relevantFieldRefs, validationResult, result;
|
|
200
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
201
|
+
while (1) switch (_context.prev = _context.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
currentRowId = rowId || (isNewRow ? "new-row" : null);
|
|
204
|
+
if (currentRowId) {
|
|
205
|
+
_context.next = 3;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
return _context.abrupt("return", Promise.resolve(false));
|
|
209
|
+
case 3:
|
|
210
|
+
// Capture value from active input element BEFORE blur
|
|
211
|
+
// This is needed because inputs use updateon="blur" and save triggers on mousedown (before blur)
|
|
212
|
+
// The blur event handler runs async, so we need to read the DOM value directly
|
|
213
|
+
activeElement = document.activeElement;
|
|
214
|
+
if (activeElement) {
|
|
215
|
+
// Get the field name from the closest editable cell container
|
|
216
|
+
editableCellContainer = activeElement.closest("[data-field-name]");
|
|
217
|
+
if (editableCellContainer) {
|
|
218
|
+
fieldName = editableCellContainer.getAttribute("data-field-name");
|
|
219
|
+
inputValue = activeElement.value; // Update editingRowDataRef with the current DOM value
|
|
220
|
+
if (fieldName && inputValue !== undefined) {
|
|
221
|
+
rowDataRef.current = _objectSpread(_objectSpread({}, rowDataRef.current), {}, (0, _defineProperty2["default"])({}, fieldName, inputValue));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Now blur to clean up focus state
|
|
226
|
+
if (activeElement.blur) {
|
|
227
|
+
activeElement.blur();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Get current editing data
|
|
232
|
+
currentEditingData = rowDataRef.current;
|
|
233
|
+
originalData = originalRowDataRef.current; // Check if any changes were made (only for existing rows, not new rows)
|
|
234
|
+
if (!(!isNewRow && originalData && currentEditingData)) {
|
|
235
|
+
_context.next = 13;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
hasChanges = wmTableColumns.some(function (column) {
|
|
239
|
+
if (!column.field || column.readonly) return false;
|
|
240
|
+
var originalValue = (0, _lodashEs.get)(originalData, column.field);
|
|
241
|
+
var currentValue = (0, _lodashEs.get)(currentEditingData, column.field);
|
|
242
|
+
// Compare stringified values to handle type differences
|
|
243
|
+
return String(originalValue !== null && originalValue !== void 0 ? originalValue : "") !== String(currentValue !== null && currentValue !== void 0 ? currentValue : "");
|
|
244
|
+
});
|
|
245
|
+
if (hasChanges) {
|
|
246
|
+
_context.next = 13;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
showToast === null || showToast === void 0 || showToast("No changes detected", "Info");
|
|
250
|
+
// Still close edit mode even if no changes - call onSaveSuccess to reset state
|
|
251
|
+
if (onSaveSuccess) {
|
|
252
|
+
if (rowId) {
|
|
253
|
+
removeRowEdits(rowId);
|
|
254
|
+
}
|
|
255
|
+
onSaveSuccess();
|
|
256
|
+
}
|
|
257
|
+
return _context.abrupt("return", true);
|
|
258
|
+
case 13:
|
|
259
|
+
// Filter field refs to only include fields for the current row
|
|
260
|
+
relevantFieldRefs = {};
|
|
261
|
+
(0, _lodashEs.forEach)((0, _lodashEs.entries)(fieldRefs.current), function (_ref3) {
|
|
262
|
+
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
|
|
263
|
+
fieldKey = _ref4[0],
|
|
264
|
+
fieldElement = _ref4[1];
|
|
265
|
+
if (fieldKey.startsWith("".concat(currentRowId, "_"))) {
|
|
266
|
+
relevantFieldRefs[fieldKey] = fieldElement;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Validate only the relevant fields
|
|
271
|
+
validationResult = (0, _utils.validateEditingFields)(relevantFieldRefs, currentRowId);
|
|
272
|
+
if (validationResult.isValid) {
|
|
273
|
+
_context.next = 19;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
(0, _validation.updateValidationErrors)(validationResult, relevantFieldRefs, validationState);
|
|
277
|
+
return _context.abrupt("return", false);
|
|
278
|
+
case 19:
|
|
279
|
+
_context.next = 21;
|
|
280
|
+
return (0, _crudHandlers.handleServerOperation)({
|
|
281
|
+
isNewRow: isNewRow,
|
|
282
|
+
rowId: rowId,
|
|
283
|
+
currentEditingData: currentEditingData,
|
|
284
|
+
wmTableColumns: wmTableColumns,
|
|
285
|
+
datasource: datasource,
|
|
286
|
+
binddataset: binddataset,
|
|
287
|
+
setInternalDataset: setInternalDataset,
|
|
288
|
+
onNewRowAdded: onNewRowAdded,
|
|
289
|
+
onRowUpdate: onRowUpdate,
|
|
290
|
+
showToast: showToast,
|
|
291
|
+
onSuccess: onSuccess,
|
|
292
|
+
onError: onError,
|
|
293
|
+
onRowinsert: onRowinsert,
|
|
294
|
+
onRowupdate: onRowupdate,
|
|
295
|
+
insertmessage: insertmessage,
|
|
296
|
+
updatemessage: updatemessage,
|
|
297
|
+
errormessage: errormessage,
|
|
298
|
+
tableInstance: tableRef === null || tableRef === void 0 ? void 0 : tableRef.current,
|
|
299
|
+
isServerSidePagination: isServerSidePagination,
|
|
300
|
+
listener: listener,
|
|
301
|
+
widgetName: tableName
|
|
302
|
+
});
|
|
303
|
+
case 21:
|
|
304
|
+
result = _context.sent;
|
|
305
|
+
if (result) {
|
|
306
|
+
_context.next = 24;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
return _context.abrupt("return", false);
|
|
310
|
+
case 24:
|
|
311
|
+
if (updateFormData && tableName) {
|
|
312
|
+
// Sync the complete array to parent form using functional updater for latest state
|
|
313
|
+
setInternalDataset(function (currentDataset) {
|
|
314
|
+
var tableKey = tableName;
|
|
315
|
+
|
|
316
|
+
// Clean and filter the dataset
|
|
317
|
+
var cleanedDataset = currentDataset.map(function (row) {
|
|
318
|
+
// Remove all internal properties from each row using centralized constant
|
|
319
|
+
var cleanRow = _objectSpread({}, row);
|
|
320
|
+
_utils.INTERNAL_PROPERTIES.forEach(function (prop) {
|
|
321
|
+
return delete cleanRow[prop];
|
|
322
|
+
});
|
|
323
|
+
return cleanRow;
|
|
324
|
+
}).filter(function (row) {
|
|
325
|
+
// Filter out empty rows - check if row has at least one meaningful value
|
|
326
|
+
var hasData = Object.entries(row).some(function (_ref5) {
|
|
327
|
+
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
328
|
+
_ = _ref6[0],
|
|
329
|
+
value = _ref6[1];
|
|
330
|
+
return value !== null && value !== undefined && value !== "";
|
|
331
|
+
});
|
|
332
|
+
return hasData;
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// Update parent form with cleaned data (without internal properties)
|
|
336
|
+
updateFormData((0, _defineProperty2["default"])({}, tableKey, cleanedDataset));
|
|
337
|
+
|
|
338
|
+
// Return the original dataset unchanged (internal properties needed for table functionality)
|
|
339
|
+
return currentDataset;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
if (onSaveSuccess) {
|
|
343
|
+
// CLEAR EDITS ON SUCCESS
|
|
344
|
+
if (rowId) {
|
|
345
|
+
removeRowEdits(rowId);
|
|
346
|
+
}
|
|
347
|
+
onSaveSuccess();
|
|
348
|
+
}
|
|
349
|
+
return _context.abrupt("return", true);
|
|
350
|
+
case 27:
|
|
351
|
+
case "end":
|
|
352
|
+
return _context.stop();
|
|
184
353
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
(0, _lodashEs.forEach)((0, _lodashEs.entries)(fieldRefs.current), function (_ref2) {
|
|
192
|
-
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
193
|
-
fieldKey = _ref3[0],
|
|
194
|
-
fieldElement = _ref3[1];
|
|
195
|
-
if (fieldKey.startsWith("".concat(currentRowId, "_"))) {
|
|
196
|
-
relevantFieldRefs[fieldKey] = fieldElement;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Validate only the relevant fields
|
|
201
|
-
var validationResult = (0, _utils.validateEditingFields)(relevantFieldRefs, currentRowId);
|
|
202
|
-
if (!validationResult.isValid) {
|
|
203
|
-
(0, _validation.updateValidationErrors)(validationResult, relevantFieldRefs, validationState);
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Handle server insert and update operation
|
|
208
|
-
(0, _crudHandlers.handleServerOperation)({
|
|
209
|
-
isNewRow: isNewRow,
|
|
210
|
-
rowId: rowId,
|
|
211
|
-
currentEditingData: currentEditingData,
|
|
212
|
-
wmTableColumns: wmTableColumns,
|
|
213
|
-
datasource: datasource,
|
|
214
|
-
binddataset: binddataset,
|
|
215
|
-
setInternalDataset: setInternalDataset,
|
|
216
|
-
onNewRowAdded: onNewRowAdded,
|
|
217
|
-
onRowUpdate: onRowUpdate,
|
|
218
|
-
showToast: showToast,
|
|
219
|
-
onSuccess: onSuccess,
|
|
220
|
-
onError: onError,
|
|
221
|
-
onRowinsert: onRowinsert,
|
|
222
|
-
onRowupdate: onRowupdate,
|
|
223
|
-
insertmessage: insertmessage,
|
|
224
|
-
updatemessage: updatemessage,
|
|
225
|
-
errormessage: errormessage,
|
|
226
|
-
tableInstance: tableRef === null || tableRef === void 0 ? void 0 : tableRef.current,
|
|
227
|
-
isServerSidePagination: isServerSidePagination
|
|
228
|
-
});
|
|
229
|
-
if (onSaveSuccess) {
|
|
230
|
-
onSaveSuccess();
|
|
231
|
-
}
|
|
232
|
-
return true;
|
|
233
|
-
}, [internalDataset, wmTableColumns, datasource, binddataset, setInternalDataset, onNewRowAdded, onRowUpdate, showToast, onSuccess, onError, onRowinsert, onRowupdate, insertmessage, updatemessage, errormessage]);
|
|
354
|
+
}, _callee);
|
|
355
|
+
}));
|
|
356
|
+
return function (_x, _x2, _x3, _x4) {
|
|
357
|
+
return _ref2.apply(this, arguments);
|
|
358
|
+
};
|
|
359
|
+
}(), [internalDataset, wmTableColumns, datasource, binddataset, setInternalDataset, onNewRowAdded, onRowUpdate, showToast, onSuccess, onError, onRowinsert, onRowupdate, insertmessage, updatemessage, errormessage, removeRowEdits, updateFormData, tableName]);
|
|
234
360
|
|
|
235
361
|
// Save editing function
|
|
236
|
-
var saveEditing = (0, _react.useCallback)(function () {
|
|
237
|
-
var isNewRow
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
362
|
+
var saveEditing = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
363
|
+
var isNewRow, rowId, dataRef, success;
|
|
364
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
365
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
366
|
+
case 0:
|
|
367
|
+
isNewRow = editMode === "inline" ? isAddingNewRow : false;
|
|
368
|
+
rowId = editingRowId || (isNewRow ? "new-row" : null);
|
|
369
|
+
dataRef = editMode === "quickedit" && !editingRowId ? newRowDataRef : editingRowDataRef;
|
|
370
|
+
_context2.next = 5;
|
|
371
|
+
return saveEditingInternal(rowId, isNewRow, dataRef, function () {
|
|
372
|
+
// Reset editing state
|
|
373
|
+
setEditingRowId(null);
|
|
374
|
+
|
|
375
|
+
// For inline mode, reset add new row and clear the ref completely
|
|
376
|
+
if (editMode === "inline") {
|
|
377
|
+
setIsAddingNewRow(false);
|
|
378
|
+
// Clear the editing data ref to ensure no old values persist
|
|
379
|
+
editingRowDataRef.current = {};
|
|
380
|
+
}
|
|
381
|
+
resetEditingData();
|
|
382
|
+
|
|
383
|
+
// Reset validation based on context
|
|
384
|
+
resetValidationState(editMode === "quickedit" ? editingRowId ? "editing" : "new-row" : undefined);
|
|
385
|
+
incrementSessionKey();
|
|
386
|
+
});
|
|
387
|
+
case 5:
|
|
388
|
+
success = _context2.sent;
|
|
389
|
+
return _context2.abrupt("return", success);
|
|
390
|
+
case 7:
|
|
391
|
+
case "end":
|
|
392
|
+
return _context2.stop();
|
|
247
393
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// Reset validation based on context
|
|
251
|
-
resetValidationState(editMode === "quickedit" ? editingRowId ? "editing" : "new-row" : undefined);
|
|
252
|
-
incrementSessionKey();
|
|
253
|
-
});
|
|
254
|
-
return success;
|
|
255
|
-
}, [editMode, editingRowId, isAddingNewRow, resetEditingData, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, saveEditingInternal]);
|
|
394
|
+
}, _callee2);
|
|
395
|
+
})), [editMode, editingRowId, isAddingNewRow, resetEditingData, resetValidationState, setEditingRowId, setIsAddingNewRow, incrementSessionKey, saveEditingInternal]);
|
|
256
396
|
|
|
257
397
|
// Update field value function
|
|
258
398
|
var updateFieldValue = (0, _react.useCallback)(function (fieldName, newValue, rowId) {
|
|
@@ -262,6 +402,21 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
262
402
|
// Update cellState if available (for tracking changes without re-renders)
|
|
263
403
|
if (cellState && effectiveRowId !== "new-row") {
|
|
264
404
|
cellState.setValue(["cells", effectiveRowId, fieldName], newValue);
|
|
405
|
+
updateCell(effectiveRowId, fieldName, newValue);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// FIX: Only update internalDataset for quickedit mode (real-time updates needed)
|
|
409
|
+
// For inline mode, skip this to avoid re-renders - dataset will be updated on save
|
|
410
|
+
if (editMode === "quickedit" && String(effectiveRowId) !== "new-row") {
|
|
411
|
+
setInternalDataset(function (prev) {
|
|
412
|
+
return prev.map(function (row) {
|
|
413
|
+
// Match by ID
|
|
414
|
+
if ((row._wmTableRowId || row.id) === effectiveRowId) {
|
|
415
|
+
return _objectSpread(_objectSpread({}, row), {}, (0, _defineProperty2["default"])({}, fieldName, newValue));
|
|
416
|
+
}
|
|
417
|
+
return row;
|
|
418
|
+
});
|
|
419
|
+
});
|
|
265
420
|
}
|
|
266
421
|
|
|
267
422
|
// In quickedit mode, check if this update is for the new row
|
|
@@ -280,7 +435,7 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
280
435
|
});
|
|
281
436
|
(0, _validation.validateField)(effectiveRowId, fieldName, newValue, _column, validationState);
|
|
282
437
|
}
|
|
283
|
-
}, [editMode, editingRowId, wmTableColumns, cellState]);
|
|
438
|
+
}, [editMode, editingRowId, wmTableColumns, cellState, setInternalDataset]);
|
|
284
439
|
|
|
285
440
|
// Save new row (for quickedit mode)
|
|
286
441
|
var saveNewRow = (0, _react.useCallback)(function () {
|
|
@@ -294,6 +449,21 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
294
449
|
|
|
295
450
|
// Handle keyboard events (for modes that support it)
|
|
296
451
|
var handleKeyDown = (0, _react.useCallback)(function (e, sourceRowId) {
|
|
452
|
+
// Handle Enter key for inline mode as well (not just quickedit)
|
|
453
|
+
if (editMode === "inline" && e.key === "Enter" && !e.shiftKey) {
|
|
454
|
+
e.preventDefault();
|
|
455
|
+
e.stopPropagation();
|
|
456
|
+
saveEditing();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Handle Escape key for inline mode
|
|
461
|
+
if (editMode === "inline" && e.key === "Escape") {
|
|
462
|
+
e.preventDefault();
|
|
463
|
+
e.stopPropagation();
|
|
464
|
+
cancelEditing();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
297
467
|
if (!config.hasKeyboardNavigation || editMode !== "quickedit") return;
|
|
298
468
|
|
|
299
469
|
// Determine if the event is from the new row
|
|
@@ -337,7 +507,10 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
337
507
|
renderFormWidget: renderFormWidget,
|
|
338
508
|
updateFieldValue: updateFieldValue,
|
|
339
509
|
sessionKey: sessionKey,
|
|
340
|
-
onKeyDown:
|
|
510
|
+
onKeyDown:
|
|
511
|
+
// FIX: Pass onKeyDown for both inline and quickedit modes
|
|
512
|
+
// Inline mode now supports Enter/Escape keys
|
|
513
|
+
editMode === "inline" || config.hasKeyboardNavigation ? function (e) {
|
|
341
514
|
return handleKeyDown(e, rowId);
|
|
342
515
|
} : undefined,
|
|
343
516
|
editMode: editMode
|
|
@@ -351,7 +524,9 @@ var useTableEdit = exports.useTableEdit = function useTableEdit(_ref) {
|
|
|
351
524
|
if (!config.startEditOnRowClick) return;
|
|
352
525
|
|
|
353
526
|
// If not editing this row, start editing
|
|
354
|
-
if (!isRowEditing(rowId)) {
|
|
527
|
+
if (!isRowEditing(rowId) && (editMode === "quickedit" || editMode === "inline" ? (0, _lodashEs.every)(validationState.fieldValidationErrors.current, function (error) {
|
|
528
|
+
return error === false;
|
|
529
|
+
}) : true)) {
|
|
355
530
|
startEditing(rowData, rowId);
|
|
356
531
|
}
|
|
357
532
|
}, [config.startEditOnRowClick, isRowEditing, startEditing]);
|
|
@@ -6,20 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useTableEffects = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _tableHelpers = require("../utils/table-helpers");
|
|
9
|
+
var _constants = require("../utils/constants");
|
|
9
10
|
var useTableEffects = exports.useTableEffects = function useTableEffects(props) {
|
|
10
11
|
var name = props.name,
|
|
11
12
|
navigation = props.navigation,
|
|
12
13
|
datasource = props.datasource,
|
|
13
14
|
internalDataset = props.internalDataset,
|
|
14
15
|
statehandler = props.statehandler,
|
|
15
|
-
selectedRowId = props.selectedRowId,
|
|
16
16
|
selectedRowIds = props.selectedRowIds,
|
|
17
17
|
currentPage = props.currentPage,
|
|
18
18
|
currentPageSize = props.currentPageSize,
|
|
19
|
-
sorting = props.sorting,
|
|
20
19
|
isGridEditMode = props.isGridEditMode,
|
|
21
|
-
stateManager = props.stateManager
|
|
22
|
-
initialActualPageSize = props.initialActualPageSize;
|
|
20
|
+
stateManager = props.stateManager;
|
|
23
21
|
|
|
24
22
|
// State to track if we've restored state
|
|
25
23
|
var _useState = (0, _react.useState)(false),
|
|
@@ -40,6 +38,11 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
40
38
|
|
|
41
39
|
// Effect 1: Load persisted state when component mounts
|
|
42
40
|
(0, _react.useEffect)(function () {
|
|
41
|
+
// Skip state restoration for navigation types that don't support it
|
|
42
|
+
if (_constants.UNSUPPORTED_STATE_PERSISTENCE_TYPES.includes(navigation)) {
|
|
43
|
+
setHasRestoredState(true);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
43
46
|
if (!hasRestoredState && statehandler && internalDataset.length > 0) {
|
|
44
47
|
var savedState = (0, _tableHelpers.getTableState)(name, statehandler);
|
|
45
48
|
if (savedState) {
|
|
@@ -53,9 +56,11 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
53
56
|
|
|
54
57
|
// Extract selected indices for the current page (only if no active filter)
|
|
55
58
|
if (savedState.selectedItem && savedState.selectedItem.length > 0 && !hasActiveFilter) {
|
|
59
|
+
// Default to page 1 if pagination is not saved (page 1 is the default, so it's not persisted)
|
|
60
|
+
var restoredPage = savedState.pagination || 1;
|
|
56
61
|
// Only restore selections for the current page
|
|
57
62
|
var currentPageSelections = savedState.selectedItem.filter(function (item) {
|
|
58
|
-
return item.page ===
|
|
63
|
+
return item.page === restoredPage;
|
|
59
64
|
}).map(function (item) {
|
|
60
65
|
return item.index;
|
|
61
66
|
});
|
|
@@ -65,10 +70,15 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
65
70
|
}
|
|
66
71
|
setHasRestoredState(true);
|
|
67
72
|
}
|
|
68
|
-
}, [name, statehandler, hasRestoredState, internalDataset.length]);
|
|
73
|
+
}, [name, statehandler, hasRestoredState, internalDataset.length, navigation]);
|
|
69
74
|
|
|
70
75
|
// Effect 2: Persist state on changes
|
|
71
76
|
(0, _react.useEffect)(function () {
|
|
77
|
+
// Skip persistence for navigation types that don't support it
|
|
78
|
+
if (_constants.UNSUPPORTED_STATE_PERSISTENCE_TYPES.includes(navigation)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
// Skip persistence if we haven't loaded initial data yet
|
|
73
83
|
if (internalDataset.length === 0 || !statehandler) {
|
|
74
84
|
return;
|
|
@@ -79,6 +89,12 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
79
89
|
return;
|
|
80
90
|
}
|
|
81
91
|
|
|
92
|
+
// Skip persistence while datasource is loading
|
|
93
|
+
// This prevents saving stale state (e.g., old pagination value) during page transitions
|
|
94
|
+
if (datasource !== null && datasource !== void 0 && datasource.loading) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
82
98
|
// Check if we're in default state
|
|
83
99
|
if (!stateManager.isDefaultState()) {
|
|
84
100
|
// Get existing persisted state
|
|
@@ -114,12 +130,10 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
114
130
|
|
|
115
131
|
// Only save if there's something to save
|
|
116
132
|
if (Object.keys(cleanedState).length > 0) {
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
122
|
-
}
|
|
133
|
+
// Always clear first to ensure clean replacement (not merge)
|
|
134
|
+
// This is required because setWidgetState uses lodash merge() which would
|
|
135
|
+
// preserve old properties like pagination even when they should be removed
|
|
136
|
+
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
123
137
|
|
|
124
138
|
// Save the cleaned state
|
|
125
139
|
(0, _tableHelpers.saveTableState)(name, statehandler, cleanedState);
|
|
@@ -127,8 +141,12 @@ var useTableEffects = exports.useTableEffects = function useTableEffects(props)
|
|
|
127
141
|
// If nothing to save, clear the state
|
|
128
142
|
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
129
143
|
}
|
|
144
|
+
} else {
|
|
145
|
+
// We're in default state - clear any existing persisted state
|
|
146
|
+
// This ensures old values (like pagination: 2) are removed when returning to defaults
|
|
147
|
+
(0, _tableHelpers.clearTableState)(name, statehandler);
|
|
130
148
|
}
|
|
131
|
-
}, [
|
|
149
|
+
}, [selectedRowIds, currentPage, currentPageSize, internalDataset, name, statehandler, isGridEditMode, isRestoringSelection, stateManager, navigation, datasource === null || datasource === void 0 ? void 0 : datasource.loading]);
|
|
132
150
|
return {
|
|
133
151
|
restoredPageNumber: restoredPageNumber,
|
|
134
152
|
restoredSelectedRowIds: restoredSelectedRowIds,
|
|
@@ -9,7 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _lodashEs = require("lodash-es");
|
|
12
|
-
var _types = require("
|
|
12
|
+
var _types = require("@wavemaker/react-runtime/components/data/types");
|
|
13
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
15
|
// Constants
|