vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
3 years ago
|
import type { InjectionKey, Ref } from 'vue';
|
||
|
import { inject, provide } from 'vue';
|
||
|
import type { OnSelect, PanelMode } from './interface';
|
||
|
|
||
|
export type ContextOperationRefProps = {
|
||
|
onKeydown?: (e: KeyboardEvent) => boolean;
|
||
|
onClose?: () => void;
|
||
|
};
|
||
|
|
||
|
export type PanelContextProps = {
|
||
|
operationRef?: Ref<ContextOperationRefProps | null>;
|
||
|
/** Only work with time panel */
|
||
|
hideHeader?: Ref<boolean>;
|
||
|
panelRef?: Ref<HTMLDivElement>;
|
||
|
hidePrevBtn?: Ref<boolean>;
|
||
|
hideNextBtn?: Ref<boolean>;
|
||
|
onDateMouseenter?: (date: any) => void;
|
||
|
onDateMouseleave?: (date: any) => void;
|
||
|
onSelect?: OnSelect<any>;
|
||
|
hideRanges?: Ref<boolean>;
|
||
|
open?: Ref<boolean>;
|
||
|
mode?: Ref<PanelMode>;
|
||
|
|
||
|
/** Only used for TimePicker and this is a deprecated prop */
|
||
|
defaultOpenValue?: Ref<any>;
|
||
|
};
|
||
|
|
||
|
const PanelContextKey: InjectionKey<PanelContextProps> = Symbol('PanelContextProps');
|
||
|
|
||
|
export const useProvidePanel = (props: PanelContextProps) => {
|
||
|
provide(PanelContextKey, props);
|
||
|
};
|
||
|
|
||
|
export const useInjectPanel = () => {
|
||
|
return inject(PanelContextKey, {});
|
||
|
};
|
||
|
|
||
|
export default PanelContextKey;
|