UNPKG

sard-uniapp

Version:

sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库

37 lines (36 loc) 1.12 kB
import { defaultPopupProps, } from '../popup/common'; import { defaultConfig } from '../config'; import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use'; export const defaultPopupAgentProps = () => ({ ...defaultPopupProps(), id: 'popup', ...defaultConfig.popupAgent, }); export const imperativeName = 'popup'; const show = (options = {}) => { const { id = defaultPopupAgentProps().id } = options; const imperative = getAvailableImperative(imperativeName, id); if (imperative) { imperative.show(options); } }; const popup = (options) => { show(options); }; const hide = (id = defaultPopupAgentProps().id) => { const imperatives = getImperatives(imperativeName, id); if (imperatives && imperatives.length > 0) { imperatives.forEach((item) => { item.imperative.hide(); }); } }; const hideAll = () => { const mapImperatives = getAllImperatives()[imperativeName]; if (mapImperatives) { Object.keys(mapImperatives).forEach(hide); } }; popup.hide = hide; popup.hideAll = hideAll; export { popup };