UNPKG

plus-pro-components

Version:

Page level components developed based on Element Plus.

126 lines (121 loc) 4.14 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var elementPlus = require('element-plus'); require('../../../hooks/index.js'); var useLocale = require('../../../hooks/useLocale.js'); const _hoisted_1 = { class: "plus-dialog-body" }; var _sfc_main = /* @__PURE__ */ vue.defineComponent({ ...{ name: "PlusDialog", inheritAttrs: false }, __name: "index", props: { modelValue: { type: Boolean, default: false }, confirmText: { default: "" }, cancelText: { default: "" }, confirmLoading: { type: Boolean, default: false }, hasFooter: { type: Boolean, default: true }, footerAlign: { default: "right" }, top: { default: "15vh" }, width: { default: "460px" }, title: { default: "" } }, emits: ["update:modelValue", "cancel", "confirm"], setup(__props, { emit: __emit }) { const props = __props; const emit = __emit; const style = vue.computed(() => ({ justifyContent: props.footerAlign === "left" ? "flex-start" : props.footerAlign === "center" ? "center" : "flex-end" })); const subVisible = vue.ref(false); const { t } = useLocale.useLocale(); vue.watchEffect(() => { subVisible.value = props.modelValue; }); const handleConfirm = () => { emit("confirm"); }; const handleCancel = () => { emit("update:modelValue", false); emit("cancel"); }; return (_ctx, _cache) => { return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElDialog), vue.mergeProps({ modelValue: subVisible.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => subVisible.value = $event), top: _ctx.top, width: _ctx.width, title: _ctx.title || vue.unref(t)("plus.dialog.title"), "close-on-click-modal": false, "close-on-press-escape": false, "append-to-body": false, "before-close": handleCancel, class: "plus-dialog" }, _ctx.$attrs), vue.createSlots({ default: vue.withCtx(() => [ vue.createElementVNode("div", _hoisted_1, [ vue.renderSlot(_ctx.$slots, "default") ]) ]), _: 2 /* DYNAMIC */ }, [ _ctx.$slots.header ? { name: "header", fn: vue.withCtx(() => [ vue.renderSlot(_ctx.$slots, "header") ]), key: "0" } : void 0, _ctx.hasFooter ? { name: "footer", fn: vue.withCtx(() => [ vue.createElementVNode( "div", { class: "plus-dialog-footer", style: vue.normalizeStyle(style.value) }, [ vue.renderSlot(_ctx.$slots, "footer", {}, () => [ vue.createVNode(vue.unref(elementPlus.ElButton), { onClick: handleCancel }, { default: vue.withCtx(() => [ vue.createTextVNode( vue.toDisplayString(_ctx.cancelText || vue.unref(t)("plus.dialog.cancelText")), 1 /* TEXT */ ) ]), _: 1 /* STABLE */ }), vue.createVNode(vue.unref(elementPlus.ElButton), { type: "primary", loading: _ctx.confirmLoading, onClick: handleConfirm }, { default: vue.withCtx(() => [ vue.createTextVNode( vue.toDisplayString(_ctx.confirmText || vue.unref(t)("plus.dialog.confirmText")), 1 /* TEXT */ ) ]), _: 1 /* STABLE */ }, 8, ["loading"]) ]) ], 4 /* STYLE */ ) ]), key: "1" } : void 0 ]), 1040, ["modelValue", "top", "width", "title"]); }; } }); exports.default = _sfc_main;