import { RefObject } from 'react'; import { GridApi } from 'ag-grid-community'; import { ArrayField } from '@formily/core'; type CellFocusRequest = { isCurrent: () => boolean; schedule: (callback: () => void, delay: number) => void; }; type BeginCellFocusRequest = (resolveCell: () => Element | null | undefined, isTargetCurrent?: () => boolean) => CellFocusRequest; /** 单元格聚焦;已获得焦点的控件保留用户光标,等待挂载的请求可被新操作取消。@author nokecy */ export declare const useCellFocus: () => { focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean) => void; scheduleCellFocus: (resolveCell: () => Element | null | undefined, delay: number, isTargetCurrent?: () => boolean) => void; beginFocusRequest: BeginCellFocusRequest; }; /** * 键盘导航 Hook * 处理方向键在表格单元格间的导航 */ export declare const useKeyboardNavigation: (ref: RefObject, dataSource: any[], focusInputInCell: (cell: Element, isTargetCurrent?: () => boolean) => void, activateCell?: ((api: GridApi, node: any, colId: string) => boolean) | undefined, beginSharedFocusRequest?: BeginCellFocusRequest) => { handleCellKeyDown: (event: any) => void; }; /** * 行拖拽 Hook * 处理行拖拽排序逻辑 */ export declare const useRowDrag: (field: ArrayField) => { handleRowDragMove: (event: any) => void; }; /** * 这个按键该不该交给单元格里的输入框自己处理(浏览器原生行为),而不是当成表格的快捷键/单元格导航。 * * AG-Grid 把 Ctrl+A 当成「选中所有单元格」、Home/End 当成「跳到行首/行尾单元格」并 preventDefault; * 我们的 handleCellKeyDown 又把方向键一律当成「跳到相邻单元格」——输入框里全选、用方向键移动光标、 * Shift+方向键扩选文字就全都做不了。规则: * - Ctrl/Cmd+A、Home/End、带 Shift/Ctrl/Alt/Cmd 的方向键、输入法组字期间的按键 -> 输入框自己处理; * - 左右方向键:光标还能动就移动光标(有选区时先收起选区),已经在最左/最右再按才跳到相邻单元格; * - 上下方向键:单行输入框没有纵向光标,照旧在行间导航;多行文本域在首行/末行才导航; * - 焦点不在输入框里(在单元格本身)、只读输入框(如下拉选择)、不支持光标的输入框:照旧导航。 * 复制/粘贴/剪切/撤销 AG-Grid 本来就没拦,不必处理。@author nokecy */ export declare const isNativeInputKey: (event: KeyboardEvent) => boolean; /** AG-Grid 的 suppressKeyboardEvent:让 AG-Grid 不再拦截输入框自己处理的按键,并记下这次按键的判定 */ export declare const suppressNativeInputKeys: ({ event }: { event: KeyboardEvent; }) => boolean; export {};