funda-ui 4.7.445 → 4.7.515

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/Date/index.js CHANGED
@@ -5471,14 +5471,16 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5471
5471
  }
5472
5472
  function _handleKeyPressedForSplitInputs() {
5473
5473
  _handleKeyPressedForSplitInputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
5474
- var key, btnMark, isLeftArrow, isRightArrow, move;
5474
+ var key, btnMark, isNumLockOn, isLeftArrow, isRightArrow, move;
5475
5475
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5476
5476
  while (1) switch (_context2.prev = _context2.next) {
5477
5477
  case 0:
5478
5478
  key = event.code;
5479
- btnMark = event.target.dataset.mark; // Check for both regular arrow keys and numpad arrow keys
5480
- isLeftArrow = key === 'ArrowLeft' || key === 'Numpad4';
5481
- isRightArrow = key === 'ArrowRight' || key === 'Numpad6';
5479
+ btnMark = event.target.dataset.mark;
5480
+ isNumLockOn = event.getModifierState && event.getModifierState('NumLock'); // Check for both regular arrow keys and numpad arrow keys
5481
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
5482
+ isLeftArrow = key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn;
5483
+ isRightArrow = key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn;
5482
5484
  move = function move(direction) {
5483
5485
  var currentIndex = splitInputsIds.findIndex(function (s) {
5484
5486
  return s === btnMark;
@@ -5499,7 +5501,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5499
5501
  if (isRightArrow) {
5500
5502
  move('right');
5501
5503
  }
5502
- case 7:
5504
+ case 8:
5503
5505
  case "end":
5504
5506
  return _context2.stop();
5505
5507
  }
package/Table/index.js CHANGED
@@ -1131,13 +1131,14 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1131
1131
  var handleKeyPressed = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)( /*#__PURE__*/function () {
1132
1132
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
1133
1133
  var _focusableCellIdRef$c;
1134
- var key, currentCell, row, col, nextCellSignal, oldCellSignal, _row, _col, move, _nextCellSignal;
1134
+ var key, isNumLockOn, currentCell, row, col, nextCellSignal, oldCellSignal, _row, _col, move, _nextCellSignal;
1135
1135
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1136
1136
  while (1) switch (_context.prev = _context.next) {
1137
1137
  case 0:
1138
- key = event.code; // If Enter is pressed and keyboard navigation is disabled, just trigger onCellPressEnter
1138
+ key = event.code;
1139
+ isNumLockOn = event.getModifierState && event.getModifierState('NumLock'); // If Enter is pressed and keyboard navigation is disabled, just trigger onCellPressEnter
1139
1140
  if (!((key === 'Enter' || key === 'NumpadEnter') && !enabled)) {
1140
- _context.next = 8;
1141
+ _context.next = 9;
1141
1142
  break;
1142
1143
  }
1143
1144
  currentCell = event.target;
@@ -1146,13 +1147,13 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1146
1147
  nextCellSignal = cellMark(row, col);
1147
1148
  onCellPressEnter === null || onCellPressEnter === void 0 ? void 0 : onCellPressEnter(nextCellSignal, refNode.current.get(nextCellSignal), event);
1148
1149
  return _context.abrupt("return");
1149
- case 8:
1150
+ case 9:
1150
1151
  if (!(!Array.isArray(data) || rootDataInfo === null || spyElement === null || typeof enabled === 'undefined' || enabled === false)) {
1151
- _context.next = 10;
1152
+ _context.next = 11;
1152
1153
  break;
1153
1154
  }
1154
1155
  return _context.abrupt("return");
1155
- case 10:
1156
+ case 11:
1156
1157
  // Parse the current focused cell's row and column
1157
1158
  oldCellSignal = (_focusableCellIdRef$c = focusableCellIdRef.current) === null || _focusableCellIdRef$c === void 0 ? void 0 : _focusableCellIdRef$c.replace('cell-', '').split('-');
1158
1159
  _row = Number(oldCellSignal[0]);
@@ -1171,45 +1172,39 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1171
1172
  maxCol = rowInfo.colCount;
1172
1173
  }
1173
1174
  }
1174
- switch (key) {
1175
- case 'ArrowLeft':
1176
- case 'Numpad4':
1177
- if (_col - 1 < 0) {
1178
- isLeftEdge = true;
1179
- _col = 0;
1180
- } else {
1181
- _col = _col - 1;
1182
- }
1183
- break;
1184
- case 'ArrowRight':
1185
- case 'Numpad6':
1186
- {
1187
- if (_col + 1 > maxCol - 1) {
1188
- isRightEdge = true;
1189
- _col = maxCol - 1;
1190
- } else {
1191
- _col = _col + 1;
1192
- }
1193
- break;
1194
- }
1195
- case 'ArrowUp':
1196
- case 'Numpad8':
1197
- if (_row - 1 < 0) {
1198
- isTopEdge = true;
1199
- _row = 0;
1200
- } else {
1201
- _row = _row - 1;
1202
- }
1203
- break;
1204
- case 'ArrowDown':
1205
- case 'Numpad2':
1206
- if (_row + 1 > rootDataInfo.totalRow - 1) {
1207
- isBottomEdge = true;
1208
- _row = rootDataInfo.totalRow - 1;
1209
- } else {
1210
- _row = _row + 1;
1211
- }
1212
- break;
1175
+
1176
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
1177
+ if (key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn) {
1178
+ if (_col - 1 < 0) {
1179
+ isLeftEdge = true;
1180
+ _col = 0;
1181
+ } else {
1182
+ _col = _col - 1;
1183
+ }
1184
+ }
1185
+ if (key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn) {
1186
+ if (_col + 1 > maxCol - 1) {
1187
+ isRightEdge = true;
1188
+ _col = maxCol - 1;
1189
+ } else {
1190
+ _col = _col + 1;
1191
+ }
1192
+ }
1193
+ if (key === 'ArrowUp' || key === 'Numpad8' && !isNumLockOn) {
1194
+ if (_row - 1 < 0) {
1195
+ isTopEdge = true;
1196
+ _row = 0;
1197
+ } else {
1198
+ _row = _row - 1;
1199
+ }
1200
+ }
1201
+ if (key === 'ArrowDown' || key === 'Numpad2' && !isNumLockOn) {
1202
+ if (_row + 1 > rootDataInfo.totalRow - 1) {
1203
+ isBottomEdge = true;
1204
+ _row = rootDataInfo.totalRow - 1;
1205
+ } else {
1206
+ _row = _row + 1;
1207
+ }
1213
1208
  }
1214
1209
  var nextCellSignal = cellMark(_row, _col);
1215
1210
  // Focus the current cell
@@ -1223,16 +1218,17 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1223
1218
  onCellKeyPressed === null || onCellKeyPressed === void 0 ? void 0 : onCellKeyPressed(nextCellSignal, refNode.current.get(nextCellSignal), event, isLeftEdge, isRightEdge, isTopEdge, isBottomEdge);
1224
1219
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
1225
1220
  }; // Handle arrow key navigation
1226
- if (key === 'ArrowLeft' || key === 'Numpad4') {
1221
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
1222
+ if (key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn) {
1227
1223
  move('ArrowLeft');
1228
1224
  }
1229
- if (key === 'ArrowRight' || key === 'Numpad6') {
1225
+ if (key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn) {
1230
1226
  move('ArrowRight');
1231
1227
  }
1232
- if (key === 'ArrowUp' || key === 'Numpad8') {
1228
+ if (key === 'ArrowUp' || key === 'Numpad8' && !isNumLockOn) {
1233
1229
  move('ArrowUp');
1234
1230
  }
1235
- if (key === 'ArrowDown' || key === 'Numpad2') {
1231
+ if (key === 'ArrowDown' || key === 'Numpad2' && !isNumLockOn) {
1236
1232
  move('ArrowDown');
1237
1233
  }
1238
1234
 
@@ -1241,7 +1237,7 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1241
1237
  _nextCellSignal = cellMark(_row, _col);
1242
1238
  onCellPressEnter === null || onCellPressEnter === void 0 ? void 0 : onCellPressEnter(_nextCellSignal, refNode.current.get(_nextCellSignal), event);
1243
1239
  }
1244
- case 19:
1240
+ case 20:
1245
1241
  case "end":
1246
1242
  return _context.stop();
1247
1243
  }
@@ -2069,7 +2065,28 @@ const App = () => {
2069
2065
 
2070
2066
  useTableSort({
2071
2067
  enabled: sortableTable && rootRef.current,
2072
- spyElement: rootRef.current
2068
+ spyElement: rootRef.current,
2069
+ sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
2070
+
2071
+ // Custom comparison logic
2072
+ let v1 = a.textContent, v2 = b.textContent;
2073
+ if (filterType === 'number') {
2074
+ v1 = parseFloat(v1);
2075
+ v2 = parseFloat(v2);
2076
+ }
2077
+
2078
+ let result = 0;
2079
+ if (filterType === 'text') {
2080
+ result = v1.localeCompare(v2);
2081
+ } else {
2082
+ result = v1 - v2;
2083
+ }
2084
+
2085
+ // Apply display animation and status updates
2086
+ handleProcess();
2087
+
2088
+ return inverse ? -result : result;
2089
+ }
2073
2090
  }, [rootRef]);
2074
2091
 
2075
2092
  return (
@@ -2090,7 +2107,8 @@ function useTableSort(_ref, deps) {
2090
2107
  _ref$isReverse = _ref.isReverse,
2091
2108
  isReverse = _ref$isReverse === void 0 ? false : _ref$isReverse,
2092
2109
  onColSort = _ref.onColSort,
2093
- onClick = _ref.onClick;
2110
+ onClick = _ref.onClick,
2111
+ sortBy = _ref.sortBy;
2094
2112
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
2095
2113
  _useState2 = useTableSort_slicedToArray(_useState, 2),
2096
2114
  inverse = _useState2[0],
@@ -2104,16 +2122,22 @@ function useTableSort(_ref, deps) {
2104
2122
  var filterType = fieldType || 'text';
2105
2123
  var curIndex = el.dataset.tableCol;
2106
2124
  var targetComparator = [].slice.call(tbodyRef.querySelectorAll("[data-table-col=\"".concat(curIndex, "\"]")));
2125
+ var handleProcess = function handleProcess() {
2126
+ allRows(spyElement).forEach(function (node) {
2127
+ node.classList.add('newsort');
2128
+ });
2129
+ setInverse(!inverse);
2130
+ };
2107
2131
 
2108
- //sort of HTML elements
2109
- var sortBy = function sortBy(a, b) {
2132
+ //
2133
+ var defaultSortBy = function defaultSortBy(a, b) {
2110
2134
  var txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
2111
2135
  txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
2112
2136
 
2113
2137
  //type of number
2114
2138
  if (filterType == 'number') {
2115
- txt1 = Number(txt1.replace(/[^0-9.-]+/g, ''));
2116
- txt2 = Number(txt2.replace(/[^0-9.-]+/g, ''));
2139
+ txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
2140
+ txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
2117
2141
  }
2118
2142
 
2119
2143
  //type of date
@@ -2123,10 +2147,7 @@ function useTableSort(_ref, deps) {
2123
2147
  }
2124
2148
 
2125
2149
  //add filter class
2126
- allRows(spyElement).forEach(function (node) {
2127
- node.classList.add('newsort');
2128
- });
2129
- setInverse(!inverse);
2150
+ handleProcess();
2130
2151
 
2131
2152
  // result
2132
2153
  if (filterType == 'text') {
@@ -2139,7 +2160,10 @@ function useTableSort(_ref, deps) {
2139
2160
  return isReverse ? txt1 < txt2 ? -1 : txt1 > txt2 ? 1 : 0 : txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0;
2140
2161
  }
2141
2162
  };
2142
- targetComparator.sort(sortBy);
2163
+
2164
+ // Use a custom sort method if available, otherwise default is used
2165
+ var sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
2166
+ targetComparator.sort(sortFn);
2143
2167
 
2144
2168
  //console.log( 'targetComparator:', targetComparator );
2145
2169
  //console.log( 'inverse:', inverse );
@@ -2191,7 +2215,8 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
2191
2215
  icon = props.icon,
2192
2216
  _props$isReverse = props.isReverse,
2193
2217
  isReverse = _props$isReverse === void 0 ? false : _props$isReverse,
2194
- onClick = props.onClick;
2218
+ onClick = props.onClick,
2219
+ sortBy = props.sortBy;
2195
2220
  var _useContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(TableContext),
2196
2221
  originData = _useContext.originData,
2197
2222
  rootRef = _useContext.rootRef,
@@ -2206,7 +2231,8 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
2206
2231
  fieldType: fieldType,
2207
2232
  onColSort: onColSort,
2208
2233
  isReverse: isReverse,
2209
- onClick: onClick
2234
+ onClick: onClick,
2235
+ sortBy: sortBy
2210
2236
  }, [rootRef]),
2211
2237
  handleSortList = _useTableSort.handleSortList;
2212
2238
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
@@ -5471,14 +5471,16 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5471
5471
  }
5472
5472
  function _handleKeyPressedForSplitInputs() {
5473
5473
  _handleKeyPressedForSplitInputs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
5474
- var key, btnMark, isLeftArrow, isRightArrow, move;
5474
+ var key, btnMark, isNumLockOn, isLeftArrow, isRightArrow, move;
5475
5475
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5476
5476
  while (1) switch (_context2.prev = _context2.next) {
5477
5477
  case 0:
5478
5478
  key = event.code;
5479
- btnMark = event.target.dataset.mark; // Check for both regular arrow keys and numpad arrow keys
5480
- isLeftArrow = key === 'ArrowLeft' || key === 'Numpad4';
5481
- isRightArrow = key === 'ArrowRight' || key === 'Numpad6';
5479
+ btnMark = event.target.dataset.mark;
5480
+ isNumLockOn = event.getModifierState && event.getModifierState('NumLock'); // Check for both regular arrow keys and numpad arrow keys
5481
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
5482
+ isLeftArrow = key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn;
5483
+ isRightArrow = key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn;
5482
5484
  move = function move(direction) {
5483
5485
  var currentIndex = splitInputsIds.findIndex(function (s) {
5484
5486
  return s === btnMark;
@@ -5499,7 +5501,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5499
5501
  if (isRightArrow) {
5500
5502
  move('right');
5501
5503
  }
5502
- case 7:
5504
+ case 8:
5503
5505
  case "end":
5504
5506
  return _context2.stop();
5505
5507
  }
@@ -1131,13 +1131,14 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1131
1131
  var handleKeyPressed = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)( /*#__PURE__*/function () {
1132
1132
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
1133
1133
  var _focusableCellIdRef$c;
1134
- var key, currentCell, row, col, nextCellSignal, oldCellSignal, _row, _col, move, _nextCellSignal;
1134
+ var key, isNumLockOn, currentCell, row, col, nextCellSignal, oldCellSignal, _row, _col, move, _nextCellSignal;
1135
1135
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1136
1136
  while (1) switch (_context.prev = _context.next) {
1137
1137
  case 0:
1138
- key = event.code; // If Enter is pressed and keyboard navigation is disabled, just trigger onCellPressEnter
1138
+ key = event.code;
1139
+ isNumLockOn = event.getModifierState && event.getModifierState('NumLock'); // If Enter is pressed and keyboard navigation is disabled, just trigger onCellPressEnter
1139
1140
  if (!((key === 'Enter' || key === 'NumpadEnter') && !enabled)) {
1140
- _context.next = 8;
1141
+ _context.next = 9;
1141
1142
  break;
1142
1143
  }
1143
1144
  currentCell = event.target;
@@ -1146,13 +1147,13 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1146
1147
  nextCellSignal = cellMark(row, col);
1147
1148
  onCellPressEnter === null || onCellPressEnter === void 0 ? void 0 : onCellPressEnter(nextCellSignal, refNode.current.get(nextCellSignal), event);
1148
1149
  return _context.abrupt("return");
1149
- case 8:
1150
+ case 9:
1150
1151
  if (!(!Array.isArray(data) || rootDataInfo === null || spyElement === null || typeof enabled === 'undefined' || enabled === false)) {
1151
- _context.next = 10;
1152
+ _context.next = 11;
1152
1153
  break;
1153
1154
  }
1154
1155
  return _context.abrupt("return");
1155
- case 10:
1156
+ case 11:
1156
1157
  // Parse the current focused cell's row and column
1157
1158
  oldCellSignal = (_focusableCellIdRef$c = focusableCellIdRef.current) === null || _focusableCellIdRef$c === void 0 ? void 0 : _focusableCellIdRef$c.replace('cell-', '').split('-');
1158
1159
  _row = Number(oldCellSignal[0]);
@@ -1171,45 +1172,39 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1171
1172
  maxCol = rowInfo.colCount;
1172
1173
  }
1173
1174
  }
1174
- switch (key) {
1175
- case 'ArrowLeft':
1176
- case 'Numpad4':
1177
- if (_col - 1 < 0) {
1178
- isLeftEdge = true;
1179
- _col = 0;
1180
- } else {
1181
- _col = _col - 1;
1182
- }
1183
- break;
1184
- case 'ArrowRight':
1185
- case 'Numpad6':
1186
- {
1187
- if (_col + 1 > maxCol - 1) {
1188
- isRightEdge = true;
1189
- _col = maxCol - 1;
1190
- } else {
1191
- _col = _col + 1;
1192
- }
1193
- break;
1194
- }
1195
- case 'ArrowUp':
1196
- case 'Numpad8':
1197
- if (_row - 1 < 0) {
1198
- isTopEdge = true;
1199
- _row = 0;
1200
- } else {
1201
- _row = _row - 1;
1202
- }
1203
- break;
1204
- case 'ArrowDown':
1205
- case 'Numpad2':
1206
- if (_row + 1 > rootDataInfo.totalRow - 1) {
1207
- isBottomEdge = true;
1208
- _row = rootDataInfo.totalRow - 1;
1209
- } else {
1210
- _row = _row + 1;
1211
- }
1212
- break;
1175
+
1176
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
1177
+ if (key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn) {
1178
+ if (_col - 1 < 0) {
1179
+ isLeftEdge = true;
1180
+ _col = 0;
1181
+ } else {
1182
+ _col = _col - 1;
1183
+ }
1184
+ }
1185
+ if (key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn) {
1186
+ if (_col + 1 > maxCol - 1) {
1187
+ isRightEdge = true;
1188
+ _col = maxCol - 1;
1189
+ } else {
1190
+ _col = _col + 1;
1191
+ }
1192
+ }
1193
+ if (key === 'ArrowUp' || key === 'Numpad8' && !isNumLockOn) {
1194
+ if (_row - 1 < 0) {
1195
+ isTopEdge = true;
1196
+ _row = 0;
1197
+ } else {
1198
+ _row = _row - 1;
1199
+ }
1200
+ }
1201
+ if (key === 'ArrowDown' || key === 'Numpad2' && !isNumLockOn) {
1202
+ if (_row + 1 > rootDataInfo.totalRow - 1) {
1203
+ isBottomEdge = true;
1204
+ _row = rootDataInfo.totalRow - 1;
1205
+ } else {
1206
+ _row = _row + 1;
1207
+ }
1213
1208
  }
1214
1209
  var nextCellSignal = cellMark(_row, _col);
1215
1210
  // Focus the current cell
@@ -1223,16 +1218,17 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1223
1218
  onCellKeyPressed === null || onCellKeyPressed === void 0 ? void 0 : onCellKeyPressed(nextCellSignal, refNode.current.get(nextCellSignal), event, isLeftEdge, isRightEdge, isTopEdge, isBottomEdge);
1224
1219
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
1225
1220
  }; // Handle arrow key navigation
1226
- if (key === 'ArrowLeft' || key === 'Numpad4') {
1221
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
1222
+ if (key === 'ArrowLeft' || key === 'Numpad4' && !isNumLockOn) {
1227
1223
  move('ArrowLeft');
1228
1224
  }
1229
- if (key === 'ArrowRight' || key === 'Numpad6') {
1225
+ if (key === 'ArrowRight' || key === 'Numpad6' && !isNumLockOn) {
1230
1226
  move('ArrowRight');
1231
1227
  }
1232
- if (key === 'ArrowUp' || key === 'Numpad8') {
1228
+ if (key === 'ArrowUp' || key === 'Numpad8' && !isNumLockOn) {
1233
1229
  move('ArrowUp');
1234
1230
  }
1235
- if (key === 'ArrowDown' || key === 'Numpad2') {
1231
+ if (key === 'ArrowDown' || key === 'Numpad2' && !isNumLockOn) {
1236
1232
  move('ArrowDown');
1237
1233
  }
1238
1234
 
@@ -1241,7 +1237,7 @@ var useTableKeyPress = function useTableKeyPress(_ref, deps) {
1241
1237
  _nextCellSignal = cellMark(_row, _col);
1242
1238
  onCellPressEnter === null || onCellPressEnter === void 0 ? void 0 : onCellPressEnter(_nextCellSignal, refNode.current.get(_nextCellSignal), event);
1243
1239
  }
1244
- case 19:
1240
+ case 20:
1245
1241
  case "end":
1246
1242
  return _context.stop();
1247
1243
  }
@@ -2069,7 +2065,28 @@ const App = () => {
2069
2065
 
2070
2066
  useTableSort({
2071
2067
  enabled: sortableTable && rootRef.current,
2072
- spyElement: rootRef.current
2068
+ spyElement: rootRef.current,
2069
+ sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
2070
+
2071
+ // Custom comparison logic
2072
+ let v1 = a.textContent, v2 = b.textContent;
2073
+ if (filterType === 'number') {
2074
+ v1 = parseFloat(v1);
2075
+ v2 = parseFloat(v2);
2076
+ }
2077
+
2078
+ let result = 0;
2079
+ if (filterType === 'text') {
2080
+ result = v1.localeCompare(v2);
2081
+ } else {
2082
+ result = v1 - v2;
2083
+ }
2084
+
2085
+ // Apply display animation and status updates
2086
+ handleProcess();
2087
+
2088
+ return inverse ? -result : result;
2089
+ }
2073
2090
  }, [rootRef]);
2074
2091
 
2075
2092
  return (
@@ -2090,7 +2107,8 @@ function useTableSort(_ref, deps) {
2090
2107
  _ref$isReverse = _ref.isReverse,
2091
2108
  isReverse = _ref$isReverse === void 0 ? false : _ref$isReverse,
2092
2109
  onColSort = _ref.onColSort,
2093
- onClick = _ref.onClick;
2110
+ onClick = _ref.onClick,
2111
+ sortBy = _ref.sortBy;
2094
2112
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
2095
2113
  _useState2 = useTableSort_slicedToArray(_useState, 2),
2096
2114
  inverse = _useState2[0],
@@ -2104,16 +2122,22 @@ function useTableSort(_ref, deps) {
2104
2122
  var filterType = fieldType || 'text';
2105
2123
  var curIndex = el.dataset.tableCol;
2106
2124
  var targetComparator = [].slice.call(tbodyRef.querySelectorAll("[data-table-col=\"".concat(curIndex, "\"]")));
2125
+ var handleProcess = function handleProcess() {
2126
+ allRows(spyElement).forEach(function (node) {
2127
+ node.classList.add('newsort');
2128
+ });
2129
+ setInverse(!inverse);
2130
+ };
2107
2131
 
2108
- //sort of HTML elements
2109
- var sortBy = function sortBy(a, b) {
2132
+ //
2133
+ var defaultSortBy = function defaultSortBy(a, b) {
2110
2134
  var txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
2111
2135
  txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
2112
2136
 
2113
2137
  //type of number
2114
2138
  if (filterType == 'number') {
2115
- txt1 = Number(txt1.replace(/[^0-9.-]+/g, ''));
2116
- txt2 = Number(txt2.replace(/[^0-9.-]+/g, ''));
2139
+ txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
2140
+ txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
2117
2141
  }
2118
2142
 
2119
2143
  //type of date
@@ -2123,10 +2147,7 @@ function useTableSort(_ref, deps) {
2123
2147
  }
2124
2148
 
2125
2149
  //add filter class
2126
- allRows(spyElement).forEach(function (node) {
2127
- node.classList.add('newsort');
2128
- });
2129
- setInverse(!inverse);
2150
+ handleProcess();
2130
2151
 
2131
2152
  // result
2132
2153
  if (filterType == 'text') {
@@ -2139,7 +2160,10 @@ function useTableSort(_ref, deps) {
2139
2160
  return isReverse ? txt1 < txt2 ? -1 : txt1 > txt2 ? 1 : 0 : txt2 < txt1 ? -1 : txt2 > txt1 ? 1 : 0;
2140
2161
  }
2141
2162
  };
2142
- targetComparator.sort(sortBy);
2163
+
2164
+ // Use a custom sort method if available, otherwise default is used
2165
+ var sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
2166
+ targetComparator.sort(sortFn);
2143
2167
 
2144
2168
  //console.log( 'targetComparator:', targetComparator );
2145
2169
  //console.log( 'inverse:', inverse );
@@ -2191,7 +2215,8 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
2191
2215
  icon = props.icon,
2192
2216
  _props$isReverse = props.isReverse,
2193
2217
  isReverse = _props$isReverse === void 0 ? false : _props$isReverse,
2194
- onClick = props.onClick;
2218
+ onClick = props.onClick,
2219
+ sortBy = props.sortBy;
2195
2220
  var _useContext = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(TableContext),
2196
2221
  originData = _useContext.originData,
2197
2222
  rootRef = _useContext.rootRef,
@@ -2206,7 +2231,8 @@ var SortSprite = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_re
2206
2231
  fieldType: fieldType,
2207
2232
  onColSort: onColSort,
2208
2233
  isReverse: isReverse,
2209
- onClick: onClick
2234
+ onClick: onClick,
2235
+ sortBy: sortBy
2210
2236
  }, [rootRef]),
2211
2237
  handleSortList = _useTableSort.handleSortList;
2212
2238
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, colSortable ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
@@ -679,10 +679,12 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
679
679
  async function handleKeyPressedForSplitInputs(event: KeyboardEvent<HTMLDivElement>) {
680
680
  const key = event.code;
681
681
  const btnMark = (event.target as any).dataset.mark;
682
+ const isNumLockOn = event.getModifierState && event.getModifierState('NumLock');
682
683
 
683
684
  // Check for both regular arrow keys and numpad arrow keys
684
- const isLeftArrow = key === 'ArrowLeft' || key === 'Numpad4';
685
- const isRightArrow = key === 'ArrowRight' || key === 'Numpad6';
685
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
686
+ const isLeftArrow = key === 'ArrowLeft' || (key === 'Numpad4' && !isNumLockOn);
687
+ const isRightArrow = key === 'ArrowRight' || (key === 'Numpad6' && !isNumLockOn);
686
688
 
687
689
  const move = (direction: 'left' | 'right') => {
688
690
  const currentIndex = splitInputsIds.findIndex((s: string) => s === btnMark);
@@ -2,7 +2,6 @@ import React, { forwardRef, useContext } from 'react';
2
2
 
3
3
  import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
4
4
 
5
-
6
5
  import { TableContext } from './TableContext';
7
6
 
8
7
  import { cellMark, removeCellFocusClassName } from './utils/func';
@@ -9,6 +9,7 @@ export type SortSpriteProps = {
9
9
  icon?: React.ReactNode;
10
10
  isReverse?: boolean;
11
11
  onClick?: (e: any) => void;
12
+ sortBy?: (handleProcess: Function, filterType: string, inverse: boolean) => ((a: Element, b: Element) => number); // A function that determines the order of the elements.
12
13
  };
13
14
 
14
15
 
@@ -18,7 +19,8 @@ const SortSprite = forwardRef((props: SortSpriteProps, externalRef: any) => {
18
19
  className,
19
20
  icon,
20
21
  isReverse = false,
21
- onClick
22
+ onClick,
23
+ sortBy
22
24
  } = props;
23
25
 
24
26
  const {
@@ -37,7 +39,8 @@ const SortSprite = forwardRef((props: SortSpriteProps, externalRef: any) => {
37
39
  fieldType: fieldType,
38
40
  onColSort: onColSort,
39
41
  isReverse: isReverse,
40
- onClick: onClick
42
+ onClick: onClick,
43
+ sortBy: sortBy
41
44
  }, [rootRef]);
42
45
 
43
46
 
@@ -104,6 +104,7 @@ const useTableKeyPress = ({
104
104
 
105
105
  const handleKeyPressed = useCallback( async (event: KeyboardEvent<HTMLTableCellElement>) => {
106
106
  const key = event.code;
107
+ const isNumLockOn = event.getModifierState && event.getModifierState('NumLock');
107
108
 
108
109
 
109
110
  // If Enter is pressed and keyboard navigation is disabled, just trigger onCellPressEnter
@@ -139,49 +140,46 @@ const useTableKeyPress = ({
139
140
  maxCol = rowInfo.colCount;
140
141
  }
141
142
  }
142
- switch (key) {
143
- case 'ArrowLeft':
144
- case 'Numpad4':
145
- if (_col - 1 < 0) {
146
- isLeftEdge = true;
147
- _col = 0;
148
- } else {
149
- _col = _col - 1;
150
- }
151
- break;
152
- case 'ArrowRight':
153
- case 'Numpad6': {
154
- if (_col + 1 > maxCol - 1) {
155
- isRightEdge = true;
156
- _col = maxCol - 1;
157
- } else {
158
- _col = _col + 1;
159
- }
160
- break;
143
+
144
+
145
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
146
+ if ((key === 'ArrowLeft') || (key === 'Numpad4' && !isNumLockOn)) {
147
+ if (_col - 1 < 0) {
148
+ isLeftEdge = true;
149
+ _col = 0;
150
+ } else {
151
+ _col = _col - 1;
161
152
  }
162
- case 'ArrowUp':
163
- case 'Numpad8':
164
- if (_row - 1 < 0) {
165
- isTopEdge = true;
166
- _row = 0;
167
- } else {
168
- _row = _row - 1;
169
- }
170
- break;
171
- case 'ArrowDown':
172
- case 'Numpad2':
153
+ }
173
154
 
174
-
175
- if (_row + 1 > rootDataInfo.totalRow - 1) {
176
- isBottomEdge = true;
177
- _row = rootDataInfo.totalRow - 1;
178
- } else {
179
- _row = _row + 1;
180
- }
181
- break;
155
+ if ((key === 'ArrowRight') || (key === 'Numpad6' && !isNumLockOn)) {
156
+ if (_col + 1 > maxCol - 1) {
157
+ isRightEdge = true;
158
+ _col = maxCol - 1;
159
+ } else {
160
+ _col = _col + 1;
161
+ }
162
+ }
163
+
164
+ if ((key === 'ArrowUp') || (key === 'Numpad8' && !isNumLockOn)) {
165
+ if (_row - 1 < 0) {
166
+ isTopEdge = true;
167
+ _row = 0;
168
+ } else {
169
+ _row = _row - 1;
170
+ }
171
+ }
172
+
173
+ if ((key === 'ArrowDown') || (key === 'Numpad2' && !isNumLockOn)) {
174
+ if (_row + 1 > rootDataInfo.totalRow - 1) {
175
+ isBottomEdge = true;
176
+ _row = rootDataInfo.totalRow - 1;
177
+ } else {
178
+ _row = _row + 1;
179
+ }
182
180
  }
183
181
 
184
-
182
+
185
183
 
186
184
  const nextCellSignal: string = cellMark(_row, _col);
187
185
  // Focus the current cell
@@ -209,19 +207,20 @@ const useTableKeyPress = ({
209
207
  };
210
208
 
211
209
  // Handle arrow key navigation
212
- if (key === 'ArrowLeft' || key === 'Numpad4') {
210
+ // Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
211
+ if ((key === 'ArrowLeft') || (key === 'Numpad4' && !isNumLockOn)) {
213
212
  move('ArrowLeft');
214
213
  }
215
214
 
216
- if (key === 'ArrowRight' || key === 'Numpad6') {
215
+ if ((key === 'ArrowRight') || (key === 'Numpad6' && !isNumLockOn)) {
217
216
  move('ArrowRight');
218
217
  }
219
218
 
220
- if (key === 'ArrowUp' || key === 'Numpad8') {
219
+ if ((key === 'ArrowUp') || (key === 'Numpad8' && !isNumLockOn)) {
221
220
  move('ArrowUp');
222
221
  }
223
222
 
224
- if (key === 'ArrowDown' || key === 'Numpad2') {
223
+ if ((key === 'ArrowDown') || (key === 'Numpad2' && !isNumLockOn)) {
225
224
  move('ArrowDown');
226
225
  }
227
226
 
@@ -10,7 +10,28 @@ const App = () => {
10
10
 
11
11
  useTableSort({
12
12
  enabled: sortableTable && rootRef.current,
13
- spyElement: rootRef.current
13
+ spyElement: rootRef.current,
14
+ sortBy: (handleProcess: Function, filterType: string, inverse: boolean) => (a: Element, b: Element) => {
15
+
16
+ // Custom comparison logic
17
+ let v1 = a.textContent, v2 = b.textContent;
18
+ if (filterType === 'number') {
19
+ v1 = parseFloat(v1);
20
+ v2 = parseFloat(v2);
21
+ }
22
+
23
+ let result = 0;
24
+ if (filterType === 'text') {
25
+ result = v1.localeCompare(v2);
26
+ } else {
27
+ result = v1 - v2;
28
+ }
29
+
30
+ // Apply display animation and status updates
31
+ handleProcess();
32
+
33
+ return inverse ? -result : result;
34
+ }
14
35
  }, [rootRef]);
15
36
 
16
37
  return (
@@ -25,6 +46,7 @@ import { useEffect, useState } from 'react';
25
46
 
26
47
  import { getTbody, allRows, sortDataByIndex, initOrderProps, initRowColProps } from '../func';
27
48
 
49
+
28
50
  export interface UseTableSortProps {
29
51
  enabled: boolean;
30
52
  data?: any[];
@@ -33,6 +55,7 @@ export interface UseTableSortProps {
33
55
  isReverse?: boolean;
34
56
  onColSort?: (fetchData: any) => void;
35
57
  onClick?: (e: any) => void;
58
+ sortBy?: (handleProcess: Function, filterType: string, inverse: boolean) => ((a: Element, b: Element) => number); // A function that determines the order of the elements.
36
59
  }
37
60
 
38
61
  function useTableSort({
@@ -42,7 +65,8 @@ function useTableSort({
42
65
  fieldType,
43
66
  isReverse = false,
44
67
  onColSort,
45
- onClick
68
+ onClick,
69
+ sortBy
46
70
  }: UseTableSortProps, deps: any[]) {
47
71
 
48
72
 
@@ -62,17 +86,24 @@ function useTableSort({
62
86
  const curIndex = el.dataset.tableCol;
63
87
  const targetComparator = [].slice.call(tbodyRef.querySelectorAll(`[data-table-col="${curIndex}"]`));
64
88
 
89
+ const handleProcess = function () {
90
+ allRows(spyElement).forEach((node: any) => {
91
+ node.classList.add('newsort');
92
+ });
93
+
94
+ setInverse(!inverse);
95
+ };
65
96
 
66
- //sort of HTML elements
67
- const sortBy = function (a: any, b: any) {
97
+ //
98
+ const defaultSortBy = function (a: Element, b: Element) {
68
99
 
69
- let txt1 = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
70
- txt2 = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
100
+ let txt1: any = a.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase(),
101
+ txt2: any = b.innerHTML.replace(/(<([^>]+)>)/ig, '').toLowerCase();
71
102
 
72
103
  //type of number
73
104
  if (filterType == 'number') {
74
- txt1 = Number(txt1.replace(/[^0-9.-]+/g, ''));
75
- txt2 = Number(txt2.replace(/[^0-9.-]+/g, ''));
105
+ txt1 = parseFloat(txt1.replace(/[^0-9.+-]+/g, ''));
106
+ txt2 = parseFloat(txt2.replace(/[^0-9.+-]+/g, ''));
76
107
  }
77
108
 
78
109
  //type of date
@@ -83,14 +114,9 @@ function useTableSort({
83
114
 
84
115
 
85
116
  //add filter class
86
- allRows(spyElement).forEach((node: any) => {
87
- node.classList.add('newsort');
88
- });
117
+ handleProcess();
89
118
 
90
119
 
91
- setInverse(!inverse);
92
-
93
-
94
120
  // result
95
121
  if (filterType == 'text') {
96
122
  return isReverse
@@ -104,7 +130,10 @@ function useTableSort({
104
130
 
105
131
  }
106
132
 
107
- targetComparator.sort(sortBy);
133
+ // Use a custom sort method if available, otherwise default is used
134
+ const sortFn = typeof sortBy === 'function' ? sortBy(handleProcess, filterType, inverse) : defaultSortBy;
135
+
136
+ targetComparator.sort(sortFn);
108
137
 
109
138
  //console.log( 'targetComparator:', targetComparator );
110
139
  //console.log( 'inverse:', inverse );
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.7.445",
5
+ "version": "4.7.515",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",