es-grid-template 1.4.7 → 1.4.9
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/InternalTable.js +22 -17
- package/es/grid-component/TableGrid.js +6 -3
- package/es/grid-component/hooks/content/HeaderContent.d.ts +1 -0
- package/es/grid-component/hooks/content/HeaderContent.js +3 -50
- package/es/grid-component/hooks/utils.js +36 -16
- package/es/grid-component/styles.scss +12 -2
- package/es/grid-component/table/GridEdit.js +12 -5
- package/lib/grid-component/InternalTable.js +21 -16
- package/lib/grid-component/TableGrid.js +6 -3
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +1 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +3 -50
- package/lib/grid-component/hooks/utils.js +36 -16
- package/lib/grid-component/styles.scss +12 -2
- package/lib/grid-component/table/GridEdit.js +12 -5
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ import withReactContent from "sweetalert2-react-content";
|
|
|
21
21
|
import { Tooltip } from "react-tooltip";
|
|
22
22
|
import classNames from "classnames";
|
|
23
23
|
import HeaderContent from "./hooks/content/HeaderContent";
|
|
24
|
-
import { ArrowDown, ArrowUp, FilterFill } from "becoxy-icons";
|
|
24
|
+
import { ArrowDown, ArrowUp, FilterFill, SortCancel } from "becoxy-icons";
|
|
25
25
|
import { Select } from "rc-master-ui";
|
|
26
26
|
import { Button, Space } from "antd";
|
|
27
27
|
import { SearchOutlined } from "@ant-design/icons";
|
|
@@ -223,17 +223,17 @@ const InternalTable = props => {
|
|
|
223
223
|
}, [dataSource]);
|
|
224
224
|
const [columns, setColumns] = React.useState([]);
|
|
225
225
|
React.useEffect(() => {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
226
|
+
if (propsHeight) {
|
|
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 > 0 ? hhh : 0);
|
|
236
|
+
}
|
|
237
237
|
}, [id, propsHeight, columns, editAble]);
|
|
238
238
|
const tableRef = React.useRef(null);
|
|
239
239
|
React.useEffect(() => {
|
|
@@ -382,7 +382,8 @@ const InternalTable = props => {
|
|
|
382
382
|
column: {
|
|
383
383
|
...column
|
|
384
384
|
},
|
|
385
|
-
t: t
|
|
385
|
+
t: t,
|
|
386
|
+
id: id
|
|
386
387
|
})),
|
|
387
388
|
ellipsis: column.ellipsis !== false,
|
|
388
389
|
align: column.textAlign ?? column.align,
|
|
@@ -440,7 +441,7 @@ const InternalTable = props => {
|
|
|
440
441
|
const {
|
|
441
442
|
sortOrder
|
|
442
443
|
} = args;
|
|
443
|
-
return /*#__PURE__*/React.createElement(Fragment, null, !sortOrder && /*#__PURE__*/React.createElement(
|
|
444
|
+
return /*#__PURE__*/React.createElement(Fragment, null, !sortOrder && /*#__PURE__*/React.createElement(SortCancel, {
|
|
444
445
|
fontSize: 15,
|
|
445
446
|
style: {
|
|
446
447
|
display: 'flex',
|
|
@@ -846,10 +847,14 @@ const InternalTable = props => {
|
|
|
846
847
|
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
847
848
|
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
848
849
|
,
|
|
849
|
-
|
|
850
|
+
|
|
851
|
+
scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
|
|
852
|
+
y: 500
|
|
853
|
+
} : {
|
|
850
854
|
y: scrollHeight - (summary ? 1 : 1)
|
|
851
855
|
} // scroll height auto, không quá 600
|
|
852
856
|
,
|
|
857
|
+
|
|
853
858
|
height: propsHeight,
|
|
854
859
|
scrollHeight: scrollHeight,
|
|
855
860
|
components: {
|
|
@@ -873,12 +878,12 @@ const InternalTable = props => {
|
|
|
873
878
|
fontWeight: 500
|
|
874
879
|
}
|
|
875
880
|
}, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
876
|
-
id:
|
|
881
|
+
id: `${id}-tooltip-form-error`,
|
|
877
882
|
style: {
|
|
878
883
|
zIndex: 1999
|
|
879
884
|
}
|
|
880
885
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
881
|
-
id:
|
|
886
|
+
id: `${id}-tooltip-cell-content`,
|
|
882
887
|
style: {
|
|
883
888
|
zIndex: 1999
|
|
884
889
|
},
|
|
@@ -36,7 +36,9 @@ const convertFilters = filters => {
|
|
|
36
36
|
filteredKeys,
|
|
37
37
|
operator
|
|
38
38
|
}) => {
|
|
39
|
-
if (!filteredKeys || filteredKeys.length === 0)
|
|
39
|
+
if (!filteredKeys || filteredKeys.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
40
42
|
if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
|
|
41
43
|
result.push({
|
|
42
44
|
key,
|
|
@@ -131,6 +133,7 @@ const useStyle = createStyles(({
|
|
|
131
133
|
const EMPTY_LIST = [];
|
|
132
134
|
const TableGrid = props => {
|
|
133
135
|
const {
|
|
136
|
+
id,
|
|
134
137
|
columns,
|
|
135
138
|
tableRef,
|
|
136
139
|
dataSource,
|
|
@@ -398,7 +401,7 @@ const TableGrid = props => {
|
|
|
398
401
|
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
399
402
|
selectedRowKeys: mergedSelectedKeys,
|
|
400
403
|
// defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
401
|
-
defaultSelectedRowKeys
|
|
404
|
+
defaultSelectedRowKeys,
|
|
402
405
|
preserveSelectedRowKeys: true,
|
|
403
406
|
hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
404
407
|
}
|
|
@@ -517,7 +520,7 @@ const TableGrid = props => {
|
|
|
517
520
|
,
|
|
518
521
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
519
522
|
}, pagination)), bottomToolbar?.(), /*#__PURE__*/React.createElement(Tooltip, {
|
|
520
|
-
id:
|
|
523
|
+
id: `${id}-tooltip-header`,
|
|
521
524
|
style: {
|
|
522
525
|
zIndex: 1999
|
|
523
526
|
}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
|
|
4
|
-
// import styled from "styled-components";
|
|
5
3
|
import { getTemplate } from "../utils";
|
|
6
|
-
// const TooltipStyle = styled.div`
|
|
7
|
-
// width: max-content;
|
|
8
|
-
// background-color: #444;
|
|
9
|
-
// color: white;
|
|
10
|
-
// font-size: 90%;
|
|
11
|
-
// padding: 4px 8px;
|
|
12
|
-
// border-radius: 4px;
|
|
13
|
-
// opacity: 0.9;
|
|
14
|
-
// z-index: 9999;
|
|
15
|
-
// max-width: 450px;
|
|
16
|
-
// `
|
|
17
|
-
|
|
18
4
|
const HeaderContent = props => {
|
|
19
5
|
const {
|
|
20
|
-
t
|
|
6
|
+
t,
|
|
7
|
+
id
|
|
21
8
|
} = props;
|
|
22
9
|
const {
|
|
23
10
|
headerTooltip,
|
|
@@ -31,43 +18,9 @@ const HeaderContent = props => {
|
|
|
31
18
|
const tooltip = React.useMemo(() => {
|
|
32
19
|
return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
|
|
33
20
|
}, [columnGroupText, headerText, headerTooltip, t]);
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// const [isOpen, setIsOpen] = useState(false)
|
|
37
|
-
//
|
|
38
|
-
// const { refs, floatingStyles, context } = useFloating({
|
|
39
|
-
// open: isOpen,
|
|
40
|
-
// onOpenChange: setIsOpen,
|
|
41
|
-
// placement: "top",
|
|
42
|
-
// whileElementsMounted: autoUpdate,
|
|
43
|
-
// middleware: [
|
|
44
|
-
// offset(5),
|
|
45
|
-
// flip({
|
|
46
|
-
// fallbackAxisSideDirection: "start"
|
|
47
|
-
// }),
|
|
48
|
-
// shift()
|
|
49
|
-
// ]
|
|
50
|
-
// })
|
|
51
|
-
//
|
|
52
|
-
// const hover = useHover(context, { move: false })
|
|
53
|
-
// const focus = useFocus(context)
|
|
54
|
-
// const dismiss = useDismiss(context)
|
|
55
|
-
// const role = useRole(context, { role: "tooltip" })
|
|
56
|
-
//
|
|
57
|
-
// const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
58
|
-
// hover,
|
|
59
|
-
// focus,
|
|
60
|
-
// dismiss,
|
|
61
|
-
// role
|
|
62
|
-
// ])
|
|
63
|
-
|
|
64
21
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
65
|
-
// ref={refs.setReference}
|
|
66
|
-
// tabIndex={-1}
|
|
67
|
-
// style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
|
|
68
|
-
// style={{flex: 1}}
|
|
69
22
|
className: classnames('', {}),
|
|
70
|
-
"data-tooltip-id":
|
|
23
|
+
"data-tooltip-id": `${id}-tooltip-header`,
|
|
71
24
|
"data-tooltip-content": tooltip,
|
|
72
25
|
"data-tooltip-offset": 16
|
|
73
26
|
}, headerTemplate ? getTemplate(headerTemplate) : t ? t(text) : text));
|
|
@@ -506,10 +506,12 @@ export const getRowsPasteIndex = pasteRows => {
|
|
|
506
506
|
return [...new Set(result)];
|
|
507
507
|
};
|
|
508
508
|
export function addRows8(arr, n) {
|
|
509
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
509
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
510
|
+
return {
|
|
511
|
+
combined: arr,
|
|
512
|
+
addedRows: []
|
|
513
|
+
};
|
|
514
|
+
}
|
|
513
515
|
const m = arr.length;
|
|
514
516
|
const numCols = arr[0].length;
|
|
515
517
|
const addedRows = [];
|
|
@@ -643,10 +645,12 @@ export function addRows8(arr, n) {
|
|
|
643
645
|
}
|
|
644
646
|
export function addRowsUp(array, n) {
|
|
645
647
|
const arr = array.reverse();
|
|
646
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
648
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
649
|
+
return {
|
|
650
|
+
combined: arr,
|
|
651
|
+
addedRows: []
|
|
652
|
+
};
|
|
653
|
+
}
|
|
650
654
|
const m = arr.length;
|
|
651
655
|
const numCols = arr[0].length;
|
|
652
656
|
const addedRows = [];
|
|
@@ -1368,12 +1372,16 @@ export const buildConnectedRegions = cells => {
|
|
|
1368
1372
|
];
|
|
1369
1373
|
const regions = [];
|
|
1370
1374
|
for (const cell of cells) {
|
|
1371
|
-
if (visited.has(cell.key))
|
|
1375
|
+
if (visited.has(cell.key)) {
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1372
1378
|
const stack = [cell];
|
|
1373
1379
|
const region = [];
|
|
1374
1380
|
while (stack.length) {
|
|
1375
1381
|
const current = stack.pop();
|
|
1376
|
-
if (visited.has(current.key))
|
|
1382
|
+
if (visited.has(current.key)) {
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1377
1385
|
visited.add(current.key);
|
|
1378
1386
|
region.push(current);
|
|
1379
1387
|
for (const [dr, dc] of directions) {
|
|
@@ -1421,9 +1429,13 @@ export function isRightMostInRegion(rowIndex, colIndex, listSelectCell) {
|
|
|
1421
1429
|
return false;
|
|
1422
1430
|
}
|
|
1423
1431
|
export function isEqualSet(setA, setB) {
|
|
1424
|
-
if (setA.size !== setB.size)
|
|
1432
|
+
if (setA.size !== setB.size) {
|
|
1433
|
+
return false;
|
|
1434
|
+
}
|
|
1425
1435
|
for (const item of setA) {
|
|
1426
|
-
if (!setB.has(item))
|
|
1436
|
+
if (!setB.has(item)) {
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1427
1439
|
}
|
|
1428
1440
|
return true;
|
|
1429
1441
|
}
|
|
@@ -1489,7 +1501,9 @@ export function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1489
1501
|
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1490
1502
|
|
|
1491
1503
|
const minRow = Math.min(...cells.map(c => c.row));
|
|
1492
|
-
if (minRow === 0)
|
|
1504
|
+
if (minRow === 0) {
|
|
1505
|
+
return [];
|
|
1506
|
+
} // Bỏ qua nếu rowIndex = 0
|
|
1493
1507
|
|
|
1494
1508
|
return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
|
|
1495
1509
|
}
|
|
@@ -1509,7 +1523,9 @@ export function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1509
1523
|
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1510
1524
|
|
|
1511
1525
|
const minCol = Math.min(...cells.map(c => c.col));
|
|
1512
|
-
if (minCol === 0)
|
|
1526
|
+
if (minCol === 0) {
|
|
1527
|
+
return [];
|
|
1528
|
+
} // Bỏ qua nếu colIndex = 0
|
|
1513
1529
|
|
|
1514
1530
|
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1515
1531
|
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
|
|
@@ -1544,7 +1560,9 @@ export function getCellsByPosition2(cellSet, position = "bottom") {
|
|
|
1544
1560
|
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1545
1561
|
|
|
1546
1562
|
const minRow = Math.min(...cells.map(c => c.row));
|
|
1547
|
-
if (minRow === 0)
|
|
1563
|
+
if (minRow === 0) {
|
|
1564
|
+
return [];
|
|
1565
|
+
} // Bỏ qua nếu rowIndex = 0
|
|
1548
1566
|
|
|
1549
1567
|
return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
|
|
1550
1568
|
}
|
|
@@ -1564,7 +1582,9 @@ export function getCellsByPosition2(cellSet, position = "bottom") {
|
|
|
1564
1582
|
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1565
1583
|
|
|
1566
1584
|
const minCol = Math.min(...cells.map(c => c.col));
|
|
1567
|
-
if (minCol === 0)
|
|
1585
|
+
if (minCol === 0) {
|
|
1586
|
+
return [];
|
|
1587
|
+
} // Bỏ qua nếu colIndex = 0
|
|
1568
1588
|
|
|
1569
1589
|
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1570
1590
|
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
|
|
@@ -294,6 +294,16 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
294
294
|
|
|
295
295
|
.#{$prefix}-table-cell {
|
|
296
296
|
|
|
297
|
+
.ui-rc-table-column-sorter{
|
|
298
|
+
line-height: normal !important;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&:hover {
|
|
302
|
+
.ui-rc-table-column-sorter-up.active {
|
|
303
|
+
opacity: 1 !important;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
297
307
|
.ui-rc-table-cell-content {
|
|
298
308
|
line-height: 22px;
|
|
299
309
|
}
|
|
@@ -508,12 +518,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
508
518
|
pointer-events: none; /* không ảnh hưởng đến tương tác */
|
|
509
519
|
z-index: 1;
|
|
510
520
|
}
|
|
511
|
-
&.ui-rc-table-cell-fix-left {
|
|
521
|
+
&.ui-rc-table-cell-fix-left.ui-rc-table-cell-fix-left-last {
|
|
512
522
|
&::after {
|
|
513
523
|
left: -100%;
|
|
514
524
|
}
|
|
515
525
|
}
|
|
516
|
-
&.ui-rc-table-cell-fix-right {
|
|
526
|
+
&.ui-rc-table-cell-fix-right.ui-rc-table-cell-fix-right-first {
|
|
517
527
|
&::after {
|
|
518
528
|
left: 100%;
|
|
519
529
|
}
|
|
@@ -976,7 +976,10 @@ const GridEdit = props => {
|
|
|
976
976
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
977
977
|
|
|
978
978
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
979
|
-
setEditingKey('')
|
|
979
|
+
// setEditingKey('')
|
|
980
|
+
setTimeout(() => {
|
|
981
|
+
setEditingKey('');
|
|
982
|
+
});
|
|
980
983
|
isSelecting.current = false;
|
|
981
984
|
startCell.current = null;
|
|
982
985
|
// setSelectedCells(new Set())
|
|
@@ -990,9 +993,12 @@ const GridEdit = props => {
|
|
|
990
993
|
setRangeCells(new Set());
|
|
991
994
|
}
|
|
992
995
|
};
|
|
996
|
+
|
|
997
|
+
// document.addEventListener('click', handleClickOutside)
|
|
993
998
|
document.addEventListener('mousedown', handleClickOutside);
|
|
994
999
|
document.addEventListener('touchstart', handleClickOutside);
|
|
995
1000
|
return () => {
|
|
1001
|
+
// document.removeEventListener('click', handleClickOutside)
|
|
996
1002
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
997
1003
|
document.removeEventListener('touchstart', handleClickOutside);
|
|
998
1004
|
};
|
|
@@ -1437,7 +1443,7 @@ const GridEdit = props => {
|
|
|
1437
1443
|
if (target.closest('.dragging-point')) {
|
|
1438
1444
|
e.stopPropagation();
|
|
1439
1445
|
e.preventDefault();
|
|
1440
|
-
|
|
1446
|
+
// Không xử lý gì cả
|
|
1441
1447
|
} else {
|
|
1442
1448
|
// setStartSelectedCell({row, col})
|
|
1443
1449
|
|
|
@@ -1686,7 +1692,9 @@ const GridEdit = props => {
|
|
|
1686
1692
|
startCell.current = null;
|
|
1687
1693
|
e.stopPropagation();
|
|
1688
1694
|
}
|
|
1689
|
-
if (!isSelectingRow.current || !rowStart.current)
|
|
1695
|
+
if (!isSelectingRow.current || !rowStart.current) {
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1690
1698
|
// const { row: startRow, col: startCol } = rowStart.current;
|
|
1691
1699
|
const {
|
|
1692
1700
|
row: startRow,
|
|
@@ -2227,7 +2235,7 @@ const GridEdit = props => {
|
|
|
2227
2235
|
disable: !isEditable(column, record)
|
|
2228
2236
|
}),
|
|
2229
2237
|
record,
|
|
2230
|
-
column
|
|
2238
|
+
column,
|
|
2231
2239
|
editType: getEditType(column, record),
|
|
2232
2240
|
dataIndex: column.dataIndex,
|
|
2233
2241
|
indexRow: rowNumber,
|
|
@@ -2441,7 +2449,6 @@ const GridEdit = props => {
|
|
|
2441
2449
|
}
|
|
2442
2450
|
if (args.item.key === 'DELETE_CONTENT') {
|
|
2443
2451
|
handleDeleteContent();
|
|
2444
|
-
return;
|
|
2445
2452
|
}
|
|
2446
2453
|
};
|
|
2447
2454
|
const hideModalAddRow = () => {
|
|
@@ -234,17 +234,17 @@ const InternalTable = props => {
|
|
|
234
234
|
}, [dataSource]);
|
|
235
235
|
const [columns, setColumns] = _react.default.useState([]);
|
|
236
236
|
_react.default.useEffect(() => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
237
|
+
if (propsHeight) {
|
|
238
|
+
const table = document.querySelector(`#${id}`);
|
|
239
|
+
const title = table?.querySelector(`.ui-rc-table-title`);
|
|
240
|
+
const header = table?.querySelector(`.ui-rc-table-header`);
|
|
241
|
+
const paginationE = table?.querySelector(`.ui-rc-pagination`);
|
|
242
|
+
const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
|
|
243
|
+
const summaryE = table?.querySelector(`.ui-rc-table-summary`);
|
|
244
|
+
const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
|
|
245
|
+
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);
|
|
246
|
+
setHeight(hhh > 0 ? hhh : 0);
|
|
247
|
+
}
|
|
248
248
|
}, [id, propsHeight, columns, editAble]);
|
|
249
249
|
const tableRef = _react.default.useRef(null);
|
|
250
250
|
_react.default.useEffect(() => {
|
|
@@ -393,7 +393,8 @@ const InternalTable = props => {
|
|
|
393
393
|
column: {
|
|
394
394
|
...column
|
|
395
395
|
},
|
|
396
|
-
t: t
|
|
396
|
+
t: t,
|
|
397
|
+
id: id
|
|
397
398
|
})),
|
|
398
399
|
ellipsis: column.ellipsis !== false,
|
|
399
400
|
align: column.textAlign ?? column.align,
|
|
@@ -451,7 +452,7 @@ const InternalTable = props => {
|
|
|
451
452
|
const {
|
|
452
453
|
sortOrder
|
|
453
454
|
} = args;
|
|
454
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !sortOrder && /*#__PURE__*/_react.default.createElement(_becoxyIcons.
|
|
455
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !sortOrder && /*#__PURE__*/_react.default.createElement(_becoxyIcons.SortCancel, {
|
|
455
456
|
fontSize: 15,
|
|
456
457
|
style: {
|
|
457
458
|
display: 'flex',
|
|
@@ -857,10 +858,14 @@ const InternalTable = props => {
|
|
|
857
858
|
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
858
859
|
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
859
860
|
,
|
|
860
|
-
|
|
861
|
+
|
|
862
|
+
scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
|
|
863
|
+
y: 500
|
|
864
|
+
} : {
|
|
861
865
|
y: scrollHeight - (summary ? 1 : 1)
|
|
862
866
|
} // scroll height auto, không quá 600
|
|
863
867
|
,
|
|
868
|
+
|
|
864
869
|
height: propsHeight,
|
|
865
870
|
scrollHeight: scrollHeight,
|
|
866
871
|
components: {
|
|
@@ -884,12 +889,12 @@ const InternalTable = props => {
|
|
|
884
889
|
fontWeight: 500
|
|
885
890
|
}
|
|
886
891
|
}, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
887
|
-
id:
|
|
892
|
+
id: `${id}-tooltip-form-error`,
|
|
888
893
|
style: {
|
|
889
894
|
zIndex: 1999
|
|
890
895
|
}
|
|
891
896
|
}), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
892
|
-
id:
|
|
897
|
+
id: `${id}-tooltip-cell-content`,
|
|
893
898
|
style: {
|
|
894
899
|
zIndex: 1999
|
|
895
900
|
},
|
|
@@ -36,7 +36,9 @@ const convertFilters = filters => {
|
|
|
36
36
|
filteredKeys,
|
|
37
37
|
operator
|
|
38
38
|
}) => {
|
|
39
|
-
if (!filteredKeys || filteredKeys.length === 0)
|
|
39
|
+
if (!filteredKeys || filteredKeys.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
40
42
|
if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
|
|
41
43
|
result.push({
|
|
42
44
|
key,
|
|
@@ -131,6 +133,7 @@ const useStyle = (0, _antdStyle.createStyles)(({
|
|
|
131
133
|
const EMPTY_LIST = [];
|
|
132
134
|
const TableGrid = props => {
|
|
133
135
|
const {
|
|
136
|
+
id,
|
|
134
137
|
columns,
|
|
135
138
|
tableRef,
|
|
136
139
|
dataSource,
|
|
@@ -398,7 +401,7 @@ const TableGrid = props => {
|
|
|
398
401
|
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
399
402
|
selectedRowKeys: mergedSelectedKeys,
|
|
400
403
|
// defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
401
|
-
defaultSelectedRowKeys
|
|
404
|
+
defaultSelectedRowKeys,
|
|
402
405
|
preserveSelectedRowKeys: true,
|
|
403
406
|
hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
404
407
|
}
|
|
@@ -517,7 +520,7 @@ const TableGrid = props => {
|
|
|
517
520
|
,
|
|
518
521
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
519
522
|
}, pagination)), bottomToolbar?.(), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
520
|
-
id:
|
|
523
|
+
id: `${id}-tooltip-header`,
|
|
521
524
|
style: {
|
|
522
525
|
zIndex: 1999
|
|
523
526
|
}
|
|
@@ -10,23 +10,10 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _utils = require("../utils");
|
|
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
|
-
// import styled from "styled-components";
|
|
14
|
-
|
|
15
|
-
// const TooltipStyle = styled.div`
|
|
16
|
-
// width: max-content;
|
|
17
|
-
// background-color: #444;
|
|
18
|
-
// color: white;
|
|
19
|
-
// font-size: 90%;
|
|
20
|
-
// padding: 4px 8px;
|
|
21
|
-
// border-radius: 4px;
|
|
22
|
-
// opacity: 0.9;
|
|
23
|
-
// z-index: 9999;
|
|
24
|
-
// max-width: 450px;
|
|
25
|
-
// `
|
|
26
|
-
|
|
27
13
|
const HeaderContent = props => {
|
|
28
14
|
const {
|
|
29
|
-
t
|
|
15
|
+
t,
|
|
16
|
+
id
|
|
30
17
|
} = props;
|
|
31
18
|
const {
|
|
32
19
|
headerTooltip,
|
|
@@ -40,43 +27,9 @@ const HeaderContent = props => {
|
|
|
40
27
|
const tooltip = _react.default.useMemo(() => {
|
|
41
28
|
return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
|
|
42
29
|
}, [columnGroupText, headerText, headerTooltip, t]);
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// const [isOpen, setIsOpen] = useState(false)
|
|
46
|
-
//
|
|
47
|
-
// const { refs, floatingStyles, context } = useFloating({
|
|
48
|
-
// open: isOpen,
|
|
49
|
-
// onOpenChange: setIsOpen,
|
|
50
|
-
// placement: "top",
|
|
51
|
-
// whileElementsMounted: autoUpdate,
|
|
52
|
-
// middleware: [
|
|
53
|
-
// offset(5),
|
|
54
|
-
// flip({
|
|
55
|
-
// fallbackAxisSideDirection: "start"
|
|
56
|
-
// }),
|
|
57
|
-
// shift()
|
|
58
|
-
// ]
|
|
59
|
-
// })
|
|
60
|
-
//
|
|
61
|
-
// const hover = useHover(context, { move: false })
|
|
62
|
-
// const focus = useFocus(context)
|
|
63
|
-
// const dismiss = useDismiss(context)
|
|
64
|
-
// const role = useRole(context, { role: "tooltip" })
|
|
65
|
-
//
|
|
66
|
-
// const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
67
|
-
// hover,
|
|
68
|
-
// focus,
|
|
69
|
-
// dismiss,
|
|
70
|
-
// role
|
|
71
|
-
// ])
|
|
72
|
-
|
|
73
30
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
-
// ref={refs.setReference}
|
|
75
|
-
// tabIndex={-1}
|
|
76
|
-
// style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
|
|
77
|
-
// style={{flex: 1}}
|
|
78
31
|
className: (0, _classnames.default)('', {}),
|
|
79
|
-
"data-tooltip-id":
|
|
32
|
+
"data-tooltip-id": `${id}-tooltip-header`,
|
|
80
33
|
"data-tooltip-content": tooltip,
|
|
81
34
|
"data-tooltip-offset": 16
|
|
82
35
|
}, headerTemplate ? (0, _utils.getTemplate)(headerTemplate) : t ? t(text) : text));
|
|
@@ -580,10 +580,12 @@ const getRowsPasteIndex = pasteRows => {
|
|
|
580
580
|
};
|
|
581
581
|
exports.getRowsPasteIndex = getRowsPasteIndex;
|
|
582
582
|
function addRows8(arr, n) {
|
|
583
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
583
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
584
|
+
return {
|
|
585
|
+
combined: arr,
|
|
586
|
+
addedRows: []
|
|
587
|
+
};
|
|
588
|
+
}
|
|
587
589
|
const m = arr.length;
|
|
588
590
|
const numCols = arr[0].length;
|
|
589
591
|
const addedRows = [];
|
|
@@ -717,10 +719,12 @@ function addRows8(arr, n) {
|
|
|
717
719
|
}
|
|
718
720
|
function addRowsUp(array, n) {
|
|
719
721
|
const arr = array.reverse();
|
|
720
|
-
if (!Array.isArray(arr) || arr.length === 0)
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
722
|
+
if (!Array.isArray(arr) || arr.length === 0) {
|
|
723
|
+
return {
|
|
724
|
+
combined: arr,
|
|
725
|
+
addedRows: []
|
|
726
|
+
};
|
|
727
|
+
}
|
|
724
728
|
const m = arr.length;
|
|
725
729
|
const numCols = arr[0].length;
|
|
726
730
|
const addedRows = [];
|
|
@@ -1459,12 +1463,16 @@ const buildConnectedRegions = cells => {
|
|
|
1459
1463
|
];
|
|
1460
1464
|
const regions = [];
|
|
1461
1465
|
for (const cell of cells) {
|
|
1462
|
-
if (visited.has(cell.key))
|
|
1466
|
+
if (visited.has(cell.key)) {
|
|
1467
|
+
continue;
|
|
1468
|
+
}
|
|
1463
1469
|
const stack = [cell];
|
|
1464
1470
|
const region = [];
|
|
1465
1471
|
while (stack.length) {
|
|
1466
1472
|
const current = stack.pop();
|
|
1467
|
-
if (visited.has(current.key))
|
|
1473
|
+
if (visited.has(current.key)) {
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1468
1476
|
visited.add(current.key);
|
|
1469
1477
|
region.push(current);
|
|
1470
1478
|
for (const [dr, dc] of directions) {
|
|
@@ -1515,9 +1523,13 @@ function isRightMostInRegion(rowIndex, colIndex, listSelectCell) {
|
|
|
1515
1523
|
return false;
|
|
1516
1524
|
}
|
|
1517
1525
|
function isEqualSet(setA, setB) {
|
|
1518
|
-
if (setA.size !== setB.size)
|
|
1526
|
+
if (setA.size !== setB.size) {
|
|
1527
|
+
return false;
|
|
1528
|
+
}
|
|
1519
1529
|
for (const item of setA) {
|
|
1520
|
-
if (!setB.has(item))
|
|
1530
|
+
if (!setB.has(item)) {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1521
1533
|
}
|
|
1522
1534
|
return true;
|
|
1523
1535
|
}
|
|
@@ -1586,7 +1598,9 @@ function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1586
1598
|
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1587
1599
|
|
|
1588
1600
|
const minRow = Math.min(...cells.map(c => c.row));
|
|
1589
|
-
if (minRow === 0)
|
|
1601
|
+
if (minRow === 0) {
|
|
1602
|
+
return [];
|
|
1603
|
+
} // Bỏ qua nếu rowIndex = 0
|
|
1590
1604
|
|
|
1591
1605
|
return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
|
|
1592
1606
|
}
|
|
@@ -1606,7 +1620,9 @@ function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1606
1620
|
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1607
1621
|
|
|
1608
1622
|
const minCol = Math.min(...cells.map(c => c.col));
|
|
1609
|
-
if (minCol === 0)
|
|
1623
|
+
if (minCol === 0) {
|
|
1624
|
+
return [];
|
|
1625
|
+
} // Bỏ qua nếu colIndex = 0
|
|
1610
1626
|
|
|
1611
1627
|
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1612
1628
|
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
|
|
@@ -1641,7 +1657,9 @@ function getCellsByPosition2(cellSet, position = "bottom") {
|
|
|
1641
1657
|
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1642
1658
|
|
|
1643
1659
|
const minRow = Math.min(...cells.map(c => c.row));
|
|
1644
|
-
if (minRow === 0)
|
|
1660
|
+
if (minRow === 0) {
|
|
1661
|
+
return [];
|
|
1662
|
+
} // Bỏ qua nếu rowIndex = 0
|
|
1645
1663
|
|
|
1646
1664
|
return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
|
|
1647
1665
|
}
|
|
@@ -1661,7 +1679,9 @@ function getCellsByPosition2(cellSet, position = "bottom") {
|
|
|
1661
1679
|
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1662
1680
|
|
|
1663
1681
|
const minCol = Math.min(...cells.map(c => c.col));
|
|
1664
|
-
if (minCol === 0)
|
|
1682
|
+
if (minCol === 0) {
|
|
1683
|
+
return [];
|
|
1684
|
+
} // Bỏ qua nếu colIndex = 0
|
|
1665
1685
|
|
|
1666
1686
|
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1667
1687
|
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
|
|
@@ -294,6 +294,16 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
294
294
|
|
|
295
295
|
.#{$prefix}-table-cell {
|
|
296
296
|
|
|
297
|
+
.ui-rc-table-column-sorter{
|
|
298
|
+
line-height: normal !important;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
&:hover {
|
|
302
|
+
.ui-rc-table-column-sorter-up.active {
|
|
303
|
+
opacity: 1 !important;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
297
307
|
.ui-rc-table-cell-content {
|
|
298
308
|
line-height: 22px;
|
|
299
309
|
}
|
|
@@ -508,12 +518,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
508
518
|
pointer-events: none; /* không ảnh hưởng đến tương tác */
|
|
509
519
|
z-index: 1;
|
|
510
520
|
}
|
|
511
|
-
&.ui-rc-table-cell-fix-left {
|
|
521
|
+
&.ui-rc-table-cell-fix-left.ui-rc-table-cell-fix-left-last {
|
|
512
522
|
&::after {
|
|
513
523
|
left: -100%;
|
|
514
524
|
}
|
|
515
525
|
}
|
|
516
|
-
&.ui-rc-table-cell-fix-right {
|
|
526
|
+
&.ui-rc-table-cell-fix-right.ui-rc-table-cell-fix-right-first {
|
|
517
527
|
&::after {
|
|
518
528
|
left: 100%;
|
|
519
529
|
}
|
|
@@ -980,7 +980,10 @@ const GridEdit = props => {
|
|
|
980
980
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
981
981
|
|
|
982
982
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
983
|
-
setEditingKey('')
|
|
983
|
+
// setEditingKey('')
|
|
984
|
+
setTimeout(() => {
|
|
985
|
+
setEditingKey('');
|
|
986
|
+
});
|
|
984
987
|
isSelecting.current = false;
|
|
985
988
|
startCell.current = null;
|
|
986
989
|
// setSelectedCells(new Set())
|
|
@@ -994,9 +997,12 @@ const GridEdit = props => {
|
|
|
994
997
|
setRangeCells(new Set());
|
|
995
998
|
}
|
|
996
999
|
};
|
|
1000
|
+
|
|
1001
|
+
// document.addEventListener('click', handleClickOutside)
|
|
997
1002
|
document.addEventListener('mousedown', handleClickOutside);
|
|
998
1003
|
document.addEventListener('touchstart', handleClickOutside);
|
|
999
1004
|
return () => {
|
|
1005
|
+
// document.removeEventListener('click', handleClickOutside)
|
|
1000
1006
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
1001
1007
|
document.removeEventListener('touchstart', handleClickOutside);
|
|
1002
1008
|
};
|
|
@@ -1441,7 +1447,7 @@ const GridEdit = props => {
|
|
|
1441
1447
|
if (target.closest('.dragging-point')) {
|
|
1442
1448
|
e.stopPropagation();
|
|
1443
1449
|
e.preventDefault();
|
|
1444
|
-
|
|
1450
|
+
// Không xử lý gì cả
|
|
1445
1451
|
} else {
|
|
1446
1452
|
// setStartSelectedCell({row, col})
|
|
1447
1453
|
|
|
@@ -1690,7 +1696,9 @@ const GridEdit = props => {
|
|
|
1690
1696
|
startCell.current = null;
|
|
1691
1697
|
e.stopPropagation();
|
|
1692
1698
|
}
|
|
1693
|
-
if (!isSelectingRow.current || !rowStart.current)
|
|
1699
|
+
if (!isSelectingRow.current || !rowStart.current) {
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1694
1702
|
// const { row: startRow, col: startCol } = rowStart.current;
|
|
1695
1703
|
const {
|
|
1696
1704
|
row: startRow,
|
|
@@ -2231,7 +2239,7 @@ const GridEdit = props => {
|
|
|
2231
2239
|
disable: !(0, _hooks.isEditable)(column, record)
|
|
2232
2240
|
}),
|
|
2233
2241
|
record,
|
|
2234
|
-
column
|
|
2242
|
+
column,
|
|
2235
2243
|
editType: (0, _hooks.getEditType)(column, record),
|
|
2236
2244
|
dataIndex: column.dataIndex,
|
|
2237
2245
|
indexRow: rowNumber,
|
|
@@ -2445,7 +2453,6 @@ const GridEdit = props => {
|
|
|
2445
2453
|
}
|
|
2446
2454
|
if (args.item.key === 'DELETE_CONTENT') {
|
|
2447
2455
|
handleDeleteContent();
|
|
2448
|
-
return;
|
|
2449
2456
|
}
|
|
2450
2457
|
};
|
|
2451
2458
|
const hideModalAddRow = () => {
|