react-table-edit 1.5.30 → 1.5.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19813,7 +19813,10 @@ const isNullOrUndefined$1 = (d) => {
19813
19813
  const generateUUID = () => {
19814
19814
  // Public Domain/MIT
19815
19815
  let d = new Date().getTime(); //Timestamp
19816
- let d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
19816
+ let d2 = (typeof performance !== 'undefined' &&
19817
+ performance.now &&
19818
+ performance.now() * 1000) ||
19819
+ 0; //Time in microseconds since page-load or 0 if unsupported
19817
19820
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
19818
19821
  let r = Math.random() * 16; //random number between 0 and 16
19819
19822
  if (d > 0) {
@@ -19845,11 +19848,16 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
19845
19848
  // eslint-disable-next-line
19846
19849
  if (str || str == '0') {
19847
19850
  str = str.toString();
19848
- const value = decimalSeparator !== '.' ? str.toString().replaceAll('.', decimalSeparator ?? '') : str;
19851
+ const value = decimalSeparator !== '.'
19852
+ ? str.toString().replaceAll('.', decimalSeparator ?? '')
19853
+ : str;
19849
19854
  const arr = value.toString().split(decimalSeparator ?? '', 2);
19850
19855
  let flag = value.toString().includes(decimalSeparator ?? '');
19851
19856
  if (arr[0].length < 3) {
19852
- return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}` : arr[0];
19857
+ const intergerArr = haveNegative ? arr[0] : arr[0].replace('-', '');
19858
+ return flag
19859
+ ? `${intergerArr}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}`
19860
+ : intergerArr;
19853
19861
  }
19854
19862
  else {
19855
19863
  let flagNegative = false;
@@ -19873,7 +19881,9 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
19873
19881
  if (flagNegative && haveNegative) {
19874
19882
  arr[0] = '-'.concat(arr[0]);
19875
19883
  }
19876
- return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}` : arr[0];
19884
+ return flag
19885
+ ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}`
19886
+ : arr[0];
19877
19887
  }
19878
19888
  }
19879
19889
  else {
@@ -19896,7 +19906,7 @@ const formatDateTime = (data, format = 'dd/MM/yyyy') => {
19896
19906
  MM: String(date.getMonth() + 1).padStart(2, '0'),
19897
19907
  yyyy: date.getFullYear(),
19898
19908
  HH: String(date.getHours()).padStart(2, '0'),
19899
- mm: String(date.getMinutes()).padStart(2, '0')
19909
+ mm: String(date.getMinutes()).padStart(2, '0'),
19900
19910
  };
19901
19911
  return format.replace(/dd|DD|MM|yyyy|HH|mm/g, (match) => map[match]);
19902
19912
  };
@@ -19913,7 +19923,12 @@ const FindNodeByPath = (tree, path) => {
19913
19923
  node = current[level];
19914
19924
  current = current[level].children ?? [];
19915
19925
  }
19916
- return { parent: current, lastIndex: levels.at(-1), firstIndex: levels.length === 1 ? levels[0] : -1, node };
19926
+ return {
19927
+ parent: current,
19928
+ lastIndex: levels.at(-1),
19929
+ firstIndex: levels.length === 1 ? levels[0] : -1,
19930
+ node,
19931
+ };
19917
19932
  };
19918
19933
  /**
19919
19934
  * Tính toán cấu trúc bảng từ dữ liệu column dạng cây:
@@ -19940,7 +19955,7 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
19940
19955
  const objHeaderWidthFixLeft = {};
19941
19956
  let maxDepth = 0;
19942
19957
  // Tính depth tối đa
19943
- const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth)));
19958
+ const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth));
19944
19959
  maxDepth = calculateDepth(columns);
19945
19960
  let leftTotal = 0;
19946
19961
  let rightTotal = 0;
@@ -19977,7 +19992,8 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
19977
19992
  cell.numericSettings = { fraction: setting.fraction };
19978
19993
  }
19979
19994
  }
19980
- cell.headerDisplay = setting.headerText || (cell.headerDisplay ?? cell.headerText);
19995
+ cell.headerDisplay =
19996
+ setting.headerText || (cell.headerDisplay ?? cell.headerText);
19981
19997
  }
19982
19998
  else {
19983
19999
  if (cell.columns?.length) {
@@ -20013,11 +20029,13 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
20013
20029
  ...col,
20014
20030
  columns: col.columns ?? [],
20015
20031
  colspan,
20016
- rowspan: hasChildren ? 1 : maxDepth - level
20032
+ rowspan: hasChildren ? 1 : maxDepth - level,
20017
20033
  };
20018
20034
  levels[level].push(cell);
20019
20035
  const headerKey = `${level}-${indexCol}`;
20020
- if (cell.fixedType === 'left' && cell.visible !== false && cell.isGroup !== true) {
20036
+ if (cell.fixedType === 'left' &&
20037
+ cell.visible !== false &&
20038
+ cell.isGroup !== true) {
20021
20039
  objHeaderWidthFixLeft[headerKey] = leftTotal;
20022
20040
  }
20023
20041
  if (!hasChildren) {
@@ -20025,16 +20043,22 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
20025
20043
  const width = cell.width ?? 40;
20026
20044
  cell.index = index;
20027
20045
  flat.push(cell);
20028
- if (cell.fixedType === 'left' && cell.visible !== false && cell.isGroup !== true) {
20046
+ if (cell.fixedType === 'left' &&
20047
+ cell.visible !== false &&
20048
+ cell.isGroup !== true) {
20029
20049
  objWidthFixLeft[index] = leftTotal;
20030
20050
  leftTotal += width;
20031
20051
  }
20032
- if (cell.fixedType === 'right' && cell.visible !== false && cell.isGroup !== true) {
20052
+ if (cell.fixedType === 'right' &&
20053
+ cell.visible !== false &&
20054
+ cell.isGroup !== true) {
20033
20055
  rightTotal -= width;
20034
20056
  objWidthFixRight[index] = rightTotal;
20035
20057
  }
20036
20058
  }
20037
- if (cell.fixedType === 'right' && cell.visible !== false && cell.isGroup !== true) {
20059
+ if (cell.fixedType === 'right' &&
20060
+ cell.visible !== false &&
20061
+ cell.isGroup !== true) {
20038
20062
  objHeaderWidthFixRight[headerKey] = rightTotal;
20039
20063
  }
20040
20064
  return colspanSum + colspan;
@@ -20047,13 +20071,20 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
20047
20071
  traverse(columns);
20048
20072
  // Danh sách các cột được hiển thị
20049
20073
  // const flatVisble = flat.filter((e) => e.visible !== false)
20050
- const flatVisbleContent = flat.filter((x) => x.visible !== false && x.field !== 'command' && x.field !== '#' && x.field !== 'checkbox');
20074
+ const flatVisbleContent = flat.filter((x) => x.visible !== false &&
20075
+ x.field !== 'command' &&
20076
+ x.field !== '#' &&
20077
+ x.field !== 'checkbox');
20051
20078
  // Tính toán vị trí đầu tiên và cuối cùng của các cột cố định
20052
20079
  const lastObjWidthFixLeft = Math.max(...Object.keys(objWidthFixLeft).map(Number), 0);
20053
20080
  const fisrtObjWidthFixRight = Math.min(...Object.keys(objWidthFixRight).map(Number), flat.length);
20054
20081
  // Tính toán vị trí đầu tiên và cuối cùng của các cột có thể sửa
20055
20082
  const indexFirstEdit = flat.findIndex((item) => item.editEnable && item.visible !== false && !item.disabledCondition);
20056
- const indexLastEdit = flat.map((item, idx) => (item.editEnable && item.visible !== false && !item.disabledCondition ? idx : -1)).reduce((acc, val) => (val > acc ? val : acc), -1);
20083
+ const indexLastEdit = flat
20084
+ .map((item, idx) => item.editEnable && item.visible !== false && !item.disabledCondition
20085
+ ? idx
20086
+ : -1)
20087
+ .reduce((acc, val) => (val > acc ? val : acc), -1);
20057
20088
  return {
20058
20089
  levels,
20059
20090
  flat,
@@ -20066,7 +20097,7 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
20066
20097
  objHeaderWidthFixRight,
20067
20098
  objHeaderWidthFixLeft,
20068
20099
  indexFirstEdit,
20069
- indexLastEdit
20100
+ indexLastEdit,
20070
20101
  };
20071
20102
  };
20072
20103
  /**
@@ -20076,7 +20107,10 @@ const CheckRowMatch = (row, filters, keyword, searchKeys) => {
20076
20107
  const isFilterMatch = filters.every((filter) => {
20077
20108
  const { key, value, ope } = filter;
20078
20109
  const rowValue = row[key];
20079
- if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
20110
+ if (rowValue === undefined ||
20111
+ rowValue === null ||
20112
+ value === undefined ||
20113
+ value === null) {
20080
20114
  return false;
20081
20115
  }
20082
20116
  const valStr = String(rowValue).toLowerCase();
@@ -20109,7 +20143,10 @@ const CheckRowMatch = (row, filters, keyword, searchKeys) => {
20109
20143
  const isSearchMatch = !keyword ||
20110
20144
  searchKeys.some((key) => {
20111
20145
  const val = row[key];
20112
- return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
20146
+ return val
20147
+ ?.toString()
20148
+ .toLowerCase()
20149
+ .includes(keyword.trim().toLowerCase());
20113
20150
  });
20114
20151
  return isFilterMatch && isSearchMatch;
20115
20152
  };
@@ -69108,7 +69145,7 @@ const TableView = ({ idTable, dataSource, height = 400, columns, isMutil = false
69108
69145
  sumValue = '';
69109
69146
  }
69110
69147
  }
69111
- return (jsxRuntime.jsx("td", { className: "r-rowcell r-cell-sum-group", children: jsxRuntime.jsx("div", { className: "r-rowcell-div", style: { justifyContent: colSum.textAlign ? colSum.textAlign : 'left' }, children: (haveSum || colSum.haveSum === true) && Number(sumValue) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] }) : sumValue }) }, `group-sum-cell-${level}-${indexRow}-${indexCol}`));
69148
+ return (jsxRuntime.jsx("td", { className: "r-rowcell r-cell-sum-group", children: jsxRuntime.jsx("div", { className: "r-rowcell-div", style: { justifyContent: colSum.textAlign ? colSum.textAlign : 'left' }, children: (haveSum || colSum.haveSum === true) && Number(row[colSum.field] ?? '0') < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] }) : sumValue }) }, `group-sum-cell-${level}-${indexRow}-${indexCol}`));
69112
69149
  })] }), expand && jsxRuntime.jsx(RenderContent, { datas: row.children, level: level + 1 })] }, `row-${level}-${indexRow}`));
69113
69150
  }
69114
69151
  else {
@@ -69177,7 +69214,7 @@ const TableView = ({ idTable, dataSource, height = 400, columns, isMutil = false
69177
69214
  left: col.fixedType === 'left' ? objWidthFixLeft[indexCol] : undefined,
69178
69215
  right: col.fixedType === 'right' ? objWidthFixRight[indexCol] : undefined,
69179
69216
  textAlign: col.textAlign ? col.textAlign : 'left'
69180
- }, children: jsxRuntime.jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) && Number(sumValue) < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] }) : sumValue }) }, `summarycell-${indexCol}`));
69217
+ }, children: jsxRuntime.jsx("div", { className: "r-footer-div", children: (item || col.haveSum === true) && Number(item?.value ?? '0') < 0 ? jsxRuntime.jsxs("div", { style: { color: formatSetting?.colorNegative ?? 'red' }, children: [" ", `${formatSetting?.prefixNegative ?? '-'}${sumValue}${formatSetting?.suffixNegative ?? ''}`] }) : sumValue }) }, `summarycell-${indexCol}`));
69181
69218
  }) })) })] }), jsxRuntime.jsx("div", { ref: virtualDivRef }), context && (contextMenuItems?.length ?? 0) > 0 && handleContextMenuClick && (jsxRuntime.jsx(Popover$1, { className: "r-context-popover", placement: "right-start", isOpen: context.show, target: virtualDivRef.current, toggle: handleCloseContext, fade: false, children: jsxRuntime.jsx(PopoverBody$1, { children: contextMenuItems?.map((item, index) => {
69182
69219
  return (jsxRuntime.jsxs("div", { className: "r-context-item", onClick: () => {
69183
69220
  handleCloseContext();