UNPKG

tdesign-mobile-vue

Version:
190 lines (186 loc) 6.3 kB
/** * tdesign v1.9.3 * (c) 2025 TDesign Group * @license MIT */ import { _ as _defineProperty } from '../_chunks/dep-900db0e1.mjs'; import { ref, reactive, nextTick, createApp, h } from 'vue'; import Dialog from './dialog.mjs'; import '../shared/index.mjs'; import './style/css.mjs'; import { isBrowser } from '../shared/util.mjs'; import '../_chunks/dep-4915223e.mjs'; import '../_chunks/dep-fb4113ef.mjs'; import '../_chunks/dep-a953013f.mjs'; import 'tdesign-icons-vue-next'; import 'lodash-es'; import '../button/index.mjs'; import '../button/button.mjs'; import '../loading/index.mjs'; import '../loading/loading.mjs'; import '../loading/icon/gradient.mjs'; import '../_common/js/loading/circle-adapter.mjs'; import '../_common/js/utils/setStyle.mjs'; import '../_common/js/utils/helper.mjs'; import '../_chunks/dep-da32ae58.mjs'; import '../_chunks/dep-26b97ced.mjs'; import '../config.mjs'; import '../hooks/useClass.mjs'; import '../config-provider/useConfig.mjs'; import '../config-provider/context.mjs'; import '../_common/js/global-config/mobile/default-config.mjs'; import '../_common/js/global-config/mobile/locale/zh_CN.mjs'; import '../_chunks/dep-bca0f578.mjs'; import '../_chunks/dep-6b2b02fd.mjs'; import '../_chunks/dep-c6f44a15.mjs'; import '../_chunks/dep-c984d53e.mjs'; import '../config-provider/type.mjs'; import '../loading/icon/spinner.mjs'; import '../loading/props.mjs'; import '../hooks/tnode.mjs'; import '../hooks/render-tnode.mjs'; import '../_common/js/utils/general.mjs'; import '../shared/dom.mjs'; import '../loading/type.mjs'; import '../loading/plugin.mjs'; import '../shared/component.mjs'; import '../button/props.mjs'; import '../form/hooks.mjs'; import '../shared/hover.mjs'; import '../button/type.mjs'; import '../shared/functions.mjs'; import '../shared/render.mjs'; import '../shared/render-tnode.mjs'; import '../shared/useCountDown/index.mjs'; import '../_chunks/dep-99e43b7b.mjs'; import '@vueuse/core'; import '../shared/useCountDown/utils.mjs'; import '../shared/useTouch/index.mjs'; import '../shared/useScrollParent/index.mjs'; import '../shared/useTest/index.mjs'; import '../shared/useClickAway/index.mjs'; import '../popup/index.mjs'; import '../popup/popup.mjs'; import '../popup/props.mjs'; import '../overlay/index.mjs'; import '../overlay/overlay.mjs'; import '../overlay/props.mjs'; import '../hooks/useVModel.mjs'; import '../hooks/useLockScroll.mjs'; import '../_util/useTouch.mjs'; import '../_util/getScrollParent.mjs'; import '../hooks/useTeleport.mjs'; import '../popup/type.mjs'; import './props.mjs'; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var DialogPropsDefault = { title: "", content: "", confirmBtn: "", cancelBtn: "", visible: false, zIndex: 2500, showOverlay: true, width: "320px", closeOnOverlayClick: false }; var propsFn = ["onConfirm", "onCancel", "onOverlayClick", "onClose", "onClosed"]; function create(options) { if (!isBrowser) return; var root = document.createElement("div"); document.body.appendChild(root); var props = ref({}); var propsObject = _objectSpread(_objectSpread({}, DialogPropsDefault), typeof options === "string" ? { content: options } : options); function callFn(fnType, context) { var fn = props.value[fnType] || propsObject[fnType]; typeof fn === "function" && fn(context); } var params = reactive(_objectSpread(_objectSpread({}, propsObject), {}, { onConfirm: function onConfirm(context) { callFn("onConfirm", context); params.visible = false; }, onCancel: function onCancel(context) { callFn("onCancel", context); params.visible = false; }, onOverlayClick: function onOverlayClick(context) { callFn("onOverlayClick", context); params.visible = false; }, onClose: function onClose(context) { callFn("onClose", context); params.visible = false; }, onClosed: function onClosed() { callFn("onClosed"); nextTick(function () { params.destroyOnClose && app.unmount(); }); } })); var app = createApp(function () { return h(Dialog, params); }); app.mount(root); var handler = { destroy: function destroy() { params.destroyOnClose = true; nextTick(function () { params.visible = false; root.remove(); }); }, hide: function hide() { params.visible = false; }, show: function show() { params.visible = true; }, update: function update(options2) { if (typeof options2 === "string") { params.content = options2; } else { for (var key in options2) { if (propsFn.includes(key)) { props.value[key] = options2[key]; } else { params[key] = options2[key]; } } } } }; nextTick(function () { return params.visible = true; }); return handler; } ["show", "alert", "confirm"].forEach(function (type) { Dialog[type] = function (options) { var props = { content: "" }; if (typeof options === "string") { props.content = options; } else { props = _objectSpread(_objectSpread({}, props), options); } if (type === "alert") { props.cancelBtn = null; } return create(props); }; }); Dialog.install = function (app) { var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; app.component(name || Dialog.name, Dialog); app.config.globalProperties.$dialog = Dialog; app.provide("$dialog", Dialog); }; var DialogPlugin = Dialog; export { DialogPlugin, DialogPlugin as default }; //# sourceMappingURL=index.mjs.map