es-grid-template 1.3.5 → 1.3.7

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 +33 -13
  2. package/assets/index.scss +49 -14
  3. package/es/grid-component/EditableCell.js +1 -0
  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 +16 -12
  7. package/es/grid-component/hooks/columns/index.js +4 -3
  8. package/es/grid-component/hooks/useColumns.js +7 -5
  9. package/es/grid-component/hooks/utils.d.ts +23 -0
  10. package/es/grid-component/hooks/utils.js +512 -2
  11. package/es/grid-component/number/index.d.ts +2 -2
  12. package/es/grid-component/number/index.js +2 -2
  13. package/es/grid-component/styles.scss +49 -14
  14. package/es/grid-component/table/Grid.js +1 -1
  15. package/es/grid-component/table/GridEdit.js +474 -206
  16. package/es/grid-component/table/Group.js +1 -1
  17. package/lib/grid-component/EditableCell.js +1 -0
  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 +14 -11
  21. package/lib/grid-component/hooks/columns/index.js +2 -1
  22. package/lib/grid-component/hooks/useColumns.js +7 -5
  23. package/lib/grid-component/hooks/utils.d.ts +23 -0
  24. package/lib/grid-component/hooks/utils.js +537 -8
  25. package/lib/grid-component/number/index.d.ts +2 -2
  26. package/lib/grid-component/number/index.js +2 -2
  27. package/lib/grid-component/styles.scss +49 -14
  28. package/lib/grid-component/table/Grid.js +1 -1
  29. package/lib/grid-component/table/GridEdit.js +474 -197
  30. package/lib/grid-component/table/Group.js +1 -1
  31. package/package.json +2 -2
@@ -317,7 +317,7 @@ export const totalFixedWidth = (columns, type, selectionSettings) => {
317
317
  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
318
318
  return sum + width;
319
319
  }, 0);
320
- const selectColumnWidth = !selectionSettings?.mode ? 0.0000001 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
320
+ const selectColumnWidth = !selectionSettings?.mode ? 0 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
321
321
  return totalFixedLeftWidth + selectColumnWidth;
322
322
  };
323
323
  export const isObjEmpty = obj => {
@@ -623,6 +623,146 @@ export function addRows8(arr, n) {
623
623
  addedRows
624
624
  };
625
625
  }
626
+ export function addRowsUp(array, n) {
627
+ const arr = array.reverse();
628
+ if (!Array.isArray(arr) || arr.length === 0) return {
629
+ combined: arr,
630
+ addedRows: []
631
+ };
632
+ const m = arr.length;
633
+ const numCols = arr[0].length;
634
+ const addedRows = [];
635
+
636
+ // Hàm kiểm tra kiểu date hợp lệ
637
+ const isValidDate = item => {
638
+ // console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
639
+ // return !isNaN(Date.parse(d))
640
+
641
+ if (typeof item === 'number') {
642
+ // return 'number'
643
+ return false;
644
+ }
645
+ if (typeof item === 'string') {
646
+ // Kiểm tra nếu là chuỗi ISO date hợp lệ
647
+ const date = new Date(item);
648
+ if (!isNaN(date.getTime()) && item.includes('T')) {
649
+ // return 'date'
650
+ return true;
651
+ }
652
+ // return 'string'
653
+ return false;
654
+ }
655
+ return !isNaN(Date.parse(item));
656
+ };
657
+
658
+ // Lấy giá trị mẫu của cột j từ hàng đầu tiên
659
+ const getSample = j => arr[0][j];
660
+
661
+ // Xác định chế độ xử lý cho mỗi cột:
662
+ // mode = 'number-stepping' | 'date-stepping' | 'number-constant' | 'cycle'
663
+ const modes = [];
664
+ const steps = []; // bước tăng, nếu có (cho number hoặc date)
665
+
666
+ for (let j = 0; j < numCols; j++) {
667
+ const sample = getSample(j);
668
+ if (m === 1) {
669
+ // Nếu mảng chỉ có 1 hàng: nếu là số thì giữ nguyên; nếu là date thì tăng 1 ngày; còn lại giữ nguyên.
670
+ if (typeof sample === "number") {
671
+ modes[j] = "number-constant";
672
+ } else if (isValidDate(sample)) {
673
+ modes[j] = "date-stepping";
674
+ steps[j] = 24 * 3600 * 1000; // 1 ngày = 86400000 ms
675
+ } else {
676
+ modes[j] = "cycle";
677
+ }
678
+ } else if (m === 2) {
679
+ // Nếu mảng có 2 hàng: nếu là số thì tính bước = row2 - row1, tương tự với date
680
+ const first = arr[0][j],
681
+ second = arr[1][j];
682
+ if (typeof first === "number" && typeof second === "number") {
683
+ modes[j] = "number-stepping";
684
+ steps[j] = second - first;
685
+ } else if (isValidDate(first) && isValidDate(second)) {
686
+ modes[j] = "date-stepping";
687
+ steps[j] = Date.parse(second) - Date.parse(first);
688
+ } else {
689
+ modes[j] = "cycle";
690
+ }
691
+ } else {
692
+ // Nếu mảng có >2 hàng
693
+ const first = arr[0][j],
694
+ second = arr[1][j],
695
+ third = arr[2][j];
696
+ if (typeof first === "number" && typeof second === "number" && typeof third === "number") {
697
+ const step1 = second - first;
698
+ const step2 = third - second;
699
+ if (step1 === step2) {
700
+ modes[j] = "number-stepping";
701
+ steps[j] = step1;
702
+ } else {
703
+ modes[j] = "cycle";
704
+ }
705
+ } else if (isValidDate(first) && isValidDate(second) && isValidDate(third)) {
706
+ const step1 = Date.parse(second) - Date.parse(first);
707
+ const step2 = Date.parse(third) - Date.parse(second);
708
+ if (step1 === step2) {
709
+ modes[j] = "date-stepping";
710
+ steps[j] = step1;
711
+ } else {
712
+ modes[j] = "cycle";
713
+ }
714
+ } else {
715
+ modes[j] = "cycle";
716
+ }
717
+ }
718
+ }
719
+
720
+ // Tạo các dòng mới (thêm n dòng)
721
+ // Với mỗi cột, nếu chế độ là stepping thì lấy giá trị cuối của mảng ban đầu và cộng thêm (i+1)*step
722
+ // Nếu chế độ là cycle thì dùng arr[i mod m][j]
723
+ for (let i = n - 1; i >= 0; i--) {
724
+ const newRow = [];
725
+ for (let j = 0; j < numCols; j++) {
726
+ let newValue;
727
+ switch (modes[j]) {
728
+ case "number-constant":
729
+ // Mảng có 1 hàng, số giữ nguyên
730
+ newValue = arr[0][j];
731
+ break;
732
+ case "number-stepping":
733
+ {
734
+ // Lấy giá trị cuối của cột j trong mảng ban đầu
735
+
736
+ const lastValue = arr[m - 1][j];
737
+ newValue = lastValue - (i + 1) * steps[j] * -1;
738
+ }
739
+ break;
740
+ case "date-stepping":
741
+ {
742
+ // 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
743
+
744
+ const lastDate = new Date(arr[m - 1][j]);
745
+ const newTime = m === 1 ? lastDate.getTime() - (i + 1) * steps[j] : lastDate.getTime() - (i + 1) * steps[j] * -1;
746
+ newValue = moment(new Date(newTime)).format();
747
+ }
748
+ break;
749
+ case "cycle":
750
+ default:
751
+ // Lặp lại nội dung theo vòng tròn: dùng hàng thứ (i mod m)
752
+
753
+ newValue = arr[i % m][j];
754
+ break;
755
+ }
756
+ newRow.push(newValue);
757
+ }
758
+ addedRows.push(newRow);
759
+ }
760
+ const combined = arr.concat(addedRows);
761
+ return {
762
+ combined,
763
+ addedRows
764
+ };
765
+ }
626
766
  export const transformColumns = (cols, convertColumns, t) => {
627
767
  // @ts-ignore
628
768
  return cols.map(column => {
@@ -654,7 +794,7 @@ export const transformColumns1 = (cols, sortMultiple) => {
654
794
  if (!column?.field && !column?.key) {
655
795
  return Table.SELECTION_COLUMN;
656
796
  }
657
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
797
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
658
798
  return {
659
799
  ...column
660
800
  };
@@ -1025,6 +1165,91 @@ export const filterDataByColumns3 = (data, queries) => {
1025
1165
  return result;
1026
1166
  });
1027
1167
  };
1168
+ export const shouldInclude = (item, queries) => {
1169
+ if (item.isFilterState === true) {
1170
+ return true;
1171
+ }
1172
+ let result = null;
1173
+ for (const query of queries) {
1174
+ const {
1175
+ field,
1176
+ value,
1177
+ operator,
1178
+ predicate
1179
+ } = query;
1180
+ const itemValue = item[field];
1181
+ let condition = false;
1182
+ const isDateComparison = isDate(itemValue) || isDateString(value);
1183
+ const itemDate = isDateComparison ? new Date(itemValue) : null;
1184
+ const queryDate = isDateComparison ? parseToDate(value) : null;
1185
+ const itemStr = itemValue?.toString().toLowerCase?.();
1186
+ const queryStr = value?.toString().toLowerCase?.();
1187
+ switch (operator.toLowerCase()) {
1188
+ case "equal":
1189
+ condition = isDateComparison ? compareDates(itemDate, queryDate) : itemValue === value;
1190
+ break;
1191
+ case "notequal":
1192
+ condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
1193
+ break;
1194
+ case "greaterthan":
1195
+ // @ts-ignore
1196
+ condition = isDateComparison ? itemDate > queryDate : itemValue > value;
1197
+
1198
+ // condition = isDateComparison ? invalidDate(itemDate) && invalidDate(queryDate) && itemDate > queryDate : itemValue > value;
1199
+ break;
1200
+ case "greaterthanorequal":
1201
+ // @ts-ignore
1202
+ condition = isDateComparison ? itemDate >= queryDate : itemValue >= value;
1203
+ break;
1204
+ case "lessthan":
1205
+ // @ts-ignore
1206
+ condition = isDateComparison ? itemDate < queryDate : itemValue < value;
1207
+ break;
1208
+ case "lessthanorequal":
1209
+ // @ts-ignore
1210
+ condition = isDateComparison ? itemDate <= queryDate : itemValue <= value;
1211
+ break;
1212
+ case "contains":
1213
+ condition = itemStr?.includes(queryStr);
1214
+ break;
1215
+ case "startswith":
1216
+ condition = itemStr?.startsWith(queryStr);
1217
+ break;
1218
+ case "endswith":
1219
+ condition = itemStr?.endsWith(queryStr);
1220
+ break;
1221
+ default:
1222
+ console.warn(`Unknown operator: ${operator}`);
1223
+ break;
1224
+ }
1225
+ if (predicate === "and") {
1226
+ result = result === null ? condition : result && condition;
1227
+ } else if (predicate === "or") {
1228
+ result = result === null ? condition : result || condition;
1229
+ }
1230
+ }
1231
+ return result;
1232
+ };
1233
+ export function filterDataByColumns4(data, queries) {
1234
+ if (!queries || queries.length === 0) {
1235
+ return data;
1236
+ }
1237
+ return data.map(item => {
1238
+ const newItem = {
1239
+ ...item
1240
+ };
1241
+ if (Array.isArray(item.children)) {
1242
+ newItem.children = filterDataByColumns4(item.children, queries);
1243
+ }
1244
+ const isSelfMatched = shouldInclude(item, queries);
1245
+
1246
+ // Nếu chính item thỏa hoặc có con thỏa → giữ lại
1247
+ if (isSelfMatched || newItem.children && newItem.children.length > 0) {
1248
+ return newItem;
1249
+ }
1250
+ return null; // loại bỏ node không phù hợp
1251
+ }).filter(Boolean); // xóa các null
1252
+ }
1028
1253
 
1029
1254
  // ======= Helper functions ========
1030
1255
 
@@ -1196,4 +1421,289 @@ export function isBottomMostInRanges(rowIndex, colIndex, regions) {
1196
1421
  }
1197
1422
  export const mergedSets = arr => {
1198
1423
  return new Set(arr.flatMap(set => Array.from(set)));
1424
+ };
1425
+ export const sortedSetASC = setValue => {
1426
+ const sorted = Array.from(setValue).sort((a, b) => {
1427
+ const [a1, a2] = a.split("-").map(Number);
1428
+ const [b1, b2] = b.split("-").map(Number);
1429
+ return a1 - b1 || a2 - b2;
1430
+ });
1431
+ return new Set(sorted);
1432
+ };
1433
+ export const sortedSetDSC = setValue => {
1434
+ const sorted = Array.from(setValue).sort((a, b) => {
1435
+ const [a1, a2] = a.split("-").map(Number);
1436
+ const [b1, b2] = b.split("-").map(Number);
1437
+ return b1 - a1 || b2 - a2;
1438
+ });
1439
+ return new Set(sorted);
1440
+ };
1441
+ export function getBottomRowCells(cellSet) {
1442
+ const cells = Array.from(cellSet).map(key => {
1443
+ const [row, col] = key.split('-').map(Number);
1444
+ return {
1445
+ row,
1446
+ col,
1447
+ key
1448
+ };
1449
+ });
1450
+ const maxRow = Math.max(...cells.map(c => c.row));
1451
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1452
+ }
1453
+ export function getCellsByPosition(cellSet, position = "bottom") {
1454
+ const cells = Array.from(cellSet).map(key => {
1455
+ const [row, col] = key.split("-").map(Number);
1456
+ return {
1457
+ row,
1458
+ col,
1459
+ key
1460
+ };
1461
+ });
1462
+ switch (position) {
1463
+ case "top":
1464
+ {
1465
+ // const minRow = Math.min(...cells.map(c => c.row));
1466
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1467
+
1468
+ // const rows = cells.map(c => c.row).filter(r => r > 0);
1469
+ // if (rows.length === 0) return [];
1470
+ // const minRow = Math.min(...rows);
1471
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1472
+
1473
+ const minRow = Math.min(...cells.map(c => c.row));
1474
+ if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1475
+
1476
+ return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1477
+ }
1478
+ case "bottom":
1479
+ {
1480
+ const maxRow = Math.max(...cells.map(c => c.row));
1481
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1482
+ }
1483
+ case "left":
1484
+ {
1485
+ // const minCol = Math.min(...cells.map(c => c.col));
1486
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1487
+
1488
+ // const cols = cells.map(c => c.col).filter(c => c > 0);
1489
+ // if (cols.length === 0) return [];
1490
+ // const minCol = Math.min(...cols);
1491
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1492
+
1493
+ const minCol = Math.min(...cells.map(c => c.col));
1494
+ if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1495
+
1496
+ // Trả về các ô cùng row, nhưng ở cột bên trái
1497
+ return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
1498
+ }
1499
+ case "right":
1500
+ {
1501
+ const maxCol = Math.max(...cells.map(c => c.col));
1502
+ return cells.filter(c => c.col === maxCol).map(c => c.key);
1503
+ }
1504
+ default:
1505
+ return [];
1506
+ }
1507
+ }
1508
+ export const addBorderClass = (selectedCells, type, className, id) => {
1509
+ const table = document.querySelector(`#${id}`);
1510
+ const typeCells = getCellsByPosition(selectedCells, type);
1511
+ const selectorsCells = typeCells.map(pos => {
1512
+ const [row, col] = pos.split('-');
1513
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1514
+ });
1515
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1516
+ if (cellsFilter && cellsFilter.length > 0) {
1517
+ cellsFilter.forEach(cell => {
1518
+ cell.classList.add(className);
1519
+ });
1520
+ }
1521
+ };
1522
+ export const removeBorderClass = (selectedCells, type, className, id) => {
1523
+ const table = document.querySelector(`#${id}`);
1524
+ const typeCells = getCellsByPosition(selectedCells, type);
1525
+ const selectorsCells = typeCells.map(pos => {
1526
+ const [row, col] = pos.split('-');
1527
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1528
+ });
1529
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1530
+ if (cellsFilter && cellsFilter.length > 0) {
1531
+ cellsFilter.forEach(cell => {
1532
+ cell.classList.remove(className);
1533
+ });
1534
+ }
1535
+ };
1536
+ export const onAddClassBgSelectedCell = (selectedCells, id) => {
1537
+ const selectors = Array.from(selectedCells).map(pos => {
1538
+ const [row1, col1] = pos.split('-');
1539
+ return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
1540
+ });
1541
+ const table = document.querySelector(`#${id}`);
1542
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1543
+ if (cells) {
1544
+ cells.forEach(cell => {
1545
+ cell.classList.add('selected');
1546
+ });
1547
+ }
1548
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1549
+ const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1550
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1551
+ if (cellsIndex) {
1552
+ cellsIndex.forEach(cell => {
1553
+ cell.classList.add('focus');
1554
+ });
1555
+ }
1556
+
1557
+ // tăng z-index để hiển thị round point paste
1558
+ const row = getLastSelectCell(selectedCells).row;
1559
+ const col = getLastSelectCell(selectedCells).col;
1560
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1561
+ if (cell) {
1562
+ cell.style.zIndex = 1;
1563
+ }
1564
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1565
+ cell.style.zIndex = 3;
1566
+ }
1567
+
1568
+ // thêm class border selected
1569
+
1570
+ addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1571
+ addBorderClass(selectedCells, 'right', 'cell-border-right', id);
1572
+ addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1573
+ addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1574
+ };
1575
+ export const onRemoveClassSelectedCell = (selectedCells, id, rowsSelected) => {
1576
+ const selectors = Array.from(selectedCells).map(pos => {
1577
+ const [row, col] = pos.split('-');
1578
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1579
+ });
1580
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1581
+ const rowsSelectors = rowsArray.map(row => `.rc-ui-cell-index[data-row-index="${row}"]`).join(", ");
1582
+ const table = document.querySelector(`#${id}`);
1583
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1584
+ // const cells = table?.querySelectorAll(selectors.join(','))
1585
+
1586
+ // const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
1587
+
1588
+ if (cells) {
1589
+ cells.forEach(cell => {
1590
+ cell.classList.remove('selected');
1591
+ });
1592
+ }
1593
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1594
+ if (cellsIndex) {
1595
+ cellsIndex.forEach(cell => {
1596
+ cell.classList.remove('focus');
1597
+ });
1598
+ }
1599
+
1600
+ // xóa class selected ô STT
1601
+
1602
+ if (rowsSelected && rowsSelected.size > 0) {
1603
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1604
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1605
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1606
+ if (cellsSelectedIndex) {
1607
+ cellsSelectedIndex.forEach(cell => {
1608
+ cell.classList.remove('selected');
1609
+ });
1610
+ }
1611
+ }
1612
+
1613
+ // xóa z-index về mặc định
1614
+
1615
+ const row = getLastSelectCell(selectedCells).row;
1616
+ const col = getLastSelectCell(selectedCells).col;
1617
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1618
+ if (cell) {
1619
+ cell.style.zIndex = 0;
1620
+ }
1621
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1622
+ cell.style.zIndex = 2;
1623
+ }
1624
+
1625
+ // remove class border
1626
+
1627
+ removeBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1628
+ removeBorderClass(selectedCells, 'right', 'cell-border-right', id);
1629
+ removeBorderClass(selectedCells, 'top', 'cell-border-top', id);
1630
+ removeBorderClass(selectedCells, 'left', 'cell-border-left', id);
1631
+ };
1632
+ export const addClassBorderPasteCell = (pasteCells, type, id) => {
1633
+ // thêm class border
1634
+
1635
+ addBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1636
+ addBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1637
+ if (type === 'up') {
1638
+ addBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1639
+ }
1640
+ if (type === 'down') {
1641
+ addBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1642
+ }
1643
+ };
1644
+ export const removeClassBorderPasteCell = (pasteCells, type, id) => {
1645
+ // remove class border
1646
+
1647
+ removeBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1648
+ removeBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1649
+ removeBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1650
+ removeBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1651
+ };
1652
+ export const addClassCellIndexSelected = (rowsSelected, id) => {
1653
+ // thêm class selected vào ô STT
1654
+ const table = document.querySelector(`#${id}`);
1655
+ if (rowsSelected && rowsSelected.size > 0) {
1656
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1657
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1658
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1659
+ if (cellsSelectedIndex) {
1660
+ cellsSelectedIndex.forEach(cell => {
1661
+ cell.classList.add('selected');
1662
+ });
1663
+ }
1664
+ }
1665
+ };
1666
+ export const removeClassCellIndexSelected = (rowsSelected, id) => {
1667
+ // thêm class selected vào ô STT
1668
+ const table = document.querySelector(`#${id}`);
1669
+ if (rowsSelected && rowsSelected.size > 0) {
1670
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1671
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1672
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1673
+ if (cellsSelectedIndex) {
1674
+ cellsSelectedIndex.forEach(cell => {
1675
+ cell.classList.remove('selected');
1676
+ });
1677
+ }
1678
+ }
1679
+ };
1680
+ export const showDraggingPoint = (selectedCells, id) => {
1681
+ const row = getLastSelectCell(selectedCells).row;
1682
+ const col = getLastSelectCell(selectedCells).col;
1683
+ const table = document.querySelector(`#${id}`);
1684
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1685
+ const point = cell?.querySelector('.dragging-point');
1686
+ if (point) {
1687
+ point.classList.add('show');
1688
+ point.classList.remove('hidden');
1689
+ }
1690
+ };
1691
+ export const hideDraggingPoint = (selectedCells, id) => {
1692
+ const table = document.querySelector(`#${id}`);
1693
+
1694
+ // const point = table?.querySelector('.dragging-point.show')
1695
+ // const points = document.querySelectorAll('.dragging-point.show')
1696
+ const points = table?.querySelectorAll('.dragging-point.show');
1697
+
1698
+ // if (point) {
1699
+ // point.classList.add('hidden')
1700
+ // point.classList.remove('show')
1701
+ // }
1702
+
1703
+ if (points && points.length > 0) {
1704
+ points.forEach(cell => {
1705
+ cell.classList.add('hidden');
1706
+ cell.classList.remove('show');
1707
+ });
1708
+ }
1199
1709
  };
@@ -6,5 +6,5 @@ type Props = {
6
6
  value: number | string | undefined;
7
7
  onChange?: (values: any[]) => void;
8
8
  };
9
- declare const Number: (props: Props) => React.JSX.Element;
10
- export default Number;
9
+ declare const NumberInput: (props: Props) => React.JSX.Element;
10
+ export default NumberInput;
@@ -2,7 +2,7 @@ import React, { Fragment } from "react";
2
2
  import { NumericFormat } from "react-numeric-component";
3
3
  import { Input } from "rc-master-ui";
4
4
  import { checkDecimalSeparator, checkThousandSeparator } from "../hooks";
5
- const Number = props => {
5
+ const NumberInput = props => {
6
6
  const {
7
7
  t,
8
8
  value,
@@ -36,4 +36,4 @@ const Number = props => {
36
36
  autoFocus: true
37
37
  }));
38
38
  };
39
- export default Number;
39
+ export default NumberInput;
@@ -144,6 +144,19 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
144
144
 
145
145
  .#{$prefix}-table-cell {
146
146
  line-height: 22px;
147
+ &:focus-visible {
148
+ outline: none;
149
+ }
150
+
151
+
152
+ &.disable {
153
+ background-color: #f0f0f0;
154
+ }
155
+
156
+ &.selected {
157
+ //background: red;
158
+ background-color: $cell-selected-bg;
159
+ }
147
160
 
148
161
  .ui-rc-table-cell-content {
149
162
  line-height: 22px;
@@ -406,7 +419,20 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
406
419
  left: 8px;
407
420
  }
408
421
 
422
+ &.rc-ui-cell-index {
423
+ &.focus {
424
+ background-color: $cell-index-focus-bg;
425
+ font-weight: 500;
426
+ }
427
+ &.selected {
428
+ background-color: $cell-index-selected-bg;
429
+ color: #fff;
430
+ //font-weight: 500;
431
+ }
432
+ }
433
+
409
434
  &.cell-editable {
435
+
410
436
  &.cell-border-top {
411
437
  border-bottom: 1px solid $border-selected-color;
412
438
  }
@@ -415,26 +441,31 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
415
441
  border-bottom: 1px solid $border-selected-color;
416
442
  }
417
443
 
418
- &.cell-paste-border-bottom {
419
- border-bottom: 1px dashed #949494;
444
+ &.cell-border-left {
445
+ border-inline-end: 1px solid $border-selected-color;
420
446
  }
421
447
 
422
- &.cell-border-left {
448
+ &.cell-border-right {
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-paste-border-top {
453
+ border-bottom: 1px dashed #949494;
428
454
  }
429
455
 
430
- &.cell-border-right {
431
- border-inline-end: 1px solid $border-selected-color;
456
+ &.cell-paste-border-bottom {
457
+ border-bottom: 1px dashed #949494;
458
+ }
459
+
460
+ &.cell-paste-border-left {
461
+ border-inline-end: 1px dashed #949494;
432
462
  }
433
463
 
434
464
  &.cell-paste-border-right {
435
465
  border-inline-end: 1px dashed #949494;
436
466
  }
437
467
 
468
+
438
469
  &.#{$prefix}-table-cell-fix-left {
439
470
  &:has(.ui-rc_cell-content.selected) {
440
471
  }
@@ -617,18 +648,22 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
617
648
  height: 10px;
618
649
  position: absolute;
619
650
  cursor: crosshair;
620
- right: 0;
621
- bottom: 0;
651
+ right: -1px;
652
+ bottom: -1px;
622
653
  //background: red;
623
654
 
655
+ &.hidden {
656
+ display: none;
657
+ }
658
+
624
659
  .dot-point {
625
660
  position: absolute;
626
661
  width: 8px;
627
662
  height: 8px;
628
663
  border-radius: 6px;
629
664
  background-color: $border-selected-color;
630
- bottom: -4px;
631
- right: -4px;
665
+ bottom: -3px;
666
+ right: -3px;
632
667
  }
633
668
 
634
669
  }
@@ -638,9 +673,9 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
638
673
  background-color: $cell-selected-bg;
639
674
  }
640
675
 
641
- .ui-rc_cell-content.disable {
642
- background-color: #f0f0f0;
643
- }
676
+ //.ui-rc_cell-content.disable {
677
+ // background-color: #f0f0f0;
678
+ //}
644
679
 
645
680
  .ui-rc_cell-content--index {
646
681
  &.focus {
@@ -14,7 +14,7 @@ const Grid = props => {
14
14
  ...rest
15
15
  } = props;
16
16
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
17
- heightTable: height,
17
+ $heightTable: height,
18
18
  style: {
19
19
  position: 'relative'
20
20
  }