es-grid-template 1.8.82 → 1.8.83
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/group-component/body/EditableCell.js +4 -4
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/group-component/table/Grid.js +5 -1
- package/es/group-component/table/TableWrapper.js +33 -18
- package/es/table-component/ContextMenu.js +3 -1
- package/es/table-component/TableContainer.js +2 -3
- package/es/table-component/TableContainerEdit.js +1 -2
- package/es/table-component/body/EditableCell.js +4 -4
- package/es/table-component/table/Grid.js +5 -1
- package/es/table-component/table/TableWrapper.js +35 -18
- package/es/table-virtuoso/table/TableContainer.js +1 -2
- package/es/table-virtuoso/table/TableWrapper.js +0 -12
- package/lib/group-component/body/EditableCell.js +4 -4
- package/lib/group-component/table/Grid.js +5 -1
- package/lib/group-component/table/TableWrapper.js +33 -18
- package/lib/table-component/ContextMenu.js +3 -1
- package/lib/table-component/TableContainer.js +2 -3
- package/lib/table-component/TableContainerEdit.js +1 -2
- package/lib/table-component/body/EditableCell.js +4 -4
- package/lib/table-component/table/Grid.js +5 -1
- package/lib/table-component/table/TableWrapper.js +35 -18
- package/lib/table-virtuoso/table/TableContainer.js +1 -2
- package/lib/table-virtuoso/table/TableWrapper.js +0 -8
- package/package.json +2 -2
- package/es/group-component/ContextMenu.d.ts +0 -19
- package/es/group-component/ContextMenu.js +0 -74
- package/lib/group-component/ContextMenu.d.ts +0 -19
- package/lib/group-component/ContextMenu.js +0 -83
|
@@ -364,7 +364,7 @@ const EditableCell = props => {
|
|
|
364
364
|
columns: columnsTable,
|
|
365
365
|
options: options,
|
|
366
366
|
defaultOptions: options,
|
|
367
|
-
value: valueSelectTable
|
|
367
|
+
value: valueSelectTable ?? undefined,
|
|
368
368
|
rowData: record,
|
|
369
369
|
autoDestroy: true,
|
|
370
370
|
onChange: (val, option) => {
|
|
@@ -461,7 +461,7 @@ const EditableCell = props => {
|
|
|
461
461
|
}
|
|
462
462
|
return /*#__PURE__*/React.createElement(Select, {
|
|
463
463
|
options: options,
|
|
464
|
-
value: valueSelect
|
|
464
|
+
value: valueSelect ?? undefined,
|
|
465
465
|
onChange: (val, option) => {
|
|
466
466
|
onChange(val ?? '');
|
|
467
467
|
const formState = getValues();
|
|
@@ -541,7 +541,7 @@ const EditableCell = props => {
|
|
|
541
541
|
return /*#__PURE__*/React.createElement(AsyncSelect, {
|
|
542
542
|
options: options,
|
|
543
543
|
defaultOptions: options,
|
|
544
|
-
value: valueAsyncSelect
|
|
544
|
+
value: valueAsyncSelect ?? undefined,
|
|
545
545
|
onChange: (val, option) => {
|
|
546
546
|
onChange(val ?? '');
|
|
547
547
|
const formState = getValues();
|
|
@@ -677,7 +677,7 @@ const EditableCell = props => {
|
|
|
677
677
|
width: '100%',
|
|
678
678
|
height: '100%'
|
|
679
679
|
},
|
|
680
|
-
value: valueTreeSelect
|
|
680
|
+
value: valueTreeSelect ?? undefined,
|
|
681
681
|
dropdownStyle: {
|
|
682
682
|
maxHeight: 400,
|
|
683
683
|
overflow: 'auto'
|
|
@@ -212,9 +212,9 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
212
212
|
ellipsis?: boolean;
|
|
213
213
|
allowResizing?: boolean;
|
|
214
214
|
allowSelection?: boolean | ((rowData: RecordType) => boolean);
|
|
215
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
216
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
217
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
215
|
+
onCellStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
|
|
216
|
+
onCellHeaderStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
|
|
217
|
+
onCellFooterStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
|
|
218
218
|
sumGroup?: boolean;
|
|
219
219
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
220
220
|
}[];
|
|
@@ -381,7 +381,11 @@ const Grid = props => {
|
|
|
381
381
|
zIndex: 1050
|
|
382
382
|
}
|
|
383
383
|
},
|
|
384
|
-
title: /*#__PURE__*/React.createElement(
|
|
384
|
+
title: /*#__PURE__*/React.createElement("div", {
|
|
385
|
+
style: {
|
|
386
|
+
minHeight: 24
|
|
387
|
+
}
|
|
388
|
+
}, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
385
389
|
destroyOnClose: true
|
|
386
390
|
}, /*#__PURE__*/React.createElement("div", {
|
|
387
391
|
style: {}
|
|
@@ -4,9 +4,9 @@ import TableBody from "../body/TableBody";
|
|
|
4
4
|
import TableFooter from "../footer/TableFooter";
|
|
5
5
|
import ComponentSpinner from "../../grid-component/LoadingSpinner";
|
|
6
6
|
import { Tooltip } from "react-tooltip";
|
|
7
|
-
import ContextMenu from "../ContextMenu";
|
|
8
7
|
import React, { useContext } from "react";
|
|
9
8
|
import { TableContext } from "../useContext";
|
|
9
|
+
import ContextMenu from "../../table-component/ContextMenu";
|
|
10
10
|
const TableWrapper = props => {
|
|
11
11
|
const {
|
|
12
12
|
id,
|
|
@@ -146,24 +146,39 @@ const TableWrapper = props => {
|
|
|
146
146
|
y
|
|
147
147
|
}));
|
|
148
148
|
}, 100);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
149
|
+
|
|
150
|
+
// if (!menuVisible) {
|
|
151
|
+
// document.addEventListener(`click`, function onClickOutside(e) {
|
|
152
|
+
// const element: any = e.target
|
|
153
|
+
// const menuContainer = document.querySelector('.popup-context-menu')
|
|
154
|
+
|
|
155
|
+
// const isInsideContainer = element.closest('.popup-context-menu') && menuContainer
|
|
156
|
+
|
|
157
|
+
// if (isInsideContainer) {
|
|
158
|
+
// return
|
|
159
|
+
// }
|
|
160
|
+
// setMenuVisible(false)
|
|
161
|
+
// setPosition(prevState => ({ ...prevState, x: undefined, y: undefined }))
|
|
162
|
+
// document.removeEventListener(`click`, onClickOutside)
|
|
163
|
+
// })
|
|
164
|
+
// }
|
|
166
165
|
};
|
|
166
|
+
React.useEffect(() => {
|
|
167
|
+
const handleClickOutside = event => {
|
|
168
|
+
const element = event.target;
|
|
169
|
+
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
170
|
+
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
171
|
+
if (isInsideContainerContext) {
|
|
172
|
+
return;
|
|
173
|
+
} else {
|
|
174
|
+
setMenuVisible(false);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
178
|
+
return () => {
|
|
179
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
180
|
+
};
|
|
181
|
+
}, []);
|
|
167
182
|
return /*#__PURE__*/React.createElement("div", {
|
|
168
183
|
style: {
|
|
169
184
|
position: 'relative'
|
|
@@ -212,8 +212,7 @@ const TableContainer = props => {
|
|
|
212
212
|
style: {
|
|
213
213
|
display: 'flex',
|
|
214
214
|
justifyContent: 'space-between',
|
|
215
|
-
alignItems: 'center'
|
|
216
|
-
gap: '.75rem'
|
|
215
|
+
alignItems: 'center'
|
|
217
216
|
}
|
|
218
217
|
}, /*#__PURE__*/React.createElement("div", {
|
|
219
218
|
style: {
|
|
@@ -228,7 +227,7 @@ const TableContainer = props => {
|
|
|
228
227
|
display: 'flex',
|
|
229
228
|
justifyContent: 'space-between',
|
|
230
229
|
alignItems: 'center',
|
|
231
|
-
gap: '.
|
|
230
|
+
gap: '.25rem'
|
|
232
231
|
}
|
|
233
232
|
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
234
233
|
showSizeChanger: true,
|
|
@@ -1631,8 +1631,7 @@ const TableContainerEdit = props => {
|
|
|
1631
1631
|
style: {
|
|
1632
1632
|
display: 'flex',
|
|
1633
1633
|
justifyContent: 'space-between',
|
|
1634
|
-
alignItems: 'center'
|
|
1635
|
-
gap: '.75rem'
|
|
1634
|
+
alignItems: 'center'
|
|
1636
1635
|
}
|
|
1637
1636
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1638
1637
|
style: {
|
|
@@ -350,7 +350,7 @@ const EditableCell = props => {
|
|
|
350
350
|
columns: columnsTable,
|
|
351
351
|
options: options,
|
|
352
352
|
defaultOptions: options,
|
|
353
|
-
value: valueSelectTable
|
|
353
|
+
value: valueSelectTable ?? undefined,
|
|
354
354
|
rowData: record,
|
|
355
355
|
autoDestroy: true,
|
|
356
356
|
onChange: (val, option) => {
|
|
@@ -447,7 +447,7 @@ const EditableCell = props => {
|
|
|
447
447
|
}
|
|
448
448
|
return /*#__PURE__*/React.createElement(Select, {
|
|
449
449
|
options: options,
|
|
450
|
-
value: valueSelect
|
|
450
|
+
value: valueSelect ?? undefined,
|
|
451
451
|
onChange: (val, option) => {
|
|
452
452
|
onChange(val ?? '');
|
|
453
453
|
const formState = getValues();
|
|
@@ -527,7 +527,7 @@ const EditableCell = props => {
|
|
|
527
527
|
return /*#__PURE__*/React.createElement(AsyncSelect, {
|
|
528
528
|
options: options,
|
|
529
529
|
defaultOptions: options,
|
|
530
|
-
value: valueAsyncSelect
|
|
530
|
+
value: valueAsyncSelect ?? undefined,
|
|
531
531
|
onChange: (val, option) => {
|
|
532
532
|
onChange(val ?? '');
|
|
533
533
|
const formState = getValues();
|
|
@@ -651,7 +651,7 @@ const EditableCell = props => {
|
|
|
651
651
|
width: '100%',
|
|
652
652
|
height: '100%'
|
|
653
653
|
},
|
|
654
|
-
value: valueTreeSelect,
|
|
654
|
+
value: valueTreeSelect ?? undefined,
|
|
655
655
|
dropdownStyle: {
|
|
656
656
|
maxHeight: 400,
|
|
657
657
|
overflow: 'auto'
|
|
@@ -334,7 +334,11 @@ const Grid = props => {
|
|
|
334
334
|
zIndex: 1050
|
|
335
335
|
}
|
|
336
336
|
},
|
|
337
|
-
title: /*#__PURE__*/React.createElement(
|
|
337
|
+
title: /*#__PURE__*/React.createElement("div", {
|
|
338
|
+
style: {
|
|
339
|
+
minHeight: 24
|
|
340
|
+
}
|
|
341
|
+
}, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
338
342
|
destroyOnClose: true
|
|
339
343
|
}, /*#__PURE__*/React.createElement("div", {
|
|
340
344
|
style: {}
|
|
@@ -124,10 +124,10 @@ const TableWrapper = props => {
|
|
|
124
124
|
},
|
|
125
125
|
event
|
|
126
126
|
});
|
|
127
|
-
setMenuVisible(true);
|
|
128
127
|
|
|
129
128
|
// Đợi DOM cập nhật và lấy kích thước menu
|
|
130
129
|
setTimeout(() => {
|
|
130
|
+
setMenuVisible(true);
|
|
131
131
|
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
132
132
|
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
133
133
|
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
@@ -151,24 +151,41 @@ const TableWrapper = props => {
|
|
|
151
151
|
y
|
|
152
152
|
}));
|
|
153
153
|
}, 100);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
154
|
+
|
|
155
|
+
// if (!menuVisible) {
|
|
156
|
+
|
|
157
|
+
// document.addEventListener(`click`, function onClickOutside(e) {
|
|
158
|
+
// const element: any = e.target
|
|
159
|
+
// const menuContainer = document.querySelector('.popup-context-menu')
|
|
160
|
+
|
|
161
|
+
// const isInsideContainer = element.closest('.popup-context-menu') && menuContainer
|
|
162
|
+
|
|
163
|
+
// if (isInsideContainer) {
|
|
164
|
+
// return
|
|
165
|
+
// }
|
|
166
|
+
// setMenuVisible(false)
|
|
167
|
+
// setPosition(prevState => ({ ...prevState, x: undefined, y: undefined }))
|
|
168
|
+
// document.removeEventListener(`click`, onClickOutside)
|
|
169
|
+
// })
|
|
170
|
+
|
|
171
|
+
// }
|
|
171
172
|
};
|
|
173
|
+
React.useEffect(() => {
|
|
174
|
+
const handleClickOutside = event => {
|
|
175
|
+
const element = event.target;
|
|
176
|
+
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
177
|
+
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
178
|
+
if (isInsideContainerContext) {
|
|
179
|
+
return;
|
|
180
|
+
} else {
|
|
181
|
+
setMenuVisible(false);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
185
|
+
return () => {
|
|
186
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
172
189
|
return /*#__PURE__*/React.createElement("div", {
|
|
173
190
|
style: {
|
|
174
191
|
position: 'relative'
|
|
@@ -171,8 +171,7 @@ const TableContainer = props => {
|
|
|
171
171
|
style: {
|
|
172
172
|
display: 'flex',
|
|
173
173
|
justifyContent: 'space-between',
|
|
174
|
-
alignItems: 'center'
|
|
175
|
-
gap: '.75rem'
|
|
174
|
+
alignItems: 'center'
|
|
176
175
|
}
|
|
177
176
|
}, groupToolbar(), /*#__PURE__*/React.createElement("div", {
|
|
178
177
|
style: {
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
3
|
-
|
|
4
|
-
// import type { Dispatch, SetStateAction } from 'react';
|
|
5
3
|
import React, { useContext, useRef } from 'react';
|
|
6
4
|
import { TableVirtuoso } from "react-virtuoso";
|
|
7
|
-
import "@tanstack/react-table"; // useReactTable,
|
|
8
|
-
// getCoreRowModel,
|
|
9
|
-
// flexRender,
|
|
10
|
-
// getGroupedRowModel,
|
|
11
|
-
// getExpandedRowModel
|
|
12
5
|
import TableHeadCell from "../header/TableHeadCell";
|
|
13
6
|
import { TableContext } from "../useContext";
|
|
14
7
|
import classNames from 'classnames';
|
|
@@ -16,10 +9,6 @@ import TableBodyRow from "../body/TableBodyRow";
|
|
|
16
9
|
import TableFooterCell from "../footer/TableFooterCell";
|
|
17
10
|
import { Tooltip } from 'react-tooltip';
|
|
18
11
|
import ContextMenu from "../../table-component/ContextMenu";
|
|
19
|
-
// import type { ColumnsTable, TableProps } from '../type';
|
|
20
|
-
|
|
21
|
-
// type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
22
|
-
|
|
23
12
|
const TableWrapper = props => {
|
|
24
13
|
const {
|
|
25
14
|
table,
|
|
@@ -39,7 +28,6 @@ const TableWrapper = props => {
|
|
|
39
28
|
rowEditable,
|
|
40
29
|
windowSize
|
|
41
30
|
} = useContext(TableContext); //onRowHeaderStyles
|
|
42
|
-
// const { windowSize } = useContext(TableContext)
|
|
43
31
|
|
|
44
32
|
// ref cho scroll container
|
|
45
33
|
const scrollRef = useRef(null);
|
|
@@ -372,7 +372,7 @@ const EditableCell = props => {
|
|
|
372
372
|
columns: columnsTable,
|
|
373
373
|
options: options,
|
|
374
374
|
defaultOptions: options,
|
|
375
|
-
value: valueSelectTable
|
|
375
|
+
value: valueSelectTable ?? undefined,
|
|
376
376
|
rowData: record,
|
|
377
377
|
autoDestroy: true,
|
|
378
378
|
onChange: (val, option) => {
|
|
@@ -469,7 +469,7 @@ const EditableCell = props => {
|
|
|
469
469
|
}
|
|
470
470
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
471
471
|
options: options,
|
|
472
|
-
value: valueSelect
|
|
472
|
+
value: valueSelect ?? undefined,
|
|
473
473
|
onChange: (val, option) => {
|
|
474
474
|
onChange(val ?? '');
|
|
475
475
|
const formState = getValues();
|
|
@@ -549,7 +549,7 @@ const EditableCell = props => {
|
|
|
549
549
|
return /*#__PURE__*/_react.default.createElement(_asyncSelect.AsyncSelect, {
|
|
550
550
|
options: options,
|
|
551
551
|
defaultOptions: options,
|
|
552
|
-
value: valueAsyncSelect
|
|
552
|
+
value: valueAsyncSelect ?? undefined,
|
|
553
553
|
onChange: (val, option) => {
|
|
554
554
|
onChange(val ?? '');
|
|
555
555
|
const formState = getValues();
|
|
@@ -685,7 +685,7 @@ const EditableCell = props => {
|
|
|
685
685
|
width: '100%',
|
|
686
686
|
height: '100%'
|
|
687
687
|
},
|
|
688
|
-
value: valueTreeSelect
|
|
688
|
+
value: valueTreeSelect ?? undefined,
|
|
689
689
|
dropdownStyle: {
|
|
690
690
|
maxHeight: 400,
|
|
691
691
|
overflow: 'auto'
|
|
@@ -387,7 +387,11 @@ const Grid = props => {
|
|
|
387
387
|
zIndex: 1050
|
|
388
388
|
}
|
|
389
389
|
},
|
|
390
|
-
title: /*#__PURE__*/_react.default.createElement(
|
|
390
|
+
title: /*#__PURE__*/_react.default.createElement("div", {
|
|
391
|
+
style: {
|
|
392
|
+
minHeight: 24
|
|
393
|
+
}
|
|
394
|
+
}, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
391
395
|
destroyOnClose: true
|
|
392
396
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
393
397
|
style: {}
|
|
@@ -11,9 +11,9 @@ var _TableBody = _interopRequireDefault(require("../body/TableBody"));
|
|
|
11
11
|
var _TableFooter = _interopRequireDefault(require("../footer/TableFooter"));
|
|
12
12
|
var _LoadingSpinner = _interopRequireDefault(require("../../grid-component/LoadingSpinner"));
|
|
13
13
|
var _reactTooltip = require("react-tooltip");
|
|
14
|
-
var _ContextMenu = _interopRequireDefault(require("../ContextMenu"));
|
|
15
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
15
|
var _useContext = require("../useContext");
|
|
16
|
+
var _ContextMenu = _interopRequireDefault(require("../../table-component/ContextMenu"));
|
|
17
17
|
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); }
|
|
18
18
|
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; }
|
|
19
19
|
const TableWrapper = props => {
|
|
@@ -155,24 +155,39 @@ const TableWrapper = props => {
|
|
|
155
155
|
y
|
|
156
156
|
}));
|
|
157
157
|
}, 100);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
158
|
+
|
|
159
|
+
// if (!menuVisible) {
|
|
160
|
+
// document.addEventListener(`click`, function onClickOutside(e) {
|
|
161
|
+
// const element: any = e.target
|
|
162
|
+
// const menuContainer = document.querySelector('.popup-context-menu')
|
|
163
|
+
|
|
164
|
+
// const isInsideContainer = element.closest('.popup-context-menu') && menuContainer
|
|
165
|
+
|
|
166
|
+
// if (isInsideContainer) {
|
|
167
|
+
// return
|
|
168
|
+
// }
|
|
169
|
+
// setMenuVisible(false)
|
|
170
|
+
// setPosition(prevState => ({ ...prevState, x: undefined, y: undefined }))
|
|
171
|
+
// document.removeEventListener(`click`, onClickOutside)
|
|
172
|
+
// })
|
|
173
|
+
// }
|
|
175
174
|
};
|
|
175
|
+
_react.default.useEffect(() => {
|
|
176
|
+
const handleClickOutside = event => {
|
|
177
|
+
const element = event.target;
|
|
178
|
+
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
179
|
+
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
180
|
+
if (isInsideContainerContext) {
|
|
181
|
+
return;
|
|
182
|
+
} else {
|
|
183
|
+
setMenuVisible(false);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
187
|
+
return () => {
|
|
188
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
189
|
+
};
|
|
190
|
+
}, []);
|
|
176
191
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
177
192
|
style: {
|
|
178
193
|
position: 'relative'
|
|
@@ -219,8 +219,7 @@ const TableContainer = props => {
|
|
|
219
219
|
style: {
|
|
220
220
|
display: 'flex',
|
|
221
221
|
justifyContent: 'space-between',
|
|
222
|
-
alignItems: 'center'
|
|
223
|
-
gap: '.75rem'
|
|
222
|
+
alignItems: 'center'
|
|
224
223
|
}
|
|
225
224
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
226
225
|
style: {
|
|
@@ -235,7 +234,7 @@ const TableContainer = props => {
|
|
|
235
234
|
display: 'flex',
|
|
236
235
|
justifyContent: 'space-between',
|
|
237
236
|
alignItems: 'center',
|
|
238
|
-
gap: '.
|
|
237
|
+
gap: '.25rem'
|
|
239
238
|
}
|
|
240
239
|
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
241
240
|
showSizeChanger: true,
|
|
@@ -1638,8 +1638,7 @@ const TableContainerEdit = props => {
|
|
|
1638
1638
|
style: {
|
|
1639
1639
|
display: 'flex',
|
|
1640
1640
|
justifyContent: 'space-between',
|
|
1641
|
-
alignItems: 'center'
|
|
1642
|
-
gap: '.75rem'
|
|
1641
|
+
alignItems: 'center'
|
|
1643
1642
|
}
|
|
1644
1643
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1645
1644
|
style: {
|
|
@@ -358,7 +358,7 @@ const EditableCell = props => {
|
|
|
358
358
|
columns: columnsTable,
|
|
359
359
|
options: options,
|
|
360
360
|
defaultOptions: options,
|
|
361
|
-
value: valueSelectTable
|
|
361
|
+
value: valueSelectTable ?? undefined,
|
|
362
362
|
rowData: record,
|
|
363
363
|
autoDestroy: true,
|
|
364
364
|
onChange: (val, option) => {
|
|
@@ -455,7 +455,7 @@ const EditableCell = props => {
|
|
|
455
455
|
}
|
|
456
456
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
457
457
|
options: options,
|
|
458
|
-
value: valueSelect
|
|
458
|
+
value: valueSelect ?? undefined,
|
|
459
459
|
onChange: (val, option) => {
|
|
460
460
|
onChange(val ?? '');
|
|
461
461
|
const formState = getValues();
|
|
@@ -535,7 +535,7 @@ const EditableCell = props => {
|
|
|
535
535
|
return /*#__PURE__*/_react.default.createElement(_asyncSelect.AsyncSelect, {
|
|
536
536
|
options: options,
|
|
537
537
|
defaultOptions: options,
|
|
538
|
-
value: valueAsyncSelect
|
|
538
|
+
value: valueAsyncSelect ?? undefined,
|
|
539
539
|
onChange: (val, option) => {
|
|
540
540
|
onChange(val ?? '');
|
|
541
541
|
const formState = getValues();
|
|
@@ -659,7 +659,7 @@ const EditableCell = props => {
|
|
|
659
659
|
width: '100%',
|
|
660
660
|
height: '100%'
|
|
661
661
|
},
|
|
662
|
-
value: valueTreeSelect,
|
|
662
|
+
value: valueTreeSelect ?? undefined,
|
|
663
663
|
dropdownStyle: {
|
|
664
664
|
maxHeight: 400,
|
|
665
665
|
overflow: 'auto'
|
|
@@ -339,7 +339,11 @@ const Grid = props => {
|
|
|
339
339
|
zIndex: 1050
|
|
340
340
|
}
|
|
341
341
|
},
|
|
342
|
-
title: /*#__PURE__*/_react.default.createElement(
|
|
342
|
+
title: /*#__PURE__*/_react.default.createElement("div", {
|
|
343
|
+
style: {
|
|
344
|
+
minHeight: 24
|
|
345
|
+
}
|
|
346
|
+
}, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
343
347
|
destroyOnClose: true
|
|
344
348
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
345
349
|
style: {}
|
|
@@ -133,10 +133,10 @@ const TableWrapper = props => {
|
|
|
133
133
|
},
|
|
134
134
|
event
|
|
135
135
|
});
|
|
136
|
-
setMenuVisible(true);
|
|
137
136
|
|
|
138
137
|
// Đợi DOM cập nhật và lấy kích thước menu
|
|
139
138
|
setTimeout(() => {
|
|
139
|
+
setMenuVisible(true);
|
|
140
140
|
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
141
141
|
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
142
142
|
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
@@ -160,24 +160,41 @@ const TableWrapper = props => {
|
|
|
160
160
|
y
|
|
161
161
|
}));
|
|
162
162
|
}, 100);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
|
|
164
|
+
// if (!menuVisible) {
|
|
165
|
+
|
|
166
|
+
// document.addEventListener(`click`, function onClickOutside(e) {
|
|
167
|
+
// const element: any = e.target
|
|
168
|
+
// const menuContainer = document.querySelector('.popup-context-menu')
|
|
169
|
+
|
|
170
|
+
// const isInsideContainer = element.closest('.popup-context-menu') && menuContainer
|
|
171
|
+
|
|
172
|
+
// if (isInsideContainer) {
|
|
173
|
+
// return
|
|
174
|
+
// }
|
|
175
|
+
// setMenuVisible(false)
|
|
176
|
+
// setPosition(prevState => ({ ...prevState, x: undefined, y: undefined }))
|
|
177
|
+
// document.removeEventListener(`click`, onClickOutside)
|
|
178
|
+
// })
|
|
179
|
+
|
|
180
|
+
// }
|
|
180
181
|
};
|
|
182
|
+
_react.default.useEffect(() => {
|
|
183
|
+
const handleClickOutside = event => {
|
|
184
|
+
const element = event.target;
|
|
185
|
+
const containerContextMenu = document.querySelector(".popup-context-menu");
|
|
186
|
+
const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
|
|
187
|
+
if (isInsideContainerContext) {
|
|
188
|
+
return;
|
|
189
|
+
} else {
|
|
190
|
+
setMenuVisible(false);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
194
|
+
return () => {
|
|
195
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
196
|
+
};
|
|
197
|
+
}, []);
|
|
181
198
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
182
199
|
style: {
|
|
183
200
|
position: 'relative'
|
|
@@ -179,8 +179,7 @@ const TableContainer = props => {
|
|
|
179
179
|
style: {
|
|
180
180
|
display: 'flex',
|
|
181
181
|
justifyContent: 'space-between',
|
|
182
|
-
alignItems: 'center'
|
|
183
|
-
gap: '.75rem'
|
|
182
|
+
alignItems: 'center'
|
|
184
183
|
}
|
|
185
184
|
}, groupToolbar(), /*#__PURE__*/_react.default.createElement("div", {
|
|
186
185
|
style: {
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _reactVirtuoso = require("react-virtuoso");
|
|
11
|
-
require("@tanstack/react-table");
|
|
12
11
|
var _TableHeadCell = _interopRequireDefault(require("../header/TableHeadCell"));
|
|
13
12
|
var _useContext = require("../useContext");
|
|
14
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -20,12 +19,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
20
19
|
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; }
|
|
21
20
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
22
21
|
|
|
23
|
-
// import type { Dispatch, SetStateAction } from 'react';
|
|
24
|
-
|
|
25
|
-
// import type { ColumnsTable, TableProps } from '../type';
|
|
26
|
-
|
|
27
|
-
// type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
28
|
-
|
|
29
22
|
const TableWrapper = props => {
|
|
30
23
|
const {
|
|
31
24
|
table,
|
|
@@ -45,7 +38,6 @@ const TableWrapper = props => {
|
|
|
45
38
|
rowEditable,
|
|
46
39
|
windowSize
|
|
47
40
|
} = (0, _react.useContext)(_useContext.TableContext); //onRowHeaderStyles
|
|
48
|
-
// const { windowSize } = useContext(TableContext)
|
|
49
41
|
|
|
50
42
|
// ref cho scroll container
|
|
51
43
|
const scrollRef = (0, _react.useRef)(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.83",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"rc-checkbox": "^3.5.0",
|
|
65
65
|
"rc-dropdown": "^4.2.1",
|
|
66
66
|
"rc-field-form": "^2.6.0",
|
|
67
|
-
"rc-master-ui": "1.1.
|
|
67
|
+
"rc-master-ui": "1.1.52",
|
|
68
68
|
"rc-select": "^14.16.3",
|
|
69
69
|
"rc-tooltip": "^6.3.0",
|
|
70
70
|
"rc-tree": "^5.10.1",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ContextInfo, ContextMenuItem } from "./../grid-component/type";
|
|
3
|
-
export declare const findItemByKey: (array: any[], key: string, value: any) => any;
|
|
4
|
-
type Props<RecordType> = {
|
|
5
|
-
rowData: RecordType | null;
|
|
6
|
-
contextMenuItems: ContextMenuItem[];
|
|
7
|
-
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
8
|
-
open: boolean;
|
|
9
|
-
menuRef?: any;
|
|
10
|
-
setOpen: (open: boolean) => void;
|
|
11
|
-
pos: {
|
|
12
|
-
x: number | undefined;
|
|
13
|
-
y: number | undefined;
|
|
14
|
-
viewportWidth: number;
|
|
15
|
-
viewportHeight: number;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
declare const ContextMenu: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
19
|
-
export default ContextMenu;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Dropdown, Menu } from "antd";
|
|
3
|
-
export const findItemByKey = (array, key, value) => {
|
|
4
|
-
for (let i = 0; i < array.length; i++) {
|
|
5
|
-
const item = array[i];
|
|
6
|
-
if (item[key] === value) {
|
|
7
|
-
return item;
|
|
8
|
-
}
|
|
9
|
-
if (item.children && item.children.length > 0) {
|
|
10
|
-
const foundInChildren = findItemByKey(item.children, key, value);
|
|
11
|
-
if (foundInChildren) {
|
|
12
|
-
return foundInChildren;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
const ContextMenu = props => {
|
|
19
|
-
const {
|
|
20
|
-
menuRef,
|
|
21
|
-
open,
|
|
22
|
-
setOpen,
|
|
23
|
-
pos,
|
|
24
|
-
contextMenuClick,
|
|
25
|
-
contextMenuItems,
|
|
26
|
-
rowData
|
|
27
|
-
} = props;
|
|
28
|
-
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
29
|
-
placement: 'topRight',
|
|
30
|
-
open: open,
|
|
31
|
-
overlayClassName: 'be-popup-container',
|
|
32
|
-
overlayStyle: {
|
|
33
|
-
left: `${pos.x}px`,
|
|
34
|
-
top: `${pos.y}px`
|
|
35
|
-
},
|
|
36
|
-
dropdownRender: () => {
|
|
37
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
-
ref: menuRef
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Menu, {
|
|
40
|
-
items: contextMenuItems,
|
|
41
|
-
style: {
|
|
42
|
-
minWidth: 200,
|
|
43
|
-
maxHeight: pos.viewportHeight - 20,
|
|
44
|
-
width: 'fit-content'
|
|
45
|
-
},
|
|
46
|
-
rootClassName: 'popup-context-menu'
|
|
47
|
-
// rootClassName={'be-popup-container'}
|
|
48
|
-
,
|
|
49
|
-
|
|
50
|
-
onClick: e => {
|
|
51
|
-
setOpen(false);
|
|
52
|
-
contextMenuClick?.({
|
|
53
|
-
rowInfo: {
|
|
54
|
-
rowData
|
|
55
|
-
},
|
|
56
|
-
event: e.domEvent,
|
|
57
|
-
item: {
|
|
58
|
-
...findItemByKey(contextMenuItems, 'key', e.key),
|
|
59
|
-
id: e.key
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// if (!open) {
|
|
64
|
-
// document.addEventListener(`click`, function onClickOutside() {
|
|
65
|
-
// setOpen(false);
|
|
66
|
-
// document.removeEventListener(`click`, onClickOutside);
|
|
67
|
-
// });
|
|
68
|
-
// }
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
73
|
-
};
|
|
74
|
-
export default ContextMenu;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ContextInfo, ContextMenuItem } from "./../grid-component/type";
|
|
3
|
-
export declare const findItemByKey: (array: any[], key: string, value: any) => any;
|
|
4
|
-
type Props<RecordType> = {
|
|
5
|
-
rowData: RecordType | null;
|
|
6
|
-
contextMenuItems: ContextMenuItem[];
|
|
7
|
-
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
8
|
-
open: boolean;
|
|
9
|
-
menuRef?: any;
|
|
10
|
-
setOpen: (open: boolean) => void;
|
|
11
|
-
pos: {
|
|
12
|
-
x: number | undefined;
|
|
13
|
-
y: number | undefined;
|
|
14
|
-
viewportWidth: number;
|
|
15
|
-
viewportHeight: number;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
declare const ContextMenu: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
19
|
-
export default ContextMenu;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findItemByKey = exports.default = void 0;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _antd = require("antd");
|
|
9
|
-
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); }
|
|
10
|
-
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; }
|
|
11
|
-
const findItemByKey = (array, key, value) => {
|
|
12
|
-
for (let i = 0; i < array.length; i++) {
|
|
13
|
-
const item = array[i];
|
|
14
|
-
if (item[key] === value) {
|
|
15
|
-
return item;
|
|
16
|
-
}
|
|
17
|
-
if (item.children && item.children.length > 0) {
|
|
18
|
-
const foundInChildren = findItemByKey(item.children, key, value);
|
|
19
|
-
if (foundInChildren) {
|
|
20
|
-
return foundInChildren;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
exports.findItemByKey = findItemByKey;
|
|
27
|
-
const ContextMenu = props => {
|
|
28
|
-
const {
|
|
29
|
-
menuRef,
|
|
30
|
-
open,
|
|
31
|
-
setOpen,
|
|
32
|
-
pos,
|
|
33
|
-
contextMenuClick,
|
|
34
|
-
contextMenuItems,
|
|
35
|
-
rowData
|
|
36
|
-
} = props;
|
|
37
|
-
return /*#__PURE__*/React.createElement(_antd.Dropdown, {
|
|
38
|
-
placement: 'topRight',
|
|
39
|
-
open: open,
|
|
40
|
-
overlayClassName: 'be-popup-container',
|
|
41
|
-
overlayStyle: {
|
|
42
|
-
left: `${pos.x}px`,
|
|
43
|
-
top: `${pos.y}px`
|
|
44
|
-
},
|
|
45
|
-
dropdownRender: () => {
|
|
46
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
ref: menuRef
|
|
48
|
-
}, /*#__PURE__*/React.createElement(_antd.Menu, {
|
|
49
|
-
items: contextMenuItems,
|
|
50
|
-
style: {
|
|
51
|
-
minWidth: 200,
|
|
52
|
-
maxHeight: pos.viewportHeight - 20,
|
|
53
|
-
width: 'fit-content'
|
|
54
|
-
},
|
|
55
|
-
rootClassName: 'popup-context-menu'
|
|
56
|
-
// rootClassName={'be-popup-container'}
|
|
57
|
-
,
|
|
58
|
-
|
|
59
|
-
onClick: e => {
|
|
60
|
-
setOpen(false);
|
|
61
|
-
contextMenuClick?.({
|
|
62
|
-
rowInfo: {
|
|
63
|
-
rowData
|
|
64
|
-
},
|
|
65
|
-
event: e.domEvent,
|
|
66
|
-
item: {
|
|
67
|
-
...findItemByKey(contextMenuItems, 'key', e.key),
|
|
68
|
-
id: e.key
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// if (!open) {
|
|
73
|
-
// document.addEventListener(`click`, function onClickOutside() {
|
|
74
|
-
// setOpen(false);
|
|
75
|
-
// document.removeEventListener(`click`, onClickOutside);
|
|
76
|
-
// });
|
|
77
|
-
// }
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
82
|
-
};
|
|
83
|
-
var _default = exports.default = ContextMenu;
|