es-grid-template 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/GridStyle.d.ts +2 -1
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +88 -16
- package/es/grid-component/hooks/utils.js +27 -20
- package/es/grid-component/styles.scss +1333 -1243
- package/es/grid-component/table/Grid.d.ts +1 -0
- package/es/grid-component/table/Grid.js +7 -1
- package/es/grid-component/table/GridEdit.d.ts +1 -0
- package/es/grid-component/table/GridEdit.js +460 -305
- package/es/grid-component/table/Group.d.ts +1 -0
- package/es/grid-component/table/Group.js +6 -1
- package/lib/grid-component/GridStyle.d.ts +2 -1
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +88 -16
- package/lib/grid-component/hooks/utils.js +27 -20
- package/lib/grid-component/styles.scss +1333 -1243
- package/lib/grid-component/table/Grid.d.ts +1 -0
- package/lib/grid-component/table/Grid.js +7 -1
- package/lib/grid-component/table/GridEdit.d.ts +1 -0
- package/lib/grid-component/table/GridEdit.js +461 -305
- package/lib/grid-component/table/Group.d.ts +1 -0
- package/lib/grid-component/table/Group.js +6 -1
- package/package.json +110 -110
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface GridProps {
|
|
3
|
-
$heightTable?: number
|
|
3
|
+
$heightTable?: number;
|
|
4
|
+
$heightScroll?: number;
|
|
4
5
|
}
|
|
5
6
|
export declare const GridStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, GridProps>> & string;
|
|
6
7
|
export {};
|
|
@@ -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
|
-
})([".ui-rc-table-container{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 ?
|
|
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);
|
|
@@ -30,6 +30,7 @@ import { closestCenter, DndContext, DragOverlay, PointerSensor, useSensor, useSe
|
|
|
30
30
|
import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
|
|
31
31
|
// import {CSS} from "@dnd-kit/utilities";
|
|
32
32
|
import { Resizable } from "react-resizable";
|
|
33
|
+
import { faker } from "@faker-js/faker";
|
|
33
34
|
dayjs.extend(customParseFormat);
|
|
34
35
|
const MySwal = withReactContent(Swal);
|
|
35
36
|
const ASCEND = 'ascend';
|
|
@@ -142,6 +143,7 @@ const SortableHeaderCell = ({
|
|
|
142
143
|
const InternalTable = props => {
|
|
143
144
|
const {
|
|
144
145
|
t,
|
|
146
|
+
id: tableId,
|
|
145
147
|
// columns,
|
|
146
148
|
columns: propsColumns,
|
|
147
149
|
lang,
|
|
@@ -168,11 +170,37 @@ const InternalTable = props => {
|
|
|
168
170
|
commandClick,
|
|
169
171
|
commandSettings,
|
|
170
172
|
pagination,
|
|
173
|
+
height: propsHeight,
|
|
174
|
+
summary,
|
|
171
175
|
...rest
|
|
172
176
|
} = props;
|
|
177
|
+
const id = React.useMemo(() => {
|
|
178
|
+
return tableId ?? faker.string.alpha(20);
|
|
179
|
+
// return tableId ?? newGuid()
|
|
180
|
+
}, [tableId]);
|
|
173
181
|
const rowKey = React.useMemo(() => {
|
|
174
|
-
return
|
|
175
|
-
}, [propRowKey
|
|
182
|
+
return propRowKey ?? 'rowId';
|
|
183
|
+
}, [propRowKey]);
|
|
184
|
+
const [scrollHeight, setHeight] = useState(0);
|
|
185
|
+
|
|
186
|
+
// const heightt = React.useMemo(() => {
|
|
187
|
+
//
|
|
188
|
+
// const table = document.querySelector(`#${id}`)
|
|
189
|
+
// console.log('table', table)
|
|
190
|
+
//
|
|
191
|
+
// const title: any = table?.querySelector(`.ui-rc-table-title`)
|
|
192
|
+
//
|
|
193
|
+
// console.log('title', title)
|
|
194
|
+
//
|
|
195
|
+
// if (title) {
|
|
196
|
+
// const titleHeight = title.offsetHeight;
|
|
197
|
+
// console.log('Chiều cao:', titleHeight);
|
|
198
|
+
// }
|
|
199
|
+
//
|
|
200
|
+
// return (height ?? 0) - (title ? title.offsetHeight : 0)
|
|
201
|
+
//
|
|
202
|
+
// }, [height, id])
|
|
203
|
+
|
|
176
204
|
const local = lang && lang === 'en' ? en : vi;
|
|
177
205
|
const buddhistLocale = {
|
|
178
206
|
...local,
|
|
@@ -194,6 +222,19 @@ const InternalTable = props => {
|
|
|
194
222
|
return addRowIdArray(dataSource);
|
|
195
223
|
}, [dataSource]);
|
|
196
224
|
const [columns, setColumns] = React.useState([]);
|
|
225
|
+
React.useEffect(() => {
|
|
226
|
+
// setTimeout(() => {
|
|
227
|
+
const table = document.querySelector(`#${id}`);
|
|
228
|
+
const title = table?.querySelector(`.ui-rc-table-title`);
|
|
229
|
+
const header = table?.querySelector(`.ui-rc-table-header`);
|
|
230
|
+
const paginationE = table?.querySelector(`.ui-rc-pagination`);
|
|
231
|
+
const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
|
|
232
|
+
const summaryE = table?.querySelector(`.ui-rc-table-summary`);
|
|
233
|
+
const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
|
|
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
|
+
setHeight(hhh);
|
|
236
|
+
// })
|
|
237
|
+
}, [id, propsHeight, columns]);
|
|
197
238
|
const tableRef = React.useRef(null);
|
|
198
239
|
React.useEffect(() => {
|
|
199
240
|
setColumns(propsColumns);
|
|
@@ -483,26 +524,46 @@ const InternalTable = props => {
|
|
|
483
524
|
if (column === SELECTION_COLUMN) {
|
|
484
525
|
return SELECTION_COLUMN;
|
|
485
526
|
}
|
|
486
|
-
|
|
527
|
+
const tmpColumn = {
|
|
528
|
+
...column,
|
|
529
|
+
dataIndex: column.field ?? column.dataIndex,
|
|
530
|
+
key: column.field ?? column.key,
|
|
531
|
+
title: /*#__PURE__*/React.createElement(SortableHeaderCell, {
|
|
532
|
+
columnKey: column.field
|
|
533
|
+
}, /*#__PURE__*/React.createElement(HeaderContent, {
|
|
534
|
+
column: {
|
|
535
|
+
...column
|
|
536
|
+
},
|
|
537
|
+
t: t
|
|
538
|
+
})),
|
|
539
|
+
ellipsis: column.ellipsis !== false,
|
|
540
|
+
align: column.textAlign ?? column.align,
|
|
541
|
+
fixed: column.fixedType ?? column.fixed,
|
|
542
|
+
isSummary: column.isSummary ?? column.haveSum,
|
|
543
|
+
hidden: column.hidden ?? column.visible === false
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
// Xử lý đệ quy cho children
|
|
547
|
+
if (column.children?.length) {
|
|
487
548
|
return {
|
|
488
|
-
...
|
|
549
|
+
...column,
|
|
550
|
+
...tmpColumn,
|
|
551
|
+
children: transformColumns(column.children)
|
|
489
552
|
};
|
|
490
553
|
}
|
|
491
|
-
if (
|
|
554
|
+
if (find) {
|
|
492
555
|
return {
|
|
493
|
-
...
|
|
556
|
+
...find
|
|
494
557
|
};
|
|
495
558
|
}
|
|
496
|
-
|
|
497
|
-
// Xử lý đệ quy cho children
|
|
498
|
-
if (column.children?.length) {
|
|
559
|
+
if (!find) {
|
|
499
560
|
return {
|
|
500
561
|
...column,
|
|
501
|
-
|
|
562
|
+
...tmpColumn
|
|
502
563
|
};
|
|
503
564
|
}
|
|
504
565
|
});
|
|
505
|
-
}, [convertColumns]);
|
|
566
|
+
}, [convertColumns, t]);
|
|
506
567
|
const mergedColumns = React.useMemo(() => {
|
|
507
568
|
return transformColumns(columns);
|
|
508
569
|
}, [columns, transformColumns]);
|
|
@@ -596,13 +657,13 @@ const InternalTable = props => {
|
|
|
596
657
|
};
|
|
597
658
|
const triggerCommandClick = args => {
|
|
598
659
|
const {
|
|
599
|
-
id,
|
|
660
|
+
id: idCommand,
|
|
600
661
|
rowId,
|
|
601
662
|
rowData,
|
|
602
663
|
index
|
|
603
664
|
} = args;
|
|
604
665
|
const tmpData = [...mergedData];
|
|
605
|
-
if (
|
|
666
|
+
if (idCommand === 'DELETE') {
|
|
606
667
|
// bật modal confirm
|
|
607
668
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
608
669
|
MySwal.fire({
|
|
@@ -688,7 +749,7 @@ const InternalTable = props => {
|
|
|
688
749
|
}
|
|
689
750
|
if (commandClick) {
|
|
690
751
|
commandClick({
|
|
691
|
-
id,
|
|
752
|
+
id: idCommand,
|
|
692
753
|
rowId,
|
|
693
754
|
rowData,
|
|
694
755
|
index,
|
|
@@ -699,7 +760,7 @@ const InternalTable = props => {
|
|
|
699
760
|
// server
|
|
700
761
|
if (commandClick) {
|
|
701
762
|
commandClick({
|
|
702
|
-
id,
|
|
763
|
+
id: idCommand,
|
|
703
764
|
rowId,
|
|
704
765
|
rowData,
|
|
705
766
|
index,
|
|
@@ -760,6 +821,7 @@ const InternalTable = props => {
|
|
|
760
821
|
value: dragIndex
|
|
761
822
|
}, /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
762
823
|
t: t,
|
|
824
|
+
id: id,
|
|
763
825
|
locale: locale,
|
|
764
826
|
tableRef: tableRef,
|
|
765
827
|
dataSource: mergedData,
|
|
@@ -779,7 +841,17 @@ const InternalTable = props => {
|
|
|
779
841
|
groupAble: groupAble,
|
|
780
842
|
groupColumns: groupColumns,
|
|
781
843
|
commandClick: triggerCommandClick,
|
|
782
|
-
|
|
844
|
+
summary: summary,
|
|
845
|
+
pagination: pagination
|
|
846
|
+
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
847
|
+
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
848
|
+
,
|
|
849
|
+
scroll: {
|
|
850
|
+
y: scrollHeight - (summary ? 0 : 0)
|
|
851
|
+
} // scroll height auto, không quá 600
|
|
852
|
+
,
|
|
853
|
+
height: propsHeight,
|
|
854
|
+
scrollHeight: scrollHeight,
|
|
783
855
|
components: {
|
|
784
856
|
header: {
|
|
785
857
|
cell: ResizableTitle
|
|
@@ -1491,7 +1491,7 @@ export function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1491
1491
|
const minRow = Math.min(...cells.map(c => c.row));
|
|
1492
1492
|
if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
|
|
1493
1493
|
|
|
1494
|
-
return cells.filter(c => c.row === minRow).map(c => `${c.row
|
|
1494
|
+
return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
|
|
1495
1495
|
}
|
|
1496
1496
|
case "bottom":
|
|
1497
1497
|
{
|
|
@@ -1512,7 +1512,7 @@ export function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1512
1512
|
if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
|
|
1513
1513
|
|
|
1514
1514
|
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1515
|
-
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col
|
|
1515
|
+
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
|
|
1516
1516
|
}
|
|
1517
1517
|
case "right":
|
|
1518
1518
|
{
|
|
@@ -1539,20 +1539,29 @@ export const addBorderClass = (selectedCells, type, className, id, nextCellRight
|
|
|
1539
1539
|
}
|
|
1540
1540
|
});
|
|
1541
1541
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1542
|
+
|
|
1543
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1544
|
+
|
|
1545
|
+
// if (type === 'left') {
|
|
1546
|
+
//
|
|
1547
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1548
|
+
// const [row, col] = pos.split('-');
|
|
1549
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1550
|
+
// });
|
|
1551
|
+
//
|
|
1552
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1553
|
+
//
|
|
1554
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1555
|
+
//
|
|
1556
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1557
|
+
//
|
|
1558
|
+
// cellsFilter2.forEach(cell => {
|
|
1559
|
+
// // cell.classList.add('has-before');
|
|
1560
|
+
// cell.classList.add('cell-border-left');
|
|
1561
|
+
// });
|
|
1562
|
+
// }
|
|
1563
|
+
//
|
|
1564
|
+
// }
|
|
1556
1565
|
};
|
|
1557
1566
|
export const removeBorderClass = (selectedCells, type, className, id) => {
|
|
1558
1567
|
const table = document.querySelector(`#${id}`);
|
|
@@ -1697,9 +1706,7 @@ export const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1697
1706
|
const col = getLastSelectCell(selectedCells).col;
|
|
1698
1707
|
const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
|
|
1699
1708
|
const nextCellLeft = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`);
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
console.log('nextCell', nextCellLeft);
|
|
1709
|
+
const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
|
|
1703
1710
|
if (cell) {
|
|
1704
1711
|
cell.style.zIndex = nextCellLeft ? 3 : 1;
|
|
1705
1712
|
}
|
|
@@ -1714,7 +1721,7 @@ export const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1714
1721
|
// thêm class border selected
|
|
1715
1722
|
|
|
1716
1723
|
addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
|
|
1717
|
-
addBorderClass(selectedCells, 'right', 'cell-border-right', id);
|
|
1724
|
+
addBorderClass(selectedCells, 'right', 'cell-border-right', id, !!nextCellRight);
|
|
1718
1725
|
addBorderClass(selectedCells, 'top', 'cell-border-top', id);
|
|
1719
1726
|
addBorderClass(selectedCells, 'left', 'cell-border-left', id);
|
|
1720
1727
|
};
|