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
@@ -4,16 +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
+ exports.addRowsUp = addRowsUp;
9
10
  exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
10
11
  exports.compareDate = compareDate;
11
12
  exports.compareDates = compareDates;
12
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;
13
15
  exports.findAllChildrenKeys = findAllChildrenKeys;
14
- 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;
15
20
  exports.getHiddenParentKeys = getHiddenParentKeys;
16
- 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;
17
22
  exports.invalidDate = invalidDate;
18
23
  exports.isArraysEqual = void 0;
19
24
  exports.isBottomMostInRanges = isBottomMostInRanges;
@@ -23,7 +28,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
23
28
  exports.isEqualSet = isEqualSet;
24
29
  exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
25
30
  exports.isRightMostInRegion = isRightMostInRegion;
26
- exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = 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.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveClassSelectedCell = exports.onAddClassBgSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
27
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
28
33
  var _moment = _interopRequireDefault(require("moment/moment"));
29
34
  var _uuid = require("uuid");
@@ -368,7 +373,7 @@ const totalFixedWidth = (columns, type, selectionSettings) => {
368
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
369
374
  return sum + width;
370
375
  }, 0);
371
- 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;
372
377
  return totalFixedLeftWidth + selectColumnWidth;
373
378
  };
374
379
  exports.totalFixedWidth = totalFixedWidth;
@@ -690,6 +695,146 @@ function addRows8(arr, n) {
690
695
  addedRows
691
696
  };
692
697
  }
698
+ function addRowsUp(array, n) {
699
+ const arr = array.reverse();
700
+ if (!Array.isArray(arr) || arr.length === 0) return {
701
+ combined: arr,
702
+ addedRows: []
703
+ };
704
+ const m = arr.length;
705
+ const numCols = arr[0].length;
706
+ const addedRows = [];
707
+
708
+ // Hàm kiểm tra kiểu date hợp lệ
709
+ const isValidDate = item => {
710
+ // console.log('!isNaN(Date.parse(d))', !isNaN(Date.parse(d)))
711
+ // return !isNaN(Date.parse(d))
712
+
713
+ if (typeof item === 'number') {
714
+ // return 'number'
715
+ return false;
716
+ }
717
+ if (typeof item === 'string') {
718
+ // Kiểm tra nếu là chuỗi ISO date hợp lệ
719
+ const date = new Date(item);
720
+ if (!isNaN(date.getTime()) && item.includes('T')) {
721
+ // return 'date'
722
+ return true;
723
+ }
724
+ // return 'string'
725
+ return false;
726
+ }
727
+ return !isNaN(Date.parse(item));
728
+ };
729
+
730
+ // Lấy giá trị mẫu của cột j từ hàng đầu tiên
731
+ const getSample = j => arr[0][j];
732
+
733
+ // Xác định chế độ xử lý cho mỗi cột:
734
+ // mode = 'number-stepping' | 'date-stepping' | 'number-constant' | 'cycle'
735
+ const modes = [];
736
+ const steps = []; // bước tăng, nếu có (cho number hoặc date)
737
+
738
+ for (let j = 0; j < numCols; j++) {
739
+ const sample = getSample(j);
740
+ if (m === 1) {
741
+ // 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.
742
+ if (typeof sample === "number") {
743
+ modes[j] = "number-constant";
744
+ } else if (isValidDate(sample)) {
745
+ modes[j] = "date-stepping";
746
+ steps[j] = 24 * 3600 * 1000; // 1 ngày = 86400000 ms
747
+ } else {
748
+ modes[j] = "cycle";
749
+ }
750
+ } else if (m === 2) {
751
+ // 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
752
+ const first = arr[0][j],
753
+ second = arr[1][j];
754
+ if (typeof first === "number" && typeof second === "number") {
755
+ modes[j] = "number-stepping";
756
+ steps[j] = second - first;
757
+ } else if (isValidDate(first) && isValidDate(second)) {
758
+ modes[j] = "date-stepping";
759
+ steps[j] = Date.parse(second) - Date.parse(first);
760
+ } else {
761
+ modes[j] = "cycle";
762
+ }
763
+ } else {
764
+ // Nếu mảng có >2 hàng
765
+ const first = arr[0][j],
766
+ second = arr[1][j],
767
+ third = arr[2][j];
768
+ if (typeof first === "number" && typeof second === "number" && typeof third === "number") {
769
+ const step1 = second - first;
770
+ const step2 = third - second;
771
+ if (step1 === step2) {
772
+ modes[j] = "number-stepping";
773
+ steps[j] = step1;
774
+ } else {
775
+ modes[j] = "cycle";
776
+ }
777
+ } else if (isValidDate(first) && isValidDate(second) && isValidDate(third)) {
778
+ const step1 = Date.parse(second) - Date.parse(first);
779
+ const step2 = Date.parse(third) - Date.parse(second);
780
+ if (step1 === step2) {
781
+ modes[j] = "date-stepping";
782
+ steps[j] = step1;
783
+ } else {
784
+ modes[j] = "cycle";
785
+ }
786
+ } else {
787
+ modes[j] = "cycle";
788
+ }
789
+ }
790
+ }
791
+
792
+ // Tạo các dòng mới (thêm n dòng)
793
+ // 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
794
+ // Nếu chế độ là cycle thì dùng arr[i mod m][j]
795
+ for (let i = n - 1; i >= 0; i--) {
796
+ const newRow = [];
797
+ for (let j = 0; j < numCols; j++) {
798
+ let newValue;
799
+ switch (modes[j]) {
800
+ case "number-constant":
801
+ // Mảng có 1 hàng, số giữ nguyên
802
+ newValue = arr[0][j];
803
+ break;
804
+ case "number-stepping":
805
+ {
806
+ // Lấy giá trị cuối của cột j trong mảng ban đầu
807
+
808
+ const lastValue = arr[m - 1][j];
809
+ newValue = lastValue - (i + 1) * steps[j] * -1;
810
+ }
811
+ break;
812
+ case "date-stepping":
813
+ {
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
815
+
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;
818
+ newValue = (0, _moment.default)(new Date(newTime)).format();
819
+ }
820
+ break;
821
+ case "cycle":
822
+ default:
823
+ // Lặp lại nội dung theo vòng tròn: dùng hàng thứ (i mod m)
824
+
825
+ newValue = arr[i % m][j];
826
+ break;
827
+ }
828
+ newRow.push(newValue);
829
+ }
830
+ addedRows.push(newRow);
831
+ }
832
+ const combined = arr.concat(addedRows);
833
+ return {
834
+ combined,
835
+ addedRows
836
+ };
837
+ }
693
838
  const transformColumns = (cols, convertColumns, t) => {
694
839
  // @ts-ignore
695
840
  return cols.map(column => {
@@ -722,7 +867,7 @@ const transformColumns1 = (cols, sortMultiple) => {
722
867
  if (!column?.field && !column?.key) {
723
868
  return _rcMasterUi.Table.SELECTION_COLUMN;
724
869
  }
725
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
870
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
726
871
  return {
727
872
  ...column
728
873
  };
@@ -1105,6 +1250,93 @@ const filterDataByColumns3 = (data, queries) => {
1105
1250
  return result;
1106
1251
  });
1107
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
+ }
1108
1340
 
1109
1341
  // ======= Helper functions ========
1110
1342
 
@@ -1112,7 +1344,7 @@ const filterDataByColumns3 = (data, queries) => {
1112
1344
  // function isDate(value: any) {
1113
1345
  // return value instanceof Date || !isNaN(Date.parse(value));
1114
1346
  // }
1115
- exports.filterDataByColumns3 = filterDataByColumns3;
1347
+
1116
1348
  function isDate(value) {
1117
1349
  if (value instanceof Date) {
1118
1350
  return !isNaN(value.getTime());
@@ -1282,4 +1514,301 @@ function isBottomMostInRanges(rowIndex, colIndex, regions) {
1282
1514
  const mergedSets = arr => {
1283
1515
  return new Set(arr.flatMap(set => Array.from(set)));
1284
1516
  };
1285
- exports.mergedSets = mergedSets;
1517
+ exports.mergedSets = mergedSets;
1518
+ const sortedSetASC = setValue => {
1519
+ const sorted = Array.from(setValue).sort((a, b) => {
1520
+ const [a1, a2] = a.split("-").map(Number);
1521
+ const [b1, b2] = b.split("-").map(Number);
1522
+ return a1 - b1 || a2 - b2;
1523
+ });
1524
+ return new Set(sorted);
1525
+ };
1526
+ exports.sortedSetASC = sortedSetASC;
1527
+ const sortedSetDSC = setValue => {
1528
+ const sorted = Array.from(setValue).sort((a, b) => {
1529
+ const [a1, a2] = a.split("-").map(Number);
1530
+ const [b1, b2] = b.split("-").map(Number);
1531
+ return b1 - a1 || b2 - a2;
1532
+ });
1533
+ return new Set(sorted);
1534
+ };
1535
+ exports.sortedSetDSC = sortedSetDSC;
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 onAddClassBgSelectedCell = (selectedCells, id) => {
1634
+ const selectors = Array.from(selectedCells).map(pos => {
1635
+ const [row1, col1] = pos.split('-');
1636
+ return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
1637
+ });
1638
+ const table = document.querySelector(`#${id}`);
1639
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1640
+ if (cells) {
1641
+ cells.forEach(cell => {
1642
+ cell.classList.add('selected');
1643
+ });
1644
+ }
1645
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1646
+ const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1647
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1648
+ if (cellsIndex) {
1649
+ cellsIndex.forEach(cell => {
1650
+ cell.classList.add('focus');
1651
+ });
1652
+ }
1653
+
1654
+ // tăng z-index để hiển thị round point paste
1655
+ const row = getLastSelectCell(selectedCells).row;
1656
+ const col = getLastSelectCell(selectedCells).col;
1657
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1658
+ if (cell) {
1659
+ cell.style.zIndex = 1;
1660
+ }
1661
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1662
+ cell.style.zIndex = 3;
1663
+ }
1664
+
1665
+ // thêm class border selected
1666
+
1667
+ addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1668
+ addBorderClass(selectedCells, 'right', 'cell-border-right', id);
1669
+ addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1670
+ addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1671
+ };
1672
+ exports.onAddClassBgSelectedCell = onAddClassBgSelectedCell;
1673
+ const onRemoveClassSelectedCell = (selectedCells, id, rowsSelected) => {
1674
+ const selectors = Array.from(selectedCells).map(pos => {
1675
+ const [row, col] = pos.split('-');
1676
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1677
+ });
1678
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1679
+ const rowsSelectors = rowsArray.map(row => `.rc-ui-cell-index[data-row-index="${row}"]`).join(", ");
1680
+ const table = document.querySelector(`#${id}`);
1681
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1682
+ // const cells = table?.querySelectorAll(selectors.join(','))
1683
+
1684
+ // const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
1685
+
1686
+ if (cells) {
1687
+ cells.forEach(cell => {
1688
+ cell.classList.remove('selected');
1689
+ });
1690
+ }
1691
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1692
+ if (cellsIndex) {
1693
+ cellsIndex.forEach(cell => {
1694
+ cell.classList.remove('focus');
1695
+ });
1696
+ }
1697
+
1698
+ // xóa class selected ô STT
1699
+
1700
+ if (rowsSelected && rowsSelected.size > 0) {
1701
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1702
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1703
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1704
+ if (cellsSelectedIndex) {
1705
+ cellsSelectedIndex.forEach(cell => {
1706
+ cell.classList.remove('selected');
1707
+ });
1708
+ }
1709
+ }
1710
+
1711
+ // xóa z-index về mặc định
1712
+
1713
+ const row = getLastSelectCell(selectedCells).row;
1714
+ const col = getLastSelectCell(selectedCells).col;
1715
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1716
+ if (cell) {
1717
+ cell.style.zIndex = 0;
1718
+ }
1719
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1720
+ cell.style.zIndex = 2;
1721
+ }
1722
+
1723
+ // remove class border
1724
+
1725
+ removeBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1726
+ removeBorderClass(selectedCells, 'right', 'cell-border-right', id);
1727
+ removeBorderClass(selectedCells, 'top', 'cell-border-top', id);
1728
+ removeBorderClass(selectedCells, 'left', 'cell-border-left', id);
1729
+ };
1730
+ exports.onRemoveClassSelectedCell = onRemoveClassSelectedCell;
1731
+ const addClassBorderPasteCell = (pasteCells, type, id) => {
1732
+ // thêm class border
1733
+
1734
+ addBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1735
+ addBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1736
+ if (type === 'up') {
1737
+ addBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1738
+ }
1739
+ if (type === 'down') {
1740
+ addBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1741
+ }
1742
+ };
1743
+ exports.addClassBorderPasteCell = addClassBorderPasteCell;
1744
+ const removeClassBorderPasteCell = (pasteCells, type, id) => {
1745
+ // remove class border
1746
+
1747
+ removeBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1748
+ removeBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1749
+ removeBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1750
+ removeBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1751
+ };
1752
+ exports.removeClassBorderPasteCell = removeClassBorderPasteCell;
1753
+ const addClassCellIndexSelected = (rowsSelected, id) => {
1754
+ // thêm class selected vào ô STT
1755
+ const table = document.querySelector(`#${id}`);
1756
+ if (rowsSelected && rowsSelected.size > 0) {
1757
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1758
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1759
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1760
+ if (cellsSelectedIndex) {
1761
+ cellsSelectedIndex.forEach(cell => {
1762
+ cell.classList.add('selected');
1763
+ });
1764
+ }
1765
+ }
1766
+ };
1767
+ exports.addClassCellIndexSelected = addClassCellIndexSelected;
1768
+ const removeClassCellIndexSelected = (rowsSelected, id) => {
1769
+ // thêm class selected vào ô STT
1770
+ const table = document.querySelector(`#${id}`);
1771
+ if (rowsSelected && rowsSelected.size > 0) {
1772
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1773
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1774
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1775
+ if (cellsSelectedIndex) {
1776
+ cellsSelectedIndex.forEach(cell => {
1777
+ cell.classList.remove('selected');
1778
+ });
1779
+ }
1780
+ }
1781
+ };
1782
+ exports.removeClassCellIndexSelected = removeClassCellIndexSelected;
1783
+ const showDraggingPoint = (selectedCells, id) => {
1784
+ const row = getLastSelectCell(selectedCells).row;
1785
+ const col = getLastSelectCell(selectedCells).col;
1786
+ const table = document.querySelector(`#${id}`);
1787
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1788
+ const point = cell?.querySelector('.dragging-point');
1789
+ if (point) {
1790
+ point.classList.add('show');
1791
+ point.classList.remove('hidden');
1792
+ }
1793
+ };
1794
+ exports.showDraggingPoint = showDraggingPoint;
1795
+ const hideDraggingPoint = (selectedCells, id) => {
1796
+ const table = document.querySelector(`#${id}`);
1797
+
1798
+ // const point = table?.querySelector('.dragging-point.show')
1799
+ // const points = document.querySelectorAll('.dragging-point.show')
1800
+ const points = table?.querySelectorAll('.dragging-point.show');
1801
+
1802
+ // if (point) {
1803
+ // point.classList.add('hidden')
1804
+ // point.classList.remove('show')
1805
+ // }
1806
+
1807
+ if (points && points.length > 0) {
1808
+ points.forEach(cell => {
1809
+ cell.classList.add('hidden');
1810
+ cell.classList.remove('show');
1811
+ });
1812
+ }
1813
+ };
1814
+ exports.hideDraggingPoint = hideDraggingPoint;
@@ -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;
@@ -10,7 +10,7 @@ var _rcMasterUi = require("rc-master-ui");
10
10
  var _hooks = require("../hooks");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- const Number = props => {
13
+ const NumberInput = props => {
14
14
  const {
15
15
  t,
16
16
  value,
@@ -44,4 +44,4 @@ const Number = props => {
44
44
  autoFocus: true
45
45
  }));
46
46
  };
47
- var _default = exports.default = Number;
47
+ var _default = exports.default = NumberInput;