es-grid-template 1.9.92 → 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/ali-table/pipeline/features/columnCustom.js +6 -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 +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 +9 -4
- package/es/table-component/body/TableBodyRow.js +12 -4
- package/es/table-component/style.js +1 -1
- package/es/table-component/style.scss +6 -2
- 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/ali-table/pipeline/features/columnCustom.js +6 -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 +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/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 +9 -4
- package/lib/table-component/body/TableBodyRow.js +12 -4
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/style.scss +6 -2
- 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
|
@@ -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;
|
|
@@ -334,6 +334,9 @@ function columnCustom(opts) {
|
|
|
334
334
|
// Chức năng edit
|
|
335
335
|
|
|
336
336
|
const handleEdit = (e, record, col, editType, isKeyDown, isHeader) => {
|
|
337
|
+
if (!isHeader && (!(0, _hooks.isEditable)(col, record) || rowEditable?.(record) === false)) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
337
340
|
reset?.();
|
|
338
341
|
const cell = e.currentTarget;
|
|
339
342
|
pipeline.setStateAtKey(_constants.stateKeyIsEditing, {
|
|
@@ -546,6 +549,9 @@ function columnCustom(opts) {
|
|
|
546
549
|
// Không vượt quá số cột
|
|
547
550
|
return;
|
|
548
551
|
}
|
|
552
|
+
if (!(0, _hooks.isEditable)(leafColumns[targetCol], newData[targetRow])) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
549
555
|
const columnKey = leafColumns[targetCol].field;
|
|
550
556
|
newData[targetRow] = {
|
|
551
557
|
...newData[targetRow],
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.ui-rc-grid-refresh-spin {
|
|
2
|
-
transform-origin: center;
|
|
3
|
-
transform-box: fill-box;
|
|
4
|
-
animation: ui-rc-grid-refresh-spin 0.8s linear infinite;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
@keyframes ui-rc-grid-refresh-spin {
|
|
8
|
-
to { transform: rotate(360deg); }
|
|
9
|
-
}
|
|
1
|
+
.ui-rc-grid-refresh-spin {
|
|
2
|
+
transform-origin: center;
|
|
3
|
+
transform-box: fill-box;
|
|
4
|
+
animation: ui-rc-grid-refresh-spin 0.8s linear infinite;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@keyframes ui-rc-grid-refresh-spin {
|
|
8
|
+
to { transform: rotate(360deg); }
|
|
9
|
+
}
|
|
@@ -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,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRowFocusHandlers = getRowFocusHandlers;
|
|
7
|
+
exports.notifyArrowRowFocus = notifyArrowRowFocus;
|
|
8
|
+
/** Capture clicks even when a cell handles the event itself. */
|
|
9
|
+
function getRowFocusHandlers(rowData, rowFocus) {
|
|
10
|
+
return {
|
|
11
|
+
onClickCapture: event => {
|
|
12
|
+
if (event.button === 0) rowFocus?.({
|
|
13
|
+
rowData,
|
|
14
|
+
method: 'mouseLeftClick'
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
onContextMenuCapture: event => {
|
|
18
|
+
if (event.button === 2) rowFocus?.({
|
|
19
|
+
rowData,
|
|
20
|
+
method: 'mouseRightClick'
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Notify arrow focus without changing the existing navigation or selection. */
|
|
27
|
+
function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
|
|
28
|
+
if (useArrow === true) rowFocus?.({
|
|
29
|
+
rowData,
|
|
30
|
+
method
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -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;
|
|
@@ -38,6 +38,7 @@ const TableContainer = props => {
|
|
|
38
38
|
expandable,
|
|
39
39
|
wrapSettings,
|
|
40
40
|
recordDoubleClick,
|
|
41
|
+
rowFocus,
|
|
41
42
|
// triggerFilter,
|
|
42
43
|
selectionSettings,
|
|
43
44
|
isSelectionChange,
|
|
@@ -325,6 +326,7 @@ const TableContainer = props => {
|
|
|
325
326
|
// triggerFilter,
|
|
326
327
|
wrapSettings,
|
|
327
328
|
recordDoubleClick,
|
|
329
|
+
rowFocus,
|
|
328
330
|
selectionSettings,
|
|
329
331
|
isSelectionChange,
|
|
330
332
|
setIsSelectionChange,
|
|
@@ -86,6 +86,7 @@ const TableContainerEdit = props => {
|
|
|
86
86
|
expandable,
|
|
87
87
|
wrapSettings,
|
|
88
88
|
recordDoubleClick,
|
|
89
|
+
rowFocus,
|
|
89
90
|
// triggerFilter,
|
|
90
91
|
selectionSettings,
|
|
91
92
|
isSelectionChange,
|
|
@@ -2213,6 +2214,7 @@ const TableContainerEdit = props => {
|
|
|
2213
2214
|
originData,
|
|
2214
2215
|
wrapSettings,
|
|
2215
2216
|
recordDoubleClick,
|
|
2217
|
+
rowFocus,
|
|
2216
2218
|
selectionSettings: {
|
|
2217
2219
|
...selectionSettings,
|
|
2218
2220
|
checkboxOnly: true
|
|
@@ -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");
|
|
@@ -164,6 +165,7 @@ const TableBodyCell = props => {
|
|
|
164
165
|
id,
|
|
165
166
|
prefix,
|
|
166
167
|
focusedCell,
|
|
168
|
+
rowFocus,
|
|
167
169
|
setFocusedCell,
|
|
168
170
|
// endCell,
|
|
169
171
|
// startCell,
|
|
@@ -462,6 +464,7 @@ const TableBodyCell = props => {
|
|
|
462
464
|
colId: cell.column.id,
|
|
463
465
|
rowId: nextId
|
|
464
466
|
});
|
|
467
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
465
468
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
466
469
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
467
470
|
if (cellFocus) {
|
|
@@ -475,6 +478,7 @@ const TableBodyCell = props => {
|
|
|
475
478
|
colId: cell.column.id,
|
|
476
479
|
rowId: nextId
|
|
477
480
|
});
|
|
481
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
478
482
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
479
483
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
480
484
|
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");
|
|
@@ -202,6 +203,7 @@ const TableBodyCellEdit = props => {
|
|
|
202
203
|
editingKey,
|
|
203
204
|
prefix,
|
|
204
205
|
focusedCell,
|
|
206
|
+
rowFocus,
|
|
205
207
|
rangeState,
|
|
206
208
|
setFocusedCell,
|
|
207
209
|
setEditingKey,
|
|
@@ -810,6 +812,7 @@ const TableBodyCellEdit = props => {
|
|
|
810
812
|
rowId: nextRowId,
|
|
811
813
|
colId
|
|
812
814
|
});
|
|
815
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
813
816
|
setStartCell?.({
|
|
814
817
|
rowId: nextRowId,
|
|
815
818
|
colId
|
|
@@ -857,6 +860,7 @@ const TableBodyCellEdit = props => {
|
|
|
857
860
|
rowId: nextRowId,
|
|
858
861
|
colId
|
|
859
862
|
});
|
|
863
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
860
864
|
setStartCell?.({
|
|
861
865
|
rowId: nextRowId,
|
|
862
866
|
colId
|
|
@@ -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"));
|
|
@@ -22,6 +23,7 @@ const TableBodyCellEmpty = props => {
|
|
|
22
23
|
id,
|
|
23
24
|
prefix,
|
|
24
25
|
focusedCell,
|
|
26
|
+
rowFocus,
|
|
25
27
|
setFocusedCell,
|
|
26
28
|
setIsSelectionChange,
|
|
27
29
|
isSelectionChange,
|
|
@@ -107,6 +109,7 @@ const TableBodyCellEmpty = props => {
|
|
|
107
109
|
colId: cell.column.id,
|
|
108
110
|
rowId: nextId
|
|
109
111
|
});
|
|
112
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
110
113
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
111
114
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
112
115
|
if (cellFocus) {
|
|
@@ -120,6 +123,7 @@ const TableBodyCellEmpty = props => {
|
|
|
120
123
|
colId: cell.column.id,
|
|
121
124
|
rowId: nextId
|
|
122
125
|
});
|
|
126
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
123
127
|
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
124
128
|
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
125
129
|
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 _TableBodyCellEdit = _interopRequireDefault(require("./TableBodyCellEdit"));
|
|
11
12
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -35,6 +36,7 @@ const TableBodyRow = ({
|
|
|
35
36
|
const {
|
|
36
37
|
prefix,
|
|
37
38
|
recordDoubleClick,
|
|
39
|
+
rowFocus,
|
|
38
40
|
focusedCell,
|
|
39
41
|
rowClassName,
|
|
40
42
|
rowEditable,
|
|
@@ -60,7 +62,7 @@ const TableBodyRow = ({
|
|
|
60
62
|
const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
|
|
61
63
|
const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
|
|
62
64
|
const isRowEditable = rowEditable ? rowEditable(row.original) : true;
|
|
63
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
64
66
|
"data-index": virtualRow.index //needed for dynamic row height measurement
|
|
65
67
|
,
|
|
66
68
|
ref: rowVirtualizer.measureElement //measure dynamic row height
|
|
@@ -86,7 +88,8 @@ const TableBodyRow = ({
|
|
|
86
88
|
height: isEditing ? virtualRow.size : undefined,
|
|
87
89
|
minHeight: isEditing ? undefined : virtualRow.size,
|
|
88
90
|
...rowStyles
|
|
89
|
-
}
|
|
91
|
+
}
|
|
92
|
+
}, (0, _rowFocus.getRowFocusHandlers)(row.original, rowFocus), {
|
|
90
93
|
onDoubleClick: e => {
|
|
91
94
|
recordDoubleClick?.({
|
|
92
95
|
e,
|
|
@@ -110,7 +113,7 @@ const TableBodyRow = ({
|
|
|
110
113
|
field: colKey
|
|
111
114
|
})(e);
|
|
112
115
|
}
|
|
113
|
-
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
116
|
+
}), fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
114
117
|
const cell = row.getVisibleCells().find(c => c.column.id === column.id);
|
|
115
118
|
if (row.subRows && row.subRows.length === 0 && groupColumns?.includes(cell.column.id)) {
|
|
116
119
|
return /*#__PURE__*/_react.default.createElement(_TableBodyCellEmpty.default, (0, _extends2.default)({}, rest, {
|
|
@@ -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");
|
|
@@ -164,6 +165,7 @@ const TableBodyCell = props => {
|
|
|
164
165
|
id,
|
|
165
166
|
prefix,
|
|
166
167
|
focusedCell,
|
|
168
|
+
rowFocus,
|
|
167
169
|
setFocusedCell,
|
|
168
170
|
// endCell,
|
|
169
171
|
// startCell,
|
|
@@ -442,6 +444,7 @@ const TableBodyCell = props => {
|
|
|
442
444
|
colId: cell.column.id,
|
|
443
445
|
rowId: nextId
|
|
444
446
|
});
|
|
447
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
445
448
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
446
449
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
447
450
|
if (cellFocus) {
|
|
@@ -455,6 +458,7 @@ const TableBodyCell = props => {
|
|
|
455
458
|
colId: cell.column.id,
|
|
456
459
|
rowId: nextId
|
|
457
460
|
});
|
|
461
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
458
462
|
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
459
463
|
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
460
464
|
if (cellFocus) {
|
|
@@ -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,
|
|
@@ -274,6 +276,7 @@ const TableBodyCellEdit = props => {
|
|
|
274
276
|
return selectRowIds.includes(cell.row.id) && colIdss.includes(cell.column.id);
|
|
275
277
|
}, [cell.column.id, cell.row.id, endCell, selectRowIds, startCell, table]);
|
|
276
278
|
const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
|
|
279
|
+
const isSelectCell = ['select', 'selectTable', 'asyncSelect', 'treeSelect'].includes(editType ?? 'text');
|
|
277
280
|
const {
|
|
278
281
|
rowRange,
|
|
279
282
|
colRange,
|
|
@@ -832,6 +835,7 @@ const TableBodyCellEdit = props => {
|
|
|
832
835
|
rowId: nextRowId,
|
|
833
836
|
colId
|
|
834
837
|
});
|
|
838
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
835
839
|
setStartCell?.({
|
|
836
840
|
rowId: nextRowId,
|
|
837
841
|
colId
|
|
@@ -870,6 +874,7 @@ const TableBodyCellEdit = props => {
|
|
|
870
874
|
rowId: nextRowId,
|
|
871
875
|
colId
|
|
872
876
|
});
|
|
877
|
+
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
873
878
|
setStartCell?.({
|
|
874
879
|
rowId: nextRowId,
|
|
875
880
|
colId
|
|
@@ -1458,7 +1463,7 @@ const TableBodyCellEdit = props => {
|
|
|
1458
1463
|
}, cellContent)))
|
|
1459
1464
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1460
1465
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
1461
|
-
'select-cell':
|
|
1466
|
+
'select-cell': isSelectCell
|
|
1462
1467
|
})
|
|
1463
1468
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
1464
1469
|
className: "ui-rc-table-row-expand-trigger",
|
|
@@ -1496,14 +1501,14 @@ const TableBodyCellEdit = props => {
|
|
|
1496
1501
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
1497
1502
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
1498
1503
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
1499
|
-
}))), cellContent,
|
|
1504
|
+
}))), cellContent, isSelectCell && canEdit && /*#__PURE__*/_react.default.createElement("span", {
|
|
1500
1505
|
className: 'caret-down',
|
|
1501
1506
|
onClick: e => {
|
|
1502
1507
|
handleEdit(e);
|
|
1503
1508
|
}
|
|
1504
1509
|
})))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
1505
1510
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
1506
|
-
'select-cell':
|
|
1511
|
+
'select-cell': isSelectCell
|
|
1507
1512
|
})
|
|
1508
1513
|
}, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
|
|
1509
1514
|
className: "ui-rc-table-row-expand-trigger",
|
|
@@ -1541,7 +1546,7 @@ const TableBodyCellEdit = props => {
|
|
|
1541
1546
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
|
|
1542
1547
|
})) : /*#__PURE__*/_react.default.createElement("span", {
|
|
1543
1548
|
className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
|
|
1544
|
-
}))), cellContent,
|
|
1549
|
+
}))), cellContent, isSelectCell && canEdit && /*#__PURE__*/_react.default.createElement("span", {
|
|
1545
1550
|
className: 'caret-down',
|
|
1546
1551
|
onClick: e => {
|
|
1547
1552
|
handleEdit(e);
|