es-grid-template 1.8.28 → 1.8.30
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/CHANGELOG.md +6 -0
- package/LICENSE +21 -21
- package/README.md +1 -1
- package/assets/index.scss +1170 -1170
- package/es/grid-component/hooks/constant.js +6 -6
- package/es/grid-component/hooks/useColumns.d.ts +1 -3
- package/es/grid-component/styles.scss +1437 -1437
- package/es/table-component/TableContainer.d.ts +7 -0
- package/es/table-component/TableContainer.js +7 -2
- package/es/table-component/TableContainerEdit.d.ts +7 -0
- package/es/table-component/TableContainerEdit.js +24 -9
- package/es/table-component/body/TableBodyCell.js +79 -37
- package/es/table-component/body/TableBodyCellEdit.js +57 -73
- package/es/table-component/body/TableBodyRow.js +4 -2
- package/es/table-component/components/number/index.d.ts +2 -1
- package/es/table-component/components/number/index.js +13 -5
- package/es/table-component/components/number-range/index.d.ts +2 -1
- package/es/table-component/components/number-range/index.js +22 -6
- package/es/table-component/header/TableHeadCell.js +2 -1
- package/es/table-component/header/TableHeadCell2.js +41 -16
- package/es/table-component/header/TableHeadGroupCell.js +2 -1
- package/es/table-component/header/renderFilter.d.ts +1 -1
- package/es/table-component/header/renderFilter.js +13 -5
- package/es/table-component/hook/constant.js +6 -6
- package/es/table-component/hook/useColumns.d.ts +21 -2
- package/es/table-component/hook/useColumns.js +115 -4
- package/es/table-component/hook/utils.d.ts +12 -1
- package/es/table-component/hook/utils.js +173 -0
- package/es/table-component/style.scss +1220 -1220
- package/es/table-component/table/Grid.js +29 -24
- package/es/table-component/table/TableWrapper.js +2 -1
- package/es/table-component/type.d.ts +10 -5
- package/es/table-component/useContext.d.ts +11 -2
- package/lib/grid-component/hooks/constant.js +6 -6
- package/lib/grid-component/hooks/useColumns.d.ts +1 -3
- package/lib/grid-component/styles.scss +1437 -1437
- package/lib/table-component/TableContainer.d.ts +7 -0
- package/lib/table-component/TableContainer.js +7 -2
- package/lib/table-component/TableContainerEdit.d.ts +7 -0
- package/lib/table-component/TableContainerEdit.js +23 -8
- package/lib/table-component/body/TableBodyCell.js +79 -37
- package/lib/table-component/body/TableBodyCellEdit.js +57 -73
- package/lib/table-component/body/TableBodyRow.js +4 -2
- package/lib/table-component/components/number/index.d.ts +2 -1
- package/lib/table-component/components/number/index.js +13 -5
- package/lib/table-component/components/number-range/index.d.ts +2 -1
- package/lib/table-component/components/number-range/index.js +22 -6
- package/lib/table-component/header/TableHeadCell.js +2 -1
- package/lib/table-component/header/TableHeadCell2.js +40 -15
- package/lib/table-component/header/TableHeadGroupCell.js +2 -1
- package/lib/table-component/header/renderFilter.d.ts +1 -1
- package/lib/table-component/header/renderFilter.js +13 -5
- package/lib/table-component/hook/constant.js +6 -6
- package/lib/table-component/hook/useColumns.d.ts +21 -2
- package/lib/table-component/hook/useColumns.js +116 -4
- package/lib/table-component/hook/utils.d.ts +12 -1
- package/lib/table-component/hook/utils.js +193 -4
- package/lib/table-component/style.scss +1220 -1220
- package/lib/table-component/table/Grid.js +28 -23
- package/lib/table-component/table/TableWrapper.js +2 -1
- package/lib/table-component/type.d.ts +10 -5
- package/lib/table-component/useContext.d.ts +11 -2
- package/package.json +117 -116
|
@@ -11,6 +11,7 @@ exports.addRowsUp = addRowsUp;
|
|
|
11
11
|
exports.addRowsUpWithCtrl = addRowsUpWithCtrl;
|
|
12
12
|
exports.appendIfNotExists = void 0;
|
|
13
13
|
exports.areStringArraysEqual = areStringArraysEqual;
|
|
14
|
+
exports.arraysEqualIgnoreOrderFast = arraysEqualIgnoreOrderFast;
|
|
14
15
|
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = void 0;
|
|
15
16
|
exports.compareDate = compareDate;
|
|
16
17
|
exports.compareDates = compareDates;
|
|
@@ -18,11 +19,18 @@ exports.convertArrayWithIndent = void 0;
|
|
|
18
19
|
exports.convertColumnsToTreeData = convertColumnsToTreeData;
|
|
19
20
|
exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs = void 0;
|
|
20
21
|
exports.convertFormat = convertFormat;
|
|
21
|
-
exports.
|
|
22
|
+
exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
|
|
23
|
+
exports.countUnselectedChildren = countUnselectedChildren;
|
|
24
|
+
exports.detectSeparators = exports.customWeekStartEndFormat = void 0;
|
|
25
|
+
exports.excludeItems = excludeItems;
|
|
26
|
+
exports.extendsObject = void 0;
|
|
27
|
+
exports.filterByIds = filterByIds;
|
|
22
28
|
exports.filterDataByColumns = filterDataByColumns;
|
|
23
29
|
exports.findAllChildrenKeys2 = findAllChildrenKeys2;
|
|
24
30
|
exports.findFirst = findFirst;
|
|
25
|
-
exports.
|
|
31
|
+
exports.genPresets = exports.flattenData = exports.flattenArray = exports.flatColumns2 = exports.findItemByKey = void 0;
|
|
32
|
+
exports.getAllChildren = getAllChildren;
|
|
33
|
+
exports.getAllVisibleKeys1 = exports.getAllVisibleKeys = exports.getAllRowKey = void 0;
|
|
26
34
|
exports.getCellsByPosition = getCellsByPosition;
|
|
27
35
|
exports.getColIdsBetween = getColIdsBetween;
|
|
28
36
|
exports.getFormat = exports.getFixedFields = exports.getEditType = exports.getDiffent2Array = exports.getDefaultValue = exports.getDefaultOperator = exports.getDatepickerFormat = exports.getDateRangeFormat = exports.getCommonPinningStyles2 = exports.getCommonPinningStyles = void 0;
|
|
@@ -41,9 +49,17 @@ exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.i
|
|
|
41
49
|
exports.isObjEqual = isObjEqual;
|
|
42
50
|
exports.isTree = isTree;
|
|
43
51
|
exports.isTreeArray = isTreeArray;
|
|
44
|
-
exports.
|
|
52
|
+
exports.parseBooleanToValue = exports.onRemoveBgSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = void 0;
|
|
53
|
+
exports.parseClipboardEvent = parseClipboardEvent;
|
|
54
|
+
exports.parseExcelClipboard = parseExcelClipboard;
|
|
55
|
+
exports.parseExcelClipboardText = parseExcelClipboardText;
|
|
56
|
+
exports.parseExcelText = parseExcelText;
|
|
57
|
+
exports.removeDuplicatesByKey = removeDuplicatesByKey;
|
|
58
|
+
exports.sortByType = exports.shouldInclude = exports.removeVietnameseTones = void 0;
|
|
45
59
|
exports.sortData = sortData;
|
|
46
|
-
exports.
|
|
60
|
+
exports.sumSize = void 0;
|
|
61
|
+
exports.toggleRowAndChildren = toggleRowAndChildren;
|
|
62
|
+
exports.updateArrayByKey = exports.unFlattenData = void 0;
|
|
47
63
|
exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
|
|
48
64
|
exports.updateColumns1 = void 0;
|
|
49
65
|
exports.updateOrInsert = updateOrInsert;
|
|
@@ -2145,4 +2161,177 @@ function findAllChildrenKeys2(data, rowKey, childrenColumnName) {
|
|
|
2145
2161
|
}
|
|
2146
2162
|
dig(data);
|
|
2147
2163
|
return keys;
|
|
2164
|
+
}
|
|
2165
|
+
function parseExcelText(text) {
|
|
2166
|
+
// const text = e.clipboardData?.getData('text/plain') ?? '';
|
|
2167
|
+
if (!text) return [];
|
|
2168
|
+
|
|
2169
|
+
// Excel thường dùng \r\n giữa dòng, \t giữa cột
|
|
2170
|
+
const rows = text.split(/\r?\n/) // tách theo dòng
|
|
2171
|
+
.filter(r => r.trim() !== '') // bỏ dòng trống
|
|
2172
|
+
.map(row => row.split('\t') // tách theo cột
|
|
2173
|
+
.map(cell => cell.replace(/\r/g, '').replace(/\n/g, '\n')) // giữ xuống dòng trong ô
|
|
2174
|
+
);
|
|
2175
|
+
return rows;
|
|
2176
|
+
}
|
|
2177
|
+
function parseExcelClipboard(e) {
|
|
2178
|
+
const text = e.clipboardData?.getData('text/plain') ?? '';
|
|
2179
|
+
if (!text) return [];
|
|
2180
|
+
|
|
2181
|
+
// Excel thường dùng \r\n giữa dòng, \t giữa cột
|
|
2182
|
+
const rows = text.split(/\r?\n/) // tách theo dòng
|
|
2183
|
+
.filter(r => r.trim() !== '') // bỏ dòng trống
|
|
2184
|
+
.map(row => row.split('\t') // tách theo cột
|
|
2185
|
+
.map(cell => cell.replace(/\r/g, '').replace(/\n/g, '\n')) // giữ xuống dòng trong ô
|
|
2186
|
+
);
|
|
2187
|
+
return rows;
|
|
2188
|
+
}
|
|
2189
|
+
function parseExcelClipboardText(text) {
|
|
2190
|
+
const rows = [];
|
|
2191
|
+
let curRow = [];
|
|
2192
|
+
let curCell = '';
|
|
2193
|
+
let inQuotes = false;
|
|
2194
|
+
for (let i = 0; i < text.length; i++) {
|
|
2195
|
+
const ch = text[i];
|
|
2196
|
+
if (ch === '"') {
|
|
2197
|
+
// "" -> an escaped quote inside quoted field
|
|
2198
|
+
if (inQuotes && text[i + 1] === '"') {
|
|
2199
|
+
curCell += '"';
|
|
2200
|
+
i++; // skip next
|
|
2201
|
+
} else {
|
|
2202
|
+
inQuotes = !inQuotes; // open/close quote
|
|
2203
|
+
}
|
|
2204
|
+
continue;
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// tab as column separator (only if not inside quotes)
|
|
2208
|
+
if (ch === '\t' && !inQuotes) {
|
|
2209
|
+
curRow.push(curCell);
|
|
2210
|
+
curCell = '';
|
|
2211
|
+
continue;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
// newline as row separator (handle \r\n and lone \r or \n), only outside quotes
|
|
2215
|
+
if ((ch === '\r' || ch === '\n') && !inQuotes) {
|
|
2216
|
+
// handle CRLF
|
|
2217
|
+
if (ch === '\r' && text[i + 1] === '\n') i++;
|
|
2218
|
+
curRow.push(curCell);
|
|
2219
|
+
curCell = '';
|
|
2220
|
+
rows.push(curRow);
|
|
2221
|
+
curRow = [];
|
|
2222
|
+
continue;
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// normal character
|
|
2226
|
+
curCell += ch;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
// push last cell/row (if any)
|
|
2230
|
+
// avoid adding one spurious empty row when text ends with newline (we already pushed that row)
|
|
2231
|
+
if (curCell !== '' || curRow.length > 0) {
|
|
2232
|
+
curRow.push(curCell);
|
|
2233
|
+
rows.push(curRow);
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
// if the whole input was empty, return []
|
|
2237
|
+
if (rows.length === 1 && rows[0].length === 1 && rows[0][0] === '' && text.trim() === '') {
|
|
2238
|
+
return [];
|
|
2239
|
+
}
|
|
2240
|
+
return rows;
|
|
2241
|
+
}
|
|
2242
|
+
function parseClipboardEvent(e) {
|
|
2243
|
+
const dataTransfer = e.clipboardData ?? e.nativeEvent?.clipboardData;
|
|
2244
|
+
if (!dataTransfer) return [];
|
|
2245
|
+
|
|
2246
|
+
// 1) try HTML (better fidelity for Excel)
|
|
2247
|
+
const html = dataTransfer.getData?.('text/html');
|
|
2248
|
+
if (html) {
|
|
2249
|
+
try {
|
|
2250
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
2251
|
+
const table = doc.querySelector('table');
|
|
2252
|
+
if (table) {
|
|
2253
|
+
const result = [];
|
|
2254
|
+
for (const tr of Array.from(table.rows)) {
|
|
2255
|
+
const row = [];
|
|
2256
|
+
for (const cell of Array.from(tr.cells)) {
|
|
2257
|
+
// innerText preserves newlines from <br>
|
|
2258
|
+
row.push(cell.innerText ?? '');
|
|
2259
|
+
}
|
|
2260
|
+
result.push(row);
|
|
2261
|
+
}
|
|
2262
|
+
if (result.length) return result;
|
|
2263
|
+
}
|
|
2264
|
+
} catch {
|
|
2265
|
+
// fallback to text parsing
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// 2) fallback: parse plain text (TSV with quoted fields)
|
|
2270
|
+
const text = dataTransfer.getData?.('text/plain') ?? '';
|
|
2271
|
+
return parseExcelClipboardText(text);
|
|
2272
|
+
}
|
|
2273
|
+
function arraysEqualIgnoreOrderFast(a, b) {
|
|
2274
|
+
if (a.length !== b.length) return false;
|
|
2275
|
+
const count = Object.create(null);
|
|
2276
|
+
for (let i = 0; i < a.length; i++) {
|
|
2277
|
+
const key = a[i];
|
|
2278
|
+
count[key] = (count[key] || 0) + 1;
|
|
2279
|
+
}
|
|
2280
|
+
for (let i = 0; i < b.length; i++) {
|
|
2281
|
+
const key = b[i];
|
|
2282
|
+
if (!count[key]) return false;
|
|
2283
|
+
count[key]--;
|
|
2284
|
+
if (count[key] === 0) delete count[key];
|
|
2285
|
+
}
|
|
2286
|
+
return Object.keys(count).length === 0;
|
|
2287
|
+
}
|
|
2288
|
+
function filterByIds(a, b) {
|
|
2289
|
+
const idSet = new Set(a);
|
|
2290
|
+
return b.filter(item => idSet.has(item.id));
|
|
2291
|
+
}
|
|
2292
|
+
function excludeItems(arrayA, arrayB) {
|
|
2293
|
+
const idsInB = new Set(arrayB.map(item => item.id));
|
|
2294
|
+
|
|
2295
|
+
// Lọc A, chỉ giữ lại phần tử không có trong B
|
|
2296
|
+
return arrayA.filter(item => !idsInB.has(item.id));
|
|
2297
|
+
}
|
|
2298
|
+
function getAllChildren(row) {
|
|
2299
|
+
const children = row.subRows ?? [];
|
|
2300
|
+
return children.reduce((acc, child) => {
|
|
2301
|
+
return acc.concat(child, getAllChildren(child));
|
|
2302
|
+
}, []);
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// export function toggleSelectAllChildren(row: any) {
|
|
2306
|
+
// const children = row.subRows ?? [];
|
|
2307
|
+
|
|
2308
|
+
// return children.reduce((acc: any, child: any) => {
|
|
2309
|
+
// return acc.concat(child, getAllChildren(child));
|
|
2310
|
+
// }, []);
|
|
2311
|
+
// }
|
|
2312
|
+
|
|
2313
|
+
function toggleRowAndChildren(row, isSelected) {
|
|
2314
|
+
// Toggle chính row hiện tại
|
|
2315
|
+
row.toggleSelected(isSelected);
|
|
2316
|
+
|
|
2317
|
+
// Nếu có subRows thì gọi đệ quy
|
|
2318
|
+
if (row.subRows && row.subRows.length > 0) {
|
|
2319
|
+
row.subRows.forEach(subRow => toggleRowAndChildren(subRow, isSelected));
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
function countUnselectedChildren(row) {
|
|
2323
|
+
const parent = row.getParentRow();
|
|
2324
|
+
if (!parent) return 0; // Không có cha thì return 0
|
|
2325
|
+
|
|
2326
|
+
const unselectedCount = parent.subRows.filter(child => !child.getIsSelected()).length;
|
|
2327
|
+
return unselectedCount;
|
|
2328
|
+
}
|
|
2329
|
+
function removeDuplicatesByKey(arr, key = 'id') {
|
|
2330
|
+
const map = new Map();
|
|
2331
|
+
for (const item of arr) {
|
|
2332
|
+
if (!map.has(item[key])) {
|
|
2333
|
+
map.set(item[key], item);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
return Array.from(map.values());
|
|
2148
2337
|
}
|