es-grid-template 1.4.4 → 1.4.6
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/EditableCell.js +3 -2
- 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.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +137 -21
- 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 +1054 -897
- package/es/grid-component/table/Group.d.ts +1 -0
- package/es/grid-component/table/Group.js +6 -1
- package/lib/grid-component/EditableCell.js +2 -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.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +144 -25
- 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 +1054 -896
- package/lib/grid-component/table/Group.d.ts +1 -0
- package/lib/grid-component/table/Group.js +6 -1
- package/package.json +110 -110
|
@@ -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
|
|
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;
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -1469,6 +1469,61 @@ export function getBottomRowCells(cellSet) {
|
|
|
1469
1469
|
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1470
1470
|
}
|
|
1471
1471
|
export function getCellsByPosition(cellSet, position = "bottom") {
|
|
1472
|
+
const cells = Array.from(cellSet).map(key => {
|
|
1473
|
+
const [row, col] = key.split("-").map(Number);
|
|
1474
|
+
return {
|
|
1475
|
+
row,
|
|
1476
|
+
col,
|
|
1477
|
+
key
|
|
1478
|
+
};
|
|
1479
|
+
});
|
|
1480
|
+
switch (position) {
|
|
1481
|
+
case "top":
|
|
1482
|
+
{
|
|
1483
|
+
// const minRow = Math.min(...cells.map(c => c.row));
|
|
1484
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1485
|
+
|
|
1486
|
+
// const rows = cells.map(c => c.row).filter(r => r > 0);
|
|
1487
|
+
// if (rows.length === 0) return [];
|
|
1488
|
+
// const minRow = Math.min(...rows);
|
|
1489
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1490
|
+
|
|
1491
|
+
const minRow = Math.min(...cells.map(c => c.row));
|
|
1492
|
+
if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
|
|
1493
|
+
|
|
1494
|
+
return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
|
|
1495
|
+
}
|
|
1496
|
+
case "bottom":
|
|
1497
|
+
{
|
|
1498
|
+
const maxRow = Math.max(...cells.map(c => c.row));
|
|
1499
|
+
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1500
|
+
}
|
|
1501
|
+
case "left":
|
|
1502
|
+
{
|
|
1503
|
+
// const minCol = Math.min(...cells.map(c => c.col));
|
|
1504
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1505
|
+
|
|
1506
|
+
// const cols = cells.map(c => c.col).filter(c => c > 0);
|
|
1507
|
+
// if (cols.length === 0) return [];
|
|
1508
|
+
// const minCol = Math.min(...cols);
|
|
1509
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1510
|
+
|
|
1511
|
+
const minCol = Math.min(...cells.map(c => c.col));
|
|
1512
|
+
if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
|
|
1513
|
+
|
|
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}`);
|
|
1516
|
+
}
|
|
1517
|
+
case "right":
|
|
1518
|
+
{
|
|
1519
|
+
const maxCol = Math.max(...cells.map(c => c.col));
|
|
1520
|
+
return cells.filter(c => c.col === maxCol).map(c => c.key);
|
|
1521
|
+
}
|
|
1522
|
+
default:
|
|
1523
|
+
return [];
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
export function getCellsByPosition2(cellSet, position = "bottom") {
|
|
1472
1527
|
const cells = Array.from(cellSet).map(key => {
|
|
1473
1528
|
const [row, col] = key.split("-").map(Number);
|
|
1474
1529
|
return {
|
|
@@ -1539,22 +1594,85 @@ export const addBorderClass = (selectedCells, type, className, id, nextCellRight
|
|
|
1539
1594
|
}
|
|
1540
1595
|
});
|
|
1541
1596
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1597
|
+
|
|
1598
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1599
|
+
|
|
1600
|
+
// if (type === 'left') {
|
|
1601
|
+
//
|
|
1602
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1603
|
+
// const [row, col] = pos.split('-');
|
|
1604
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1605
|
+
// });
|
|
1606
|
+
//
|
|
1607
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1608
|
+
//
|
|
1609
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1610
|
+
//
|
|
1611
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1612
|
+
//
|
|
1613
|
+
// cellsFilter2.forEach(cell => {
|
|
1614
|
+
// // cell.classList.add('has-before');
|
|
1615
|
+
// cell.classList.add('cell-border-left');
|
|
1616
|
+
// });
|
|
1617
|
+
// }
|
|
1618
|
+
//
|
|
1619
|
+
// }
|
|
1620
|
+
};
|
|
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);
|
|
1546
1632
|
});
|
|
1547
|
-
const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1548
|
-
const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null;
|
|
1549
|
-
if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1550
|
-
cellsFilter2.forEach(cell => {
|
|
1551
|
-
// cell.classList.add('has-before');
|
|
1552
|
-
cell.classList.add('cell-border-left');
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
1633
|
}
|
|
1556
1634
|
};
|
|
1557
|
-
export const
|
|
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) => {
|
|
1558
1676
|
const table = document.querySelector(`#${id}`);
|
|
1559
1677
|
const typeCells = getCellsByPosition(selectedCells, type);
|
|
1560
1678
|
const selectorsCells = typeCells.map(pos => {
|
|
@@ -1697,9 +1815,7 @@ export const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1697
1815
|
const col = getLastSelectCell(selectedCells).col;
|
|
1698
1816
|
const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
|
|
1699
1817
|
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);
|
|
1818
|
+
const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
|
|
1703
1819
|
if (cell) {
|
|
1704
1820
|
cell.style.zIndex = nextCellLeft ? 3 : 1;
|
|
1705
1821
|
}
|
|
@@ -1714,7 +1830,7 @@ export const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1714
1830
|
// thêm class border selected
|
|
1715
1831
|
|
|
1716
1832
|
addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
|
|
1717
|
-
addBorderClass(selectedCells, 'right', 'cell-border-right', id);
|
|
1833
|
+
addBorderClass(selectedCells, 'right', 'cell-border-right', id, !!nextCellRight);
|
|
1718
1834
|
addBorderClass(selectedCells, 'top', 'cell-border-top', id);
|
|
1719
1835
|
addBorderClass(selectedCells, 'left', 'cell-border-left', id);
|
|
1720
1836
|
};
|
|
@@ -1743,13 +1859,13 @@ export const onRemoveBorderSelectedCell = (selectedCells, id) => {
|
|
|
1743
1859
|
export const addClassBorderPasteCell = (pasteCells, type, id) => {
|
|
1744
1860
|
// thêm class border
|
|
1745
1861
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1862
|
+
addBorderPasteClass(pasteCells, 'right', 'cell-paste-border-right', id);
|
|
1863
|
+
addBorderPasteClass(pasteCells, 'left', 'cell-paste-border-left', id);
|
|
1748
1864
|
if (type === 'up') {
|
|
1749
|
-
|
|
1865
|
+
addBorderPasteClass(pasteCells, 'top', 'cell-paste-border-top', id);
|
|
1750
1866
|
}
|
|
1751
1867
|
if (type === 'down') {
|
|
1752
|
-
|
|
1868
|
+
addBorderPasteClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
|
|
1753
1869
|
}
|
|
1754
1870
|
};
|
|
1755
1871
|
export const removeClassBorderPasteCell = (pasteCells, type, id) => {
|