react-table-edit 1.5.32 → 1.5.33
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/component/utils.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +40 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -56,3 +56,4 @@ export declare const calculateTableStructure: (columns: any[], settingColumns?:
|
|
|
56
56
|
*/
|
|
57
57
|
export declare const CheckRowMatch: (row: Record<string, any>, filters: IFFilterTable[], keyword: string, searchKeys: string[]) => boolean;
|
|
58
58
|
export declare const getMaxExpandedLevel: (items: any[], fieldChildren?: string, level?: number) => number;
|
|
59
|
+
export declare const findItemInTree: (items: any[], filter: string, keyFilter?: string, keyChildren?: string) => any;
|
package/dist/index.d.ts
CHANGED
|
@@ -802,6 +802,7 @@ declare const calculateTableStructure: (columns: any[], settingColumns?: IFSetti
|
|
|
802
802
|
*/
|
|
803
803
|
declare const CheckRowMatch: (row: Record<string, any>, filters: IFFilterTable[], keyword: string, searchKeys: string[]) => boolean;
|
|
804
804
|
declare const getMaxExpandedLevel: (items: any[], fieldChildren?: string, level?: number) => number;
|
|
805
|
+
declare const findItemInTree: (items: any[], filter: string, keyFilter?: string, keyChildren?: string) => any;
|
|
805
806
|
|
|
806
807
|
type IFSteps = {
|
|
807
808
|
id: string;
|
|
@@ -829,5 +830,5 @@ type IFProps = {
|
|
|
829
830
|
};
|
|
830
831
|
declare const Wizard: React.ForwardRefExoticComponent<IFProps & React.RefAttributes<unknown>>;
|
|
831
832
|
|
|
832
|
-
export { CheckRowMatch, ExportExcelComponent, FindNodeByPath, InputStyleComponent, ModalImportComponent, SelectTable, SelectTableTree, TableView, TabsMenuComponent, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, formartNumberic, formatDateTime, generateUUID, getMaxExpandedLevel, isNullOrUndefined, messageBoxConfirm, messageBoxConfirmAsync, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxConfirmAsync, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
|
833
|
+
export { CheckRowMatch, ExportExcelComponent, FindNodeByPath, InputStyleComponent, ModalImportComponent, SelectTable, SelectTableTree, TableView, TabsMenuComponent, Wizard, calculateTableStructure, checkDecimalSeparator, checkThousandSeparator, TableEdit as default, findItemInTree, formartNumberic, formatDateTime, generateUUID, getMaxExpandedLevel, isNullOrUndefined, messageBoxConfirm, messageBoxConfirmAsync, messageBoxConfirmDelete, messageBoxError, messageHtmlBoxConfirm, messageHtmlBoxConfirmAsync, messageHtmlBoxError, notificationError, notificationSuccess, roundNumber, useOnClickOutside };
|
|
833
834
|
export type { FromItemsField, ICellInfo, IColumnTable, IColumnType, IColumnsAgg, ICommandItem, IContextItem, IFColumnSelectTable, IFColumnSelectTableTree, IFCurrentPage, IFCurrentPageConfig, IFFilterTable, IFOrderTable, IFPageSize, IFSettingColumns, IFTableEditButton, IFTableEditFormat, IFTableEditPaging, IFTableEditSearchSetting, IFTableEditToolbar, IFTableSelectFormat, IFTableTreeSelectFormat, IFToolbarOptions, IFilterType, IHeaderColumnTable, ISettingFormElement, ISettingNumericElement, ISettingSelectElement };
|
package/dist/index.js
CHANGED
|
@@ -19813,10 +19813,7 @@ 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' &&
|
|
19817
|
-
performance.now &&
|
|
19818
|
-
performance.now() * 1000) ||
|
|
19819
|
-
0; //Time in microseconds since page-load or 0 if unsupported
|
|
19816
|
+
let d2 = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
|
|
19820
19817
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
19821
19818
|
let r = Math.random() * 16; //random number between 0 and 16
|
|
19822
19819
|
if (d > 0) {
|
|
@@ -19848,16 +19845,12 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
19848
19845
|
// eslint-disable-next-line
|
|
19849
19846
|
if (str || str == '0') {
|
|
19850
19847
|
str = str.toString();
|
|
19851
|
-
const value = decimalSeparator !== '.'
|
|
19852
|
-
? str.toString().replaceAll('.', decimalSeparator ?? '')
|
|
19853
|
-
: str;
|
|
19848
|
+
const value = decimalSeparator !== '.' ? str.toString().replaceAll('.', decimalSeparator ?? '') : str;
|
|
19854
19849
|
const arr = value.toString().split(decimalSeparator ?? '', 2);
|
|
19855
19850
|
let flag = value.toString().includes(decimalSeparator ?? '');
|
|
19856
19851
|
if (arr[0].length < 3) {
|
|
19857
19852
|
const intergerArr = haveNegative ? arr[0] : arr[0].replace('-', '');
|
|
19858
|
-
return flag
|
|
19859
|
-
? `${intergerArr}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}`
|
|
19860
|
-
: intergerArr;
|
|
19853
|
+
return flag ? `${intergerArr}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}` : intergerArr;
|
|
19861
19854
|
}
|
|
19862
19855
|
else {
|
|
19863
19856
|
let flagNegative = false;
|
|
@@ -19881,9 +19874,7 @@ const formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10
|
|
|
19881
19874
|
if (flagNegative && haveNegative) {
|
|
19882
19875
|
arr[0] = '-'.concat(arr[0]);
|
|
19883
19876
|
}
|
|
19884
|
-
return flag
|
|
19885
|
-
? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}`
|
|
19886
|
-
: arr[0];
|
|
19877
|
+
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ''}` : arr[0];
|
|
19887
19878
|
}
|
|
19888
19879
|
}
|
|
19889
19880
|
else {
|
|
@@ -19906,7 +19897,7 @@ const formatDateTime = (data, format = 'dd/MM/yyyy') => {
|
|
|
19906
19897
|
MM: String(date.getMonth() + 1).padStart(2, '0'),
|
|
19907
19898
|
yyyy: date.getFullYear(),
|
|
19908
19899
|
HH: String(date.getHours()).padStart(2, '0'),
|
|
19909
|
-
mm: String(date.getMinutes()).padStart(2, '0')
|
|
19900
|
+
mm: String(date.getMinutes()).padStart(2, '0')
|
|
19910
19901
|
};
|
|
19911
19902
|
return format.replace(/dd|DD|MM|yyyy|HH|mm/g, (match) => map[match]);
|
|
19912
19903
|
};
|
|
@@ -19927,7 +19918,7 @@ const FindNodeByPath = (tree, path) => {
|
|
|
19927
19918
|
parent: current,
|
|
19928
19919
|
lastIndex: levels.at(-1),
|
|
19929
19920
|
firstIndex: levels.length === 1 ? levels[0] : -1,
|
|
19930
|
-
node
|
|
19921
|
+
node
|
|
19931
19922
|
};
|
|
19932
19923
|
};
|
|
19933
19924
|
/**
|
|
@@ -19955,7 +19946,7 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
19955
19946
|
const objHeaderWidthFixLeft = {};
|
|
19956
19947
|
let maxDepth = 0;
|
|
19957
19948
|
// Tính depth tối đa
|
|
19958
|
-
const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth));
|
|
19949
|
+
const calculateDepth = (cols, depth = 1) => Math.max(...cols.map((col) => (col.columns?.length ? calculateDepth(col.columns, depth + 1) : depth)));
|
|
19959
19950
|
maxDepth = calculateDepth(columns);
|
|
19960
19951
|
let leftTotal = 0;
|
|
19961
19952
|
let rightTotal = 0;
|
|
@@ -19992,8 +19983,7 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
19992
19983
|
cell.numericSettings = { fraction: setting.fraction };
|
|
19993
19984
|
}
|
|
19994
19985
|
}
|
|
19995
|
-
cell.headerDisplay =
|
|
19996
|
-
setting.headerText || (cell.headerDisplay ?? cell.headerText);
|
|
19986
|
+
cell.headerDisplay = setting.headerText || (cell.headerDisplay ?? cell.headerText);
|
|
19997
19987
|
}
|
|
19998
19988
|
else {
|
|
19999
19989
|
if (cell.columns?.length) {
|
|
@@ -20029,13 +20019,11 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
20029
20019
|
...col,
|
|
20030
20020
|
columns: col.columns ?? [],
|
|
20031
20021
|
colspan,
|
|
20032
|
-
rowspan: hasChildren ? 1 : maxDepth - level
|
|
20022
|
+
rowspan: hasChildren ? 1 : maxDepth - level
|
|
20033
20023
|
};
|
|
20034
20024
|
levels[level].push(cell);
|
|
20035
20025
|
const headerKey = `${level}-${indexCol}`;
|
|
20036
|
-
if (cell.fixedType === 'left' &&
|
|
20037
|
-
cell.visible !== false &&
|
|
20038
|
-
cell.isGroup !== true) {
|
|
20026
|
+
if (cell.fixedType === 'left' && cell.visible !== false && cell.isGroup !== true) {
|
|
20039
20027
|
objHeaderWidthFixLeft[headerKey] = leftTotal;
|
|
20040
20028
|
}
|
|
20041
20029
|
if (!hasChildren) {
|
|
@@ -20043,22 +20031,16 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
20043
20031
|
const width = cell.width ?? 40;
|
|
20044
20032
|
cell.index = index;
|
|
20045
20033
|
flat.push(cell);
|
|
20046
|
-
if (cell.fixedType === 'left' &&
|
|
20047
|
-
cell.visible !== false &&
|
|
20048
|
-
cell.isGroup !== true) {
|
|
20034
|
+
if (cell.fixedType === 'left' && cell.visible !== false && cell.isGroup !== true) {
|
|
20049
20035
|
objWidthFixLeft[index] = leftTotal;
|
|
20050
20036
|
leftTotal += width;
|
|
20051
20037
|
}
|
|
20052
|
-
if (cell.fixedType === 'right' &&
|
|
20053
|
-
cell.visible !== false &&
|
|
20054
|
-
cell.isGroup !== true) {
|
|
20038
|
+
if (cell.fixedType === 'right' && cell.visible !== false && cell.isGroup !== true) {
|
|
20055
20039
|
rightTotal -= width;
|
|
20056
20040
|
objWidthFixRight[index] = rightTotal;
|
|
20057
20041
|
}
|
|
20058
20042
|
}
|
|
20059
|
-
if (cell.fixedType === 'right' &&
|
|
20060
|
-
cell.visible !== false &&
|
|
20061
|
-
cell.isGroup !== true) {
|
|
20043
|
+
if (cell.fixedType === 'right' && cell.visible !== false && cell.isGroup !== true) {
|
|
20062
20044
|
objHeaderWidthFixRight[headerKey] = rightTotal;
|
|
20063
20045
|
}
|
|
20064
20046
|
return colspanSum + colspan;
|
|
@@ -20071,20 +20053,13 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
20071
20053
|
traverse(columns);
|
|
20072
20054
|
// Danh sách các cột được hiển thị
|
|
20073
20055
|
// const flatVisble = flat.filter((e) => e.visible !== false)
|
|
20074
|
-
const flatVisbleContent = flat.filter((x) => x.visible !== false &&
|
|
20075
|
-
x.field !== 'command' &&
|
|
20076
|
-
x.field !== '#' &&
|
|
20077
|
-
x.field !== 'checkbox');
|
|
20056
|
+
const flatVisbleContent = flat.filter((x) => x.visible !== false && x.field !== 'command' && x.field !== '#' && x.field !== 'checkbox');
|
|
20078
20057
|
// Tính toán vị trí đầu tiên và cuối cùng của các cột cố định
|
|
20079
20058
|
const lastObjWidthFixLeft = Math.max(...Object.keys(objWidthFixLeft).map(Number), 0);
|
|
20080
20059
|
const fisrtObjWidthFixRight = Math.min(...Object.keys(objWidthFixRight).map(Number), flat.length);
|
|
20081
20060
|
// Tính toán vị trí đầu tiên và cuối cùng của các cột có thể sửa
|
|
20082
20061
|
const indexFirstEdit = flat.findIndex((item) => item.editEnable && item.visible !== false && !item.disabledCondition);
|
|
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);
|
|
20062
|
+
const indexLastEdit = flat.map((item, idx) => (item.editEnable && item.visible !== false && !item.disabledCondition ? idx : -1)).reduce((acc, val) => (val > acc ? val : acc), -1);
|
|
20088
20063
|
return {
|
|
20089
20064
|
levels,
|
|
20090
20065
|
flat,
|
|
@@ -20097,7 +20072,7 @@ const calculateTableStructure = (columns, settingColumns, groupColumns) => {
|
|
|
20097
20072
|
objHeaderWidthFixRight,
|
|
20098
20073
|
objHeaderWidthFixLeft,
|
|
20099
20074
|
indexFirstEdit,
|
|
20100
|
-
indexLastEdit
|
|
20075
|
+
indexLastEdit
|
|
20101
20076
|
};
|
|
20102
20077
|
};
|
|
20103
20078
|
/**
|
|
@@ -20107,10 +20082,7 @@ const CheckRowMatch = (row, filters, keyword, searchKeys) => {
|
|
|
20107
20082
|
const isFilterMatch = filters.every((filter) => {
|
|
20108
20083
|
const { key, value, ope } = filter;
|
|
20109
20084
|
const rowValue = row[key];
|
|
20110
|
-
if (rowValue === undefined ||
|
|
20111
|
-
rowValue === null ||
|
|
20112
|
-
value === undefined ||
|
|
20113
|
-
value === null) {
|
|
20085
|
+
if (rowValue === undefined || rowValue === null || value === undefined || value === null) {
|
|
20114
20086
|
return false;
|
|
20115
20087
|
}
|
|
20116
20088
|
const valStr = String(rowValue).toLowerCase();
|
|
@@ -20143,10 +20115,7 @@ const CheckRowMatch = (row, filters, keyword, searchKeys) => {
|
|
|
20143
20115
|
const isSearchMatch = !keyword ||
|
|
20144
20116
|
searchKeys.some((key) => {
|
|
20145
20117
|
const val = row[key];
|
|
20146
|
-
return val
|
|
20147
|
-
?.toString()
|
|
20148
|
-
.toLowerCase()
|
|
20149
|
-
.includes(keyword.trim().toLowerCase());
|
|
20118
|
+
return val?.toString().toLowerCase().includes(keyword.trim().toLowerCase());
|
|
20150
20119
|
});
|
|
20151
20120
|
return isFilterMatch && isSearchMatch;
|
|
20152
20121
|
};
|
|
@@ -20159,6 +20128,20 @@ const getMaxExpandedLevel = (items, fieldChildren = 'children', level = 0) => {
|
|
|
20159
20128
|
});
|
|
20160
20129
|
return max;
|
|
20161
20130
|
};
|
|
20131
|
+
const findItemInTree = (items, filter, keyFilter = "value", keyChildren = "children") => {
|
|
20132
|
+
for (let index = 0; index < items.length; index++) {
|
|
20133
|
+
const item = items[index];
|
|
20134
|
+
if (item[keyFilter] === filter) {
|
|
20135
|
+
return { ...item };
|
|
20136
|
+
}
|
|
20137
|
+
else if (item[keyChildren]?.length > 0) {
|
|
20138
|
+
const itemFilter = findItemInTree(item[keyChildren], filter, keyFilter, keyChildren);
|
|
20139
|
+
if (itemFilter) {
|
|
20140
|
+
return itemFilter;
|
|
20141
|
+
}
|
|
20142
|
+
}
|
|
20143
|
+
}
|
|
20144
|
+
};
|
|
20162
20145
|
|
|
20163
20146
|
const defaultMaxHeight$1 = 250;
|
|
20164
20147
|
const SelectTable = React$5.forwardRef((props, ref) => {
|
|
@@ -40071,7 +40054,13 @@ const TableEdit = React$5.forwardRef((props, ref) => {
|
|
|
40071
40054
|
return;
|
|
40072
40055
|
}
|
|
40073
40056
|
let objCallback;
|
|
40074
|
-
|
|
40057
|
+
let ele;
|
|
40058
|
+
if (column.type === 'select') {
|
|
40059
|
+
ele = column.selectSettings?.options?.find((item) => item[column.selectSettings?.fieldValue ?? 'value'] === copyData);
|
|
40060
|
+
}
|
|
40061
|
+
else if (column.type === 'selectTree') {
|
|
40062
|
+
ele = findItemInTree(column.selectSettings?.options ?? [], copyData, column.selectSettings?.fieldValue ?? 'value');
|
|
40063
|
+
}
|
|
40075
40064
|
if (ele) {
|
|
40076
40065
|
objCallback = ele;
|
|
40077
40066
|
}
|
|
@@ -69243,6 +69232,7 @@ exports.calculateTableStructure = calculateTableStructure;
|
|
|
69243
69232
|
exports.checkDecimalSeparator = checkDecimalSeparator;
|
|
69244
69233
|
exports.checkThousandSeparator = checkThousandSeparator;
|
|
69245
69234
|
exports["default"] = TableEdit;
|
|
69235
|
+
exports.findItemInTree = findItemInTree;
|
|
69246
69236
|
exports.formartNumberic = formartNumberic;
|
|
69247
69237
|
exports.formatDateTime = formatDateTime;
|
|
69248
69238
|
exports.generateUUID = generateUUID;
|