ant-design-vue/components/vc-cascader/context.ts
tangjinzhou f0385d7c24
Refactor cascader (#5192)
* feat: tree

* refactor: select

* refactor: select

* refactor: select

* refactor: vc-tree-select

* refactor: tree-select

* refactor: tree-select

* feat: add showLeafIcon

* refactor: remove lod vc-tree-select

* feat: tree-select add tag-render

* refactor: cascader

* refactor: cascader

* refactor: cascader

* refactor: cascader

* fix: maxTagmaxTagPlaceholder not work
2022-01-21 21:58:10 +08:00

37 lines
1.2 KiB
TypeScript

import type { CSSProperties, InjectionKey, Ref } from 'vue';
import { inject, provide } from 'vue';
import type { VueNode } from '../_util/type';
import type {
BaseCascaderProps,
InternalFieldNames,
DefaultOptionType,
SingleValueType,
} from './Cascader';
export interface CascaderContextProps {
options: Ref<BaseCascaderProps['options']>;
fieldNames: Ref<InternalFieldNames>;
values: Ref<SingleValueType[]>;
halfValues: Ref<SingleValueType[]>;
changeOnSelect: Ref<boolean>;
onSelect: (valuePath: SingleValueType) => void;
checkable: Ref<boolean | VueNode>;
searchOptions: Ref<DefaultOptionType[]>;
dropdownPrefixCls?: Ref<string>;
loadData: Ref<(selectOptions: DefaultOptionType[]) => void>;
expandTrigger: Ref<'hover' | 'click'>;
expandIcon: Ref<VueNode>;
loadingIcon: Ref<VueNode>;
dropdownMenuColumnStyle: Ref<CSSProperties>;
customSlots: Ref<Record<string, Function>>;
}
const CascaderContextKey: InjectionKey<CascaderContextProps> = Symbol('CascaderContextKey');
export const useProvideCascader = (props: CascaderContextProps) => {
provide(CascaderContextKey, props);
};
export const useInjectCascader = () => {
return inject(CascaderContextKey);
};