@wavemaker/react-runtime 11.14.3-rc.6401 → 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.
Files changed (245) hide show
  1. package/actions/base-action.js +5 -7
  2. package/actions/login-action.js +7 -8
  3. package/actions/logout-action.js +5 -7
  4. package/actions/navigation-action.js +73 -18
  5. package/actions/notification-action.js +22 -8
  6. package/actions/timer-action.js +13 -15
  7. package/actions/toast.js +4 -2
  8. package/actions/toast.service.js +1 -2
  9. package/components/advanced/carousel/index.js +1 -1
  10. package/components/advanced/carousel/template.js +1 -1
  11. package/components/basic/anchor/index.js +31 -11
  12. package/components/basic/html/index.js +115 -24
  13. package/components/basic/icon/index.js +2 -1
  14. package/components/basic/iframe/index.js +2 -1
  15. package/components/basic/label/index.js +12 -9
  16. package/components/basic/message/index.js +12 -3
  17. package/components/basic/picture/index.js +11 -4
  18. package/components/basic/progress-bar/index.js +4 -1
  19. package/components/basic/progress-circle/index.js +34 -28
  20. package/components/basic/progress-circle/props.js +10 -2
  21. package/components/basic/richtexteditor/index.js +95 -94
  22. package/components/basic/search/index.js +401 -156
  23. package/components/basic/search/providers.js +126 -61
  24. package/components/basic/spinner/index.js +2 -1
  25. package/components/basic/tree/index.js +34 -34
  26. package/components/basic/tree/utils.js +10 -4
  27. package/components/chart/components/barColumnChart/index.js +36 -33
  28. package/components/chart/components/bubbleChart/index.js +35 -25
  29. package/components/chart/components/chartLegend/utils.js +2 -1
  30. package/components/chart/components/cumulativeLineChart/index.js +30 -26
  31. package/components/chart/components/lineAreaChart/index.js +50 -32
  32. package/components/chart/components/pieDonutChart/index.js +13 -4
  33. package/components/chart/hooks/useXAxisConfig.js +15 -8
  34. package/components/chart/index.js +223 -53
  35. package/components/chart/utils.js +12 -1
  36. package/components/constants.js +5 -2
  37. package/components/container/accordion/accordion-pane/index.js +17 -12
  38. package/components/container/accordion/index.js +9 -4
  39. package/components/container/alignment-utils.js +56 -1
  40. package/components/container/index.js +49 -20
  41. package/components/container/panel/components/panel-header/index.js +3 -4
  42. package/components/container/panel/index.js +15 -10
  43. package/components/container/repeat-template/index.js +33 -0
  44. package/components/container/tabs/index.js +83 -14
  45. package/components/container/tabs/tab-pane/index.js +33 -10
  46. package/components/container/tabs/utils.js +51 -0
  47. package/components/container/wizard/components/StepComponents.js +2 -1
  48. package/components/container/wizard/components/WizardStep.js +2 -1
  49. package/components/container/wizard/index.js +64 -35
  50. package/components/container/wizard/utils.js +46 -1
  51. package/components/container/wizard/wizard-step/index.js +11 -1
  52. package/components/data/card/card-content/index.js +1 -1
  53. package/components/data/form/base-form/index.js +985 -183
  54. package/components/data/form/base-form/props.js +3 -1
  55. package/components/data/form/base-form/utils.js +159 -1
  56. package/components/data/form/dynamic-fields/constant.js +53 -0
  57. package/components/data/form/dynamic-fields/index.js +10 -45
  58. package/components/data/form/dynamic-fields/utils.js +37 -2
  59. package/components/data/form/form-action/index.js +5 -4
  60. package/components/data/form/form-context.js +5 -1
  61. package/components/data/form/form-controller/utils.js +84 -0
  62. package/components/data/form/form-controller/validation-contrustor.js +402 -189
  63. package/components/data/form/form-controller/withFormController.js +191 -52
  64. package/components/data/form/form-field/base-field.js +67 -45
  65. package/components/data/form/form-field/index.js +28 -5
  66. package/components/data/form/form-header/index.js +3 -4
  67. package/components/data/form/index.js +20 -1
  68. package/components/data/list/components/ListDND.js +2 -1
  69. package/components/data/list/components/ListItem.js +6 -2
  70. package/components/data/list/components/ListItemWithTemplate.js +46 -2
  71. package/components/data/list/components/ListItems.js +17 -26
  72. package/components/data/list/components/ListPagination.js +3 -3
  73. package/components/data/list/components/StandardListItems.js +3 -4
  74. package/components/data/list/hooks/useListEffects.js +55 -14
  75. package/components/data/list/hooks/useListEventHandlers.js +3 -1
  76. package/components/data/list/hooks/useListState.js +3 -1
  77. package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
  78. package/components/data/list/index.js +74 -55
  79. package/components/data/list/utils/list-helpers.js +73 -35
  80. package/components/data/list/utils/list-widget-methods.js +138 -95
  81. package/components/data/live-filter/index.js +26 -15
  82. package/components/data/live-form/index.js +51 -18
  83. package/components/data/live-form/props.js +1 -1
  84. package/components/data/pagination/components/BasicPagination.js +71 -16
  85. package/components/data/pagination/components/PageSizeSelector.js +8 -3
  86. package/components/data/pagination/components/TotalRecords.js +1 -5
  87. package/components/data/pagination/hooks/usePagination.js +349 -66
  88. package/components/data/pagination/index.js +137 -19
  89. package/components/data/table/components/AddNewRow.js +5 -1
  90. package/components/data/table/components/EditableCell.js +2 -2
  91. package/components/data/table/components/RowCells.js +64 -0
  92. package/components/data/table/components/RowExpansionButton.js +2 -2
  93. package/components/data/table/components/SummaryCell.js +111 -0
  94. package/components/data/table/components/SummaryRow.js +54 -0
  95. package/components/data/table/components/SummaryRowFooter.js +46 -0
  96. package/components/data/table/components/TableBody.js +61 -59
  97. package/components/data/table/components/TableDataRow.js +109 -0
  98. package/components/data/table/components/TableFilters.js +225 -121
  99. package/components/data/table/components/TableHeader.js +291 -23
  100. package/components/data/table/components/TablePanelHeading.js +139 -8
  101. package/components/data/table/components/index.js +22 -1
  102. package/components/data/table/hooks/use-edited-rows.js +141 -0
  103. package/components/data/table/hooks/useCellState.js +5 -12
  104. package/components/data/table/hooks/useFormWidget.js +58 -52
  105. package/components/data/table/hooks/usePaginationState.js +45 -24
  106. package/components/data/table/hooks/usePanelStructure.js +4 -4
  107. package/components/data/table/hooks/useRowHandlers.js +39 -5
  108. package/components/data/table/hooks/useRowSelection.js +244 -50
  109. package/components/data/table/hooks/useServerSideSorting.js +81 -37
  110. package/components/data/table/hooks/useTableColumns.js +211 -118
  111. package/components/data/table/hooks/useTableData.js +54 -9
  112. package/components/data/table/hooks/useTableEdit.js +272 -97
  113. package/components/data/table/hooks/useTableEffects.js +31 -13
  114. package/components/data/table/hooks/useTableFilter.js +1 -1
  115. package/components/data/table/hooks/useTableInitialization.js +23 -22
  116. package/components/data/table/hooks/useTableState.js +11 -5
  117. package/components/data/table/hooks/useTableStateManager.js +140 -65
  118. package/components/data/table/index.js +637 -274
  119. package/components/data/table/live-table/index.js +54 -22
  120. package/components/data/table/table-action/index.js +1 -1
  121. package/components/data/table/table-group/index.js +26 -0
  122. package/components/data/table/table-row-action/index.js +32 -18
  123. package/components/data/table/utils/buildSelectionColumns.js +12 -21
  124. package/components/data/table/utils/columnBuilder.js +29 -14
  125. package/components/data/table/utils/columnProxy.js +68 -1
  126. package/components/data/table/utils/constants.js +6 -2
  127. package/components/data/table/utils/crud-handlers.js +68 -63
  128. package/components/data/table/utils/groupHeaderUtils.js +102 -0
  129. package/components/data/table/utils/index.js +210 -21
  130. package/components/data/table/utils/renderDisplayCell.js +6 -6
  131. package/components/data/table/utils/selectionUtils.js +25 -26
  132. package/components/data/table/utils/validation.js +1 -0
  133. package/components/data/utils/filter-field-util.js +3 -3
  134. package/components/dialogs/alert-dialog/index.js +1 -1
  135. package/components/dialogs/confirm-dialog/index.js +1 -1
  136. package/components/dialogs/dialog/index.js +4 -1
  137. package/components/dialogs/dialog-content/index.js +3 -1
  138. package/components/dialogs/dialog-header/index.js +2 -2
  139. package/components/dialogs/iframe-dialog/index.js +11 -5
  140. package/components/dialogs/index.js +1 -1
  141. package/components/dialogs/login-dialog/index.js +1 -1
  142. package/components/dialogs/page-dialog/index.js +1 -1
  143. package/components/form/button/index.js +33 -7
  144. package/components/input/calendar/index.js +18 -6
  145. package/components/input/chips/index.js +99 -28
  146. package/components/input/chips/utils.js +34 -4
  147. package/components/input/color-picker/index.js +74 -25
  148. package/components/input/composite/index.js +3 -3
  149. package/components/input/currency/index.js +35 -49
  150. package/components/input/default/checkbox/index.js +23 -28
  151. package/components/input/default/checkboxset/index.js +38 -18
  152. package/components/input/default/checkboxset/utils.js +30 -0
  153. package/components/input/default/radioset/index.js +36 -39
  154. package/components/input/default/switch/index.js +30 -13
  155. package/components/input/epoch/date/index.js +130 -69
  156. package/components/input/epoch/date/utils.js +94 -1
  157. package/components/input/epoch/datetime/index.js +72 -22
  158. package/components/input/epoch/datetime/utils.js +49 -10
  159. package/components/input/epoch/time/index.js +68 -19
  160. package/components/input/epoch/time/utils.js +62 -14
  161. package/components/input/fileupload/Utils.js +12 -7
  162. package/components/input/fileupload/components/MultiUpload.js +2 -6
  163. package/components/input/fileupload/components/SingleUpload.js +3 -7
  164. package/components/input/fileupload/index.js +6 -10
  165. package/components/input/fileupload/useFileUpload.js +16 -5
  166. package/components/input/number/index.js +158 -43
  167. package/components/input/rating/index.js +90 -7
  168. package/components/input/select/index.js +209 -72
  169. package/components/input/slider/index.js +84 -26
  170. package/components/input/text/index.js +38 -18
  171. package/components/input/text/util.js +283 -130
  172. package/components/input/textarea/index.js +13 -10
  173. package/components/input/upload/index.js +124 -0
  174. package/components/input/upload/props.js +5 -0
  175. package/components/input/util/index.js +11 -0
  176. package/components/navbar/index.js +51 -3
  177. package/components/navbar/nav/index.js +46 -16
  178. package/components/navbar/nav-item/index.js +11 -5
  179. package/components/navigation/menu/components/ListItems.js +3 -0
  180. package/components/navigation/menu/constants.js +2 -1
  181. package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
  182. package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
  183. package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
  184. package/components/navigation/menu/index.js +326 -188
  185. package/components/navigation/menu/utils/action-task.js +14 -0
  186. package/components/navigation/menu/utils/role-filter.js +76 -0
  187. package/components/navigation/popover/index.js +105 -32
  188. package/components/page/partial-container/index.js +34 -5
  189. package/components/prefab/index.js +2 -4
  190. package/context/PrefabContext.js +10 -6
  191. package/context/WidgetProvider.js +30 -31
  192. package/core/app.service.js +1 -1
  193. package/core/constants/events.js +57 -1
  194. package/core/dialog.service.js +1 -2
  195. package/core/event-notifier.js +1 -2
  196. package/core/formatter/array-formatters.js +33 -0
  197. package/core/formatter/date-formatters.js +2 -4
  198. package/core/formatter/index.js +2 -1
  199. package/core/formatter/number-formatters.js +5 -10
  200. package/core/formatter/security-formatters.js +2 -4
  201. package/core/formatter/string-formatters.js +3 -6
  202. package/core/proxy-service.js +85 -13
  203. package/core/script-registry.js +108 -48
  204. package/core/util/common.js +4 -4
  205. package/core/util/compare.js +30 -0
  206. package/core/util/dom.js +8 -8
  207. package/core/util/index.js +16 -6
  208. package/core/util/safe-is-equal.js +156 -0
  209. package/core/util/security.js +1 -2
  210. package/core/util/utils.js +16 -7
  211. package/higherOrder/BaseApp.js +108 -65
  212. package/higherOrder/BaseDateTime.js +31 -13
  213. package/higherOrder/BasePage.js +268 -144
  214. package/higherOrder/BasePartial.js +1 -1
  215. package/higherOrder/BasePrefab.js +33 -15
  216. package/higherOrder/DataNav.js +99 -16
  217. package/higherOrder/helper.js +41 -3
  218. package/higherOrder/withBaseWrapper.js +41 -28
  219. package/hooks/useAuth.js +11 -5
  220. package/hooks/useHttp.js +280 -94
  221. package/mui-config/theme-provider.js +1 -1
  222. package/mui-config/theme.js +1 -1
  223. package/package-lock.json +307 -266
  224. package/package.json +8 -8
  225. package/store/bindActions/i18nActions.js +18 -0
  226. package/store/index.js +3 -1
  227. package/store/slices/appConfigSlice.js +2 -2
  228. package/store/slices/authSlice.js +31 -28
  229. package/store/slices/i18nSlice.js +2 -2
  230. package/store/slices/navigationSlice.js +35 -0
  231. package/store/viewport.service.js +255 -0
  232. package/utils/attr.js +35 -0
  233. package/utils/dataset-util.js +1 -2
  234. package/utils/form-state.util.js +43 -12
  235. package/utils/form-utils.js +47 -2
  236. package/utils/format-util.js +28 -13
  237. package/utils/page-params-util.js +33 -1
  238. package/utils/state-persistance.js +72 -13
  239. package/utils/transformedDataset-utils.js +35 -24
  240. package/variables/base-variable.js +12 -14
  241. package/variables/crud-variable.js +225 -0
  242. package/variables/live-variable.js +56 -20
  243. package/variables/metadata.service.js +123 -0
  244. package/variables/model-variable.js +21 -15
  245. 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
- editingRowDataRef.current = _objectSpread({}, rowData);
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 (rowId, isNewRow, rowDataRef, onSaveSuccess) {
164
- var currentRowId = rowId || (isNewRow ? "new-row" : null);
165
- if (!currentRowId) return false;
166
-
167
- // Get original row data
168
- var originalRow = !isNewRow && rowId ? internalDataset.find(function (row) {
169
- return row._wmTableRowId === rowId;
170
- }) : null;
171
- var currentEditingData = rowDataRef.current;
172
-
173
- // For existing rows, check if there are any changes
174
- if (!isNewRow && rowId && originalRow) {
175
- var hasChanges = Object.keys(currentEditingData).some(function (key) {
176
- return currentEditingData[key] !== originalRow[key];
177
- });
178
- if (!hasChanges) {
179
- if (showToast) {
180
- showToast("No Changes Detected", "Info");
181
- }
182
- if (onSaveSuccess) {
183
- onSaveSuccess();
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
- return true;
186
- }
187
- }
188
-
189
- // Filter field refs to only include fields for the current row
190
- var relevantFieldRefs = {};
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 = editMode === "inline" ? isAddingNewRow : false;
238
- var rowId = editingRowId || (isNewRow ? "new-row" : null);
239
- var dataRef = editMode === "quickedit" && !editingRowId ? newRowDataRef : editingRowDataRef;
240
- var success = saveEditingInternal(rowId, isNewRow, dataRef, function () {
241
- // Reset editing state
242
- setEditingRowId(null);
243
-
244
- // For inline mode, reset add new row
245
- if (editMode === "inline") {
246
- setIsAddingNewRow(false);
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
- resetEditingData();
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: config.hasKeyboardNavigation ? function (e) {
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 === savedState.pagination;
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
- // If we have a filter active, use clear-then-save to avoid merge issues
118
- var hasActiveFilter = cleanedState.search && cleanedState.search.length > 0;
119
- if (hasActiveFilter) {
120
- // Clear first to ensure no merge happens
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
- }, [selectedRowId, selectedRowIds, currentPage, currentPageSize, internalDataset, name, statehandler, isGridEditMode, isRestoringSelection, stateManager]);
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("../../types");
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