es-grid-template 1.9.19 → 1.9.21
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/es/grid-component/type.d.ts +116 -36
- package/es/group-component/hook/utils.d.ts +22 -21
- package/es/table-component/body/EditableCell.js +4 -6
- package/es/table-component/body/TableBodyCell.js +13 -12
- package/es/table-component/body/TableBodyCellEdit.js +21 -5
- package/es/table-component/header/TableHeadCell2.js +3 -1
- package/es/table-component/header/renderFilter.d.ts +2 -0
- package/es/table-component/header/renderFilter.js +32 -4
- package/es/table-component/hook/useColumns.d.ts +1 -0
- package/es/table-component/hook/useColumns.js +56 -1
- package/es/table-component/hook/utils.d.ts +2 -0
- package/es/table-component/hook/utils.js +171 -2
- package/es/table-virtuoso/body/TableBodyRow.js +0 -1
- package/lib/grid-component/type.d.ts +116 -36
- package/lib/group-component/hook/utils.d.ts +22 -21
- package/lib/table-component/body/EditableCell.js +4 -6
- package/lib/table-component/body/TableBodyCell.js +12 -11
- package/lib/table-component/body/TableBodyCellEdit.js +20 -4
- package/lib/table-component/header/TableHeadCell2.js +3 -1
- package/lib/table-component/header/renderFilter.d.ts +2 -0
- package/lib/table-component/header/renderFilter.js +32 -4
- package/lib/table-component/hook/useColumns.d.ts +1 -0
- package/lib/table-component/hook/useColumns.js +58 -2
- package/lib/table-component/hook/utils.d.ts +2 -0
- package/lib/table-component/hook/utils.js +177 -5
- package/lib/table-virtuoso/body/TableBodyRow.js +0 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { Dispatch, SetStateAction } from "react";
|
|
|
2
2
|
import type { ColumnsTable, ColumnTable, IFormat, SelectionSettings } from '../../grid-component/type';
|
|
3
3
|
import type { Cell, ColumnDef } from '@tanstack/react-table';
|
|
4
4
|
export declare const renderValueCell: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat, editAble?: boolean) => any;
|
|
5
|
+
export declare const getValueCellString: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat) => any;
|
|
5
6
|
export declare function convertToTanStackColumns<T>({ t, columns, format, editAble }: {
|
|
6
7
|
t?: any;
|
|
7
8
|
columns: ColumnsTable<T>;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.convertToTanStackColumns = convertToTanStackColumns;
|
|
8
|
-
exports.toggleRowSelection = exports.renderValueCell = void 0;
|
|
8
|
+
exports.toggleRowSelection = exports.renderValueCell = exports.getValueCellString = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _ControlCheckbox = _interopRequireDefault(require("../components/ControlCheckbox"));
|
|
11
11
|
var _utils = require("./utils");
|
|
@@ -51,7 +51,7 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
|
|
|
51
51
|
return value ? value : '';
|
|
52
52
|
case 'year':
|
|
53
53
|
const year = value ? (0, _moment.default)(value).format('yyyy') : '';
|
|
54
|
-
return
|
|
54
|
+
return year;
|
|
55
55
|
case 'datetime':
|
|
56
56
|
return value ? (0, _moment.default)(value).format(format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
|
|
57
57
|
case 'boolean':
|
|
@@ -87,6 +87,62 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
exports.renderValueCell = renderValueCell;
|
|
90
|
+
const getValueCellString = (column, value, record, rowIndex, colIndex, format) => {
|
|
91
|
+
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
92
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
93
|
+
switch (column?.type) {
|
|
94
|
+
case 'number':
|
|
95
|
+
// const colFormat = typeof column.format === 'function' ? column.format(record) : column.format
|
|
96
|
+
|
|
97
|
+
// const cellFormat = getFormat(colFormat, format)
|
|
98
|
+
|
|
99
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
100
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
101
|
+
const dec = cellFormat?.decimalScale;
|
|
102
|
+
|
|
103
|
+
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
104
|
+
|
|
105
|
+
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
106
|
+
const numericFormatProps = {
|
|
107
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
108
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
109
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
110
|
+
prefix: cellFormat?.prefix,
|
|
111
|
+
suffix: cellFormat?.suffix,
|
|
112
|
+
decimalScale: dec,
|
|
113
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// if ( typeof value === "string") {
|
|
117
|
+
// const ttt = removeNumericFormat(value, undefined, numericFormatProps )
|
|
118
|
+
//
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
|
|
122
|
+
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? tmpval.toString() : tmpval.toString()) : '0'
|
|
123
|
+
|
|
124
|
+
return !(0, _utils.isEmpty)(contentNumber) ? (0, _reactNumericComponent.numericFormatter)(contentNumber, numericFormatProps) : '';
|
|
125
|
+
case 'date':
|
|
126
|
+
return value ? (0, _dayjs.default)(value).format(cellFormat?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
127
|
+
case 'time':
|
|
128
|
+
return value ? value : '';
|
|
129
|
+
case 'year':
|
|
130
|
+
const year = value ? (0, _moment.default)(value).format('yyyy') : '';
|
|
131
|
+
return year;
|
|
132
|
+
case 'datetime':
|
|
133
|
+
return value ? (0, _moment.default)(value).format(cellFormat?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
|
|
134
|
+
case 'boolean':
|
|
135
|
+
return value ? 'true' : 'false';
|
|
136
|
+
const nameFile = typeof value === 'object' && !Array.isArray(value) ? value.name : Array.isArray(value) ? value.map(it => typeof it === 'object' ? it.name : it).filter(Boolean).join(", ") : '';
|
|
137
|
+
return value ? nameFile : '';
|
|
138
|
+
default:
|
|
139
|
+
if (Array.isArray(value)) {
|
|
140
|
+
return value.join(', ');
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
exports.getValueCellString = getValueCellString;
|
|
90
146
|
function convertToTanStackColumns({
|
|
91
147
|
t,
|
|
92
148
|
columns,
|
|
@@ -67,6 +67,8 @@ export declare const detectSeparators: (str: string) => {
|
|
|
67
67
|
thousandSeparator: string;
|
|
68
68
|
decimalSeparator: string;
|
|
69
69
|
};
|
|
70
|
+
export declare const isDateValue: (value: any) => boolean;
|
|
71
|
+
export declare const convertFomatedDateToDate: (value: string) => Date | null;
|
|
70
72
|
export declare function isDateString(str: any): boolean;
|
|
71
73
|
export declare function compareDates(date1: any, date2: any): boolean;
|
|
72
74
|
export declare function compareDate(itemValue: any, value: any): boolean;
|
|
@@ -17,7 +17,7 @@ exports.compareDate = compareDate;
|
|
|
17
17
|
exports.compareDates = compareDates;
|
|
18
18
|
exports.convertArrayWithIndent = void 0;
|
|
19
19
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
20
|
-
exports.convertFlatColumn1 = exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
20
|
+
exports.convertFomatedDateToDate = exports.convertFlatColumn1 = exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
21
21
|
exports.convertFormat = convertFormat;
|
|
22
22
|
exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
23
23
|
exports.countUnselectedChildren = countUnselectedChildren;
|
|
@@ -44,7 +44,7 @@ exports.getVisibleFields = getVisibleFields;
|
|
|
44
44
|
exports.groupArrayByColumns = groupArrayByColumns;
|
|
45
45
|
exports.isColor = void 0;
|
|
46
46
|
exports.isDateString = isDateString;
|
|
47
|
-
exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
47
|
+
exports.isEmpty = exports.isEditable = exports.isDisable = exports.isDateValue = void 0;
|
|
48
48
|
exports.isEqualSet = isEqualSet;
|
|
49
49
|
exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isFormattedNumber = void 0;
|
|
50
50
|
exports.isObjEqual = isObjEqual;
|
|
@@ -61,7 +61,8 @@ exports.sumFields = sumFields;
|
|
|
61
61
|
exports.sumNumberFields = sumNumberFields;
|
|
62
62
|
exports.sumSize = void 0;
|
|
63
63
|
exports.toggleRowAndChildren = toggleRowAndChildren;
|
|
64
|
-
exports.
|
|
64
|
+
exports.unFlattenData = void 0;
|
|
65
|
+
exports.updateArrayByKey = void 0;
|
|
65
66
|
exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
|
|
66
67
|
exports.updateColumnsByGroup = exports.updateColumns1 = void 0;
|
|
67
68
|
exports.updateOrInsert = updateOrInsert;
|
|
@@ -825,6 +826,174 @@ const detectSeparators = str => {
|
|
|
825
826
|
return null;
|
|
826
827
|
};
|
|
827
828
|
exports.detectSeparators = detectSeparators;
|
|
829
|
+
const isDateValue = value => {
|
|
830
|
+
if (value === null || value === undefined) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// Date object
|
|
835
|
+
if (value instanceof Date) {
|
|
836
|
+
return !isNaN(value.getTime());
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// number timestamp
|
|
840
|
+
if (typeof value === 'number') {
|
|
841
|
+
const date = new Date(value);
|
|
842
|
+
return !isNaN(date.getTime());
|
|
843
|
+
}
|
|
844
|
+
if (typeof value !== 'string') return false;
|
|
845
|
+
const str = value.trim();
|
|
846
|
+
if (!str) {
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// Các format date phổ biến
|
|
851
|
+
const patterns = [
|
|
852
|
+
// dd/MM/yyyy
|
|
853
|
+
/^\d{2}\/\d{2}\/\d{4}$/,
|
|
854
|
+
// d/M/yyyy
|
|
855
|
+
/^\d{1,2}\/\d{1,2}\/\d{4}$/,
|
|
856
|
+
// yyyy/MM/dd
|
|
857
|
+
/^\d{4}\/\d{2}\/\d{2}$/,
|
|
858
|
+
// yyyy/M/d
|
|
859
|
+
/^\d{4}\/\d{1,2}\/\d{1,2}$/,
|
|
860
|
+
// MM/yyyy
|
|
861
|
+
/^\d{2}\/\d{4}$/,
|
|
862
|
+
// M/yyyy
|
|
863
|
+
/^\d{1,2}\/\d{4}$/,
|
|
864
|
+
// yyyy/MM
|
|
865
|
+
/^\d{4}\/\d{2}$/,
|
|
866
|
+
// yyyy/M
|
|
867
|
+
/^\d{4}\/\d{1,2}$/,
|
|
868
|
+
// dd-MM-yyyy
|
|
869
|
+
/^\d{2}-\d{2}-\d{4}$/,
|
|
870
|
+
// yyyy-MM-dd
|
|
871
|
+
/^\d{4}-\d{2}-\d{2}$/,
|
|
872
|
+
// yyyy-M-d
|
|
873
|
+
/^\d{4}-\d{1,2}-\d{1,2}$/,
|
|
874
|
+
// ISO datetime
|
|
875
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,
|
|
876
|
+
// ISO datetime milliseconds
|
|
877
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?$/,
|
|
878
|
+
// yyyyMMdd
|
|
879
|
+
/^\d{8}$/,
|
|
880
|
+
// dd MMM yyyy
|
|
881
|
+
/^\d{1,2}\s[A-Za-z]{3}\s\d{4}$/,
|
|
882
|
+
// MMM dd, yyyy
|
|
883
|
+
/^[A-Za-z]{3}\s\d{1,2},\s\d{4}$/,
|
|
884
|
+
// full text date
|
|
885
|
+
/^[A-Za-z]+,\s[A-Za-z]+\s\d{1,2},\s\d{4}$/];
|
|
886
|
+
const matched = patterns.some(regex => regex.test(str));
|
|
887
|
+
if (matched) {
|
|
888
|
+
return true;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// fallback:
|
|
892
|
+
// nếu regex không match nhưng Date parse được
|
|
893
|
+
if (!matched) {
|
|
894
|
+
const fallbackDate = new Date(str);
|
|
895
|
+
return !isNaN(fallbackDate.getTime());
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// validate real date
|
|
899
|
+
const date = new Date(str);
|
|
900
|
+
return !isNaN(date.getTime());
|
|
901
|
+
};
|
|
902
|
+
exports.isDateValue = isDateValue;
|
|
903
|
+
const convertFomatedDateToDate = value => {
|
|
904
|
+
const monthMap = {
|
|
905
|
+
Jan: 0,
|
|
906
|
+
Feb: 1,
|
|
907
|
+
Mar: 2,
|
|
908
|
+
Apr: 3,
|
|
909
|
+
May: 4,
|
|
910
|
+
Jun: 5,
|
|
911
|
+
Jul: 6,
|
|
912
|
+
Aug: 7,
|
|
913
|
+
Sep: 8,
|
|
914
|
+
Oct: 9,
|
|
915
|
+
Nov: 10,
|
|
916
|
+
Dec: 11
|
|
917
|
+
};
|
|
918
|
+
let date = null;
|
|
919
|
+
|
|
920
|
+
// dd/MM/yyyy | d/M/yyyy
|
|
921
|
+
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(value)) {
|
|
922
|
+
const [d, m, y] = value.split('/').map(Number);
|
|
923
|
+
date = new Date(y, m - 1, d);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// yyyy/MM/dd | yyyy/M/d
|
|
927
|
+
else if (/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(value)) {
|
|
928
|
+
const [y, m, d] = value.split('/').map(Number);
|
|
929
|
+
date = new Date(y, m - 1, d);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// MM/yyyy | M/yyyy
|
|
933
|
+
else if (/^\d{1,2}\/\d{4}$/.test(value)) {
|
|
934
|
+
const [m, y] = value.split('/').map(Number);
|
|
935
|
+
date = new Date(y, m - 1, 1);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// yyyy/MM | yyyy/M
|
|
939
|
+
else if (/^\d{4}\/\d{1,2}$/.test(value)) {
|
|
940
|
+
const [y, m] = value.split('/').map(Number);
|
|
941
|
+
date = new Date(y, m - 1, 1);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// dd-MM-yyyy
|
|
945
|
+
else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
946
|
+
const [d, m, y] = value.split('-').map(Number);
|
|
947
|
+
date = new Date(y, m - 1, d);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// yyyy-MM-dd | yyyy-M-d
|
|
951
|
+
else if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(value)) {
|
|
952
|
+
const [y, m, d] = value.split('-').map(Number);
|
|
953
|
+
date = new Date(y, m - 1, d);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// ISO datetime
|
|
957
|
+
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(value)) {
|
|
958
|
+
date = new Date(value);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// ISO datetime milliseconds
|
|
962
|
+
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z?$/.test(value)) {
|
|
963
|
+
date = new Date(value);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// yyyyMMdd
|
|
967
|
+
else if (/^\d{8}$/.test(value)) {
|
|
968
|
+
const y = Number(value.slice(0, 4));
|
|
969
|
+
const m = Number(value.slice(4, 6));
|
|
970
|
+
const d = Number(value.slice(6, 8));
|
|
971
|
+
date = new Date(y, m - 1, d);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// dd MMM yyyy
|
|
975
|
+
else if (/^\d{1,2}\s[A-Za-z]{3}\s\d{4}$/.test(value)) {
|
|
976
|
+
const [d, mon, y] = value.split(' ');
|
|
977
|
+
date = new Date(Number(y), monthMap[mon], Number(d));
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// MMM dd, yyyy
|
|
981
|
+
else if (/^[A-Za-z]{3}\s\d{1,2},\s\d{4}$/.test(value)) {
|
|
982
|
+
const [mon, dayComma, y] = value.split(' ');
|
|
983
|
+
const d = Number(dayComma.replace(',', ''));
|
|
984
|
+
date = new Date(Number(y), monthMap[mon], d);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// full text date
|
|
988
|
+
else if (/^[A-Za-z]+,\s[A-Za-z]+\s\d{1,2},\s\d{4}$/.test(value)) {
|
|
989
|
+
date = new Date(value);
|
|
990
|
+
}
|
|
991
|
+
if (!date || isNaN(date.getTime())) {
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
return date;
|
|
995
|
+
};
|
|
996
|
+
exports.convertFomatedDateToDate = convertFomatedDateToDate;
|
|
828
997
|
function isDate(value) {
|
|
829
998
|
if (value instanceof Date) {
|
|
830
999
|
return !isNaN(value.getTime());
|
|
@@ -885,8 +1054,11 @@ const shouldInclude = (item, queries, ignoreAccents) => {
|
|
|
885
1054
|
} = query;
|
|
886
1055
|
const itemValue = item[field];
|
|
887
1056
|
let condition = false;
|
|
888
|
-
|
|
889
|
-
const
|
|
1057
|
+
|
|
1058
|
+
// const aaa = convertFomatedDateToDate('25/01/2026')
|
|
1059
|
+
|
|
1060
|
+
const isDateComparison = isDate(itemValue) || isDateString(value) || isDateValue(itemValue) || isDateValue(value);
|
|
1061
|
+
const itemDate = isDateComparison ? isNaN(new Date(itemValue).getTime()) ? convertFomatedDateToDate(itemValue) : new Date(itemValue) : null;
|
|
890
1062
|
const queryDate = isDateComparison ? parseToDate(value) : null;
|
|
891
1063
|
const itemStr = removeVietnameseTones(itemValue?.toString().toLowerCase?.() ?? '');
|
|
892
1064
|
const queryStr = removeVietnameseTones(value?.toString().toLowerCase?.() ?? '');
|