@nokecy/qc-ui-components 2.0.0-beta.0 → 2.0.0-beta.2
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/dist/cjs/ConfirmPro/index.d.ts +12 -9
- package/dist/cjs/ConfirmPro/index.js +11 -34
- package/dist/cjs/ag-grid-plus/ag-gridPlus.js +425 -157
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +12 -1
- package/dist/cjs/ag-grid-plus/context/queryFormContext.d.ts +2 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.js +8 -0
- package/dist/cjs/ag-grid-plus/density.d.ts +25 -0
- package/dist/cjs/ag-grid-plus/density.js +52 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +1 -0
- package/dist/cjs/ag-grid-plus/index.js +7 -0
- package/dist/cjs/ag-grid-plus/index.less +43 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +58 -1
- package/dist/cjs/ag-grid-plus/interface.js +1 -1
- package/dist/cjs/ag-grid-plus/queryForm/index.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/queryForm/index.js +62 -10
- package/dist/cjs/ag-grid-plus/queryForm/queryForm.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/queryForm/queryForm.js +63 -26
- package/dist/cjs/ag-grid-plus/queryForm/queryValues.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/queryForm/queryValues.js +61 -0
- package/dist/cjs/ag-grid-plus/rowColors.d.ts +12 -0
- package/dist/cjs/ag-grid-plus/rowColors.js +58 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.js +14 -5
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +108 -76
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +10 -9
- package/dist/cjs/ag-grid-plus/setting/autoColumnMemory.d.ts +37 -0
- package/dist/cjs/ag-grid-plus/setting/autoColumnMemory.js +206 -0
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.d.ts +2 -0
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +19 -1
- package/dist/cjs/ag-grid-plus/setting/index.js +5 -14
- package/dist/cjs/ag-grid-plus/settingItem/index.d.ts +11 -1
- package/dist/cjs/ag-grid-plus/settingItem/index.js +34 -12
- package/dist/cjs/ag-grid-plus/shared/EmptyIllustration.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/shared/EmptyIllustration.js +87 -0
- package/dist/cjs/ag-grid-plus/shared/NoRowsOverlay.js +9 -1
- package/dist/cjs/ag-grid-plus/shared/SkeletonOverlay.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/shared/SkeletonOverlay.js +40 -0
- package/dist/cjs/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/theme.d.ts +7 -1
- package/dist/cjs/ag-grid-plus/theme.js +31 -6
- package/dist/cjs/ag-grid-plus/toolBar/OverflowActions.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/toolBar/OverflowActions.js +128 -0
- package/dist/cjs/ag-grid-plus/toolBar/index.d.ts +3 -1
- package/dist/cjs/ag-grid-plus/toolBar/index.js +43 -35
- package/dist/cjs/ag-grid-plus/toolBar/leftContent.d.ts +2 -2
- package/dist/cjs/ag-grid-plus/toolBar/leftContent.js +2 -2
- package/dist/cjs/ag-grid-plus/toolBar/overflow.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/toolBar/overflow.js +48 -0
- package/dist/cjs/ag-grid-plus/toolBar/style.js +71 -15
- package/dist/cjs/ag-grid-plus/types.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/utils/agGridCompat.js +12 -3
- package/dist/cjs/ag-grid-plus/utils/agGridLicenseNotice.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/utils/agGridLicenseNotice.js +105 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +13 -2
- package/dist/cjs/ag-grid-plus/utils/constants.d.ts +3 -2
- package/dist/cjs/ag-grid-plus/utils/constants.js +3 -2
- package/dist/cjs/ag-grid-plus/utils/crossPageSelection.d.ts +21 -0
- package/dist/cjs/ag-grid-plus/utils/crossPageSelection.js +58 -0
- package/dist/cjs/ag-grid-plus/utils/emptyState.d.ts +2 -0
- package/dist/cjs/ag-grid-plus/utils/emptyState.js +9 -5
- package/dist/cjs/ag-grid-plus/utils/listKeyboard.d.ts +24 -0
- package/dist/cjs/ag-grid-plus/utils/listKeyboard.js +83 -0
- package/dist/cjs/ag-grid-plus/utils/pagination.d.ts +26 -0
- package/dist/cjs/ag-grid-plus/utils/pagination.js +69 -0
- package/dist/cjs/ag-grid-plus/utils/queryDispatch.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/utils/queryDispatch.js +17 -0
- package/dist/cjs/ag-grid-plus/utils/statusPill.d.ts +25 -0
- package/dist/cjs/ag-grid-plus/utils/statusPill.js +196 -0
- package/dist/cjs/ag-grid-plus/utils/valueEnumColor.d.ts +6 -1
- package/dist/cjs/ag-grid-plus/utils/valueEnumColor.js +13 -9
- package/dist/cjs/ag-grid-plus/utils/valueFormat.d.ts +19 -0
- package/dist/cjs/ag-grid-plus/utils/valueFormat.js +73 -0
- package/dist/cjs/ag-grid-plus/utils.js +3 -2
- package/dist/cjs/array-table/arrayAddBtn.d.ts +1 -0
- package/dist/cjs/array-table/arrayAddBtn.js +2 -2
- package/dist/cjs/array-table/autoHeight.d.ts +18 -0
- package/dist/cjs/array-table/autoHeight.js +30 -0
- package/dist/cjs/array-table/batchRemove.d.ts +2 -2
- package/dist/cjs/array-table/cellEditorMarker.d.ts +18 -0
- package/dist/cjs/array-table/cellEditorMarker.js +92 -0
- package/dist/cjs/array-table/errorLocator.d.ts +29 -0
- package/dist/cjs/array-table/errorLocator.js +101 -0
- package/dist/cjs/array-table/hooks.d.ts +52 -4
- package/dist/cjs/array-table/hooks.js +251 -18
- package/dist/cjs/array-table/index.d.ts +6 -0
- package/dist/cjs/array-table/index.js +167 -23
- package/dist/cjs/array-table/interface.d.ts +22 -0
- package/dist/cjs/array-table/preview.js +39 -5
- package/dist/cjs/array-table/rowFeedback.d.ts +2 -2
- package/dist/cjs/array-table/rowFeedback.js +8 -8
- package/dist/cjs/array-table/summary.d.ts +25 -0
- package/dist/cjs/array-table/summary.js +70 -0
- package/dist/cjs/array-table/theme.d.ts +35 -5
- package/dist/cjs/array-table/theme.js +49 -12
- package/dist/cjs/array-table/title.d.ts +3 -0
- package/dist/cjs/array-table/title.js +29 -0
- package/dist/cjs/array-table/utils.d.ts +2 -1
- package/dist/cjs/array-table/utils.js +94 -23
- package/dist/cjs/card/pro-card/Card/useLegacyItems.d.ts +1 -1
- package/dist/cjs/dateCellEditor/DateCellEditor.d.ts +5 -0
- package/dist/cjs/dateCellEditor/DateCellEditor.js +42 -17
- package/dist/cjs/deleteConfirm/index.d.ts +14 -0
- package/dist/cjs/deleteConfirm/index.js +73 -12
- package/dist/cjs/dialogSelect/index.d.ts +19 -0
- package/dist/cjs/dialogSelect/index.js +189 -15
- package/dist/cjs/dialogSelect/index.less +18 -0
- package/dist/cjs/documentPage/documentPage.d.ts +6 -3
- package/dist/cjs/documentPage/documentPage.js +23 -8
- package/dist/cjs/documentPage/index.d.ts +2 -0
- package/dist/cjs/documentPage/index.js +19 -0
- package/dist/cjs/documentPage/leaveGuard.d.ts +31 -0
- package/dist/cjs/documentPage/leaveGuard.js +91 -0
- package/dist/cjs/draggableModal/index.d.ts +24 -1
- package/dist/cjs/draggableModal/index.js +36 -6
- package/dist/cjs/fullScreenAlert/index.less +10 -10
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/readPretty/arrayTable.js +5 -1
- package/dist/cjs/scanCollect/ScanFeedbackInput.d.ts +26 -0
- package/dist/cjs/scanCollect/ScanFeedbackInput.js +113 -0
- package/dist/cjs/scanCollect/index.d.ts +4 -0
- package/dist/cjs/scanCollect/index.js +14 -0
- package/dist/cjs/scanCollect/scanSound.d.ts +15 -0
- package/dist/cjs/scanCollect/scanSound.js +91 -0
- package/dist/esm/ConfirmPro/index.d.ts +12 -9
- package/dist/esm/ConfirmPro/index.js +11 -34
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +426 -157
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +12 -1
- package/dist/esm/ag-grid-plus/context/queryFormContext.d.ts +2 -0
- package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.js +8 -0
- package/dist/esm/ag-grid-plus/density.d.ts +25 -0
- package/dist/esm/ag-grid-plus/density.js +45 -0
- package/dist/esm/ag-grid-plus/index.d.ts +1 -0
- package/dist/esm/ag-grid-plus/index.js +3 -0
- package/dist/esm/ag-grid-plus/index.less +43 -0
- package/dist/esm/ag-grid-plus/interface.d.ts +58 -1
- package/dist/esm/ag-grid-plus/interface.js +2 -0
- package/dist/esm/ag-grid-plus/queryForm/index.d.ts +11 -0
- package/dist/esm/ag-grid-plus/queryForm/index.js +62 -10
- package/dist/esm/ag-grid-plus/queryForm/queryForm.d.ts +10 -0
- package/dist/esm/ag-grid-plus/queryForm/queryForm.js +64 -26
- package/dist/esm/ag-grid-plus/queryForm/queryValues.d.ts +9 -0
- package/dist/esm/ag-grid-plus/queryForm/queryValues.js +54 -0
- package/dist/esm/ag-grid-plus/rowColors.d.ts +12 -0
- package/dist/esm/ag-grid-plus/rowColors.js +50 -0
- package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.d.ts +5 -0
- package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.js +14 -5
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +110 -78
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +10 -9
- package/dist/esm/ag-grid-plus/setting/autoColumnMemory.d.ts +37 -0
- package/dist/esm/ag-grid-plus/setting/autoColumnMemory.js +198 -0
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.d.ts +2 -0
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +18 -1
- package/dist/esm/ag-grid-plus/setting/index.js +6 -15
- package/dist/esm/ag-grid-plus/settingItem/index.d.ts +11 -1
- package/dist/esm/ag-grid-plus/settingItem/index.js +35 -13
- package/dist/esm/ag-grid-plus/shared/EmptyIllustration.d.ts +16 -0
- package/dist/esm/ag-grid-plus/shared/EmptyIllustration.js +82 -0
- package/dist/esm/ag-grid-plus/shared/NoRowsOverlay.js +9 -1
- package/dist/esm/ag-grid-plus/shared/SkeletonOverlay.d.ts +11 -0
- package/dist/esm/ag-grid-plus/shared/SkeletonOverlay.js +34 -0
- package/dist/esm/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +1 -1
- package/dist/esm/ag-grid-plus/theme.d.ts +7 -1
- package/dist/esm/ag-grid-plus/theme.js +31 -6
- package/dist/esm/ag-grid-plus/toolBar/OverflowActions.d.ts +16 -0
- package/dist/esm/ag-grid-plus/toolBar/OverflowActions.js +120 -0
- package/dist/esm/ag-grid-plus/toolBar/index.d.ts +3 -1
- package/dist/esm/ag-grid-plus/toolBar/index.js +43 -35
- package/dist/esm/ag-grid-plus/toolBar/leftContent.d.ts +2 -2
- package/dist/esm/ag-grid-plus/toolBar/leftContent.js +2 -2
- package/dist/esm/ag-grid-plus/toolBar/overflow.d.ts +20 -0
- package/dist/esm/ag-grid-plus/toolBar/overflow.js +41 -0
- package/dist/esm/ag-grid-plus/toolBar/style.js +71 -15
- package/dist/esm/ag-grid-plus/types.d.ts +6 -0
- package/dist/esm/ag-grid-plus/utils/agGridCompat.js +12 -3
- package/dist/esm/ag-grid-plus/utils/agGridLicenseNotice.d.ts +7 -0
- package/dist/esm/ag-grid-plus/utils/agGridLicenseNotice.js +97 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +3 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +14 -3
- package/dist/esm/ag-grid-plus/utils/constants.d.ts +3 -2
- package/dist/esm/ag-grid-plus/utils/constants.js +3 -2
- package/dist/esm/ag-grid-plus/utils/crossPageSelection.d.ts +21 -0
- package/dist/esm/ag-grid-plus/utils/crossPageSelection.js +52 -0
- package/dist/esm/ag-grid-plus/utils/emptyState.d.ts +2 -0
- package/dist/esm/ag-grid-plus/utils/emptyState.js +9 -5
- package/dist/esm/ag-grid-plus/utils/listKeyboard.d.ts +24 -0
- package/dist/esm/ag-grid-plus/utils/listKeyboard.js +77 -0
- package/dist/esm/ag-grid-plus/utils/pagination.d.ts +26 -0
- package/dist/esm/ag-grid-plus/utils/pagination.js +60 -0
- package/dist/esm/ag-grid-plus/utils/queryDispatch.d.ts +7 -0
- package/dist/esm/ag-grid-plus/utils/queryDispatch.js +11 -0
- package/dist/esm/ag-grid-plus/utils/statusPill.d.ts +25 -0
- package/dist/esm/ag-grid-plus/utils/statusPill.js +192 -0
- package/dist/esm/ag-grid-plus/utils/valueEnumColor.d.ts +6 -1
- package/dist/esm/ag-grid-plus/utils/valueEnumColor.js +12 -8
- package/dist/esm/ag-grid-plus/utils/valueFormat.d.ts +19 -0
- package/dist/esm/ag-grid-plus/utils/valueFormat.js +63 -0
- package/dist/esm/ag-grid-plus/utils.js +3 -2
- package/dist/esm/array-table/arrayAddBtn.d.ts +1 -0
- package/dist/esm/array-table/arrayAddBtn.js +1 -1
- package/dist/esm/array-table/autoHeight.d.ts +18 -0
- package/dist/esm/array-table/autoHeight.js +25 -0
- package/dist/esm/array-table/batchRemove.d.ts +2 -2
- package/dist/esm/array-table/cellEditorMarker.d.ts +18 -0
- package/dist/esm/array-table/cellEditorMarker.js +84 -0
- package/dist/esm/array-table/errorLocator.d.ts +29 -0
- package/dist/esm/array-table/errorLocator.js +95 -0
- package/dist/esm/array-table/hooks.d.ts +52 -4
- package/dist/esm/array-table/hooks.js +251 -17
- package/dist/esm/array-table/index.d.ts +6 -0
- package/dist/esm/array-table/index.js +170 -25
- package/dist/esm/array-table/interface.d.ts +22 -0
- package/dist/esm/array-table/preview.js +43 -7
- package/dist/esm/array-table/rowFeedback.d.ts +2 -2
- package/dist/esm/array-table/rowFeedback.js +8 -8
- package/dist/esm/array-table/summary.d.ts +25 -0
- package/dist/esm/array-table/summary.js +66 -0
- package/dist/esm/array-table/theme.d.ts +35 -5
- package/dist/esm/array-table/theme.js +47 -12
- package/dist/esm/array-table/title.d.ts +3 -0
- package/dist/esm/array-table/title.js +24 -0
- package/dist/esm/array-table/utils.d.ts +2 -1
- package/dist/esm/array-table/utils.js +93 -22
- package/dist/esm/card/pro-card/Card/useLegacyItems.d.ts +1 -1
- package/dist/esm/dateCellEditor/DateCellEditor.d.ts +5 -0
- package/dist/esm/dateCellEditor/DateCellEditor.js +42 -17
- package/dist/esm/deleteConfirm/index.d.ts +14 -0
- package/dist/esm/deleteConfirm/index.js +72 -12
- package/dist/esm/dialogSelect/index.d.ts +19 -0
- package/dist/esm/dialogSelect/index.js +190 -16
- package/dist/esm/dialogSelect/index.less +18 -0
- package/dist/esm/documentPage/documentPage.d.ts +6 -3
- package/dist/esm/documentPage/documentPage.js +23 -8
- package/dist/esm/documentPage/index.d.ts +2 -0
- package/dist/esm/documentPage/index.js +1 -0
- package/dist/esm/documentPage/leaveGuard.d.ts +31 -0
- package/dist/esm/documentPage/leaveGuard.js +86 -0
- package/dist/esm/draggableModal/index.d.ts +24 -1
- package/dist/esm/draggableModal/index.js +35 -5
- package/dist/esm/fullScreenAlert/index.less +10 -10
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/readPretty/arrayTable.js +6 -2
- package/dist/esm/scanCollect/ScanFeedbackInput.d.ts +26 -0
- package/dist/esm/scanCollect/ScanFeedbackInput.js +107 -0
- package/dist/esm/scanCollect/index.d.ts +4 -0
- package/dist/esm/scanCollect/index.js +2 -0
- package/dist/esm/scanCollect/scanSound.d.ts +15 -0
- package/dist/esm/scanCollect/scanSound.js +84 -0
- package/package.json +2 -2
|
@@ -7,16 +7,23 @@ type CellFocusRequest = {
|
|
|
7
7
|
};
|
|
8
8
|
type BeginCellFocusRequest = (resolveCell: () => Element | null | undefined, isTargetCurrent?: () => boolean) => CellFocusRequest;
|
|
9
9
|
/** 单元格聚焦;已获得焦点的控件保留用户光标,等待挂载的请求可被新操作取消。@author nokecy */
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export type CellFocusSource = 'keyboard' | 'pointer' | 'pointer-activated';
|
|
11
|
+
/**
|
|
12
|
+
* @param options.openDateOnKeyboard 键盘到达日期格时是否自动展开面板,默认 false:与演示一致——
|
|
13
|
+
* 鼠标点击由 antd 自己展开,键盘到达保持收起、直接键入覆盖。传 true 才在键盘落焦那一次展开。
|
|
14
|
+
*/
|
|
15
|
+
export declare const useCellFocus: (options?: {
|
|
16
|
+
openDateOnKeyboard?: boolean | undefined;
|
|
17
|
+
}) => {
|
|
18
|
+
focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean, source?: CellFocusSource) => void;
|
|
19
|
+
scheduleCellFocus: (resolveCell: () => Element | null | undefined, delay: number, isTargetCurrent?: () => boolean, source?: CellFocusSource) => void;
|
|
13
20
|
beginFocusRequest: BeginCellFocusRequest;
|
|
14
21
|
};
|
|
15
22
|
/**
|
|
16
23
|
* 键盘导航 Hook
|
|
17
24
|
* 处理方向键在表格单元格间的导航
|
|
18
25
|
*/
|
|
19
|
-
export declare const useKeyboardNavigation: (ref: RefObject<any>, dataSource: any[], focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean) => void, activateCell?: ((api: GridApi, node: any, colId: string) => boolean) | undefined, beginSharedFocusRequest?: BeginCellFocusRequest) => {
|
|
26
|
+
export declare const useKeyboardNavigation: (ref: RefObject<any>, dataSource: any[], focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean, source?: CellFocusSource) => void, activateCell?: ((api: GridApi, node: any, colId: string) => boolean) | undefined, beginSharedFocusRequest?: BeginCellFocusRequest, isTabFocusDeferred?: () => boolean) => {
|
|
20
27
|
handleCellKeyDown: (event: any) => void;
|
|
21
28
|
};
|
|
22
29
|
/**
|
|
@@ -43,4 +50,45 @@ export declare const isNativeInputKey: (event: KeyboardEvent) => boolean;
|
|
|
43
50
|
export declare const suppressNativeInputKeys: ({ event }: {
|
|
44
51
|
event: KeyboardEvent;
|
|
45
52
|
}) => boolean;
|
|
53
|
+
type GridCellFocusParams = {
|
|
54
|
+
api: GridApi;
|
|
55
|
+
root: RefObject<HTMLElement | null | undefined>;
|
|
56
|
+
rowIndex: number;
|
|
57
|
+
colId: string;
|
|
58
|
+
beginFocusRequest: BeginCellFocusRequest;
|
|
59
|
+
focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean, source?: CellFocusSource) => void;
|
|
60
|
+
activateCell?: (api: GridApi, node: any, colId: string) => boolean;
|
|
61
|
+
/** 列不在可视区时也滚到可见(横向滚动),错误定位用 */
|
|
62
|
+
ensureColumnVisible?: boolean;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 行已在行模型里:滚到可见、设焦点格、必要时激活懒挂载格,等格子渲染出来后把焦点落进输入控件。
|
|
66
|
+
* 行进入模型后 DOM 还要再渲染一拍(懒挂载格还要挂载),所以分多次轮询,直到格子出现;
|
|
67
|
+
* 返回的 Promise 在落焦完成(返回获得焦点的控件)、或请求被用户操作取消 / 超时(返回 undefined)时结束。@author nokecy
|
|
68
|
+
*/
|
|
69
|
+
export declare const focusGridCell: (params: GridCellFocusParams) => Promise<HTMLElement | undefined>;
|
|
70
|
+
export type PendingAddedRowFocus = {
|
|
71
|
+
rowId: string;
|
|
72
|
+
colId: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 新增行进入 AG-Grid 行模型之后,把焦点落到它的首个可编辑格。
|
|
76
|
+
*
|
|
77
|
+
* 新行是 field.push 之后经 React 重渲、rowData 更新才进入行模型的,push 当下 getDisplayedRowAtIndex 还取不到它,
|
|
78
|
+
* 所以由 onRowDataUpdated 调用本函数;行模型里还没有该行时返回 false,调用方保留待办等下一次。@author nokecy
|
|
79
|
+
*/
|
|
80
|
+
export declare const focusAddedRow: (params: Omit<GridCellFocusParams, "colId" | "rowIndex"> & {
|
|
81
|
+
pending: PendingAddedRowFocus;
|
|
82
|
+
}) => boolean;
|
|
83
|
+
/**
|
|
84
|
+
* AG-Grid `tabToNextCell`:跳过序号列/勾选列;末行末格再按 Tab 时,传了 `onTabPastEnd` 就由它新增一行并落焦,
|
|
85
|
+
* 否则保持默认(焦点离开表格)。返回值语义见 AG-Grid:位置=去那格,true=留在原格,false=交浏览器。@author nokecy
|
|
86
|
+
*/
|
|
87
|
+
export declare const createTabToNextCell: (onTabPastEnd?: () => void) => (params: any) => any;
|
|
88
|
+
/**
|
|
89
|
+
* Esc 放弃本格修改(规范 §7.6.3):Formily 受控值是实时写入的,没有「进入时的值」,
|
|
90
|
+
* 所以在输入框获得焦点时记下当时的文本,Esc 时用原生 setter + input 事件写回,值照常经 Formily 回流。
|
|
91
|
+
* 下拉/日期等自带 Esc 语义的控件不处理。@author nokecy
|
|
92
|
+
*/
|
|
93
|
+
export declare const useCellEscapeRevert: (ref: RefObject<HTMLElement | null | undefined>) => void;
|
|
46
94
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["pending"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1
10
|
import { useCallback, useEffect, useRef } from 'react';
|
|
11
|
+
import { ARRAY_TABLE_INDEX_FIELD } from "./indexColumn";
|
|
12
|
+
|
|
2
13
|
// setSelectionRange 仅 textarea 与 text/search/url/tel/password 类型 input 支持;
|
|
3
14
|
// checkbox/number/date 等调用会抛 InvalidStateError,故用白名单守卫。@author nokecy
|
|
4
15
|
var supportsSelectionRange = function supportsSelectionRange(el) {
|
|
@@ -66,13 +77,43 @@ var useCellFocusRequests = function useCellFocusRequests() {
|
|
|
66
77
|
};
|
|
67
78
|
|
|
68
79
|
/** 单元格聚焦;已获得焦点的控件保留用户光标,等待挂载的请求可被新操作取消。@author nokecy */
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 鼠标点击刚把懒挂载格挂成真控件后,补一次展开。
|
|
83
|
+
* 点击落在纯文本上,控件是点击之后才挂载的,antd 根本没收到这次点击,所以要自己补:
|
|
84
|
+
* Select 在 mousedown 上切换展开(已展开则不动,避免补成关闭),DatePicker 在 click 上展开。@author nokecy
|
|
85
|
+
*/
|
|
86
|
+
var openFreshlyMountedControl = function openFreshlyMountedControl(input) {
|
|
87
|
+
if (input.closest('.ant-picker')) {
|
|
88
|
+
input.click();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
var select = input.closest('.ant-select');
|
|
92
|
+
if (select && !select.classList.contains('ant-select-open')) {
|
|
93
|
+
input.dispatchEvent(new MouseEvent('mousedown', {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
cancelable: true
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param options.openDateOnKeyboard 键盘到达日期格时是否自动展开面板,默认 false:与演示一致——
|
|
102
|
+
* 鼠标点击由 antd 自己展开,键盘到达保持收起、直接键入覆盖。传 true 才在键盘落焦那一次展开。
|
|
103
|
+
*/
|
|
69
104
|
export var useCellFocus = function useCellFocus() {
|
|
105
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
70
106
|
var beginFocusRequest = useCellFocusRequests();
|
|
107
|
+
var openDateOnKeyboard = options.openDateOnKeyboard === true;
|
|
108
|
+
var openDateRef = useRef(openDateOnKeyboard);
|
|
109
|
+
openDateRef.current = openDateOnKeyboard;
|
|
110
|
+
/** source 是一次性的来源提示,只作用于这一次落焦;鼠标来源与已聚焦的格不会触发展开。 */
|
|
71
111
|
var focusInputInCell = useCallback(function (cell) {
|
|
72
112
|
var _ref, _cell$querySelector;
|
|
73
113
|
var isTargetCurrent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
74
114
|
return true;
|
|
75
115
|
};
|
|
116
|
+
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'pointer';
|
|
76
117
|
var row = cell.closest('.ag-row');
|
|
77
118
|
var rowId = row === null || row === void 0 ? void 0 : row.getAttribute('row-id');
|
|
78
119
|
var rowIndex = row === null || row === void 0 ? void 0 : row.getAttribute('row-index');
|
|
@@ -87,10 +128,15 @@ export var useCellFocus = function useCellFocus() {
|
|
|
87
128
|
if (!(element !== null && element !== void 0 && element.isConnected) || !cell.contains(element) || !request.isCurrent()) return;
|
|
88
129
|
if (document.activeElement === element) return;
|
|
89
130
|
element.focus();
|
|
90
|
-
//
|
|
131
|
+
// 懒挂载格的鼠标点击落在纯文本上,antd 没收到点击,挂载后补展开一次(只在刚挂载的那一次,
|
|
132
|
+
// 已聚焦的格在上面直接返回,再点不会重复触发);键盘到达保持收起,openDateOnKeyboard 才在日期格展开。
|
|
133
|
+
if (document.activeElement === element) {
|
|
134
|
+
if (source === 'pointer-activated') openFreshlyMountedControl(element);else if (source === 'keyboard' && openDateRef.current && element.closest('.ant-picker')) element.click();
|
|
135
|
+
}
|
|
136
|
+
// 首次进入全选(规范 §7.6.3:键入即覆盖,不是追加);同步设置,避免延迟任务覆盖用户随后选择的文字。
|
|
137
|
+
// 已聚焦的输入框在上面直接返回,所以用户点出来的光标/选区不会被改动。@author nokecy
|
|
91
138
|
if (document.activeElement === element && element.matches('input, textarea') && supportsSelectionRange(element)) {
|
|
92
|
-
|
|
93
|
-
input.setSelectionRange(input.value.length, input.value.length);
|
|
139
|
+
element.select();
|
|
94
140
|
}
|
|
95
141
|
};
|
|
96
142
|
var active = document.activeElement;
|
|
@@ -115,11 +161,11 @@ export var useCellFocus = function useCellFocus() {
|
|
|
115
161
|
}
|
|
116
162
|
focusElement((_ref = (_cell$querySelector = cell.querySelector(selector)) !== null && _cell$querySelector !== void 0 ? _cell$querySelector : cell.querySelector('input:not([disabled]), textarea:not([disabled]), [contenteditable="true"], [tabindex]:not([disabled])')) !== null && _ref !== void 0 ? _ref : cell);
|
|
117
163
|
}, [beginFocusRequest]);
|
|
118
|
-
var scheduleCellFocus = useCallback(function (resolveCell, delay, isTargetCurrent) {
|
|
164
|
+
var scheduleCellFocus = useCallback(function (resolveCell, delay, isTargetCurrent, source) {
|
|
119
165
|
var request = beginFocusRequest(resolveCell, isTargetCurrent);
|
|
120
166
|
request.schedule(function () {
|
|
121
167
|
var cell = resolveCell();
|
|
122
|
-
if (cell !== null && cell !== void 0 && cell.isConnected) focusInputInCell(cell, isTargetCurrent);
|
|
168
|
+
if (cell !== null && cell !== void 0 && cell.isConnected) focusInputInCell(cell, isTargetCurrent, source);
|
|
123
169
|
}, delay);
|
|
124
170
|
}, [beginFocusRequest, focusInputInCell]);
|
|
125
171
|
return {
|
|
@@ -133,7 +179,7 @@ export var useCellFocus = function useCellFocus() {
|
|
|
133
179
|
* 键盘导航 Hook
|
|
134
180
|
* 处理方向键在表格单元格间的导航
|
|
135
181
|
*/
|
|
136
|
-
export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSource, focusInputInCell, activateCell, beginSharedFocusRequest) {
|
|
182
|
+
export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSource, focusInputInCell, activateCell, beginSharedFocusRequest, isTabFocusDeferred) {
|
|
137
183
|
var beginLocalFocusRequest = useCellFocusRequests(!beginSharedFocusRequest);
|
|
138
184
|
var beginFocusRequest = beginSharedFocusRequest !== null && beginSharedFocusRequest !== void 0 ? beginSharedFocusRequest : beginLocalFocusRequest;
|
|
139
185
|
var handleCellKeyDown = useCallback(function (event) {
|
|
@@ -147,6 +193,31 @@ export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSourc
|
|
|
147
193
|
// 判定用 keydown 当时记下的(见 suppressNativeInputKeys);没记过(不是 AG-Grid 触发的)才现算。
|
|
148
194
|
if ((_nativeKeyDecisions$g = nativeKeyDecisions.get(keyEvent)) !== null && _nativeKeyDecisions$g !== void 0 ? _nativeKeyDecisions$g : isNativeInputKey(keyEvent)) return;
|
|
149
195
|
|
|
196
|
+
// Tab / Enter 由 AG-Grid 自己换格,但它只聚焦单元格 div,输入框拿不到焦点、键入无效:
|
|
197
|
+
// 等 AG-Grid 换完格再把焦点落进新格的输入框(并全选)。方向键走下面自己的导航。@author nokecy
|
|
198
|
+
if ((keyEvent.key === 'Tab' || keyEvent.key === 'Enter') && !keyEvent.ctrlKey && !keyEvent.altKey && !keyEvent.metaKey) {
|
|
199
|
+
if (keyEvent.key === 'Tab' && isTabFocusDeferred !== null && isTabFocusDeferred !== void 0 && isTabFocusDeferred()) return;
|
|
200
|
+
var resolveFocused = function resolveFocused() {
|
|
201
|
+
var _api$getFocusedCell, _ref$current$querySel, _ref$current;
|
|
202
|
+
var focused = (_api$getFocusedCell = api.getFocusedCell) === null || _api$getFocusedCell === void 0 ? void 0 : _api$getFocusedCell.call(api);
|
|
203
|
+
if (!focused) return null;
|
|
204
|
+
return (_ref$current$querySel = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector(".ag-row[row-index=\"".concat(focused.rowIndex, "\"] .ag-cell[col-id=\"").concat(focused.column.getColId(), "\"]"))) !== null && _ref$current$querySel !== void 0 ? _ref$current$querySel : null;
|
|
205
|
+
};
|
|
206
|
+
var request = beginFocusRequest(resolveFocused);
|
|
207
|
+
request.schedule(function () {
|
|
208
|
+
var _api$getFocusedCell2, _api$getDisplayedRowA;
|
|
209
|
+
// 懒挂载格先激活挂树,再给挂载留出时间。
|
|
210
|
+
var focused = (_api$getFocusedCell2 = api.getFocusedCell) === null || _api$getFocusedCell2 === void 0 ? void 0 : _api$getFocusedCell2.call(api);
|
|
211
|
+
var focusedNode = focused ? (_api$getDisplayedRowA = api.getDisplayedRowAtIndex) === null || _api$getDisplayedRowA === void 0 ? void 0 : _api$getDisplayedRowA.call(api, focused.rowIndex) : undefined;
|
|
212
|
+
var justActivated = !!(activateCell && focused && focusedNode && activateCell(api, focusedNode, focused.column.getColId()));
|
|
213
|
+
request.schedule(function () {
|
|
214
|
+
var cell = resolveFocused();
|
|
215
|
+
if (cell !== null && cell !== void 0 && cell.isConnected) focusInputInCell(cell, undefined, 'keyboard');
|
|
216
|
+
}, justActivated ? 150 : 10);
|
|
217
|
+
}, 10);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
150
221
|
// 处理上下左右键导航
|
|
151
222
|
if (keyEvent.key === 'ArrowDown' || keyEvent.key === 'ArrowUp' || keyEvent.key === 'ArrowLeft' || keyEvent.key === 'ArrowRight') {
|
|
152
223
|
var currentRowIndex = node.rowIndex;
|
|
@@ -188,17 +259,17 @@ export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSourc
|
|
|
188
259
|
// 检查目标位置是否有效
|
|
189
260
|
var isValidTarget = keyEvent.key === 'ArrowLeft' || keyEvent.key === 'ArrowRight' || targetRowIndex >= 0 && targetRowIndex < dataSource.length;
|
|
190
261
|
if (isValidTarget) {
|
|
191
|
-
var _api$
|
|
192
|
-
var targetNode = (_api$
|
|
262
|
+
var _api$getDisplayedRowA2;
|
|
263
|
+
var targetNode = (_api$getDisplayedRowA2 = api.getDisplayedRowAtIndex) === null || _api$getDisplayedRowA2 === void 0 ? void 0 : _api$getDisplayedRowA2.call(api, targetRowIndex);
|
|
193
264
|
var navigated = false;
|
|
194
265
|
var resolveTarget = function resolveTarget() {
|
|
195
|
-
var _ref$
|
|
196
|
-
return (_ref$
|
|
266
|
+
var _ref$current2;
|
|
267
|
+
return (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelector(".ag-row[row-index=\"".concat(targetRowIndex, "\"] .ag-cell[col-id=\"").concat(targetColId, "\"]"));
|
|
197
268
|
};
|
|
198
269
|
var _isTargetCurrent = function _isTargetCurrent() {
|
|
199
|
-
var _ref$
|
|
200
|
-
if (!((_ref$
|
|
201
|
-
if (targetNode && ((_api$
|
|
270
|
+
var _ref$current3, _api$isDestroyed, _api$getDisplayedRowA3;
|
|
271
|
+
if (!((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.isConnected) || (_api$isDestroyed = api.isDestroyed) !== null && _api$isDestroyed !== void 0 && _api$isDestroyed.call(api)) return false;
|
|
272
|
+
if (targetNode && ((_api$getDisplayedRowA3 = api.getDisplayedRowAtIndex) === null || _api$getDisplayedRowA3 === void 0 ? void 0 : _api$getDisplayedRowA3.call(api, targetRowIndex)) !== targetNode) return false;
|
|
202
273
|
if (navigated && api.getFocusedCell) {
|
|
203
274
|
var _focused$column;
|
|
204
275
|
var focused = api.getFocusedCell();
|
|
@@ -206,9 +277,9 @@ export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSourc
|
|
|
206
277
|
}
|
|
207
278
|
return true;
|
|
208
279
|
};
|
|
209
|
-
var
|
|
280
|
+
var _request = beginFocusRequest(resolveTarget, _isTargetCurrent);
|
|
210
281
|
// 延迟执行以确保当前编辑完成
|
|
211
|
-
|
|
282
|
+
_request.schedule(function () {
|
|
212
283
|
api.setFocusedCell(targetRowIndex, targetColId);
|
|
213
284
|
navigated = true;
|
|
214
285
|
|
|
@@ -220,10 +291,10 @@ export var useKeyboardNavigation = function useKeyboardNavigation(ref, dataSourc
|
|
|
220
291
|
// 不使用原生startEditingCell,而是手动触发编辑状态
|
|
221
292
|
// v33 themeQuartz 容器不再有 .ag-theme-alpine 类;且行虚拟化下 DOM 顺序与 rowIndex 不一致,
|
|
222
293
|
// 改为直接在 ref 容器内按 row-index + col-id 属性定位目标单元格 @author nokecy
|
|
223
|
-
|
|
294
|
+
_request.schedule(function () {
|
|
224
295
|
var targetCell = resolveTarget();
|
|
225
296
|
if (targetCell !== null && targetCell !== void 0 && targetCell.isConnected) {
|
|
226
|
-
focusInputInCell(targetCell, _isTargetCurrent);
|
|
297
|
+
focusInputInCell(targetCell, _isTargetCurrent, 'keyboard');
|
|
227
298
|
}
|
|
228
299
|
}, 150);
|
|
229
300
|
}, 10);
|
|
@@ -287,6 +358,8 @@ export var isNativeInputKey = function isNativeInputKey(event) {
|
|
|
287
358
|
var key = event.key;
|
|
288
359
|
if (event.isComposing) return true;
|
|
289
360
|
if ((event.ctrlKey || event.metaKey) && key.toLowerCase() === 'a') return true;
|
|
361
|
+
// 复制/剪切/粘贴交给输入框的原生行为:AG-Grid 不应拦走单元格内输入框的 Ctrl/Cmd+C/X/V(允许粘贴,规范 §11)。
|
|
362
|
+
if ((event.ctrlKey || event.metaKey) && !event.altKey && ['c', 'x', 'v'].includes(key.toLowerCase())) return true;
|
|
290
363
|
if (key === 'Home' || key === 'End') return true;
|
|
291
364
|
if (!key.startsWith('Arrow')) return false;
|
|
292
365
|
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) return true;
|
|
@@ -317,4 +390,165 @@ export var suppressNativeInputKeys = function suppressNativeInputKeys(_ref2) {
|
|
|
317
390
|
var native = isNativeInputKey(event);
|
|
318
391
|
nativeKeyDecisions.set(event, native);
|
|
319
392
|
return native;
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* 行已在行模型里:滚到可见、设焦点格、必要时激活懒挂载格,等格子渲染出来后把焦点落进输入控件。
|
|
396
|
+
* 行进入模型后 DOM 还要再渲染一拍(懒挂载格还要挂载),所以分多次轮询,直到格子出现;
|
|
397
|
+
* 返回的 Promise 在落焦完成(返回获得焦点的控件)、或请求被用户操作取消 / 超时(返回 undefined)时结束。@author nokecy
|
|
398
|
+
*/
|
|
399
|
+
export var focusGridCell = function focusGridCell(params) {
|
|
400
|
+
var _api$getDisplayedRowA4, _api$isDestroyed2, _api$ensureIndexVisib, _api$ensureColumnVisi;
|
|
401
|
+
var api = params.api,
|
|
402
|
+
root = params.root,
|
|
403
|
+
rowIndex = params.rowIndex,
|
|
404
|
+
colId = params.colId,
|
|
405
|
+
beginFocusRequest = params.beginFocusRequest,
|
|
406
|
+
focusInputInCell = params.focusInputInCell,
|
|
407
|
+
activateCell = params.activateCell;
|
|
408
|
+
var node = (_api$getDisplayedRowA4 = api.getDisplayedRowAtIndex) === null || _api$getDisplayedRowA4 === void 0 ? void 0 : _api$getDisplayedRowA4.call(api, rowIndex);
|
|
409
|
+
if (!node || (_api$isDestroyed2 = api.isDestroyed) !== null && _api$isDestroyed2 !== void 0 && _api$isDestroyed2.call(api)) return Promise.resolve(undefined);
|
|
410
|
+
var resolveCell = function resolveCell() {
|
|
411
|
+
var _root$current;
|
|
412
|
+
return (_root$current = root.current) === null || _root$current === void 0 ? void 0 : _root$current.querySelector(".ag-row[row-index=\"".concat(rowIndex, "\"] .ag-cell[col-id=\"").concat(colId, "\"]"));
|
|
413
|
+
};
|
|
414
|
+
var isTargetCurrent = function isTargetCurrent() {
|
|
415
|
+
var _root$current2, _api$isDestroyed3, _api$getFocusedCell3;
|
|
416
|
+
if (!((_root$current2 = root.current) !== null && _root$current2 !== void 0 && _root$current2.isConnected) || (_api$isDestroyed3 = api.isDestroyed) !== null && _api$isDestroyed3 !== void 0 && _api$isDestroyed3.call(api)) return false;
|
|
417
|
+
var focused = (_api$getFocusedCell3 = api.getFocusedCell) === null || _api$getFocusedCell3 === void 0 ? void 0 : _api$getFocusedCell3.call(api);
|
|
418
|
+
return !focused || focused.rowIndex === rowIndex && focused.column.getColId() === colId;
|
|
419
|
+
};
|
|
420
|
+
var request = beginFocusRequest(resolveCell, isTargetCurrent);
|
|
421
|
+
(_api$ensureIndexVisib = api.ensureIndexVisible) === null || _api$ensureIndexVisib === void 0 || _api$ensureIndexVisib.call(api, rowIndex);
|
|
422
|
+
if (params.ensureColumnVisible) (_api$ensureColumnVisi = api.ensureColumnVisible) === null || _api$ensureColumnVisi === void 0 || _api$ensureColumnVisi.call(api, colId);
|
|
423
|
+
api.setFocusedCell(rowIndex, colId);
|
|
424
|
+
var activated = activateCell ? activateCell(api, node, colId) : false;
|
|
425
|
+
return new Promise(function (resolve) {
|
|
426
|
+
var attempt = function attempt(remaining) {
|
|
427
|
+
if (!request.isCurrent()) return resolve(undefined);
|
|
428
|
+
var cell = resolveCell();
|
|
429
|
+
if (cell !== null && cell !== void 0 && cell.isConnected) {
|
|
430
|
+
focusInputInCell(cell, isTargetCurrent, 'keyboard');
|
|
431
|
+
var active = document.activeElement;
|
|
432
|
+
return resolve(active instanceof HTMLElement && cell.contains(active) ? active : undefined);
|
|
433
|
+
}
|
|
434
|
+
if (remaining <= 0) return resolve(undefined);
|
|
435
|
+
setTimeout(function () {
|
|
436
|
+
return attempt(remaining - 1);
|
|
437
|
+
}, 50);
|
|
438
|
+
};
|
|
439
|
+
setTimeout(function () {
|
|
440
|
+
return attempt(8);
|
|
441
|
+
}, activated ? 150 : 30);
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// 按行 id 记录:排序时新行的显示行号与数据下标不一致,落焦必须取行节点的显示行号。
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 新增行进入 AG-Grid 行模型之后,把焦点落到它的首个可编辑格。
|
|
449
|
+
*
|
|
450
|
+
* 新行是 field.push 之后经 React 重渲、rowData 更新才进入行模型的,push 当下 getDisplayedRowAtIndex 还取不到它,
|
|
451
|
+
* 所以由 onRowDataUpdated 调用本函数;行模型里还没有该行时返回 false,调用方保留待办等下一次。@author nokecy
|
|
452
|
+
*/
|
|
453
|
+
export var focusAddedRow = function focusAddedRow(params) {
|
|
454
|
+
var _rest$api$isDestroyed, _rest$api, _rest$api$getRowNode, _rest$api2;
|
|
455
|
+
var pending = params.pending,
|
|
456
|
+
rest = _objectWithoutProperties(params, _excluded);
|
|
457
|
+
if ((_rest$api$isDestroyed = (_rest$api = rest.api).isDestroyed) !== null && _rest$api$isDestroyed !== void 0 && _rest$api$isDestroyed.call(_rest$api)) return true;
|
|
458
|
+
var rowIndex = (_rest$api$getRowNode = (_rest$api2 = rest.api).getRowNode) === null || _rest$api$getRowNode === void 0 || (_rest$api$getRowNode = _rest$api$getRowNode.call(_rest$api2, pending.rowId)) === null || _rest$api$getRowNode === void 0 ? void 0 : _rest$api$getRowNode.rowIndex;
|
|
459
|
+
if (typeof rowIndex !== 'number') return false;
|
|
460
|
+
void focusGridCell(_objectSpread(_objectSpread({}, rest), {}, {
|
|
461
|
+
rowIndex: rowIndex,
|
|
462
|
+
colId: pending.colId
|
|
463
|
+
}));
|
|
464
|
+
return true;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/** 不应被 Tab 停留的列:默认序号列与勾选列(规范 §7.6.3:Tab 只在可编辑格之间移动)。@author nokecy */
|
|
468
|
+
var isTabSkippedColumn = function isTabSkippedColumn(colId) {
|
|
469
|
+
return colId === ARRAY_TABLE_INDEX_FIELD || colId === 'ag-Grid-SelectionColumn';
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* AG-Grid `tabToNextCell`:跳过序号列/勾选列;末行末格再按 Tab 时,传了 `onTabPastEnd` 就由它新增一行并落焦,
|
|
474
|
+
* 否则保持默认(焦点离开表格)。返回值语义见 AG-Grid:位置=去那格,true=留在原格,false=交浏览器。@author nokecy
|
|
475
|
+
*/
|
|
476
|
+
export var createTabToNextCell = function createTabToNextCell(onTabPastEnd) {
|
|
477
|
+
return function (params) {
|
|
478
|
+
var _params$api$getAllDis, _params$api$getAllDis2, _params$api, _params$api$getDispla, _params$api$getDispla2, _params$api2;
|
|
479
|
+
var columns = (_params$api$getAllDis = (_params$api$getAllDis2 = (_params$api = params.api).getAllDisplayedColumns) === null || _params$api$getAllDis2 === void 0 ? void 0 : _params$api$getAllDis2.call(_params$api)) !== null && _params$api$getAllDis !== void 0 ? _params$api$getAllDis : [];
|
|
480
|
+
var step = params.backwards ? -1 : 1;
|
|
481
|
+
var rowCount = (_params$api$getDispla = (_params$api$getDispla2 = (_params$api2 = params.api).getDisplayedRowCount) === null || _params$api$getDispla2 === void 0 ? void 0 : _params$api$getDispla2.call(_params$api2)) !== null && _params$api$getDispla !== void 0 ? _params$api$getDispla : 0;
|
|
482
|
+
var next = params.nextCellPosition;
|
|
483
|
+
var prev = params.previousCellPosition;
|
|
484
|
+
// AG-Grid 在行首/行尾会折到相邻行;统一在这里按列序重新找下一个可停留的格。
|
|
485
|
+
if (next && isTabSkippedColumn(next.column.getColId())) {
|
|
486
|
+
var rowIndex = next.rowIndex;
|
|
487
|
+
var colIndex = columns.indexOf(next.column) + step;
|
|
488
|
+
for (;;) {
|
|
489
|
+
if (colIndex < 0 || colIndex >= columns.length) {
|
|
490
|
+
rowIndex += step;
|
|
491
|
+
if (rowIndex < 0 || rowIndex >= rowCount) {
|
|
492
|
+
next = null;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
colIndex = step > 0 ? 0 : columns.length - 1;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (!isTabSkippedColumn(columns[colIndex].getColId())) {
|
|
499
|
+
next = _objectSpread(_objectSpread({}, next), {}, {
|
|
500
|
+
rowIndex: rowIndex,
|
|
501
|
+
column: columns[colIndex]
|
|
502
|
+
});
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
colIndex += step;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (next) return next;
|
|
509
|
+
// 没有下一格:前进方向且正处在最后一格 -> 新增行
|
|
510
|
+
if (!params.backwards && onTabPastEnd && prev && prev.rowIndex === rowCount - 1) {
|
|
511
|
+
onTabPastEnd();
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
return false;
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Esc 放弃本格修改(规范 §7.6.3):Formily 受控值是实时写入的,没有「进入时的值」,
|
|
520
|
+
* 所以在输入框获得焦点时记下当时的文本,Esc 时用原生 setter + input 事件写回,值照常经 Formily 回流。
|
|
521
|
+
* 下拉/日期等自带 Esc 语义的控件不处理。@author nokecy
|
|
522
|
+
*/
|
|
523
|
+
export var useCellEscapeRevert = function useCellEscapeRevert(ref) {
|
|
524
|
+
useEffect(function () {
|
|
525
|
+
var root = ref.current;
|
|
526
|
+
if (!root) return;
|
|
527
|
+
var snapshots = new WeakMap();
|
|
528
|
+
var isPlainInput = function isPlainInput(el) {
|
|
529
|
+
return el instanceof HTMLInputElement && !el.readOnly && !el.disabled && !el.closest('.ant-select, .ant-picker') && /^(text|search|url|tel|number)$/i.test(el.type || 'text');
|
|
530
|
+
};
|
|
531
|
+
var onFocusIn = function onFocusIn(event) {
|
|
532
|
+
if (isPlainInput(event.target)) snapshots.set(event.target, event.target.value);
|
|
533
|
+
};
|
|
534
|
+
var onKeyDown = function onKeyDown(event) {
|
|
535
|
+
var _Object$getOwnPropert;
|
|
536
|
+
if (event.key !== 'Escape' || event.isComposing || !isPlainInput(event.target)) return;
|
|
537
|
+
var snapshot = snapshots.get(event.target);
|
|
538
|
+
if (snapshot === undefined || snapshot === event.target.value) return;
|
|
539
|
+
var setter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.set;
|
|
540
|
+
setter === null || setter === void 0 || setter.call(event.target, snapshot);
|
|
541
|
+
event.target.dispatchEvent(new Event('input', {
|
|
542
|
+
bubbles: true
|
|
543
|
+
}));
|
|
544
|
+
event.target.select();
|
|
545
|
+
event.stopPropagation();
|
|
546
|
+
};
|
|
547
|
+
root.addEventListener('focusin', onFocusIn);
|
|
548
|
+
root.addEventListener('keydown', onKeyDown, true);
|
|
549
|
+
return function () {
|
|
550
|
+
root.removeEventListener('focusin', onFocusIn);
|
|
551
|
+
root.removeEventListener('keydown', onKeyDown, true);
|
|
552
|
+
};
|
|
553
|
+
}, [ref]);
|
|
320
554
|
};
|
|
@@ -2,12 +2,18 @@ import React from "react";
|
|
|
2
2
|
import { AgGridReactProps } from "ag-grid-react";
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<Partial<AgGridReactProps<any> & {
|
|
4
4
|
height?: string | number | undefined;
|
|
5
|
+
minRows?: number | undefined;
|
|
6
|
+
maxRows?: number | undefined;
|
|
5
7
|
gridKey: string;
|
|
8
|
+
title?: React.ReactNode;
|
|
6
9
|
onRowDrag?: boolean | undefined;
|
|
7
10
|
disabled?: boolean | undefined;
|
|
8
11
|
batchRemove?: boolean | undefined;
|
|
9
12
|
onRemove?: ((index: number) => void) | undefined;
|
|
10
13
|
fixedColumnsMaxRatio?: number | undefined;
|
|
14
|
+
tabAddsRow?: boolean | undefined;
|
|
15
|
+
openDateOnKeyboard?: boolean | undefined;
|
|
16
|
+
summary?: import("./summary").ArrayTableSummary | undefined;
|
|
11
17
|
} & {
|
|
12
18
|
children?: React.ReactNode;
|
|
13
19
|
}> & React.RefAttributes<any>>;
|