es-grid-template 1.4.5 → 1.4.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.
@@ -5,7 +5,7 @@ import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertAr
5
5
  // convertDayjsToDate,
6
6
  convertLabelToTitle,
7
7
  // customWeekStartEndFormat,
8
- getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets
8
+ getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets, getFormat
9
9
  // isEditable,
10
10
  // convertDayjsToDate
11
11
  } from "./hooks";
@@ -67,7 +67,8 @@ const EditableCell = props => {
67
67
  const dateTimePickerRef = React.useRef(null);
68
68
  // const timePickerRef = React.useRef(null);
69
69
 
70
- const cellFormat = column?.format ? typeof column?.format === 'function' ? column?.format?.(record) : column?.format : format;
70
+ const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
71
+ const cellFormat = getFormat(colFormat, format);
71
72
  const inputNode = (value, onChange) => {
72
73
  const dateFormat = getDatepickerFormat(editType, cellFormat);
73
74
  const date = !isEmpty(value) ? convertDateToDayjs(new Date(value), dateFormat) : null;
@@ -2,4 +2,4 @@ import styled from "styled-components";
2
2
  export const GridStyle = styled.div.withConfig({
3
3
  displayName: "GridStyle",
4
4
  componentId: "es-grid-template__sc-sueu2e-0"
5
- })(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined);
5
+ })(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{&:has(.ui-rc-table-tbody-virtual-scrollbar-horizontal){padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined);
@@ -234,7 +234,7 @@ const InternalTable = props => {
234
234
  const hhh = (propsHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
235
235
  setHeight(hhh);
236
236
  // })
237
- }, [id, propsHeight, columns]);
237
+ }, [id, propsHeight, columns, editAble]);
238
238
  const tableRef = React.useRef(null);
239
239
  React.useEffect(() => {
240
240
  setColumns(propsColumns);
@@ -847,7 +847,7 @@ const InternalTable = props => {
847
847
  // scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
848
848
  ,
849
849
  scroll: {
850
- y: scrollHeight - (summary ? 0 : 0)
850
+ y: scrollHeight - (summary ? 1 : 1)
851
851
  } // scroll height auto, không quá 600
852
852
  ,
853
853
  height: propsHeight,
@@ -121,8 +121,11 @@ export declare const sortedSetASC: (setValue: any) => Set<unknown>;
121
121
  export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
122
122
  export declare function getBottomRowCells(cellSet: any): any[];
123
123
  export declare function getCellsByPosition(cellSet: any, position?: string): any[];
124
+ export declare function getCellsByPosition2(cellSet: any, position?: string): any[];
124
125
  export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string, nextCellRight?: boolean) => void;
125
126
  export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
127
+ export declare const addBorderPasteClass: (selectedCells: any, type: string, className: string, id?: string, nextCellRight?: boolean) => void;
128
+ export declare const removeBorderPasteClass: (selectedCells: any, type: string, className: string, id?: string) => void;
126
129
  export declare const removeBorderClass2: (className: string, id?: string) => void;
127
130
  export declare const onAddBgSelectedCell: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
128
131
  export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
@@ -1523,6 +1523,61 @@ export function getCellsByPosition(cellSet, position = "bottom") {
1523
1523
  return [];
1524
1524
  }
1525
1525
  }
1526
+ export function getCellsByPosition2(cellSet, position = "bottom") {
1527
+ const cells = Array.from(cellSet).map(key => {
1528
+ const [row, col] = key.split("-").map(Number);
1529
+ return {
1530
+ row,
1531
+ col,
1532
+ key
1533
+ };
1534
+ });
1535
+ switch (position) {
1536
+ case "top":
1537
+ {
1538
+ // const minRow = Math.min(...cells.map(c => c.row));
1539
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1540
+
1541
+ // const rows = cells.map(c => c.row).filter(r => r > 0);
1542
+ // if (rows.length === 0) return [];
1543
+ // const minRow = Math.min(...rows);
1544
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1545
+
1546
+ const minRow = Math.min(...cells.map(c => c.row));
1547
+ if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1548
+
1549
+ return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1550
+ }
1551
+ case "bottom":
1552
+ {
1553
+ const maxRow = Math.max(...cells.map(c => c.row));
1554
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1555
+ }
1556
+ case "left":
1557
+ {
1558
+ // const minCol = Math.min(...cells.map(c => c.col));
1559
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1560
+
1561
+ // const cols = cells.map(c => c.col).filter(c => c > 0);
1562
+ // if (cols.length === 0) return [];
1563
+ // const minCol = Math.min(...cols);
1564
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1565
+
1566
+ const minCol = Math.min(...cells.map(c => c.col));
1567
+ if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1568
+
1569
+ // Trả về các ô cùng row, nhưng ở cột bên trái
1570
+ return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
1571
+ }
1572
+ case "right":
1573
+ {
1574
+ const maxCol = Math.max(...cells.map(c => c.col));
1575
+ return cells.filter(c => c.col === maxCol).map(c => c.key);
1576
+ }
1577
+ default:
1578
+ return [];
1579
+ }
1580
+ }
1526
1581
  export const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
1527
1582
  const table = document.querySelector(`#${id}`);
1528
1583
  const typeCells = getCellsByPosition(selectedCells, type);
@@ -1564,6 +1619,60 @@ export const addBorderClass = (selectedCells, type, className, id, nextCellRight
1564
1619
  // }
1565
1620
  };
1566
1621
  export const removeBorderClass = (selectedCells, type, className, id) => {
1622
+ const table = document.querySelector(`#${id}`);
1623
+ const typeCells = getCellsByPosition2(selectedCells, type);
1624
+ const selectorsCells = typeCells.map(pos => {
1625
+ const [row, col] = pos.split('-');
1626
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1627
+ });
1628
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1629
+ if (cellsFilter && cellsFilter.length > 0) {
1630
+ cellsFilter.forEach(cell => {
1631
+ cell.classList.remove(className);
1632
+ });
1633
+ }
1634
+ };
1635
+ export const addBorderPasteClass = (selectedCells, type, className, id, nextCellRight) => {
1636
+ const table = document.querySelector(`#${id}`);
1637
+ const typeCells = getCellsByPosition2(selectedCells, type);
1638
+ const selectorsCells = typeCells.map(pos => {
1639
+ const [row, col] = pos.split('-');
1640
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1641
+ });
1642
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1643
+ if (cellsFilter && cellsFilter.length > 0) {
1644
+ cellsFilter.forEach(cell => {
1645
+ cell.classList.add(className);
1646
+ if (nextCellRight) {
1647
+ cell.style.zIndex = 1;
1648
+ }
1649
+ });
1650
+ }
1651
+
1652
+ // ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
1653
+
1654
+ // if (type === 'left') {
1655
+ //
1656
+ // const selectorsCells2 = typeCells.map((pos: any) => {
1657
+ // const [row, col] = pos.split('-');
1658
+ // return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
1659
+ // });
1660
+ //
1661
+ // const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
1662
+ //
1663
+ // const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
1664
+ //
1665
+ // if (cellsFilter2 && cellsFilter2.length > 0) {
1666
+ //
1667
+ // cellsFilter2.forEach(cell => {
1668
+ // // cell.classList.add('has-before');
1669
+ // cell.classList.add('cell-border-left');
1670
+ // });
1671
+ // }
1672
+ //
1673
+ // }
1674
+ };
1675
+ export const removeBorderPasteClass = (selectedCells, type, className, id) => {
1567
1676
  const table = document.querySelector(`#${id}`);
1568
1677
  const typeCells = getCellsByPosition(selectedCells, type);
1569
1678
  const selectorsCells = typeCells.map(pos => {
@@ -1750,13 +1859,13 @@ export const onRemoveBorderSelectedCell = (selectedCells, id) => {
1750
1859
  export const addClassBorderPasteCell = (pasteCells, type, id) => {
1751
1860
  // thêm class border
1752
1861
 
1753
- addBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1754
- addBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1862
+ addBorderPasteClass(pasteCells, 'right', 'cell-paste-border-right', id);
1863
+ addBorderPasteClass(pasteCells, 'left', 'cell-paste-border-left', id);
1755
1864
  if (type === 'up') {
1756
- addBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1865
+ addBorderPasteClass(pasteCells, 'top', 'cell-paste-border-top', id);
1757
1866
  }
1758
1867
  if (type === 'down') {
1759
- addBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1868
+ addBorderPasteClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1760
1869
  }
1761
1870
  };
1762
1871
  export const removeClassBorderPasteCell = (pasteCells, type, id) => {
@@ -85,7 +85,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
85
85
 
86
86
  .ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal {
87
87
  visibility: visible !important;
88
- //bottom: -7px !important;
88
+ bottom: -8px !important;
89
89
  z-index: 5 !important;
90
90
  background-color: #f0f0f0;
91
91
  }