es-grid-template 1.3.6 → 1.3.8

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.
Files changed (31) hide show
  1. package/assets/index.css +35 -24
  2. package/assets/index.scss +57 -21
  3. package/es/grid-component/EditableCell.js +12 -11
  4. package/es/grid-component/GridStyle.d.ts +5 -3
  5. package/es/grid-component/GridStyle.js +1 -1
  6. package/es/grid-component/TableGrid.js +28 -21
  7. package/es/grid-component/hooks/columns/index.d.ts +1 -1
  8. package/es/grid-component/hooks/columns/index.js +15 -14
  9. package/es/grid-component/hooks/useColumns.js +12 -9
  10. package/es/grid-component/hooks/utils.d.ts +19 -4
  11. package/es/grid-component/hooks/utils.js +377 -26
  12. package/es/grid-component/styles.scss +57 -21
  13. package/es/grid-component/table/Grid.js +1 -1
  14. package/es/grid-component/table/GridEdit.js +383 -268
  15. package/es/grid-component/table/Group.js +1 -1
  16. package/es/grid-component/type.d.ts +4 -4
  17. package/lib/grid-component/EditableCell.js +12 -11
  18. package/lib/grid-component/GridStyle.d.ts +5 -3
  19. package/lib/grid-component/GridStyle.js +1 -1
  20. package/lib/grid-component/TableGrid.js +26 -20
  21. package/lib/grid-component/hooks/columns/index.d.ts +1 -1
  22. package/lib/grid-component/hooks/columns/index.js +15 -14
  23. package/lib/grid-component/hooks/useColumns.js +12 -9
  24. package/lib/grid-component/hooks/utils.d.ts +19 -4
  25. package/lib/grid-component/hooks/utils.js +401 -33
  26. package/lib/grid-component/styles.scss +57 -21
  27. package/lib/grid-component/table/Grid.js +1 -1
  28. package/lib/grid-component/table/GridEdit.js +382 -259
  29. package/lib/grid-component/table/Group.js +1 -1
  30. package/lib/grid-component/type.d.ts +4 -4
  31. package/package.json +2 -2
@@ -4,17 +4,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.addRowIdArray = void 0;
7
+ exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderClass = void 0;
8
8
  exports.addRows8 = addRows8;
9
9
  exports.addRowsUp = addRowsUp;
10
10
  exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
11
11
  exports.compareDate = compareDate;
12
12
  exports.compareDates = compareDates;
13
13
  exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = void 0;
14
+ exports.filterDataByColumns4 = filterDataByColumns4;
14
15
  exports.findAllChildrenKeys = findAllChildrenKeys;
15
- exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
16
+ exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
17
+ exports.getBottomRowCells = getBottomRowCells;
18
+ exports.getCellsByPosition = getCellsByPosition;
19
+ exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
16
20
  exports.getHiddenParentKeys = getHiddenParentKeys;
17
- exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
21
+ exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
18
22
  exports.invalidDate = invalidDate;
19
23
  exports.isArraysEqual = void 0;
20
24
  exports.isBottomMostInRanges = isBottomMostInRanges;
@@ -24,7 +28,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
24
28
  exports.isEqualSet = isEqualSet;
25
29
  exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
26
30
  exports.isRightMostInRegion = isRightMostInRegion;
27
- exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveClassSelectedCell = exports.onAddClassSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
31
+ exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
28
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
29
33
  var _moment = _interopRequireDefault(require("moment/moment"));
30
34
  var _uuid = require("uuid");
@@ -212,24 +216,24 @@ const updateColumnsByGroup = (columns, columnsGroup) => {
212
216
  });
213
217
  };
214
218
  exports.updateColumnsByGroup = updateColumnsByGroup;
215
- const getDatepickerFormat = (type, col) => {
219
+ const getDatepickerFormat = (type, format) => {
216
220
  const typeFormat = type ? type.toLowerCase() : '';
217
221
  switch (typeFormat) {
218
222
  case "date":
219
223
  case "daterange":
220
- return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY';
224
+ return format?.dateFormat ?? 'DD/MM/YYYY';
221
225
  case "datetime":
222
- return col.format?.datetimeFormat ? col.format?.datetimeFormat : 'DD/MM/YYYY HH:mm';
226
+ return format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm';
223
227
  case "week":
224
- return col.format?.weekFormat ? col.format?.weekFormat : 'DD/MM';
228
+ return format?.weekFormat ?? 'DD/MM';
225
229
  case "month":
226
- return col.format?.monthFormat ? col.format?.monthFormat : 'MM/YYYY';
230
+ return format?.monthFormat ?? 'MM/YYYY';
227
231
  case "quarter":
228
- return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY';
232
+ return format?.dateFormat ?? 'DD/MM/YYYY';
229
233
  case "year":
230
- return col.format?.yearFormat ? col.format?.yearFormat : 'YYYY';
234
+ return format?.yearFormat ?? 'YYYY';
231
235
  case "time":
232
- return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm';
236
+ return format?.timeFormat ?? 'HH:mm';
233
237
  default:
234
238
  return 'DD/MM/YYYY';
235
239
  }
@@ -369,7 +373,7 @@ const totalFixedWidth = (columns, type, selectionSettings) => {
369
373
  const width = typeof column.width === 'number' ? column.width : parseInt(column.width, 10) || 0; // Chuyển từ chuỗi sang số, nếu không hợp lệ thì lấy 0
370
374
  return sum + width;
371
375
  }, 0);
372
- const selectColumnWidth = !selectionSettings?.mode ? 0.0000001 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
376
+ const selectColumnWidth = !selectionSettings?.mode ? 0 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
373
377
  return totalFixedLeftWidth + selectColumnWidth;
374
378
  };
375
379
  exports.totalFixedWidth = totalFixedWidth;
@@ -809,8 +813,8 @@ function addRowsUp(array, n) {
809
813
  {
810
814
  // Lấy giá trị cuối, chuyển về date, cộng thêm (i+1)*step, chuyển lại về định dạng ISO
811
815
 
812
- const lastDate = new Date(array[m - 1][j]);
813
- const newTime = lastDate.getTime() - (i + 1) * steps[j] * -1;
816
+ const lastDate = new Date(arr[m - 1][j]);
817
+ const newTime = m === 1 ? lastDate.getTime() - (i + 1) * steps[j] : lastDate.getTime() - (i + 1) * steps[j] * -1;
814
818
  newValue = (0, _moment.default)(new Date(newTime)).format();
815
819
  }
816
820
  break;
@@ -863,7 +867,7 @@ const transformColumns1 = (cols, sortMultiple) => {
863
867
  if (!column?.field && !column?.key) {
864
868
  return _rcMasterUi.Table.SELECTION_COLUMN;
865
869
  }
866
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
870
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
867
871
  return {
868
872
  ...column
869
873
  };
@@ -1246,6 +1250,93 @@ const filterDataByColumns3 = (data, queries) => {
1246
1250
  return result;
1247
1251
  });
1248
1252
  };
1253
+ exports.filterDataByColumns3 = filterDataByColumns3;
1254
+ const shouldInclude = (item, queries) => {
1255
+ if (item.isFilterState === true) {
1256
+ return true;
1257
+ }
1258
+ let result = null;
1259
+ for (const query of queries) {
1260
+ const {
1261
+ field,
1262
+ value,
1263
+ operator,
1264
+ predicate
1265
+ } = query;
1266
+ const itemValue = item[field];
1267
+ let condition = false;
1268
+ const isDateComparison = isDate(itemValue) || isDateString(value);
1269
+ const itemDate = isDateComparison ? new Date(itemValue) : null;
1270
+ const queryDate = isDateComparison ? parseToDate(value) : null;
1271
+ const itemStr = itemValue?.toString().toLowerCase?.();
1272
+ const queryStr = value?.toString().toLowerCase?.();
1273
+ switch (operator.toLowerCase()) {
1274
+ case "equal":
1275
+ condition = isDateComparison ? compareDates(itemDate, queryDate) : itemValue === value;
1276
+ break;
1277
+ case "notequal":
1278
+ condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
1279
+ break;
1280
+ case "greaterthan":
1281
+ // @ts-ignore
1282
+ condition = isDateComparison ? itemDate > queryDate : itemValue > value;
1283
+
1284
+ // condition = isDateComparison ? invalidDate(itemDate) && invalidDate(queryDate) && itemDate > queryDate : itemValue > value;
1285
+ break;
1286
+ case "greaterthanorequal":
1287
+ // @ts-ignore
1288
+ condition = isDateComparison ? itemDate >= queryDate : itemValue >= value;
1289
+ break;
1290
+ case "lessthan":
1291
+ // @ts-ignore
1292
+ condition = isDateComparison ? itemDate < queryDate : itemValue < value;
1293
+ break;
1294
+ case "lessthanorequal":
1295
+ // @ts-ignore
1296
+ condition = isDateComparison ? itemDate <= queryDate : itemValue <= value;
1297
+ break;
1298
+ case "contains":
1299
+ condition = itemStr?.includes(queryStr);
1300
+ break;
1301
+ case "startswith":
1302
+ condition = itemStr?.startsWith(queryStr);
1303
+ break;
1304
+ case "endswith":
1305
+ condition = itemStr?.endsWith(queryStr);
1306
+ break;
1307
+ default:
1308
+ console.warn(`Unknown operator: ${operator}`);
1309
+ break;
1310
+ }
1311
+ if (predicate === "and") {
1312
+ result = result === null ? condition : result && condition;
1313
+ } else if (predicate === "or") {
1314
+ result = result === null ? condition : result || condition;
1315
+ }
1316
+ }
1317
+ return result;
1318
+ };
1319
+ exports.shouldInclude = shouldInclude;
1320
+ function filterDataByColumns4(data, queries) {
1321
+ if (!queries || queries.length === 0) {
1322
+ return data;
1323
+ }
1324
+ return data.map(item => {
1325
+ const newItem = {
1326
+ ...item
1327
+ };
1328
+ if (Array.isArray(item.children)) {
1329
+ newItem.children = filterDataByColumns4(item.children, queries);
1330
+ }
1331
+ const isSelfMatched = shouldInclude(item, queries);
1332
+
1333
+ // Nếu chính item thỏa hoặc có con thỏa → giữ lại
1334
+ if (isSelfMatched || newItem.children && newItem.children.length > 0) {
1335
+ return newItem;
1336
+ }
1337
+ return null; // loại bỏ node không phù hợp
1338
+ }).filter(Boolean); // xóa các null
1339
+ }
1249
1340
 
1250
1341
  // ======= Helper functions ========
1251
1342
 
@@ -1253,7 +1344,7 @@ const filterDataByColumns3 = (data, queries) => {
1253
1344
  // function isDate(value: any) {
1254
1345
  // return value instanceof Date || !isNaN(Date.parse(value));
1255
1346
  // }
1256
- exports.filterDataByColumns3 = filterDataByColumns3;
1347
+
1257
1348
  function isDate(value) {
1258
1349
  if (value instanceof Date) {
1259
1350
  return !isNaN(value.getTime());
@@ -1442,39 +1533,316 @@ const sortedSetDSC = setValue => {
1442
1533
  return new Set(sorted);
1443
1534
  };
1444
1535
  exports.sortedSetDSC = sortedSetDSC;
1445
- const onAddClassSelectedCell = (selectedCells, id) => {
1536
+ function getBottomRowCells(cellSet) {
1537
+ const cells = Array.from(cellSet).map(key => {
1538
+ const [row, col] = key.split('-').map(Number);
1539
+ return {
1540
+ row,
1541
+ col,
1542
+ key
1543
+ };
1544
+ });
1545
+ const maxRow = Math.max(...cells.map(c => c.row));
1546
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1547
+ }
1548
+ function getCellsByPosition(cellSet, position = "bottom") {
1549
+ const cells = Array.from(cellSet).map(key => {
1550
+ const [row, col] = key.split("-").map(Number);
1551
+ return {
1552
+ row,
1553
+ col,
1554
+ key
1555
+ };
1556
+ });
1557
+ switch (position) {
1558
+ case "top":
1559
+ {
1560
+ // const minRow = Math.min(...cells.map(c => c.row));
1561
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1562
+
1563
+ // const rows = cells.map(c => c.row).filter(r => r > 0);
1564
+ // if (rows.length === 0) return [];
1565
+ // const minRow = Math.min(...rows);
1566
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1567
+
1568
+ const minRow = Math.min(...cells.map(c => c.row));
1569
+ if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1570
+
1571
+ return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1572
+ }
1573
+ case "bottom":
1574
+ {
1575
+ const maxRow = Math.max(...cells.map(c => c.row));
1576
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1577
+ }
1578
+ case "left":
1579
+ {
1580
+ // const minCol = Math.min(...cells.map(c => c.col));
1581
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1582
+
1583
+ // const cols = cells.map(c => c.col).filter(c => c > 0);
1584
+ // if (cols.length === 0) return [];
1585
+ // const minCol = Math.min(...cols);
1586
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1587
+
1588
+ const minCol = Math.min(...cells.map(c => c.col));
1589
+ if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1590
+
1591
+ // Trả về các ô cùng row, nhưng ở cột bên trái
1592
+ return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
1593
+ }
1594
+ case "right":
1595
+ {
1596
+ const maxCol = Math.max(...cells.map(c => c.col));
1597
+ return cells.filter(c => c.col === maxCol).map(c => c.key);
1598
+ }
1599
+ default:
1600
+ return [];
1601
+ }
1602
+ }
1603
+ const addBorderClass = (selectedCells, type, className, id) => {
1604
+ const table = document.querySelector(`#${id}`);
1605
+ const typeCells = getCellsByPosition(selectedCells, type);
1606
+ const selectorsCells = typeCells.map(pos => {
1607
+ const [row, col] = pos.split('-');
1608
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1609
+ });
1610
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1611
+ if (cellsFilter && cellsFilter.length > 0) {
1612
+ cellsFilter.forEach(cell => {
1613
+ cell.classList.add(className);
1614
+ });
1615
+ }
1616
+ };
1617
+ exports.addBorderClass = addBorderClass;
1618
+ const removeBorderClass = (selectedCells, type, className, id) => {
1619
+ const table = document.querySelector(`#${id}`);
1620
+ const typeCells = getCellsByPosition(selectedCells, type);
1621
+ const selectorsCells = typeCells.map(pos => {
1622
+ const [row, col] = pos.split('-');
1623
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1624
+ });
1625
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1626
+ if (cellsFilter && cellsFilter.length > 0) {
1627
+ cellsFilter.forEach(cell => {
1628
+ cell.classList.remove(className);
1629
+ });
1630
+ }
1631
+ };
1632
+ exports.removeBorderClass = removeBorderClass;
1633
+ const removeBorderClass2 = (className, id) => {
1634
+ const table = document.querySelector(`#${id}`);
1635
+ const cellsFilter = table ? table?.querySelectorAll(`.ui-rc-table-cell.${className}`) : null;
1636
+ if (cellsFilter && cellsFilter.length > 0) {
1637
+ cellsFilter.forEach(cell => {
1638
+ cell.classList.remove(className);
1639
+ });
1640
+ }
1641
+ };
1642
+ exports.removeBorderClass2 = removeBorderClass2;
1643
+ const onAddBgSelectedCell = (selectedCells, id) => {
1446
1644
  const selectors = Array.from(selectedCells).map(pos => {
1447
1645
  const [row1, col1] = pos.split('-');
1448
1646
  return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
1449
1647
  });
1450
-
1451
- // const cells = document.querySelectorAll(selectors.join(','));
1452
-
1453
1648
  const table = document.querySelector(`#${id}`);
1454
- console.log('table', table);
1455
- const cells = table?.querySelectorAll(selectors.join(','));
1649
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1456
1650
  if (cells) {
1457
1651
  cells.forEach(cell => {
1458
1652
  cell.classList.add('selected');
1459
1653
  });
1460
1654
  }
1655
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1656
+ const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1657
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1658
+ if (cellsIndex) {
1659
+ cellsIndex.forEach(cell => {
1660
+ cell.classList.add('focus');
1661
+ });
1662
+ }
1663
+
1664
+ // // tăng z-index để hiển thị round point paste
1665
+ // const row = getLastSelectCell(selectedCells).row
1666
+ // const col = getLastSelectCell(selectedCells).col
1667
+ // const cell: any = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`)
1668
+ //
1669
+ // if (cell) {
1670
+ // cell.style.zIndex = 1
1671
+ // }
1672
+ //
1673
+ // if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1674
+ // cell.style.zIndex = 3;
1675
+ // }
1676
+
1677
+ // thêm class border selected
1678
+
1679
+ // addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id)
1680
+ // addBorderClass(selectedCells, 'right', 'cell-border-right', id)
1681
+ // addBorderClass(selectedCells, 'top', 'cell-border-top', id)
1682
+ // addBorderClass(selectedCells, 'left', 'cell-border-left', id)
1461
1683
  };
1462
- exports.onAddClassSelectedCell = onAddClassSelectedCell;
1463
- const onRemoveClassSelectedCell = (selectedCells, id) => {
1464
- const selectors = Array.from(selectedCells).map(pos => {
1465
- const [row, col] = pos.split('-');
1466
- return `[data-row-index="${row}"][data-col-index="${col}"]`;
1467
- });
1684
+ exports.onAddBgSelectedCell = onAddBgSelectedCell;
1685
+ const onAddBorderSelectedCell = (selectedCells, id) => {
1468
1686
  const table = document.querySelector(`#${id}`);
1469
- const cells = table?.querySelectorAll(selectors.join(','));
1470
- // const cells = table?.querySelectorAll(selectors.join(','))
1471
1687
 
1472
- // const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
1688
+ // tăng z-index để hiển thị round point paste
1689
+ const row = getLastSelectCell(selectedCells).row;
1690
+ const col = getLastSelectCell(selectedCells).col;
1691
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1692
+ if (cell) {
1693
+ cell.style.zIndex = 1;
1694
+ }
1695
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1696
+ cell.style.zIndex = 3;
1697
+ }
1698
+
1699
+ // thêm class border selected
1473
1700
 
1701
+ addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1702
+ addBorderClass(selectedCells, 'right', 'cell-border-right', id);
1703
+ addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1704
+ addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1705
+ };
1706
+ exports.onAddBorderSelectedCell = onAddBorderSelectedCell;
1707
+ const onRemoveBgSelectedCell = (selectedCells, id, rowsSelected) => {
1708
+ const table = document.querySelector(`#${id}`);
1709
+ const cells = table ? table?.querySelectorAll('.ui-rc-table-cell.selected') : null;
1474
1710
  if (cells) {
1475
1711
  cells.forEach(cell => {
1476
1712
  cell.classList.remove('selected');
1477
1713
  });
1478
1714
  }
1715
+ const cellsIndex = table ? table?.querySelectorAll('.ui-rc-table-cell.focus') : null;
1716
+ if (cellsIndex) {
1717
+ cellsIndex.forEach(cell => {
1718
+ cell.classList.remove('focus');
1719
+ });
1720
+ }
1721
+
1722
+ // xóa class selected ô STT
1723
+
1724
+ if (rowsSelected && rowsSelected.size > 0) {
1725
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1726
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1727
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1728
+ if (cellsSelectedIndex) {
1729
+ cellsSelectedIndex.forEach(cell => {
1730
+ cell.classList.remove('selected');
1731
+ });
1732
+ }
1733
+ }
1734
+ };
1735
+ exports.onRemoveBgSelectedCell = onRemoveBgSelectedCell;
1736
+ const onRemoveBorderSelectedCell = (selectedCells, id) => {
1737
+ const table = document.querySelector(`#${id}`);
1738
+
1739
+ // xóa z-index về mặc định
1740
+
1741
+ const row = getLastSelectCell(selectedCells).row;
1742
+ const col = getLastSelectCell(selectedCells).col;
1743
+
1744
+ // const cell: any = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`)
1745
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1746
+ if (cell) {
1747
+ cell.style.zIndex = 0;
1748
+ }
1749
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1750
+ cell.style.zIndex = 2;
1751
+ }
1752
+
1753
+ // remove class border
1754
+
1755
+ removeBorderClass2('cell-border-bottom', id);
1756
+ removeBorderClass2('cell-border-top', id);
1757
+ removeBorderClass2('cell-border-right', id);
1758
+ removeBorderClass2('cell-border-left', id);
1759
+
1760
+ // removeBorderClass(selectedCells, 'right', 'cell-border-right', id)
1761
+ // removeBorderClass(selectedCells, 'top', 'cell-border-top', id)
1762
+ // removeBorderClass(selectedCells, 'left', 'cell-border-left', id)
1763
+ };
1764
+ exports.onRemoveBorderSelectedCell = onRemoveBorderSelectedCell;
1765
+ const addClassBorderPasteCell = (pasteCells, type, id) => {
1766
+ // thêm class border
1767
+
1768
+ addBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1769
+ addBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1770
+ if (type === 'up') {
1771
+ addBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1772
+ }
1773
+ if (type === 'down') {
1774
+ addBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1775
+ }
1776
+ };
1777
+ exports.addClassBorderPasteCell = addClassBorderPasteCell;
1778
+ const removeClassBorderPasteCell = (pasteCells, type, id) => {
1779
+ // remove class border
1780
+
1781
+ removeBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1782
+ removeBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1783
+ removeBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1784
+ removeBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1785
+ };
1786
+ exports.removeClassBorderPasteCell = removeClassBorderPasteCell;
1787
+ const addClassCellIndexSelected = (rowsSelected, id) => {
1788
+ // thêm class selected vào ô STT
1789
+ const table = document.querySelector(`#${id}`);
1790
+ if (rowsSelected && rowsSelected.size > 0) {
1791
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1792
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1793
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1794
+ if (cellsSelectedIndex) {
1795
+ cellsSelectedIndex.forEach(cell => {
1796
+ cell.classList.add('selected');
1797
+ });
1798
+ }
1799
+ }
1800
+ };
1801
+ exports.addClassCellIndexSelected = addClassCellIndexSelected;
1802
+ const removeClassCellIndexSelected = (rowsSelected, id) => {
1803
+ // thêm class selected vào ô STT
1804
+ const table = document.querySelector(`#${id}`);
1805
+ if (rowsSelected && rowsSelected.size > 0) {
1806
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1807
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1808
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1809
+ if (cellsSelectedIndex) {
1810
+ cellsSelectedIndex.forEach(cell => {
1811
+ cell.classList.remove('selected');
1812
+ });
1813
+ }
1814
+ }
1815
+ };
1816
+ exports.removeClassCellIndexSelected = removeClassCellIndexSelected;
1817
+ const showDraggingPoint = (selectedCells, id) => {
1818
+ const row = getLastSelectCell(selectedCells).row;
1819
+ const col = getLastSelectCell(selectedCells).col;
1820
+ const table = document.querySelector(`#${id}`);
1821
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1822
+ const point = cell?.querySelector('.dragging-point');
1823
+ if (point) {
1824
+ point.classList.add('show');
1825
+ point.classList.remove('hidden');
1826
+ }
1827
+ };
1828
+ exports.showDraggingPoint = showDraggingPoint;
1829
+ const hideDraggingPoint = (selectedCells, id) => {
1830
+ const table = document.querySelector(`#${id}`);
1831
+
1832
+ // const point = table?.querySelector('.dragging-point.show')
1833
+ // const points = document.querySelectorAll('.dragging-point.show')
1834
+ const points = table?.querySelectorAll('.dragging-point.show');
1835
+
1836
+ // if (point) {
1837
+ // point.classList.add('hidden')
1838
+ // point.classList.remove('show')
1839
+ // }
1840
+
1841
+ if (points && points.length > 0) {
1842
+ points.forEach(cell => {
1843
+ cell.classList.add('hidden');
1844
+ cell.classList.remove('show');
1845
+ });
1846
+ }
1479
1847
  };
1480
- exports.onRemoveClassSelectedCell = onRemoveClassSelectedCell;
1848
+ exports.hideDraggingPoint = hideDraggingPoint;
@@ -5,13 +5,17 @@ $rowHoverBg: #FBDED6 !default;
5
5
  $rowSelectedBg: #FEF2EF !default;
6
6
  //$tableBorderColor: red !default;
7
7
  $tableBorderColor: #e0e0e0 !default;
8
+ //$tableBorderColor: #C4C4C4 !default;
8
9
  //$tableBorderColor: #f0f0f0 !default;
9
10
  $border-radius: 6px !default;
10
11
  $border-selected-color: #0550C5 !default;
11
12
  $body-color: #ffffff !default;
12
- $cell-selected-bg: #E6EFFD !default;
13
- $cell-index-selected-bg: #0550C5 !default;
14
- $cell-index-focus-bg: #CEDBEF !default;
13
+ //$cell-selected-bg: #E6EFFD !default;
14
+ $cell-selected-bg: #F3F8FF !default;
15
+ //$cell-index-selected-bg: #0550C5 !default;
16
+ $cell-index-selected-bg: #1869E6 !default;
17
+ //$cell-index-focus-bg: #CEDBEF !default;
18
+ $cell-index-focus-bg: #E6EFFD !default;
15
19
  $rowSelectedHoverBg: 'ui-rc' !default;
16
20
  $boxShadowColor: rgba(5, 5, 5, 0.09) !default;
17
21
  $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
@@ -144,6 +148,19 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
144
148
 
145
149
  .#{$prefix}-table-cell {
146
150
  line-height: 22px;
151
+ &:focus-visible {
152
+ outline: none;
153
+ }
154
+
155
+
156
+ &.disable {
157
+ background-color: #f0f0f0;
158
+ }
159
+
160
+ &.selected {
161
+ //background: red;
162
+ background-color: $cell-selected-bg !important;
163
+ }
147
164
 
148
165
  .ui-rc-table-cell-content {
149
166
  line-height: 22px;
@@ -406,7 +423,20 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
406
423
  left: 8px;
407
424
  }
408
425
 
426
+ &.rc-ui-cell-index {
427
+ &.focus {
428
+ background-color: $cell-index-focus-bg;
429
+ font-weight: 500;
430
+ }
431
+ &.selected {
432
+ background-color: $cell-index-selected-bg !important;
433
+ color: #fff;
434
+ //font-weight: 500;
435
+ }
436
+ }
437
+
409
438
  &.cell-editable {
439
+
410
440
  &.cell-border-top {
411
441
  border-bottom: 1px solid $border-selected-color;
412
442
  }
@@ -415,29 +445,31 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
415
445
  border-bottom: 1px solid $border-selected-color;
416
446
  }
417
447
 
418
- &.cell-paste-border-bottom {
419
- border-bottom: 1px dashed #949494;
420
- }
421
-
422
448
  &.cell-border-left {
423
449
  border-inline-end: 1px solid $border-selected-color;
424
450
  }
425
451
 
426
- &.cell-paste-border-left {
427
- border-inline-end: 1px dashed #949494;
452
+ &.cell-border-right {
453
+ border-inline-end: 1px solid $border-selected-color;
428
454
  }
455
+
429
456
  &.cell-paste-border-top {
430
- border-bottom: 1px dashed #949494 !important;
457
+ border-bottom: 1px dashed #949494;
431
458
  }
432
459
 
433
- &.cell-border-right {
434
- border-inline-end: 1px solid $border-selected-color;
460
+ &.cell-paste-border-bottom {
461
+ border-bottom: 1px dashed #949494;
462
+ }
463
+
464
+ &.cell-paste-border-left {
465
+ border-inline-end: 1px dashed #949494;
435
466
  }
436
467
 
437
468
  &.cell-paste-border-right {
438
469
  border-inline-end: 1px dashed #949494;
439
470
  }
440
471
 
472
+
441
473
  &.#{$prefix}-table-cell-fix-left {
442
474
  &:has(.ui-rc_cell-content.selected) {
443
475
  }
@@ -620,18 +652,22 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
620
652
  height: 10px;
621
653
  position: absolute;
622
654
  cursor: crosshair;
623
- right: 0;
624
- bottom: 0;
655
+ right: -1px;
656
+ bottom: -1px;
625
657
  //background: red;
626
658
 
659
+ &.hidden {
660
+ display: none;
661
+ }
662
+
627
663
  .dot-point {
628
664
  position: absolute;
629
665
  width: 8px;
630
666
  height: 8px;
631
667
  border-radius: 6px;
632
668
  background-color: $border-selected-color;
633
- bottom: -4px;
634
- right: -4px;
669
+ bottom: -3px;
670
+ right: -3px;
635
671
  }
636
672
 
637
673
  }
@@ -641,9 +677,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
641
677
  background-color: $cell-selected-bg;
642
678
  }
643
679
 
644
- .ui-rc_cell-content.disable {
645
- background-color: #f0f0f0;
646
- }
680
+ //.ui-rc_cell-content.disable {
681
+ // background-color: #f0f0f0;
682
+ //}
647
683
 
648
684
  .ui-rc_cell-content--index {
649
685
  &.focus {
@@ -663,12 +699,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
663
699
  .#{$prefix}-table-row {
664
700
  &.#{$prefix}-table-row-selected {
665
701
  >.#{$prefix}-table-cell {
666
- background: #FEF2EF;
702
+ //background: #FEF2EF;
667
703
  }
668
704
  }
669
705
  >.#{$prefix}-table-cell {
670
706
  &.#{$prefix}-table-cell-row-hover {
671
- background: #FBDED6;
707
+ //background: #FBDED6;
672
708
  }
673
709
  }
674
710