es-grid-template 1.9.93 → 1.9.94
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/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 +8 -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 +9 -9
- 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/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/TableContainer.js +2 -0
- package/es/table-virtuoso/useContext.d.ts +2 -0
- 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 +8 -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/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/TableContainer.js +2 -0
- package/lib/table-virtuoso/useContext.d.ts +2 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MouseEvent } from 'react';
|
|
2
|
+
import type { RowFocusEventArgs } from '../type';
|
|
3
|
+
type RowFocus<T> = (args: RowFocusEventArgs<T>) => void;
|
|
4
|
+
/** Capture clicks even when a cell handles the event itself. */
|
|
5
|
+
export declare function getRowFocusHandlers<T>(rowData: T, rowFocus?: RowFocus<T>): {
|
|
6
|
+
onClickCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
onContextMenuCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
8
|
+
};
|
|
9
|
+
/** Notify arrow focus without changing the existing navigation or selection. */
|
|
10
|
+
export declare function notifyArrowRowFocus<T>(rowData: T, method: 'arrowUp' | 'arrowDown', useArrow?: boolean, rowFocus?: RowFocus<T>): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Capture clicks even when a cell handles the event itself. */
|
|
2
|
+
export function getRowFocusHandlers(rowData, rowFocus) {
|
|
3
|
+
return {
|
|
4
|
+
onClickCapture: event => {
|
|
5
|
+
if (event.button === 0) rowFocus?.({
|
|
6
|
+
rowData,
|
|
7
|
+
method: 'mouseLeftClick'
|
|
8
|
+
});
|
|
9
|
+
},
|
|
10
|
+
onContextMenuCapture: event => {
|
|
11
|
+
if (event.button === 2) rowFocus?.({
|
|
12
|
+
rowData,
|
|
13
|
+
method: 'mouseRightClick'
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Notify arrow focus without changing the existing navigation or selection. */
|
|
20
|
+
export function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
|
|
21
|
+
if (useArrow === true) rowFocus?.({
|
|
22
|
+
rowData,
|
|
23
|
+
method
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TempTable from './TempTable';
|
|
2
|
-
import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem } from './type';
|
|
2
|
+
import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem, RowFocusEventArgs } from './type';
|
|
3
3
|
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
4
|
-
export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem };
|
|
4
|
+
export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem, RowFocusEventArgs };
|
|
5
5
|
export default TempTable;
|
|
@@ -451,6 +451,8 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
451
451
|
recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
|
|
452
452
|
/** Click vào row */
|
|
453
453
|
recordClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
|
|
454
|
+
/** Notify mouse clicks or enabled arrow-key navigation independently of row selection. */
|
|
455
|
+
rowFocus?: (args: RowFocusEventArgs<RecordType>) => void;
|
|
454
456
|
/** Filter */
|
|
455
457
|
/** Hiển thị filter nâng cao */
|
|
456
458
|
showAdvanceFilter?: boolean;
|
|
@@ -789,6 +791,8 @@ export type IWrapSettings = {
|
|
|
789
791
|
wrapMode?: IWrapMode;
|
|
790
792
|
};
|
|
791
793
|
export type SelectionSettings<T = AnyObject> = {
|
|
794
|
+
/** Invoke rowFocus on ArrowUp/ArrowDown. Defaults to false. */
|
|
795
|
+
useArrow?: boolean;
|
|
792
796
|
mode?: 'checkbox' | 'radio';
|
|
793
797
|
type?: 'single' | 'multiple';
|
|
794
798
|
checkboxOnly?: boolean;
|
|
@@ -824,6 +828,10 @@ export type RowSelection<T> = {
|
|
|
824
828
|
checkboxOnly?: boolean;
|
|
825
829
|
arrowKey?: boolean;
|
|
826
830
|
};
|
|
831
|
+
export type RowFocusEventArgs<RecordType> = {
|
|
832
|
+
rowData: RecordType;
|
|
833
|
+
method: 'mouseLeftClick' | 'mouseRightClick' | 'arrowUp' | 'arrowDown';
|
|
834
|
+
};
|
|
827
835
|
export type RecordDoubleClickEventArgs<RecordType> = {
|
|
828
836
|
rowData: RecordType;
|
|
829
837
|
rowIndex: number | undefined;
|
|
@@ -30,6 +30,7 @@ const TableContainer = props => {
|
|
|
30
30
|
expandable,
|
|
31
31
|
wrapSettings,
|
|
32
32
|
recordDoubleClick,
|
|
33
|
+
rowFocus,
|
|
33
34
|
// triggerFilter,
|
|
34
35
|
selectionSettings,
|
|
35
36
|
isSelectionChange,
|
|
@@ -317,6 +318,7 @@ const TableContainer = props => {
|
|
|
317
318
|
// triggerFilter,
|
|
318
319
|
wrapSettings,
|
|
319
320
|
recordDoubleClick,
|
|
321
|
+
rowFocus,
|
|
320
322
|
selectionSettings,
|
|
321
323
|
isSelectionChange,
|
|
322
324
|
setIsSelectionChange,
|
|
@@ -78,6 +78,7 @@ const TableContainerEdit = props => {
|
|
|
78
78
|
expandable,
|
|
79
79
|
wrapSettings,
|
|
80
80
|
recordDoubleClick,
|
|
81
|
+
rowFocus,
|
|
81
82
|
// triggerFilter,
|
|
82
83
|
selectionSettings,
|
|
83
84
|
isSelectionChange,
|
|
@@ -2205,6 +2206,7 @@ const TableContainerEdit = props => {
|
|
|
2205
2206
|
originData,
|
|
2206
2207
|
wrapSettings,
|
|
2207
2208
|
recordDoubleClick,
|
|
2209
|
+
rowFocus,
|
|
2208
2210
|
selectionSettings: {
|
|
2209
2211
|
...selectionSettings,
|
|
2210
2212
|
checkboxOnly: true
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import Command from "../components/command/Command";
|
|
3
4
|
import { getCommonPinningStyles, getSelectedCellMatrix } from "../hook/utils";
|
|
@@ -156,6 +157,7 @@ const TableBodyCell = props => {
|
|
|
156
157
|
id,
|
|
157
158
|
prefix,
|
|
158
159
|
focusedCell,
|
|
160
|
+
rowFocus,
|
|
159
161
|
setFocusedCell,
|
|
160
162
|
// endCell,
|
|
161
163
|
// startCell,
|
|
@@ -454,6 +456,7 @@ const TableBodyCell = props => {
|
|
|
454
456
|
colId: cell.column.id,
|
|
455
457
|
rowId: nextId
|
|
456
458
|
});
|
|
459
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
457
460
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
458
461
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
459
462
|
if (cellFocus) {
|
|
@@ -467,6 +470,7 @@ const TableBodyCell = props => {
|
|
|
467
470
|
colId: cell.column.id,
|
|
468
471
|
rowId: nextId
|
|
469
472
|
});
|
|
473
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
470
474
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
471
475
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
472
476
|
if (cellFocus) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import Command from "../components/command/Command";
|
|
3
4
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
@@ -195,6 +196,7 @@ const TableBodyCellEdit = props => {
|
|
|
195
196
|
editingKey,
|
|
196
197
|
prefix,
|
|
197
198
|
focusedCell,
|
|
199
|
+
rowFocus,
|
|
198
200
|
rangeState,
|
|
199
201
|
setFocusedCell,
|
|
200
202
|
setEditingKey,
|
|
@@ -803,6 +805,7 @@ const TableBodyCellEdit = props => {
|
|
|
803
805
|
rowId: nextRowId,
|
|
804
806
|
colId
|
|
805
807
|
});
|
|
808
|
+
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
806
809
|
setStartCell?.({
|
|
807
810
|
rowId: nextRowId,
|
|
808
811
|
colId
|
|
@@ -850,6 +853,7 @@ const TableBodyCellEdit = props => {
|
|
|
850
853
|
rowId: nextRowId,
|
|
851
854
|
colId
|
|
852
855
|
});
|
|
856
|
+
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
853
857
|
setStartCell?.({
|
|
854
858
|
rowId: nextRowId,
|
|
855
859
|
colId
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
// import ReactDOMServer from 'react-dom/server'
|
|
2
3
|
|
|
3
4
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
@@ -15,6 +16,7 @@ const TableBodyCellEmpty = props => {
|
|
|
15
16
|
id,
|
|
16
17
|
prefix,
|
|
17
18
|
focusedCell,
|
|
19
|
+
rowFocus,
|
|
18
20
|
setFocusedCell,
|
|
19
21
|
setIsSelectionChange,
|
|
20
22
|
isSelectionChange,
|
|
@@ -100,6 +102,7 @@ const TableBodyCellEmpty = props => {
|
|
|
100
102
|
colId: cell.column.id,
|
|
101
103
|
rowId: nextId
|
|
102
104
|
});
|
|
105
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
103
106
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
104
107
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
105
108
|
if (cellFocus) {
|
|
@@ -113,6 +116,7 @@ const TableBodyCellEmpty = props => {
|
|
|
113
116
|
colId: cell.column.id,
|
|
114
117
|
rowId: nextId
|
|
115
118
|
});
|
|
119
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
116
120
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
117
121
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
118
122
|
if (cellFocus) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { getRowFocusHandlers } from "../../grid-component/hooks/rowFocus";
|
|
2
3
|
import TableBodyCell from "./TableBodyCell";
|
|
3
4
|
import TableBodyCellEdit from "./TableBodyCellEdit";
|
|
4
5
|
import React from "react";
|
|
@@ -28,6 +29,7 @@ const TableBodyRow = ({
|
|
|
28
29
|
const {
|
|
29
30
|
prefix,
|
|
30
31
|
recordDoubleClick,
|
|
32
|
+
rowFocus,
|
|
31
33
|
focusedCell,
|
|
32
34
|
rowClassName,
|
|
33
35
|
rowEditable,
|
|
@@ -53,7 +55,7 @@ const TableBodyRow = ({
|
|
|
53
55
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
54
56
|
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
55
57
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
56
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
57
59
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
58
60
|
,
|
|
59
61
|
ref: rowVirtualizer.measureElement //measure dynamic row height
|
|
@@ -79,7 +81,8 @@ const TableBodyRow = ({
|
|
|
79
81
|
height: isEditing ? virtualRow.size : undefined,
|
|
80
82
|
minHeight: isEditing ? undefined : virtualRow.size,
|
|
81
83
|
...rowStyles
|
|
82
|
-
}
|
|
84
|
+
}
|
|
85
|
+
}, getRowFocusHandlers(row.original, rowFocus), {
|
|
83
86
|
onDoubleClick: e => {
|
|
84
87
|
recordDoubleClick?.({
|
|
85
88
|
e,
|
|
@@ -103,7 +106,7 @@ const TableBodyRow = ({
|
|
|
103
106
|
field: colKey
|
|
104
107
|
})(e);
|
|
105
108
|
}
|
|
106
|
-
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
109
|
+
}), fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
107
110
|
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
108
111
|
if (row.subRows && row.subRows.length === 0 && groupColumns?.includes(cell.column.id)) {
|
|
109
112
|
return /*#__PURE__*/React.createElement(TableBodyCellEmpty, _extends({}, rest, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import Command from "../components/command/Command";
|
|
3
4
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
@@ -156,6 +157,7 @@ const TableBodyCell = props => {
|
|
|
156
157
|
id,
|
|
157
158
|
prefix,
|
|
158
159
|
focusedCell,
|
|
160
|
+
rowFocus,
|
|
159
161
|
setFocusedCell,
|
|
160
162
|
// endCell,
|
|
161
163
|
// startCell,
|
|
@@ -434,6 +436,7 @@ const TableBodyCell = props => {
|
|
|
434
436
|
colId: cell.column.id,
|
|
435
437
|
rowId: nextId
|
|
436
438
|
});
|
|
439
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
437
440
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
438
441
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
439
442
|
if (cellFocus) {
|
|
@@ -447,6 +450,7 @@ const TableBodyCell = props => {
|
|
|
447
450
|
colId: cell.column.id,
|
|
448
451
|
rowId: nextId
|
|
449
452
|
});
|
|
453
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
450
454
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
451
455
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
452
456
|
if (cellFocus) {
|
|
@@ -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").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
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").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
183
183
|
columnGroupText?: string;
|
|
184
184
|
headerTextAlign?: import("./../../grid-component/type").ITextAlign;
|
|
185
|
-
headerTemplate?: import("react").
|
|
185
|
+
headerTemplate?: import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((column: ColumnTable<RecordType>) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
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").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
193
|
+
linkTemplate?: import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
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").ReactNode | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
|
|
199
|
+
onCellStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth">);
|
|
200
|
+
onCellHeaderStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth">);
|
|
201
201
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
202
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
202
|
+
onCellFooterStyles?: Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "right" | "left" | "position" | "display" | "width" | "minWidth">);
|
|
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/es/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';
|
|
@@ -29,6 +29,7 @@ const TableContainer = props => {
|
|
|
29
29
|
expandable,
|
|
30
30
|
wrapSettings,
|
|
31
31
|
recordDoubleClick,
|
|
32
|
+
rowFocus,
|
|
32
33
|
// triggerFilter,
|
|
33
34
|
selectionSettings,
|
|
34
35
|
isSelectionChange,
|
|
@@ -325,6 +326,7 @@ const TableContainer = props => {
|
|
|
325
326
|
// triggerFilter,
|
|
326
327
|
wrapSettings,
|
|
327
328
|
recordDoubleClick,
|
|
329
|
+
rowFocus,
|
|
328
330
|
recordClick,
|
|
329
331
|
selectionSettings,
|
|
330
332
|
isSelectionChange,
|
|
@@ -84,6 +84,7 @@ const TableContainerEdit = props => {
|
|
|
84
84
|
expandable,
|
|
85
85
|
wrapSettings,
|
|
86
86
|
recordDoubleClick,
|
|
87
|
+
rowFocus,
|
|
87
88
|
selectionSettings,
|
|
88
89
|
isSelectionChange,
|
|
89
90
|
setIsSelectionChange,
|
|
@@ -2225,6 +2226,7 @@ const TableContainerEdit = props => {
|
|
|
2225
2226
|
originData,
|
|
2226
2227
|
wrapSettings,
|
|
2227
2228
|
recordDoubleClick,
|
|
2229
|
+
rowFocus,
|
|
2228
2230
|
selectionSettings,
|
|
2229
2231
|
isSelectionChange,
|
|
2230
2232
|
setIsSelectionChange,
|
|
@@ -25,9 +25,13 @@ const TableBody = ({
|
|
|
25
25
|
locale
|
|
26
26
|
} = React.useContext(TableContext);
|
|
27
27
|
|
|
28
|
+
// Keep measured heights attached to records when expanding, sorting or filtering.
|
|
29
|
+
const getItemKey = React.useCallback(index => rows[index].id, [rows]);
|
|
30
|
+
|
|
28
31
|
//dynamic row height virtualization - alternatively you could use a simpler fixed row height strategy without the need for `measureElement`
|
|
29
32
|
const rowVirtualizer = useVirtualizer({
|
|
30
33
|
count: rows.length,
|
|
34
|
+
getItemKey,
|
|
31
35
|
estimateSize: () => 32,
|
|
32
36
|
//estimate row height for accurate scrollbar dragging
|
|
33
37
|
getScrollElement: () => tableContainerRef.current,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import Command from "../components/command/Command";
|
|
3
4
|
import { getCommonPinningStyles, getFormat } from "../hook/utils";
|
|
@@ -163,6 +164,7 @@ const TableBodyCell = props => {
|
|
|
163
164
|
id,
|
|
164
165
|
prefix,
|
|
165
166
|
focusedCell,
|
|
167
|
+
rowFocus,
|
|
166
168
|
setFocusedCell,
|
|
167
169
|
// endCell,
|
|
168
170
|
// startCell,
|
|
@@ -443,6 +445,7 @@ const TableBodyCell = props => {
|
|
|
443
445
|
colId: cell.column.id,
|
|
444
446
|
rowId: nextId
|
|
445
447
|
});
|
|
448
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
446
449
|
|
|
447
450
|
// if (rowNumber < flatRows.length - 5) {
|
|
448
451
|
// e.stopPropagation()
|
|
@@ -465,6 +468,7 @@ const TableBodyCell = props => {
|
|
|
465
468
|
colId: cell.column.id,
|
|
466
469
|
rowId: nextId
|
|
467
470
|
});
|
|
471
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
468
472
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
469
473
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
470
474
|
if (cellFocus) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import Command from "../components/command/Command";
|
|
3
4
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat,
|
|
@@ -194,6 +195,7 @@ const TableBodyCellEdit = props => {
|
|
|
194
195
|
editingKey,
|
|
195
196
|
prefix,
|
|
196
197
|
focusedCell,
|
|
198
|
+
rowFocus,
|
|
197
199
|
rangeState,
|
|
198
200
|
setFocusedCell,
|
|
199
201
|
setEditingKey,
|
|
@@ -828,6 +830,7 @@ const TableBodyCellEdit = props => {
|
|
|
828
830
|
rowId: nextRowId,
|
|
829
831
|
colId
|
|
830
832
|
});
|
|
833
|
+
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
831
834
|
setStartCell?.({
|
|
832
835
|
rowId: nextRowId,
|
|
833
836
|
colId
|
|
@@ -866,6 +869,7 @@ const TableBodyCellEdit = props => {
|
|
|
866
869
|
rowId: nextRowId,
|
|
867
870
|
colId
|
|
868
871
|
});
|
|
872
|
+
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
869
873
|
setStartCell?.({
|
|
870
874
|
rowId: nextRowId,
|
|
871
875
|
colId
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { getRowFocusHandlers } from "../../grid-component/hooks/rowFocus";
|
|
2
3
|
import TableBodyCell from "./TableBodyCell";
|
|
3
4
|
import TableBodyCellEdit from "./TableBodyCellEdit";
|
|
4
5
|
import React from "react";
|
|
@@ -25,6 +26,7 @@ const TableBodyRow = ({
|
|
|
25
26
|
const {
|
|
26
27
|
prefix,
|
|
27
28
|
recordDoubleClick,
|
|
29
|
+
rowFocus,
|
|
28
30
|
focusedCell,
|
|
29
31
|
rowClassName,
|
|
30
32
|
rowEditable,
|
|
@@ -54,10 +56,15 @@ const TableBodyRow = ({
|
|
|
54
56
|
isSelected: row.getIsSelected()
|
|
55
57
|
}) : onRowStyles;
|
|
56
58
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
57
|
-
|
|
59
|
+
|
|
60
|
+
// A reused DOM row needs measuring again when its virtual index changes.
|
|
61
|
+
const measureRow = React.useCallback(element => {
|
|
62
|
+
rowVirtualizer.measureElement(element);
|
|
63
|
+
}, [rowVirtualizer, virtualRow.index]);
|
|
64
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
58
65
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
59
66
|
,
|
|
60
|
-
ref:
|
|
67
|
+
ref: measureRow //measure dynamic row height
|
|
61
68
|
,
|
|
62
69
|
key: row.id,
|
|
63
70
|
"data-row-key": row.id,
|
|
@@ -80,7 +87,8 @@ const TableBodyRow = ({
|
|
|
80
87
|
height: isEditing ? virtualRow.size : undefined,
|
|
81
88
|
minHeight: isEditing ? undefined : virtualRow.size,
|
|
82
89
|
...rowStyles
|
|
83
|
-
}
|
|
90
|
+
}
|
|
91
|
+
}, getRowFocusHandlers(row.original, rowFocus), {
|
|
84
92
|
onDoubleClick: e => {
|
|
85
93
|
recordDoubleClick?.({
|
|
86
94
|
e,
|
|
@@ -99,7 +107,7 @@ const TableBodyRow = ({
|
|
|
99
107
|
})(e);
|
|
100
108
|
// }
|
|
101
109
|
}
|
|
102
|
-
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
110
|
+
}), fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
103
111
|
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
104
112
|
if (editAble) {
|
|
105
113
|
return /*#__PURE__*/React.createElement(TableBodyCellEdit, _extends({}, 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?: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import Space from "rc-master-ui/es/space";
|
|
2
3
|
import { getCommonPinningStyles, getFormat } from "../hook/utils";
|
|
3
4
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
@@ -151,6 +152,7 @@ const TableBodyCell = props => {
|
|
|
151
152
|
id,
|
|
152
153
|
prefix,
|
|
153
154
|
focusedCell,
|
|
155
|
+
rowFocus,
|
|
154
156
|
setFocusedCell,
|
|
155
157
|
// endCell,
|
|
156
158
|
// startCell,
|
|
@@ -382,6 +384,7 @@ const TableBodyCell = props => {
|
|
|
382
384
|
colId: cell.column.id,
|
|
383
385
|
rowId: nextId
|
|
384
386
|
});
|
|
387
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
385
388
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
386
389
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
387
390
|
if (cellFocus) {
|
|
@@ -395,6 +398,7 @@ const TableBodyCell = props => {
|
|
|
395
398
|
colId: cell.column.id,
|
|
396
399
|
rowId: nextId
|
|
397
400
|
});
|
|
401
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
398
402
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
399
403
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
400
404
|
if (cellFocus) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
2
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
2
3
|
import classNames from "classnames";
|
|
3
4
|
import React from "react";
|
|
@@ -16,6 +17,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
16
17
|
id,
|
|
17
18
|
prefix,
|
|
18
19
|
focusedCell,
|
|
20
|
+
rowFocus,
|
|
19
21
|
setFocusedCell,
|
|
20
22
|
expanded,
|
|
21
23
|
setExpanded,
|
|
@@ -97,6 +99,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
97
99
|
colId: cell.column.id,
|
|
98
100
|
rowId: nextId
|
|
99
101
|
});
|
|
102
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
100
103
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
101
104
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
102
105
|
if (cellFocus) {
|
|
@@ -110,6 +113,7 @@ const TableBodyCellRowGroup = props => {
|
|
|
110
113
|
colId: cell.column.id,
|
|
111
114
|
rowId: nextId
|
|
112
115
|
});
|
|
116
|
+
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
113
117
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
114
118
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
115
119
|
if (cellFocus) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { getRowFocusHandlers } from "../../grid-component/hooks/rowFocus";
|
|
2
3
|
import TableBodyCell from "./TableBodyCell";
|
|
3
4
|
import { flexRender } from "@tanstack/react-table";
|
|
4
5
|
import React from "react";
|
|
@@ -26,6 +27,7 @@ const TableBodyRow = ({
|
|
|
26
27
|
const {
|
|
27
28
|
prefix,
|
|
28
29
|
recordDoubleClick,
|
|
30
|
+
rowFocus,
|
|
29
31
|
focusedCell,
|
|
30
32
|
rowClassName,
|
|
31
33
|
onRowStyles,
|
|
@@ -60,7 +62,8 @@ const TableBodyRow = ({
|
|
|
60
62
|
style: {
|
|
61
63
|
...rowStyles,
|
|
62
64
|
height: rowheight
|
|
63
|
-
}
|
|
65
|
+
}
|
|
66
|
+
}, getRowFocusHandlers(row.original, rowFocus), {
|
|
64
67
|
onDoubleClick: e => {
|
|
65
68
|
recordDoubleClick?.({
|
|
66
69
|
e,
|
|
@@ -29,6 +29,7 @@ const TableContainer = props => {
|
|
|
29
29
|
expandable,
|
|
30
30
|
wrapSettings,
|
|
31
31
|
recordDoubleClick,
|
|
32
|
+
rowFocus,
|
|
32
33
|
// triggerFilter,
|
|
33
34
|
selectionSettings,
|
|
34
35
|
isSelectionChange,
|
|
@@ -273,6 +274,7 @@ const TableContainer = props => {
|
|
|
273
274
|
originData,
|
|
274
275
|
wrapSettings,
|
|
275
276
|
recordDoubleClick,
|
|
277
|
+
rowFocus,
|
|
276
278
|
selectionSettings,
|
|
277
279
|
isSelectionChange,
|
|
278
280
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MouseEvent } from 'react';
|
|
2
|
+
import type { RowFocusEventArgs } from '../type';
|
|
3
|
+
type RowFocus<T> = (args: RowFocusEventArgs<T>) => void;
|
|
4
|
+
/** Capture clicks even when a cell handles the event itself. */
|
|
5
|
+
export declare function getRowFocusHandlers<T>(rowData: T, rowFocus?: RowFocus<T>): {
|
|
6
|
+
onClickCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
7
|
+
onContextMenuCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
8
|
+
};
|
|
9
|
+
/** Notify arrow focus without changing the existing navigation or selection. */
|
|
10
|
+
export declare function notifyArrowRowFocus<T>(rowData: T, method: 'arrowUp' | 'arrowDown', useArrow?: boolean, rowFocus?: RowFocus<T>): void;
|
|
11
|
+
export {};
|