import { Id, Obj, SelectableProps } from '../../types'; import { Dispatch, ReactNode, SetStateAction } from 'react'; export interface OptionType extends Obj { children?: OptionType[]; /** @private */ _parentId?: V; /** @private */ _isLast?: boolean; } export type SelectionContextBaseProps, V extends Id = Id> = { options?: O[]; primaryKey?: keyof O; /** 默认为`children` */ childrenKey?: keyof O; /** * 节点之间的关系 * @enum {'dependent'} 会自动判断子父节点的选中关系。 * @enum {'standalone'} 所有节点相互独立。 * 默认为`dependent` */ relation?: 'dependent' | 'standalone'; /** * 选中值的整合方式,relation为'dependent'时生效 * @enum {'shallowest'} 尽可能向上归集。 * @enum {'deepest'} 尽可能向下展开。 * @enum {'all'} 所有选中的值。 * 默认为`"shallowest"` */ integration?: 'shallowest' | 'deepest' | 'all'; /** 单选模式必须指定clearable才能清空选择 */ clearable?: boolean; disabled?: boolean; onToggle?(checked: boolean, value: V, option?: O): void; children?: ReactNode; /** 若设为true,则该Context不受父级Context影响,默认为`false` */ standalone?: boolean; }; export type ISelectionContext, V extends Id = Id> = { inSelection: true; multiple: boolean; disabled: boolean; value?: V | V[]; setValue: Dispatch>; options?: O[]; setOptions: Dispatch>; optionsMap: Map; selectionStatus: Map; toggleSelected(value: V): void; }; export declare function useSelectionContext, V extends Id = Id>(): ISelectionContext; export type SelectionContextProps, V extends Id = Id> = SelectionContextBaseProps & SelectableProps; export declare function SelectionContext, V extends Id = Id>(props: SelectionContextProps): import("@emotion/react/jsx-runtime").JSX.Element;