export type IHookStateInitialSetter = () => S; export type IHookStateInitAction = S | IHookStateInitialSetter; export type IHookStateSetter = ((prevState: S) => S) | (() => S); export type IHookStateSetAction = S | IHookStateSetter; type useArrayControlActions = { /** 替换现有数组 */ setList: (newList: IHookStateSetAction) => void; /** 清空数组 */ clear: () => void; /** 重置数组为初始数据 */ reset: () => void; /** 向数组开头添加一个元素 */ addStart: (item: TData) => void; /** 向数组末尾添加一个元素 */ addEnd: (item: TData) => void; /** 删除数组中处于`index`位置的元素 */ remove: (index: number) => void; /** 将位于`index`位置的元素向上(左)移动`offset`(默认为1)个位置 */ moveForwardByIndex: (index: number, offset?: number) => void; /** 将位于`index`位置的元素向下(右)移动`offset`(默认为1)个位置 */ moveBackwardsByIndex: (index: number, offset?: number) => void; /** 在位于`index`位置插入元素,通过控制`index`的值可以实现向前插入和向后插入 */ insert: (index: number, item: TData) => void; }; export type OpeType = 'clear' | 'reset' | 'addStart' | 'addEnd' | 'remove' | 'moveForwardByIndex' | 'moveBackwardsByIndex' | 'insert'; export default function useArrayControl(dataSource: TData[], opeCallback?: (opeType: OpeType, latestArray: TData[], ...restArgs: any[]) => void): [TData[], useArrayControlActions]; export {};