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
|
@@ -10,6 +10,7 @@ type Props<T> = GridTableProps<T> & {
|
|
|
10
10
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
|
|
11
11
|
triggerFilter?: (queries: any) => void;
|
|
12
12
|
setTooltipContent?: any;
|
|
13
|
+
scrollHeight?: number;
|
|
13
14
|
};
|
|
14
15
|
declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
15
16
|
export default Group;
|
|
@@ -11,8 +11,10 @@ import { Collapse2, Expand2 } from "becoxy-icons";
|
|
|
11
11
|
const Group = props => {
|
|
12
12
|
const {
|
|
13
13
|
t,
|
|
14
|
+
id,
|
|
14
15
|
columns,
|
|
15
16
|
height,
|
|
17
|
+
scrollHeight,
|
|
16
18
|
style,
|
|
17
19
|
rowHoverable,
|
|
18
20
|
groupAble,
|
|
@@ -97,11 +99,14 @@ const Group = props => {
|
|
|
97
99
|
};
|
|
98
100
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
99
101
|
$heightTable: height,
|
|
102
|
+
$heightScroll: scrollHeight,
|
|
100
103
|
style: {
|
|
101
104
|
position: 'relative'
|
|
102
|
-
}
|
|
105
|
+
},
|
|
106
|
+
id: id
|
|
103
107
|
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
104
108
|
t: t,
|
|
109
|
+
id: id,
|
|
105
110
|
columns: columns,
|
|
106
111
|
style: {
|
|
107
112
|
...style,
|
|
@@ -69,7 +69,8 @@ const EditableCell = props => {
|
|
|
69
69
|
const dateTimePickerRef = _react.default.useRef(null);
|
|
70
70
|
// const timePickerRef = React.useRef(null);
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
|
|
73
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
73
74
|
const inputNode = (value, onChange) => {
|
|
74
75
|
const dateFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
|
|
75
76
|
const date = !(0, _hooks.isEmpty)(value) ? (0, _hooks.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 {};
|
|
@@ -9,4 +9,4 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
9
9
|
const GridStyle = exports.GridStyle = _styledComponents.default.div.withConfig({
|
|
10
10
|
displayName: "GridStyle",
|
|
11
11
|
componentId: "es-grid-template__sc-sueu2e-0"
|
|
12
|
-
})([".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 ?
|
|
12
|
+
})(["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);
|
|
@@ -33,6 +33,7 @@ var _modifiers = require("@dnd-kit/modifiers");
|
|
|
33
33
|
var _core = require("@dnd-kit/core");
|
|
34
34
|
var _sortable = require("@dnd-kit/sortable");
|
|
35
35
|
var _reactResizable = require("react-resizable");
|
|
36
|
+
var _faker = require("@faker-js/faker");
|
|
36
37
|
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); }
|
|
37
38
|
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; }
|
|
38
39
|
// import {Resizable} from "react-resizable";
|
|
@@ -153,6 +154,7 @@ const SortableHeaderCell = ({
|
|
|
153
154
|
const InternalTable = props => {
|
|
154
155
|
const {
|
|
155
156
|
t,
|
|
157
|
+
id: tableId,
|
|
156
158
|
// columns,
|
|
157
159
|
columns: propsColumns,
|
|
158
160
|
lang,
|
|
@@ -179,11 +181,37 @@ const InternalTable = props => {
|
|
|
179
181
|
commandClick,
|
|
180
182
|
commandSettings,
|
|
181
183
|
pagination,
|
|
184
|
+
height: propsHeight,
|
|
185
|
+
summary,
|
|
182
186
|
...rest
|
|
183
187
|
} = props;
|
|
188
|
+
const id = _react.default.useMemo(() => {
|
|
189
|
+
return tableId ?? _faker.faker.string.alpha(20);
|
|
190
|
+
// return tableId ?? newGuid()
|
|
191
|
+
}, [tableId]);
|
|
184
192
|
const rowKey = _react.default.useMemo(() => {
|
|
185
|
-
return
|
|
186
|
-
}, [propRowKey
|
|
193
|
+
return propRowKey ?? 'rowId';
|
|
194
|
+
}, [propRowKey]);
|
|
195
|
+
const [scrollHeight, setHeight] = (0, _react.useState)(0);
|
|
196
|
+
|
|
197
|
+
// const heightt = React.useMemo(() => {
|
|
198
|
+
//
|
|
199
|
+
// const table = document.querySelector(`#${id}`)
|
|
200
|
+
// console.log('table', table)
|
|
201
|
+
//
|
|
202
|
+
// const title: any = table?.querySelector(`.ui-rc-table-title`)
|
|
203
|
+
//
|
|
204
|
+
// console.log('title', title)
|
|
205
|
+
//
|
|
206
|
+
// if (title) {
|
|
207
|
+
// const titleHeight = title.offsetHeight;
|
|
208
|
+
// console.log('Chiều cao:', titleHeight);
|
|
209
|
+
// }
|
|
210
|
+
//
|
|
211
|
+
// return (height ?? 0) - (title ? title.offsetHeight : 0)
|
|
212
|
+
//
|
|
213
|
+
// }, [height, id])
|
|
214
|
+
|
|
187
215
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
188
216
|
const buddhistLocale = {
|
|
189
217
|
...local,
|
|
@@ -205,6 +233,19 @@ const InternalTable = props => {
|
|
|
205
233
|
return (0, _hooks.addRowIdArray)(dataSource);
|
|
206
234
|
}, [dataSource]);
|
|
207
235
|
const [columns, setColumns] = _react.default.useState([]);
|
|
236
|
+
_react.default.useEffect(() => {
|
|
237
|
+
// setTimeout(() => {
|
|
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);
|
|
247
|
+
// })
|
|
248
|
+
}, [id, propsHeight, columns]);
|
|
208
249
|
const tableRef = _react.default.useRef(null);
|
|
209
250
|
_react.default.useEffect(() => {
|
|
210
251
|
setColumns(propsColumns);
|
|
@@ -494,26 +535,46 @@ const InternalTable = props => {
|
|
|
494
535
|
if (column === SELECTION_COLUMN) {
|
|
495
536
|
return SELECTION_COLUMN;
|
|
496
537
|
}
|
|
497
|
-
|
|
538
|
+
const tmpColumn = {
|
|
539
|
+
...column,
|
|
540
|
+
dataIndex: column.field ?? column.dataIndex,
|
|
541
|
+
key: column.field ?? column.key,
|
|
542
|
+
title: /*#__PURE__*/_react.default.createElement(SortableHeaderCell, {
|
|
543
|
+
columnKey: column.field
|
|
544
|
+
}, /*#__PURE__*/_react.default.createElement(_HeaderContent.default, {
|
|
545
|
+
column: {
|
|
546
|
+
...column
|
|
547
|
+
},
|
|
548
|
+
t: t
|
|
549
|
+
})),
|
|
550
|
+
ellipsis: column.ellipsis !== false,
|
|
551
|
+
align: column.textAlign ?? column.align,
|
|
552
|
+
fixed: column.fixedType ?? column.fixed,
|
|
553
|
+
isSummary: column.isSummary ?? column.haveSum,
|
|
554
|
+
hidden: column.hidden ?? column.visible === false
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
// Xử lý đệ quy cho children
|
|
558
|
+
if (column.children?.length) {
|
|
498
559
|
return {
|
|
499
|
-
...
|
|
560
|
+
...column,
|
|
561
|
+
...tmpColumn,
|
|
562
|
+
children: transformColumns(column.children)
|
|
500
563
|
};
|
|
501
564
|
}
|
|
502
|
-
if (
|
|
565
|
+
if (find) {
|
|
503
566
|
return {
|
|
504
|
-
...
|
|
567
|
+
...find
|
|
505
568
|
};
|
|
506
569
|
}
|
|
507
|
-
|
|
508
|
-
// Xử lý đệ quy cho children
|
|
509
|
-
if (column.children?.length) {
|
|
570
|
+
if (!find) {
|
|
510
571
|
return {
|
|
511
572
|
...column,
|
|
512
|
-
|
|
573
|
+
...tmpColumn
|
|
513
574
|
};
|
|
514
575
|
}
|
|
515
576
|
});
|
|
516
|
-
}, [convertColumns]);
|
|
577
|
+
}, [convertColumns, t]);
|
|
517
578
|
const mergedColumns = _react.default.useMemo(() => {
|
|
518
579
|
return transformColumns(columns);
|
|
519
580
|
}, [columns, transformColumns]);
|
|
@@ -607,13 +668,13 @@ const InternalTable = props => {
|
|
|
607
668
|
};
|
|
608
669
|
const triggerCommandClick = args => {
|
|
609
670
|
const {
|
|
610
|
-
id,
|
|
671
|
+
id: idCommand,
|
|
611
672
|
rowId,
|
|
612
673
|
rowData,
|
|
613
674
|
index
|
|
614
675
|
} = args;
|
|
615
676
|
const tmpData = [...mergedData];
|
|
616
|
-
if (
|
|
677
|
+
if (idCommand === 'DELETE') {
|
|
617
678
|
// bật modal confirm
|
|
618
679
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
619
680
|
MySwal.fire({
|
|
@@ -699,7 +760,7 @@ const InternalTable = props => {
|
|
|
699
760
|
}
|
|
700
761
|
if (commandClick) {
|
|
701
762
|
commandClick({
|
|
702
|
-
id,
|
|
763
|
+
id: idCommand,
|
|
703
764
|
rowId,
|
|
704
765
|
rowData,
|
|
705
766
|
index,
|
|
@@ -710,7 +771,7 @@ const InternalTable = props => {
|
|
|
710
771
|
// server
|
|
711
772
|
if (commandClick) {
|
|
712
773
|
commandClick({
|
|
713
|
-
id,
|
|
774
|
+
id: idCommand,
|
|
714
775
|
rowId,
|
|
715
776
|
rowData,
|
|
716
777
|
index,
|
|
@@ -771,6 +832,7 @@ const InternalTable = props => {
|
|
|
771
832
|
value: dragIndex
|
|
772
833
|
}, /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
773
834
|
t: t,
|
|
835
|
+
id: id,
|
|
774
836
|
locale: locale,
|
|
775
837
|
tableRef: tableRef,
|
|
776
838
|
dataSource: mergedData,
|
|
@@ -790,7 +852,17 @@ const InternalTable = props => {
|
|
|
790
852
|
groupAble: groupAble,
|
|
791
853
|
groupColumns: groupColumns,
|
|
792
854
|
commandClick: triggerCommandClick,
|
|
793
|
-
|
|
855
|
+
summary: summary,
|
|
856
|
+
pagination: pagination
|
|
857
|
+
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
858
|
+
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
859
|
+
,
|
|
860
|
+
scroll: {
|
|
861
|
+
y: scrollHeight - (summary ? 0 : 0)
|
|
862
|
+
} // scroll height auto, không quá 600
|
|
863
|
+
,
|
|
864
|
+
height: propsHeight,
|
|
865
|
+
scrollHeight: scrollHeight,
|
|
794
866
|
components: {
|
|
795
867
|
header: {
|
|
796
868
|
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;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderClass = void 0;
|
|
7
|
+
exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderPasteClass = exports.addBorderClass = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
9
|
exports.addRowsUp = addRowsUp;
|
|
10
10
|
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
|
|
@@ -16,6 +16,7 @@ exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
|
16
16
|
exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
|
|
17
17
|
exports.getBottomRowCells = getBottomRowCells;
|
|
18
18
|
exports.getCellsByPosition = getCellsByPosition;
|
|
19
|
+
exports.getCellsByPosition2 = getCellsByPosition2;
|
|
19
20
|
exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
|
|
20
21
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
21
22
|
exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
@@ -28,7 +29,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
|
28
29
|
exports.isEqualSet = isEqualSet;
|
|
29
30
|
exports.isRangeCell = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
|
|
30
31
|
exports.isRightMostInRegion = isRightMostInRegion;
|
|
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.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
32
|
+
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.removeBorderPasteClass = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
32
33
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
34
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
34
35
|
var _uuid = require("uuid");
|
|
@@ -1565,6 +1566,61 @@ function getBottomRowCells(cellSet) {
|
|
|
1565
1566
|
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1566
1567
|
}
|
|
1567
1568
|
function getCellsByPosition(cellSet, position = "bottom") {
|
|
1569
|
+
const cells = Array.from(cellSet).map(key => {
|
|
1570
|
+
const [row, col] = key.split("-").map(Number);
|
|
1571
|
+
return {
|
|
1572
|
+
row,
|
|
1573
|
+
col,
|
|
1574
|
+
key
|
|
1575
|
+
};
|
|
1576
|
+
});
|
|
1577
|
+
switch (position) {
|
|
1578
|
+
case "top":
|
|
1579
|
+
{
|
|
1580
|
+
// const minRow = Math.min(...cells.map(c => c.row));
|
|
1581
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1582
|
+
|
|
1583
|
+
// const rows = cells.map(c => c.row).filter(r => r > 0);
|
|
1584
|
+
// if (rows.length === 0) return [];
|
|
1585
|
+
// const minRow = Math.min(...rows);
|
|
1586
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1587
|
+
|
|
1588
|
+
const minRow = Math.min(...cells.map(c => c.row));
|
|
1589
|
+
if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
|
|
1590
|
+
|
|
1591
|
+
return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
|
|
1592
|
+
}
|
|
1593
|
+
case "bottom":
|
|
1594
|
+
{
|
|
1595
|
+
const maxRow = Math.max(...cells.map(c => c.row));
|
|
1596
|
+
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1597
|
+
}
|
|
1598
|
+
case "left":
|
|
1599
|
+
{
|
|
1600
|
+
// const minCol = Math.min(...cells.map(c => c.col));
|
|
1601
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1602
|
+
|
|
1603
|
+
// const cols = cells.map(c => c.col).filter(c => c > 0);
|
|
1604
|
+
// if (cols.length === 0) return [];
|
|
1605
|
+
// const minCol = Math.min(...cols);
|
|
1606
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1607
|
+
|
|
1608
|
+
const minCol = Math.min(...cells.map(c => c.col));
|
|
1609
|
+
if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
|
|
1610
|
+
|
|
1611
|
+
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1612
|
+
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
|
|
1613
|
+
}
|
|
1614
|
+
case "right":
|
|
1615
|
+
{
|
|
1616
|
+
const maxCol = Math.max(...cells.map(c => c.col));
|
|
1617
|
+
return cells.filter(c => c.col === maxCol).map(c => c.key);
|
|
1618
|
+
}
|
|
1619
|
+
default:
|
|
1620
|
+
return [];
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
function getCellsByPosition2(cellSet, position = "bottom") {
|
|
1568
1624
|
const cells = Array.from(cellSet).map(key => {
|
|
1569
1625
|
const [row, col] = key.split("-").map(Number);
|
|
1570
1626
|
return {
|
|
@@ -1635,25 +1691,34 @@ const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
|
1635
1691
|
}
|
|
1636
1692
|
});
|
|
1637
1693
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1694
|
+
|
|
1695
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1696
|
+
|
|
1697
|
+
// if (type === 'left') {
|
|
1698
|
+
//
|
|
1699
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1700
|
+
// const [row, col] = pos.split('-');
|
|
1701
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1702
|
+
// });
|
|
1703
|
+
//
|
|
1704
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1705
|
+
//
|
|
1706
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1707
|
+
//
|
|
1708
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1709
|
+
//
|
|
1710
|
+
// cellsFilter2.forEach(cell => {
|
|
1711
|
+
// // cell.classList.add('has-before');
|
|
1712
|
+
// cell.classList.add('cell-border-left');
|
|
1713
|
+
// });
|
|
1714
|
+
// }
|
|
1715
|
+
//
|
|
1716
|
+
// }
|
|
1652
1717
|
};
|
|
1653
1718
|
exports.addBorderClass = addBorderClass;
|
|
1654
1719
|
const removeBorderClass = (selectedCells, type, className, id) => {
|
|
1655
1720
|
const table = document.querySelector(`#${id}`);
|
|
1656
|
-
const typeCells =
|
|
1721
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1657
1722
|
const selectorsCells = typeCells.map(pos => {
|
|
1658
1723
|
const [row, col] = pos.split('-');
|
|
1659
1724
|
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
@@ -1666,6 +1731,62 @@ const removeBorderClass = (selectedCells, type, className, id) => {
|
|
|
1666
1731
|
}
|
|
1667
1732
|
};
|
|
1668
1733
|
exports.removeBorderClass = removeBorderClass;
|
|
1734
|
+
const addBorderPasteClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
1735
|
+
const table = document.querySelector(`#${id}`);
|
|
1736
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1737
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1738
|
+
const [row, col] = pos.split('-');
|
|
1739
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1740
|
+
});
|
|
1741
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1742
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1743
|
+
cellsFilter.forEach(cell => {
|
|
1744
|
+
cell.classList.add(className);
|
|
1745
|
+
if (nextCellRight) {
|
|
1746
|
+
cell.style.zIndex = 1;
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1752
|
+
|
|
1753
|
+
// if (type === 'left') {
|
|
1754
|
+
//
|
|
1755
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1756
|
+
// const [row, col] = pos.split('-');
|
|
1757
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1758
|
+
// });
|
|
1759
|
+
//
|
|
1760
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1761
|
+
//
|
|
1762
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1763
|
+
//
|
|
1764
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1765
|
+
//
|
|
1766
|
+
// cellsFilter2.forEach(cell => {
|
|
1767
|
+
// // cell.classList.add('has-before');
|
|
1768
|
+
// cell.classList.add('cell-border-left');
|
|
1769
|
+
// });
|
|
1770
|
+
// }
|
|
1771
|
+
//
|
|
1772
|
+
// }
|
|
1773
|
+
};
|
|
1774
|
+
exports.addBorderPasteClass = addBorderPasteClass;
|
|
1775
|
+
const removeBorderPasteClass = (selectedCells, type, className, id) => {
|
|
1776
|
+
const table = document.querySelector(`#${id}`);
|
|
1777
|
+
const typeCells = getCellsByPosition(selectedCells, type);
|
|
1778
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1779
|
+
const [row, col] = pos.split('-');
|
|
1780
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1781
|
+
});
|
|
1782
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1783
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1784
|
+
cellsFilter.forEach(cell => {
|
|
1785
|
+
cell.classList.remove(className);
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
exports.removeBorderPasteClass = removeBorderPasteClass;
|
|
1669
1790
|
const removeBorderClass2 = (className, id) => {
|
|
1670
1791
|
const table = document.querySelector(`#${id}`);
|
|
1671
1792
|
const cellsFilter = table ? table?.querySelectorAll(`.ui-rc-table-cell.${className}`) : null;
|
|
@@ -1800,9 +1921,7 @@ const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1800
1921
|
const col = getLastSelectCell(selectedCells).col;
|
|
1801
1922
|
const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
|
|
1802
1923
|
const nextCellLeft = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`);
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
console.log('nextCell', nextCellLeft);
|
|
1924
|
+
const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
|
|
1806
1925
|
if (cell) {
|
|
1807
1926
|
cell.style.zIndex = nextCellLeft ? 3 : 1;
|
|
1808
1927
|
}
|
|
@@ -1817,7 +1936,7 @@ const onAddBorderSelectedCell = (selectedCells, id) => {
|
|
|
1817
1936
|
// thêm class border selected
|
|
1818
1937
|
|
|
1819
1938
|
addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
|
|
1820
|
-
addBorderClass(selectedCells, 'right', 'cell-border-right', id);
|
|
1939
|
+
addBorderClass(selectedCells, 'right', 'cell-border-right', id, !!nextCellRight);
|
|
1821
1940
|
addBorderClass(selectedCells, 'top', 'cell-border-top', id);
|
|
1822
1941
|
addBorderClass(selectedCells, 'left', 'cell-border-left', id);
|
|
1823
1942
|
};
|
|
@@ -1848,13 +1967,13 @@ exports.onRemoveBorderSelectedCell = onRemoveBorderSelectedCell;
|
|
|
1848
1967
|
const addClassBorderPasteCell = (pasteCells, type, id) => {
|
|
1849
1968
|
// thêm class border
|
|
1850
1969
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1970
|
+
addBorderPasteClass(pasteCells, 'right', 'cell-paste-border-right', id);
|
|
1971
|
+
addBorderPasteClass(pasteCells, 'left', 'cell-paste-border-left', id);
|
|
1853
1972
|
if (type === 'up') {
|
|
1854
|
-
|
|
1973
|
+
addBorderPasteClass(pasteCells, 'top', 'cell-paste-border-top', id);
|
|
1855
1974
|
}
|
|
1856
1975
|
if (type === 'down') {
|
|
1857
|
-
|
|
1976
|
+
addBorderPasteClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
|
|
1858
1977
|
}
|
|
1859
1978
|
};
|
|
1860
1979
|
exports.addClassBorderPasteCell = addClassBorderPasteCell;
|