UNPKG

song-ui-u

Version:

vue3 + js的PC前端组件库

43 lines (40 loc) 1.23 kB
import { ref, getCurrentInstance, computed } from 'vue'; import { useModalEvent } from './use-modal-event.mjs'; import { useModalState } from './use-modal-state.mjs'; import { useStyle } from '../../../../hook/use-style/index.mjs'; import '../../../../hook/use-zindex/index.mjs'; function useModal({ props, visible }) { const uStyle = useStyle(); const rendered = ref(false); const { emit } = getCurrentInstance(); const { isLoading } = useModalState({ props }); const { useBeforeCancel, useBeforeChange, useClose } = useModalEvent({ props, visible, isLoading }); const useBeforeEnter = () => { rendered.value = true; }; const useEnter = () => emit("open"); const useAfterEnter = () => emit("opened"); const useBeforeLeave = () => emit("close"); const useAfterLeave = () => { props.unmountOnClose && (rendered.value = false); emit("closed"); }; const width = computed(() => { return uStyle.width(props.width); }); return { useBeforeCancel, useBeforeChange, useClose, useEnter, useBeforeEnter, useAfterEnter, useBeforeLeave, useAfterLeave, isLoading, rendered, width }; } export { useModal }; //# sourceMappingURL=use-modal.mjs.map