es-grid-template 1.9.93 → 1.9.95
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/CHANGELOG.md +10 -0
- package/es/grid-component/GridRefreshButton.css +9 -9
- package/es/grid-component/hooks/rowFocus.d.ts +11 -0
- package/es/grid-component/hooks/rowFocus.js +25 -0
- package/es/grid-component/index.d.ts +2 -2
- package/es/grid-component/type.d.ts +10 -0
- package/es/group-component/TableContainer.js +2 -0
- package/es/group-component/TableContainerEdit.js +2 -0
- package/es/group-component/body/TableBodyCell.js +4 -0
- package/es/group-component/body/TableBodyCellEdit.js +4 -0
- package/es/group-component/body/TableBodyCellEmpty.js +4 -0
- package/es/group-component/body/TableBodyRow.js +6 -3
- package/es/group-component/body/TableBodyRowGroupCell.js +4 -0
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/group-component/useContext.d.ts +2 -0
- package/es/index.d.ts +1 -1
- package/es/table-component/TableContainer.js +2 -0
- package/es/table-component/TableContainerEdit.js +2 -0
- package/es/table-component/body/TableBody.js +4 -0
- package/es/table-component/body/TableBodyCell.js +4 -0
- package/es/table-component/body/TableBodyCellEdit.js +4 -0
- package/es/table-component/body/TableBodyRow.js +12 -4
- package/es/table-component/useContext.d.ts +2 -0
- package/es/table-virtuoso/InternalTable.js +54 -11
- package/es/table-virtuoso/body/TableBodyCell.js +4 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +4 -0
- package/es/table-virtuoso/body/TableBodyRow.js +4 -1
- package/es/table-virtuoso/table/Grid.js +37 -8
- package/es/table-virtuoso/table/TableContainer.js +2 -0
- package/es/table-virtuoso/useContext.d.ts +2 -0
- package/lib/grid-component/GridRefreshButton.css +9 -9
- package/lib/grid-component/hooks/rowFocus.d.ts +11 -0
- package/lib/grid-component/hooks/rowFocus.js +32 -0
- package/lib/grid-component/index.d.ts +2 -2
- package/lib/grid-component/type.d.ts +10 -0
- package/lib/group-component/TableContainer.js +2 -0
- package/lib/group-component/TableContainerEdit.js +2 -0
- package/lib/group-component/body/TableBodyCell.js +4 -0
- package/lib/group-component/body/TableBodyCellEdit.js +4 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +4 -0
- package/lib/group-component/body/TableBodyRow.js +6 -3
- package/lib/group-component/body/TableBodyRowGroupCell.js +4 -0
- package/lib/group-component/hook/utils.d.ts +9 -9
- package/lib/group-component/useContext.d.ts +2 -0
- package/lib/index.d.ts +1 -1
- package/lib/table-component/TableContainer.js +2 -0
- package/lib/table-component/TableContainerEdit.js +2 -0
- package/lib/table-component/body/TableBody.js +4 -0
- package/lib/table-component/body/TableBodyCell.js +4 -0
- package/lib/table-component/body/TableBodyCellEdit.js +4 -0
- package/lib/table-component/body/TableBodyRow.js +12 -4
- package/lib/table-component/useContext.d.ts +2 -0
- package/lib/table-virtuoso/InternalTable.js +53 -10
- package/lib/table-virtuoso/body/TableBodyCell.js +4 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +4 -0
- package/lib/table-virtuoso/body/TableBodyRow.js +4 -1
- package/lib/table-virtuoso/table/Grid.js +37 -8
- package/lib/table-virtuoso/table/TableContainer.js +2 -0
- package/lib/table-virtuoso/useContext.d.ts +2 -0
- package/package.json +2 -2
|
@@ -167,7 +167,7 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
167
167
|
haveSum?: boolean;
|
|
168
168
|
isSummary?: boolean;
|
|
169
169
|
sumGroup?: boolean;
|
|
170
|
-
summaryTemplate?: (data: number, key: string) => import("react").
|
|
170
|
+
summaryTemplate?: (data: number, key: string) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode;
|
|
171
171
|
sorter?: boolean;
|
|
172
172
|
allowFiltering?: boolean;
|
|
173
173
|
allowSortering?: boolean;
|
|
@@ -179,27 +179,27 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
179
179
|
showFilterSearch?: boolean;
|
|
180
180
|
hidden?: boolean;
|
|
181
181
|
visible?: boolean;
|
|
182
|
-
headerTooltip?: string | boolean | (() => import("react").
|
|
182
|
+
headerTooltip?: string | boolean | (() => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
183
183
|
columnGroupText?: string;
|
|
184
184
|
headerTextAlign?: import("./../../grid-component/type").ITextAlign;
|
|
185
|
-
headerTemplate?: import("react").
|
|
185
|
+
headerTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((column: ColumnTable<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
186
186
|
fixedType?: import("./../../grid-component/type").FixedType;
|
|
187
187
|
headerTextWrap?: boolean;
|
|
188
188
|
ellipsis?: boolean;
|
|
189
189
|
allowResizing?: boolean;
|
|
190
190
|
align?: import("./../../grid-component/type").ITextAlign;
|
|
191
191
|
textAlign?: import("./../../grid-component/type").ITextAlign;
|
|
192
|
-
template?: import("react").
|
|
193
|
-
linkTemplate?: import("react").
|
|
192
|
+
template?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
193
|
+
linkTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
194
194
|
showTooltip?: boolean;
|
|
195
195
|
tooltipDescription?: string | ((args: {
|
|
196
196
|
value: any;
|
|
197
197
|
rowData: RecordType;
|
|
198
|
-
}) => import("react").
|
|
199
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
200
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
198
|
+
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
199
|
+
onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
200
|
+
onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
201
201
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
202
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
202
|
+
onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
|
|
203
203
|
getValue?: (row: any, rowIndex: number) => any;
|
|
204
204
|
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
205
205
|
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RowFocusEventArgs } from "../grid-component/type";
|
|
1
2
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
3
|
import type { ColumnTable, ExpandableConfig, IFormat, IGroupSetting, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "./../grid-component/type";
|
|
3
4
|
import type { SubmitHandler } from "react-hook-form";
|
|
@@ -19,6 +20,7 @@ export interface IContext<T> {
|
|
|
19
20
|
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
|
|
20
21
|
expanded: ExpandedState;
|
|
21
22
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
23
|
+
rowFocus?: (args: RowFocusEventArgs<T>) => void;
|
|
22
24
|
selectionSettings?: SelectionSettings;
|
|
23
25
|
isSelectionChange?: {
|
|
24
26
|
isChange: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default as Dropdown } from './dropdown';
|
|
2
2
|
export type { DropdownProps as DropDownProps, DropdownProps, } from './dropdown';
|
|
3
3
|
export { default as GridComponent } from './grid-component';
|
|
4
|
-
export type { ColumnsTable, TableProps, ColumnTable, CommandItem, ToolbarItem, ContextMenuItem } from './grid-component';
|
|
4
|
+
export type { ColumnsTable, TableProps, ColumnTable, CommandItem, ToolbarItem, ContextMenuItem, RowFocusEventArgs } from './grid-component';
|
|
5
5
|
export { default as Tabs } from './tabs';
|
|
6
6
|
export type { TabPaneProps, TabsProps } from './tabs';
|
|
7
7
|
export { default as SelectTable } from './select-table';
|
|
@@ -36,6 +36,7 @@ const TableContainer = props => {
|
|
|
36
36
|
expandable,
|
|
37
37
|
wrapSettings,
|
|
38
38
|
recordDoubleClick,
|
|
39
|
+
rowFocus,
|
|
39
40
|
// triggerFilter,
|
|
40
41
|
selectionSettings,
|
|
41
42
|
isSelectionChange,
|
|
@@ -332,6 +333,7 @@ const TableContainer = props => {
|
|
|
332
333
|
// triggerFilter,
|
|
333
334
|
wrapSettings,
|
|
334
335
|
recordDoubleClick,
|
|
336
|
+
rowFocus,
|
|
335
337
|
recordClick,
|
|
336
338
|
selectionSettings,
|
|
337
339
|
isSelectionChange,
|
|
@@ -83,6 +83,7 @@ const TableContainerEdit = props => {
|
|
|
83
83
|
expandable,
|
|
84
84
|
wrapSettings,
|
|
85
85
|
recordDoubleClick,
|
|
86
|
+
rowFocus,
|
|
86
87
|
selectionSettings,
|
|
87
88
|
isSelectionChange,
|
|
88
89
|
setIsSelectionChange,
|
|
@@ -2224,6 +2225,7 @@ const TableContainerEdit = props => {
|
|
|
2224
2225
|
originData,
|
|
2225
2226
|
wrapSettings,
|
|
2226
2227
|
recordDoubleClick,
|
|
2228
|
+
rowFocus,
|
|
2227
2229
|
selectionSettings,
|
|
2228
2230
|
isSelectionChange,
|
|
2229
2231
|
setIsSelectionChange,
|
|
@@ -34,9 +34,13 @@ const TableBody = ({
|
|
|
34
34
|
locale
|
|
35
35
|
} = _react.default.useContext(_useContext.TableContext);
|
|
36
36
|
|
|
37
|
+
// Keep measured heights attached to records when expanding, sorting or filtering.
|
|
38
|
+
const getItemKey = _react.default.useCallback(index => rows[index].id, [rows]);
|
|
39
|
+
|
|
37
40
|
//dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
|
|
38
41
|
const rowVirtualizer = (0, _reactVirtual.useVirtualizer)({
|
|
39
42
|
count: rows.length,
|
|
43
|
+
getItemKey,
|
|
40
44
|
estimateSize: () => 32,
|
|
41
45
|
//estimate row height for accurate scrollbar dragging
|
|
42
46
|
getScrollElement: () => tableContainerRef.current,
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
8
9
|
var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
|
|
9
10
|
var _Command = _interopRequireDefault(require("../components/command/Command"));
|
|
10
11
|
var _utils = require("../hook/utils");
|
|
@@ -170,6 +171,7 @@ const TableBodyCell = props => {
|
|
|
170
171
|
id,
|
|
171
172
|
prefix,
|
|
172
173
|
focusedCell,
|
|
174
|
+
rowFocus,
|
|
173
175
|
setFocusedCell,
|
|
174
176
|
// endCell,
|
|
175
177
|
// startCell,
|
|
@@ -450,6 +452,7 @@ const TableBodyCell = props => {
|
|
|
450
452
|
colId: cell.column.id,
|
|
451
453
|
rowId: nextId
|
|
452
454
|
});
|
|
455
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
453
456
|
|
|
454
457
|
// if (rowNumber < flatRows.length - 5) {
|
|
455
458
|
// e.stopPropagation()
|
|
@@ -472,6 +475,7 @@ const TableBodyCell = props => {
|
|
|
472
475
|
colId: cell.column.id,
|
|
473
476
|
rowId: nextId
|
|
474
477
|
});
|
|
478
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
475
479
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
476
480
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
477
481
|
if (cellFocus) {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
8
9
|
var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
|
|
9
10
|
var _Command = _interopRequireDefault(require("../components/command/Command"));
|
|
10
11
|
var _utils = require("../hook/utils");
|
|
@@ -199,6 +200,7 @@ const TableBodyCellEdit = props => {
|
|
|
199
200
|
editingKey,
|
|
200
201
|
prefix,
|
|
201
202
|
focusedCell,
|
|
203
|
+
rowFocus,
|
|
202
204
|
rangeState,
|
|
203
205
|
setFocusedCell,
|
|
204
206
|
setEditingKey,
|
|
@@ -833,6 +835,7 @@ const TableBodyCellEdit = props => {
|
|
|
833
835
|
rowId: nextRowId,
|
|
834
836
|
colId
|
|
835
837
|
});
|
|
838
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
836
839
|
setStartCell?.({
|
|
837
840
|
rowId: nextRowId,
|
|
838
841
|
colId
|
|
@@ -871,6 +874,7 @@ const TableBodyCellEdit = props => {
|
|
|
871
874
|
rowId: nextRowId,
|
|
872
875
|
colId
|
|
873
876
|
});
|
|
877
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
874
878
|
setStartCell?.({
|
|
875
879
|
rowId: nextRowId,
|
|
876
880
|
colId
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
9
10
|
var _TableBodyCell = _interopRequireDefault(require("./TableBodyCell"));
|
|
10
11
|
var _TableBodyCellEdit = _interopRequireDefault(require("./TableBodyCellEdit"));
|
|
11
12
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -32,6 +33,7 @@ const TableBodyRow = ({
|
|
|
32
33
|
const {
|
|
33
34
|
prefix,
|
|
34
35
|
recordDoubleClick,
|
|
36
|
+
rowFocus,
|
|
35
37
|
focusedCell,
|
|
36
38
|
rowClassName,
|
|
37
39
|
rowEditable,
|
|
@@ -61,10 +63,15 @@ const TableBodyRow = ({
|
|
|
61
63
|
isSelected: row.getIsSelected()
|
|
62
64
|
}) : onRowStyles;
|
|
63
65
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
64
|
-
|
|
66
|
+
|
|
67
|
+
// A reused DOM row needs measuring again when its virtual index changes.
|
|
68
|
+
const measureRow = _react.default.useCallback(element => {
|
|
69
|
+
rowVirtualizer.measureElement(element);
|
|
70
|
+
}, [rowVirtualizer, virtualRow.index]);
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
65
72
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
66
73
|
,
|
|
67
|
-
ref:
|
|
74
|
+
ref: measureRow //measure dynamic row height
|
|
68
75
|
,
|
|
69
76
|
key: row.id,
|
|
70
77
|
"data-row-key": row.id,
|
|
@@ -87,7 +94,8 @@ const TableBodyRow = ({
|
|
|
87
94
|
height: isEditing ? virtualRow.size : undefined,
|
|
88
95
|
minHeight: isEditing ? undefined : virtualRow.size,
|
|
89
96
|
...rowStyles
|
|
90
|
-
}
|
|
97
|
+
}
|
|
98
|
+
}, (0, _rowFocus.getRowFocusHandlers)(row.original, rowFocus), {
|
|
91
99
|
onDoubleClick: e => {
|
|
92
100
|
recordDoubleClick?.({
|
|
93
101
|
e,
|
|
@@ -106,7 +114,7 @@ const TableBodyRow = ({
|
|
|
106
114
|
})(e);
|
|
107
115
|
// }
|
|
108
116
|
}
|
|
109
|
-
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
117
|
+
}), fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
110
118
|
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
111
119
|
if (editAble) {
|
|
112
120
|
return /*#__PURE__*/_react.default.createElement(_TableBodyCellEdit.default, (0, _extends2.default)({}, rest, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RowFocusEventArgs } from "../grid-component/type";
|
|
1
2
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
3
|
import type { ColumnTable, ExpandableConfig, FilterItem, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "./../grid-component/type";
|
|
3
4
|
import type { SubmitHandler } from "react-hook-form";
|
|
@@ -20,6 +21,7 @@ export interface IContext<T> {
|
|
|
20
21
|
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
|
|
21
22
|
expanded: ExpandedState;
|
|
22
23
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
24
|
+
rowFocus?: (args: RowFocusEventArgs<T>) => void;
|
|
23
25
|
recordClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
24
26
|
selectionSettings?: SelectionSettings;
|
|
25
27
|
isSelectionChange?: {
|
|
@@ -92,6 +92,7 @@ const InternalTable = props => {
|
|
|
92
92
|
const [columnResizeMode] = _react.default.useState('onChange');
|
|
93
93
|
const [columnResizeDirection] = _react.default.useState('ltr');
|
|
94
94
|
const [rowSelection, setRowSelection] = _react.default.useState({});
|
|
95
|
+
const pruneSelection = selectionSettings?.pruneSelection === true;
|
|
95
96
|
|
|
96
97
|
// const [grouping, setGrouping] = React.useState<GroupingState>([])
|
|
97
98
|
|
|
@@ -128,6 +129,9 @@ const InternalTable = props => {
|
|
|
128
129
|
return (0, _utils.isTreeArray)(originData);
|
|
129
130
|
}, [originData]);
|
|
130
131
|
_react.default.useEffect(() => {
|
|
132
|
+
if (pruneSelection) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
131
135
|
if (groupColumns && groupColumns.length > 0 && groupSetting?.client !== false && isDataOriginTree === false) {
|
|
132
136
|
const abc = (0, _utils.groupArrayByColumns)(originData, groupColumns);
|
|
133
137
|
const rs = (0, _utils.filterDataByColumns)(abc, filterStates, sorterStates, []);
|
|
@@ -136,9 +140,48 @@ const InternalTable = props => {
|
|
|
136
140
|
const rs = (0, _utils.filterDataByColumns)(originData, filterStates, sorterStates, []);
|
|
137
141
|
setTableData(rs);
|
|
138
142
|
}
|
|
139
|
-
}, [groupColumns, originData, filterStates, sorterStates, groupSetting?.client, isDataOriginTree]);
|
|
143
|
+
}, [groupColumns, originData, filterStates, sorterStates, groupSetting?.client, isDataOriginTree, pruneSelection]);
|
|
140
144
|
// }, [groupColumns, originData, filterStates, sorterStates, groupSetting?.client])
|
|
141
145
|
|
|
146
|
+
// Resolve the opt-in view before paint, including inline grouping arrays.
|
|
147
|
+
const groupColumnsKey = JSON.stringify(groupColumns ?? []);
|
|
148
|
+
const viewData = _react.default.useMemo(() => {
|
|
149
|
+
if (!pruneSelection) {
|
|
150
|
+
return tableData;
|
|
151
|
+
}
|
|
152
|
+
const groups = JSON.parse(groupColumnsKey);
|
|
153
|
+
const grouped = groups.length && groupSetting?.client !== false && !isDataOriginTree ? (0, _utils.groupArrayByColumns)(originData, groups) : originData;
|
|
154
|
+
return (0, _utils.filterDataByColumns)(grouped, filterStates, sorterStates, []);
|
|
155
|
+
}, [pruneSelection, tableData, groupColumnsKey, originData, groupSetting?.client, isDataOriginTree, filterStates, sorterStates]);
|
|
156
|
+
const effectiveRowSelection = _react.default.useMemo(() => {
|
|
157
|
+
if (!pruneSelection || props.loading) {
|
|
158
|
+
return rowSelection;
|
|
159
|
+
}
|
|
160
|
+
const ids = new Set((0, _utils.flattenArray)(viewData).map(row => String(row.rowId)));
|
|
161
|
+
const next = Object.fromEntries(Object.entries(rowSelection).filter(([selectedId, checked]) => checked && ids.has(selectedId)));
|
|
162
|
+
|
|
163
|
+
// A group can stay checked only if its remaining real children are checked.
|
|
164
|
+
const checkGroups = rows => {
|
|
165
|
+
rows.forEach(row => {
|
|
166
|
+
if (row.isGroupRow && next[String(row.rowId)]) {
|
|
167
|
+
const children = (0, _utils.flattenData)('children', row.children ?? []).filter(child => !child.isGroupRow && !selectionSettings?.getCheckboxProps?.(child)?.disabled);
|
|
168
|
+
if (!children.length || children.some(child => !next[String(child.rowId)])) {
|
|
169
|
+
delete next[String(row.rowId)];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (Array.isArray(row.children)) {
|
|
173
|
+
checkGroups(row.children);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
checkGroups(viewData);
|
|
178
|
+
return Object.keys(next).length === Object.keys(rowSelection).length ? rowSelection : next;
|
|
179
|
+
}, [pruneSelection, props.loading, rowSelection, viewData, selectionSettings?.getCheckboxProps]);
|
|
180
|
+
_react.default.useEffect(() => {
|
|
181
|
+
if (effectiveRowSelection !== rowSelection) {
|
|
182
|
+
setRowSelection(prev => prev === rowSelection ? effectiveRowSelection : prev);
|
|
183
|
+
}
|
|
184
|
+
}, [effectiveRowSelection, rowSelection]);
|
|
142
185
|
_react.default.useEffect(() => {
|
|
143
186
|
// setColumns(updateWidthsByOther(propsColumns, columns))
|
|
144
187
|
setColumns(propsColumns);
|
|
@@ -152,8 +195,8 @@ const InternalTable = props => {
|
|
|
152
195
|
});
|
|
153
196
|
}, [t, columns, format, editAble]);
|
|
154
197
|
const isDataTree = _react.default.useMemo(() => {
|
|
155
|
-
return (0, _utils.isTreeArray)(
|
|
156
|
-
}, [
|
|
198
|
+
return (0, _utils.isTreeArray)(viewData);
|
|
199
|
+
}, [viewData]);
|
|
157
200
|
const columnPinning = _react.default.useMemo(() => {
|
|
158
201
|
return {
|
|
159
202
|
left: (0, _utils.getFixedFields)(columns, 'left'),
|
|
@@ -213,11 +256,11 @@ const InternalTable = props => {
|
|
|
213
256
|
};
|
|
214
257
|
const table = (0, _reactTable.useReactTable)({
|
|
215
258
|
_features: [_operator.OperatorFeature],
|
|
216
|
-
data:
|
|
259
|
+
data: viewData,
|
|
217
260
|
// data: mergedData,
|
|
218
261
|
columns: mergedColumns,
|
|
219
262
|
state: {
|
|
220
|
-
rowSelection,
|
|
263
|
+
rowSelection: effectiveRowSelection,
|
|
221
264
|
expanded,
|
|
222
265
|
columnPinning,
|
|
223
266
|
columnVisibility: columnsHiddenKeys ? (0, _utils.convertToObj)(columnsHiddenKeys) : columnVisibility,
|
|
@@ -292,20 +335,20 @@ const InternalTable = props => {
|
|
|
292
335
|
_react.default.useEffect(() => {
|
|
293
336
|
if (expandable?.preserveExpandedOnDataChange) {
|
|
294
337
|
// Chờ cây có dữ liệu mới khởi tạo; những lần thay đổi tableData sau đó không reset expanded.
|
|
295
|
-
if (initializedExpansionRef.current ||
|
|
338
|
+
if (initializedExpansionRef.current || viewData.length === 0) {
|
|
296
339
|
return;
|
|
297
340
|
}
|
|
298
341
|
initializedExpansionRef.current = true;
|
|
299
342
|
}
|
|
300
343
|
if (defaultExpandAllRows) {
|
|
301
|
-
const allKeys = (0, _utils.findAllChildrenKeys2)(
|
|
344
|
+
const allKeys = (0, _utils.findAllChildrenKeys2)(viewData, rowKey, 'children');
|
|
302
345
|
setExpanded((0, _utils.convertToObjTrue)(allKeys));
|
|
303
346
|
} else {
|
|
304
347
|
if (defaultExpandedRowKeys) {
|
|
305
348
|
setExpanded((0, _utils.convertToObjTrue)(defaultExpandedRowKeys ?? []));
|
|
306
349
|
}
|
|
307
350
|
}
|
|
308
|
-
}, [defaultExpandAllRows, defaultExpandedRowKeys,
|
|
351
|
+
}, [defaultExpandAllRows, defaultExpandedRowKeys, viewData, expandable?.preserveExpandedOnDataChange]);
|
|
309
352
|
const triggerGroupColumns = groupedColumns => {
|
|
310
353
|
// const abc = updateColumnsByGroup(columns, groupedColumns)
|
|
311
354
|
|
|
@@ -392,7 +435,7 @@ const InternalTable = props => {
|
|
|
392
435
|
originData: originData
|
|
393
436
|
// dataSource={mergedData}
|
|
394
437
|
,
|
|
395
|
-
dataSource:
|
|
438
|
+
dataSource: viewData,
|
|
396
439
|
locale: locale,
|
|
397
440
|
format: format
|
|
398
441
|
// columns={convertColumns(mergedColumns)}
|
|
@@ -427,7 +470,7 @@ const InternalTable = props => {
|
|
|
427
470
|
columnSizing: columnSizing,
|
|
428
471
|
columnSizingInfo: columnSizingInfo,
|
|
429
472
|
setColumnSizing: setColumnSizing,
|
|
430
|
-
rowSelection:
|
|
473
|
+
rowSelection: effectiveRowSelection,
|
|
431
474
|
pagination: pagination
|
|
432
475
|
})))));
|
|
433
476
|
};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
8
9
|
var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
|
|
9
10
|
var _utils = require("../hook/utils");
|
|
10
11
|
var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkbox"));
|
|
@@ -158,6 +159,7 @@ const TableBodyCell = props => {
|
|
|
158
159
|
id,
|
|
159
160
|
prefix,
|
|
160
161
|
focusedCell,
|
|
162
|
+
rowFocus,
|
|
161
163
|
setFocusedCell,
|
|
162
164
|
// endCell,
|
|
163
165
|
// startCell,
|
|
@@ -389,6 +391,7 @@ const TableBodyCell = props => {
|
|
|
389
391
|
colId: cell.column.id,
|
|
390
392
|
rowId: nextId
|
|
391
393
|
});
|
|
394
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
392
395
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
393
396
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
394
397
|
if (cellFocus) {
|
|
@@ -402,6 +405,7 @@ const TableBodyCell = props => {
|
|
|
402
405
|
colId: cell.column.id,
|
|
403
406
|
rowId: nextId
|
|
404
407
|
});
|
|
408
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
405
409
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
406
410
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
407
411
|
if (cellFocus) {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
8
9
|
var _utils = require("../hook/utils");
|
|
9
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -23,6 +24,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
23
24
|
id,
|
|
24
25
|
prefix,
|
|
25
26
|
focusedCell,
|
|
27
|
+
rowFocus,
|
|
26
28
|
setFocusedCell,
|
|
27
29
|
expanded,
|
|
28
30
|
setExpanded,
|
|
@@ -104,6 +106,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
104
106
|
colId: cell.column.id,
|
|
105
107
|
rowId: nextId
|
|
106
108
|
});
|
|
109
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
107
110
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
108
111
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
109
112
|
if (cellFocus) {
|
|
@@ -117,6 +120,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
117
120
|
colId: cell.column.id,
|
|
118
121
|
rowId: nextId
|
|
119
122
|
});
|
|
123
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
120
124
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
121
125
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
122
126
|
if (cellFocus) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _rowFocus = require("../../grid-component/hooks/rowFocus");
|
|
9
10
|
var _TableBodyCell = _interopRequireDefault(require("./TableBodyCell"));
|
|
10
11
|
var _reactTable = require("@tanstack/react-table");
|
|
11
12
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -33,6 +34,7 @@ const TableBodyRow = ({
|
|
|
33
34
|
const {
|
|
34
35
|
prefix,
|
|
35
36
|
recordDoubleClick,
|
|
37
|
+
rowFocus,
|
|
36
38
|
focusedCell,
|
|
37
39
|
rowClassName,
|
|
38
40
|
onRowStyles,
|
|
@@ -67,7 +69,8 @@ const TableBodyRow = ({
|
|
|
67
69
|
style: {
|
|
68
70
|
...rowStyles,
|
|
69
71
|
height: rowheight
|
|
70
|
-
}
|
|
72
|
+
}
|
|
73
|
+
}, (0, _rowFocus.getRowFocusHandlers)(row.original, rowFocus), {
|
|
71
74
|
onDoubleClick: e => {
|
|
72
75
|
recordDoubleClick?.({
|
|
73
76
|
e,
|
|
@@ -60,16 +60,46 @@ const Grid = props => {
|
|
|
60
60
|
setColumnSizing,
|
|
61
61
|
columnFilters,
|
|
62
62
|
setColumnOrder,
|
|
63
|
-
rowSelection,
|
|
64
63
|
className: tableClassNames,
|
|
65
64
|
...rest
|
|
66
65
|
} = props;
|
|
66
|
+
const selectedRowState = table.getState().rowSelection;
|
|
67
67
|
const [isSelectionChange, setIsSelectionChange] = _react.default.useState({
|
|
68
68
|
isChange: false,
|
|
69
69
|
type: '',
|
|
70
70
|
rowData: {},
|
|
71
71
|
rowsData: []
|
|
72
72
|
});
|
|
73
|
+
const rowSelectedRef = _react.default.useRef(rowSelected);
|
|
74
|
+
_react.default.useEffect(() => {
|
|
75
|
+
rowSelectedRef.current = rowSelected;
|
|
76
|
+
}, [rowSelected]);
|
|
77
|
+
const pruneSelection = selectionSettings?.pruneSelection === true;
|
|
78
|
+
const selectedViewRows = _react.default.useMemo(() => {
|
|
79
|
+
if (!pruneSelection || props.loading) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
return table.getCoreRowModel().flatRows.filter(row => !row.original.isGroupRow && selectedRowState[row.id]).map(row => row.original);
|
|
83
|
+
}, [pruneSelection, props.loading, table, dataSource, selectedRowState]);
|
|
84
|
+
const selectedViewIds = JSON.stringify(selectedViewRows.map(row => String(row.rowId)).sort());
|
|
85
|
+
const lastNotifiedSelection = _react.default.useRef(null);
|
|
86
|
+
|
|
87
|
+
// Keep event handlers in sync with the view without another state/effect.
|
|
88
|
+
const selectionChange = pruneSelection && !props.loading ? {
|
|
89
|
+
...isSelectionChange,
|
|
90
|
+
rowsData: selectedViewRows
|
|
91
|
+
} : isSelectionChange;
|
|
92
|
+
_react.default.useEffect(() => {
|
|
93
|
+
if (!pruneSelection || props.loading || lastNotifiedSelection.current === selectedViewIds) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
lastNotifiedSelection.current = selectedViewIds;
|
|
97
|
+
rowSelected?.({
|
|
98
|
+
type: isSelectionChange.isChange ? isSelectionChange.type : 'selectionPruned',
|
|
99
|
+
rowData: isSelectionChange.rowData,
|
|
100
|
+
selected: selectedViewRows
|
|
101
|
+
});
|
|
102
|
+
}, [pruneSelection, props.loading, selectedViewIds, selectedViewRows, rowSelected, isSelectionChange.isChange, isSelectionChange.type, isSelectionChange.rowData]);
|
|
73
103
|
const [sorterChange, setSorterChange] = _react.default.useState(false);
|
|
74
104
|
const [filterChange, setFilterChange] = _react.default.useState(false);
|
|
75
105
|
const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
|
|
@@ -86,18 +116,17 @@ const Grid = props => {
|
|
|
86
116
|
// }, [mergedSelectedKeys])
|
|
87
117
|
|
|
88
118
|
_react.default.useEffect(() => {
|
|
89
|
-
if (isSelectionChange.isChange) {
|
|
90
|
-
const
|
|
91
|
-
const ids = Object.keys(aa);
|
|
119
|
+
if (!pruneSelection && isSelectionChange.isChange) {
|
|
120
|
+
const ids = Object.keys(selectedRowState);
|
|
92
121
|
const ssss = (0, _utils.filterByIds)(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
|
|
93
122
|
|
|
94
|
-
|
|
123
|
+
rowSelectedRef.current?.({
|
|
95
124
|
type: isSelectionChange.type,
|
|
96
125
|
rowData: isSelectionChange.rowData,
|
|
97
126
|
selected: ssss.filter(x => !x.isGroupRow)
|
|
98
127
|
});
|
|
99
128
|
}
|
|
100
|
-
}, [isSelectionChange,
|
|
129
|
+
}, [isSelectionChange, selectedRowState, pruneSelection]);
|
|
101
130
|
_react.default.useEffect(() => {
|
|
102
131
|
if (sorterChange) {
|
|
103
132
|
const aa = table.getState().sorting;
|
|
@@ -188,7 +217,7 @@ const Grid = props => {
|
|
|
188
217
|
originData: originData,
|
|
189
218
|
prefix: prefix,
|
|
190
219
|
selectionSettings: selectionSettings,
|
|
191
|
-
isSelectionChange:
|
|
220
|
+
isSelectionChange: selectionChange,
|
|
192
221
|
setIsSelectionChange: setIsSelectionChange,
|
|
193
222
|
setSorterChange: setSorterChange,
|
|
194
223
|
setFilterChange: setFilterChange,
|
|
@@ -258,7 +287,7 @@ const Grid = props => {
|
|
|
258
287
|
originData: originData,
|
|
259
288
|
prefix: prefix,
|
|
260
289
|
selectionSettings: selectionSettings,
|
|
261
|
-
isSelectionChange:
|
|
290
|
+
isSelectionChange: selectionChange,
|
|
262
291
|
setIsSelectionChange: setIsSelectionChange,
|
|
263
292
|
setSorterChange: setSorterChange,
|
|
264
293
|
setFilterChange: setFilterChange,
|
|
@@ -37,6 +37,7 @@ const TableContainer = props => {
|
|
|
37
37
|
expandable,
|
|
38
38
|
wrapSettings,
|
|
39
39
|
recordDoubleClick,
|
|
40
|
+
rowFocus,
|
|
40
41
|
// triggerFilter,
|
|
41
42
|
selectionSettings,
|
|
42
43
|
isSelectionChange,
|
|
@@ -281,6 +282,7 @@ const TableContainer = props => {
|
|
|
281
282
|
originData,
|
|
282
283
|
wrapSettings,
|
|
283
284
|
recordDoubleClick,
|
|
285
|
+
rowFocus,
|
|
284
286
|
selectionSettings,
|
|
285
287
|
isSelectionChange,
|
|
286
288
|
setIsSelectionChange,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RowFocusEventArgs } from "../grid-component/type";
|
|
1
2
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
3
|
import type { ColumnTable, ExpandableConfig, IFormat, IGroupSetting, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "../grid-component/type";
|
|
3
4
|
import type { SubmitHandler } from "react-hook-form";
|
|
@@ -19,6 +20,7 @@ export interface IContext<T> {
|
|
|
19
20
|
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
|
|
20
21
|
expanded: ExpandedState;
|
|
21
22
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
|
|
23
|
+
rowFocus?: (args: RowFocusEventArgs<T>) => void;
|
|
22
24
|
selectionSettings?: SelectionSettings;
|
|
23
25
|
isSelectionChange?: {
|
|
24
26
|
isChange: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.95",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@hookform/resolvers": "5.0.1",
|
|
48
48
|
"@popperjs/core": "2.11.8",
|
|
49
49
|
"@rc-component/color-picker": "2.0.1",
|
|
50
|
-
"@rc-component/father-plugin": "
|
|
50
|
+
"@rc-component/father-plugin": "2.0.1",
|
|
51
51
|
"@rc-component/trigger": "2.0.0",
|
|
52
52
|
"@rc-component/util": "1.0.1",
|
|
53
53
|
"@tanstack/react-table": "8.21.3",
|