mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 21:50:07 +08:00
27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
import type { InjectionKey } from 'vue';
|
|
import { provide, inject } from 'vue';
|
|
import type { ExpandAction } from '../vc-tree/props';
|
|
import type { DefaultOptionType, InternalFieldName, OnInternalSelect } from './TreeSelect';
|
|
|
|
export interface TreeSelectContextProps {
|
|
virtual?: boolean;
|
|
dropdownMatchSelectWidth?: boolean | number;
|
|
listHeight: number;
|
|
listItemHeight: number;
|
|
treeData: DefaultOptionType[];
|
|
fieldNames: InternalFieldName;
|
|
onSelect: OnInternalSelect;
|
|
treeExpandAction?: ExpandAction;
|
|
}
|
|
|
|
const TreeSelectContextPropsKey: InjectionKey<TreeSelectContextProps> = Symbol(
|
|
'TreeSelectContextPropsKey',
|
|
);
|
|
|
|
export function useProvideSelectContext(props: TreeSelectContextProps) {
|
|
return provide(TreeSelectContextPropsKey, props);
|
|
}
|
|
export default function useInjectSelectContext() {
|
|
return inject(TreeSelectContextPropsKey, {} as TreeSelectContextProps);
|
|
}
|