es-grid-template 1.8.85 → 1.8.87
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/type.d.ts +1 -0
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/group-component/table/TableWrapper.js +7 -5
- package/es/table-component/ContextMenu.d.ts +1 -1
- package/es/table-component/ContextMenu.js +2 -1
- package/es/table-component/body/EditableCell.js +0 -1
- package/es/table-component/body/TableBodyRow.js +6 -1
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +21 -3
- package/es/table-component/style.scss +7 -2
- package/es/table-component/table/TableWrapper.js +8 -6
- package/es/table-virtuoso/body/TableBodyRow.js +6 -0
- package/es/table-virtuoso/table/TableWrapper.js +8 -6
- package/lib/grid-component/type.d.ts +1 -0
- package/lib/group-component/table/TableWrapper.js +7 -5
- package/lib/table-component/ContextMenu.d.ts +1 -1
- package/lib/table-component/ContextMenu.js +2 -1
- package/lib/table-component/body/EditableCell.js +0 -1
- package/lib/table-component/body/TableBodyRow.js +6 -1
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +23 -4
- package/lib/table-component/style.scss +7 -2
- package/lib/table-component/table/TableWrapper.js +8 -6
- package/lib/table-virtuoso/body/TableBodyRow.js +6 -0
- package/lib/table-virtuoso/table/TableWrapper.js +8 -6
- package/package.json +1 -1
|
@@ -208,9 +208,9 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
208
208
|
ellipsis?: boolean;
|
|
209
209
|
allowResizing?: boolean;
|
|
210
210
|
allowSelection?: boolean | ((rowData: RecordType) => boolean);
|
|
211
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
212
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
213
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
211
|
+
onCellStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
212
|
+
onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
213
|
+
onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
|
|
214
214
|
sumGroup?: boolean;
|
|
215
215
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
216
216
|
}[];
|
|
@@ -57,8 +57,9 @@ const TableWrapper = props => {
|
|
|
57
57
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
58
58
|
const hiddenItems = contextMenuHidden({
|
|
59
59
|
rowInfo: {
|
|
60
|
-
rowData: selectedRowData
|
|
61
|
-
}
|
|
60
|
+
rowData: selectedRowData.rowData
|
|
61
|
+
},
|
|
62
|
+
field: selectedRowData.field
|
|
62
63
|
});
|
|
63
64
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
64
65
|
}
|
|
@@ -109,14 +110,15 @@ const TableWrapper = props => {
|
|
|
109
110
|
e.target.classList.remove('ui-rc-table-ping-left');
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
|
-
const onContextMenu =
|
|
113
|
+
const onContextMenu = args => event => {
|
|
113
114
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
114
115
|
|
|
115
|
-
setSelectedRowData(
|
|
116
|
+
setSelectedRowData(args);
|
|
116
117
|
contextMenuOpen?.({
|
|
117
118
|
rowInfo: {
|
|
118
|
-
rowData:
|
|
119
|
+
rowData: args.rowData
|
|
119
120
|
},
|
|
121
|
+
field: args.field,
|
|
120
122
|
event
|
|
121
123
|
});
|
|
122
124
|
setMenuVisible(true);
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { ContextInfo, ContextMenuItem } from "./../grid-component/type";
|
|
3
3
|
export declare const findItemByKey: (array: any[], key: string, value: any) => any;
|
|
4
4
|
type Props<RecordType> = {
|
|
5
|
-
rowData:
|
|
5
|
+
rowData: any;
|
|
6
6
|
contextMenuItems: ContextMenuItem[];
|
|
7
7
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
8
8
|
open: boolean;
|
|
@@ -51,9 +51,10 @@ const ContextMenu = props => {
|
|
|
51
51
|
setOpen(false);
|
|
52
52
|
contextMenuClick?.({
|
|
53
53
|
rowInfo: {
|
|
54
|
-
rowData
|
|
54
|
+
rowData: rowData.rowData
|
|
55
55
|
},
|
|
56
56
|
event: e.domEvent,
|
|
57
|
+
field: rowData.field,
|
|
57
58
|
item: {
|
|
58
59
|
...findItemByKey(contextMenuItems, 'key', e.key),
|
|
59
60
|
id: e.key
|
|
@@ -77,7 +77,12 @@ const TableBodyRow = ({
|
|
|
77
77
|
},
|
|
78
78
|
onContextMenu: e => {
|
|
79
79
|
if (contextMenuItems && contextMenuItems.length) {
|
|
80
|
-
|
|
80
|
+
const cell = e.target.closest('[data-col-key]');
|
|
81
|
+
const colKey = cell?.getAttribute('data-col-key');
|
|
82
|
+
onContextMenu?.({
|
|
83
|
+
rowData: row.original,
|
|
84
|
+
field: colKey
|
|
85
|
+
})(e);
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
@@ -40,6 +40,7 @@ export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
|
40
40
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
41
41
|
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
42
42
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
43
|
+
export declare const flatColumnsWithoutParent: (columns: any[]) => any;
|
|
43
44
|
export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
44
45
|
export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
45
46
|
export declare const getFixedFields: <T>(columns: ColumnsTable<T>, type: 'left' | 'right') => string[];
|
|
@@ -275,6 +275,24 @@ export const flatColumns2 = columns => {
|
|
|
275
275
|
}];
|
|
276
276
|
}, []);
|
|
277
277
|
};
|
|
278
|
+
export const flatColumnsWithoutParent = columns => {
|
|
279
|
+
return columns.reduce((list, column) => {
|
|
280
|
+
const subColumns = column.children;
|
|
281
|
+
if (column.field === 'selection_column') {
|
|
282
|
+
return [...list, {
|
|
283
|
+
...column
|
|
284
|
+
}];
|
|
285
|
+
}
|
|
286
|
+
if (subColumns && subColumns.length > 0) {
|
|
287
|
+
return [...list, ...flatColumns2(subColumns).map(subColum => ({
|
|
288
|
+
...subColum
|
|
289
|
+
}))];
|
|
290
|
+
}
|
|
291
|
+
return [...list, {
|
|
292
|
+
...column
|
|
293
|
+
}];
|
|
294
|
+
}, []);
|
|
295
|
+
};
|
|
278
296
|
export const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
279
297
|
if (thousandSeparator) {
|
|
280
298
|
if (decimalSeparator) {
|
|
@@ -910,9 +928,9 @@ function getSortValue(item, field) {
|
|
|
910
928
|
}
|
|
911
929
|
function compareValues(a, b, order) {
|
|
912
930
|
const desc = order === "descend";
|
|
913
|
-
if (a
|
|
914
|
-
if (a
|
|
915
|
-
if (b
|
|
931
|
+
if (a === null && b === null) return 0;
|
|
932
|
+
if (a === null) return desc ? 1 : -1;
|
|
933
|
+
if (b === null) return desc ? -1 : 1;
|
|
916
934
|
|
|
917
935
|
// Nếu là số
|
|
918
936
|
if (typeof a === "number" && typeof b === "number") {
|
|
@@ -315,14 +315,19 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
|
|
|
315
315
|
// background-color: $body-color;
|
|
316
316
|
background-color: inherit;
|
|
317
317
|
|
|
318
|
+
&.#{$prefix}-grid-cell-text-wrap {
|
|
319
|
+
.ui-rc_cell-content {
|
|
320
|
+
word-break: break-word;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
318
325
|
&.#{$prefix}-grid-cell-ellipsis:not(:has(>.ui-rc_cell-content)) {
|
|
319
326
|
overflow: hidden;
|
|
320
327
|
white-space: nowrap;
|
|
321
328
|
text-overflow: ellipsis;
|
|
322
329
|
word-break: keep-all;
|
|
323
330
|
|
|
324
|
-
|
|
325
|
-
|
|
326
331
|
}
|
|
327
332
|
|
|
328
333
|
&.#{$prefix}-grid-cell-index-selected {
|
|
@@ -48,7 +48,7 @@ const TableWrapper = props => {
|
|
|
48
48
|
total
|
|
49
49
|
} = pagination ?? {};
|
|
50
50
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
51
|
-
const [selectedRowData, setSelectedRowData] = React.useState(
|
|
51
|
+
const [selectedRowData, setSelectedRowData] = React.useState(undefined);
|
|
52
52
|
const [position, setPosition] = React.useState({
|
|
53
53
|
x: 0,
|
|
54
54
|
y: 0,
|
|
@@ -59,8 +59,9 @@ const TableWrapper = props => {
|
|
|
59
59
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
60
60
|
const hiddenItems = contextMenuHidden({
|
|
61
61
|
rowInfo: {
|
|
62
|
-
rowData: selectedRowData
|
|
63
|
-
}
|
|
62
|
+
rowData: selectedRowData.rowData
|
|
63
|
+
},
|
|
64
|
+
field: selectedRowData.field
|
|
64
65
|
});
|
|
65
66
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
66
67
|
}
|
|
@@ -114,14 +115,15 @@ const TableWrapper = props => {
|
|
|
114
115
|
e.target.classList.remove('ui-rc-table-ping-left');
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
|
-
const onContextMenu =
|
|
118
|
+
const onContextMenu = args => event => {
|
|
118
119
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
119
120
|
|
|
120
|
-
setSelectedRowData(
|
|
121
|
+
setSelectedRowData(args);
|
|
121
122
|
contextMenuOpen?.({
|
|
122
123
|
rowInfo: {
|
|
123
|
-
rowData:
|
|
124
|
+
rowData: args.rowData
|
|
124
125
|
},
|
|
126
|
+
field: args.field,
|
|
125
127
|
event
|
|
126
128
|
});
|
|
127
129
|
|
|
@@ -60,6 +60,12 @@ const TableBodyRow = ({
|
|
|
60
60
|
},
|
|
61
61
|
onContextMenu: e => {
|
|
62
62
|
if (contextMenuItems && contextMenuItems.length) {
|
|
63
|
+
const cell = e.target.closest('[data-col-key]');
|
|
64
|
+
const colKey = cell?.getAttribute('data-col-key');
|
|
65
|
+
onContextMenu?.({
|
|
66
|
+
rowData: row.original,
|
|
67
|
+
field: colKey
|
|
68
|
+
})(e);
|
|
63
69
|
onContextMenu?.(row.original)(e);
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -35,7 +35,7 @@ const TableWrapper = props => {
|
|
|
35
35
|
rows
|
|
36
36
|
} = table.getRowModel();
|
|
37
37
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
38
|
-
const [selectedRowData, setSelectedRowData] = React.useState(
|
|
38
|
+
const [selectedRowData, setSelectedRowData] = React.useState(undefined);
|
|
39
39
|
const [position, setPosition] = React.useState({
|
|
40
40
|
x: 0,
|
|
41
41
|
y: 0,
|
|
@@ -46,8 +46,9 @@ const TableWrapper = props => {
|
|
|
46
46
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
47
47
|
const hiddenItems = contextMenuHidden({
|
|
48
48
|
rowInfo: {
|
|
49
|
-
rowData: selectedRowData
|
|
50
|
-
}
|
|
49
|
+
rowData: selectedRowData.rowData
|
|
50
|
+
},
|
|
51
|
+
field: selectedRowData.field
|
|
51
52
|
});
|
|
52
53
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
53
54
|
}
|
|
@@ -56,14 +57,15 @@ const TableWrapper = props => {
|
|
|
56
57
|
}
|
|
57
58
|
return propContextMenuItems;
|
|
58
59
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
59
|
-
const onContextMenu =
|
|
60
|
+
const onContextMenu = args => event => {
|
|
60
61
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
61
62
|
|
|
62
|
-
setSelectedRowData(
|
|
63
|
+
setSelectedRowData(args);
|
|
63
64
|
contextMenuOpen?.({
|
|
64
65
|
rowInfo: {
|
|
65
|
-
rowData:
|
|
66
|
+
rowData: args.rowData
|
|
66
67
|
},
|
|
68
|
+
field: args.field,
|
|
67
69
|
event
|
|
68
70
|
});
|
|
69
71
|
setMenuVisible(true);
|
|
@@ -66,8 +66,9 @@ const TableWrapper = props => {
|
|
|
66
66
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
67
67
|
const hiddenItems = contextMenuHidden({
|
|
68
68
|
rowInfo: {
|
|
69
|
-
rowData: selectedRowData
|
|
70
|
-
}
|
|
69
|
+
rowData: selectedRowData.rowData
|
|
70
|
+
},
|
|
71
|
+
field: selectedRowData.field
|
|
71
72
|
});
|
|
72
73
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
73
74
|
}
|
|
@@ -118,14 +119,15 @@ const TableWrapper = props => {
|
|
|
118
119
|
e.target.classList.remove('ui-rc-table-ping-left');
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
|
-
const onContextMenu =
|
|
122
|
+
const onContextMenu = args => event => {
|
|
122
123
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
123
124
|
|
|
124
|
-
setSelectedRowData(
|
|
125
|
+
setSelectedRowData(args);
|
|
125
126
|
contextMenuOpen?.({
|
|
126
127
|
rowInfo: {
|
|
127
|
-
rowData:
|
|
128
|
+
rowData: args.rowData
|
|
128
129
|
},
|
|
130
|
+
field: args.field,
|
|
129
131
|
event
|
|
130
132
|
});
|
|
131
133
|
setMenuVisible(true);
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import type { ContextInfo, ContextMenuItem } from "./../grid-component/type";
|
|
3
3
|
export declare const findItemByKey: (array: any[], key: string, value: any) => any;
|
|
4
4
|
type Props<RecordType> = {
|
|
5
|
-
rowData:
|
|
5
|
+
rowData: any;
|
|
6
6
|
contextMenuItems: ContextMenuItem[];
|
|
7
7
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
8
8
|
open: boolean;
|
|
@@ -60,9 +60,10 @@ const ContextMenu = props => {
|
|
|
60
60
|
setOpen(false);
|
|
61
61
|
contextMenuClick?.({
|
|
62
62
|
rowInfo: {
|
|
63
|
-
rowData
|
|
63
|
+
rowData: rowData.rowData
|
|
64
64
|
},
|
|
65
65
|
event: e.domEvent,
|
|
66
|
+
field: rowData.field,
|
|
66
67
|
item: {
|
|
67
68
|
...findItemByKey(contextMenuItems, 'key', e.key),
|
|
68
69
|
id: e.key
|
|
@@ -84,7 +84,12 @@ const TableBodyRow = ({
|
|
|
84
84
|
},
|
|
85
85
|
onContextMenu: e => {
|
|
86
86
|
if (contextMenuItems && contextMenuItems.length) {
|
|
87
|
-
|
|
87
|
+
const cell = e.target.closest('[data-col-key]');
|
|
88
|
+
const colKey = cell?.getAttribute('data-col-key');
|
|
89
|
+
onContextMenu?.({
|
|
90
|
+
rowData: row.original,
|
|
91
|
+
field: colKey
|
|
92
|
+
})(e);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
@@ -40,6 +40,7 @@ export declare const getTypeFilter: (col: any) => TypeFilter;
|
|
|
40
40
|
export declare const addRowIdArray: (inputArray: any[]) => any[];
|
|
41
41
|
export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
|
|
42
42
|
export declare const flatColumns2: <RecordType>(columns: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
43
|
+
export declare const flatColumnsWithoutParent: (columns: any[]) => any;
|
|
43
44
|
export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
44
45
|
export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
|
|
45
46
|
export declare const getFixedFields: <T>(columns: ColumnsTable<T>, type: 'left' | 'right') => string[];
|
|
@@ -28,7 +28,7 @@ exports.filterByIds = filterByIds;
|
|
|
28
28
|
exports.filterDataByColumns = filterDataByColumns;
|
|
29
29
|
exports.findAllChildrenKeys2 = findAllChildrenKeys2;
|
|
30
30
|
exports.findFirst = findFirst;
|
|
31
|
-
exports.genPresets = exports.flattenData = exports.flattenArray = exports.flatColumns2 = exports.findItemByKey = void 0;
|
|
31
|
+
exports.genPresets = exports.flattenData = exports.flattenArray = exports.flatColumnsWithoutParent = exports.flatColumns2 = exports.findItemByKey = void 0;
|
|
32
32
|
exports.getAllChildren = getAllChildren;
|
|
33
33
|
exports.getAllVisibleKeys1 = exports.getAllVisibleKeys = exports.getAllRowKey = void 0;
|
|
34
34
|
exports.getCellsByPosition = getCellsByPosition;
|
|
@@ -356,6 +356,25 @@ const flatColumns2 = columns => {
|
|
|
356
356
|
}, []);
|
|
357
357
|
};
|
|
358
358
|
exports.flatColumns2 = flatColumns2;
|
|
359
|
+
const flatColumnsWithoutParent = columns => {
|
|
360
|
+
return columns.reduce((list, column) => {
|
|
361
|
+
const subColumns = column.children;
|
|
362
|
+
if (column.field === 'selection_column') {
|
|
363
|
+
return [...list, {
|
|
364
|
+
...column
|
|
365
|
+
}];
|
|
366
|
+
}
|
|
367
|
+
if (subColumns && subColumns.length > 0) {
|
|
368
|
+
return [...list, ...flatColumns2(subColumns).map(subColum => ({
|
|
369
|
+
...subColum
|
|
370
|
+
}))];
|
|
371
|
+
}
|
|
372
|
+
return [...list, {
|
|
373
|
+
...column
|
|
374
|
+
}];
|
|
375
|
+
}, []);
|
|
376
|
+
};
|
|
377
|
+
exports.flatColumnsWithoutParent = flatColumnsWithoutParent;
|
|
359
378
|
const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
|
|
360
379
|
if (thousandSeparator) {
|
|
361
380
|
if (decimalSeparator) {
|
|
@@ -1005,9 +1024,9 @@ function getSortValue(item, field) {
|
|
|
1005
1024
|
}
|
|
1006
1025
|
function compareValues(a, b, order) {
|
|
1007
1026
|
const desc = order === "descend";
|
|
1008
|
-
if (a
|
|
1009
|
-
if (a
|
|
1010
|
-
if (b
|
|
1027
|
+
if (a === null && b === null) return 0;
|
|
1028
|
+
if (a === null) return desc ? 1 : -1;
|
|
1029
|
+
if (b === null) return desc ? -1 : 1;
|
|
1011
1030
|
|
|
1012
1031
|
// Nếu là số
|
|
1013
1032
|
if (typeof a === "number" && typeof b === "number") {
|
|
@@ -315,14 +315,19 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
|
|
|
315
315
|
// background-color: $body-color;
|
|
316
316
|
background-color: inherit;
|
|
317
317
|
|
|
318
|
+
&.#{$prefix}-grid-cell-text-wrap {
|
|
319
|
+
.ui-rc_cell-content {
|
|
320
|
+
word-break: break-word;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
318
325
|
&.#{$prefix}-grid-cell-ellipsis:not(:has(>.ui-rc_cell-content)) {
|
|
319
326
|
overflow: hidden;
|
|
320
327
|
white-space: nowrap;
|
|
321
328
|
text-overflow: ellipsis;
|
|
322
329
|
word-break: keep-all;
|
|
323
330
|
|
|
324
|
-
|
|
325
|
-
|
|
326
331
|
}
|
|
327
332
|
|
|
328
333
|
&.#{$prefix}-grid-cell-index-selected {
|
|
@@ -57,7 +57,7 @@ const TableWrapper = props => {
|
|
|
57
57
|
total
|
|
58
58
|
} = pagination ?? {};
|
|
59
59
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
60
|
-
const [selectedRowData, setSelectedRowData] = _react.default.useState(
|
|
60
|
+
const [selectedRowData, setSelectedRowData] = _react.default.useState(undefined);
|
|
61
61
|
const [position, setPosition] = _react.default.useState({
|
|
62
62
|
x: 0,
|
|
63
63
|
y: 0,
|
|
@@ -68,8 +68,9 @@ const TableWrapper = props => {
|
|
|
68
68
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
69
69
|
const hiddenItems = contextMenuHidden({
|
|
70
70
|
rowInfo: {
|
|
71
|
-
rowData: selectedRowData
|
|
72
|
-
}
|
|
71
|
+
rowData: selectedRowData.rowData
|
|
72
|
+
},
|
|
73
|
+
field: selectedRowData.field
|
|
73
74
|
});
|
|
74
75
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
75
76
|
}
|
|
@@ -123,14 +124,15 @@ const TableWrapper = props => {
|
|
|
123
124
|
e.target.classList.remove('ui-rc-table-ping-left');
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
const onContextMenu =
|
|
127
|
+
const onContextMenu = args => event => {
|
|
127
128
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
128
129
|
|
|
129
|
-
setSelectedRowData(
|
|
130
|
+
setSelectedRowData(args);
|
|
130
131
|
contextMenuOpen?.({
|
|
131
132
|
rowInfo: {
|
|
132
|
-
rowData:
|
|
133
|
+
rowData: args.rowData
|
|
133
134
|
},
|
|
135
|
+
field: args.field,
|
|
134
136
|
event
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -67,6 +67,12 @@ const TableBodyRow = ({
|
|
|
67
67
|
},
|
|
68
68
|
onContextMenu: e => {
|
|
69
69
|
if (contextMenuItems && contextMenuItems.length) {
|
|
70
|
+
const cell = e.target.closest('[data-col-key]');
|
|
71
|
+
const colKey = cell?.getAttribute('data-col-key');
|
|
72
|
+
onContextMenu?.({
|
|
73
|
+
rowData: row.original,
|
|
74
|
+
field: colKey
|
|
75
|
+
})(e);
|
|
70
76
|
onContextMenu?.(row.original)(e);
|
|
71
77
|
}
|
|
72
78
|
}
|
|
@@ -45,7 +45,7 @@ const TableWrapper = props => {
|
|
|
45
45
|
rows
|
|
46
46
|
} = table.getRowModel();
|
|
47
47
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
48
|
-
const [selectedRowData, setSelectedRowData] = _react.default.useState(
|
|
48
|
+
const [selectedRowData, setSelectedRowData] = _react.default.useState(undefined);
|
|
49
49
|
const [position, setPosition] = _react.default.useState({
|
|
50
50
|
x: 0,
|
|
51
51
|
y: 0,
|
|
@@ -56,8 +56,9 @@ const TableWrapper = props => {
|
|
|
56
56
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
57
57
|
const hiddenItems = contextMenuHidden({
|
|
58
58
|
rowInfo: {
|
|
59
|
-
rowData: selectedRowData
|
|
60
|
-
}
|
|
59
|
+
rowData: selectedRowData.rowData
|
|
60
|
+
},
|
|
61
|
+
field: selectedRowData.field
|
|
61
62
|
});
|
|
62
63
|
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
63
64
|
}
|
|
@@ -66,14 +67,15 @@ const TableWrapper = props => {
|
|
|
66
67
|
}
|
|
67
68
|
return propContextMenuItems;
|
|
68
69
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
69
|
-
const onContextMenu =
|
|
70
|
+
const onContextMenu = args => event => {
|
|
70
71
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
71
72
|
|
|
72
|
-
setSelectedRowData(
|
|
73
|
+
setSelectedRowData(args);
|
|
73
74
|
contextMenuOpen?.({
|
|
74
75
|
rowInfo: {
|
|
75
|
-
rowData:
|
|
76
|
+
rowData: args.rowData
|
|
76
77
|
},
|
|
78
|
+
field: args.field,
|
|
77
79
|
event
|
|
78
80
|
});
|
|
79
81
|
setMenuVisible(true);
|