UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

212 lines (211 loc) 8.16 kB
"use strict"; const vue = require("vue"); const elementPlus = require("element-plus"); const core = require("../utils/core"); const EleTooltip = require("../ele-tooltip/index"); const props$1 = require("../ele-tooltip/props"); const icons = require("../icons"); const props = require("./props"); const _sfc_main = vue.defineComponent({ name: "ElePopconfirm", components: { ElIcon: elementPlus.ElIcon, ElButton: elementPlus.ElButton, EleTooltip, QuestionCircleFilled: icons.QuestionCircleFilled }, props: props.popconfirmProps, emits: props.popconfirmEmits, setup(props2, { emit }) { const { t } = elementPlus.useLocale(); const tooltipRef = vue.ref(null); const tooltipProps = vue.computed(() => { const keys = props$1.tooltipPropKeys.filter( (k) => !["content", "bodyStyle"].includes(k) ); const options = core.pick(props2, keys); options.ariaLabel = props2.title; options.gpuAcceleration = props2.transition === "el-fade-in-linear"; const classes = ["ele-popconfirm"]; if (typeof props2.popperClass === "string" && props2.popperClass) { classes.push(props2.popperClass); } options.popperClass = classes.join(" "); return options; }); const iconOptions = vue.computed(() => { const options = props2.iconProps || {}; if (props2.iconColor) { options.style = Object.assign( { color: props2.iconColor }, options.style ); } const classes = ["ele-popconfirm-icon"]; if (options.class) { if (Array.isArray(options.class)) { options.class.forEach((c) => { classes.push(c); }); } else { classes.push(options.class); } } options.class = classes; return options; }); const confirmText = vue.computed(() => { return props2.confirmButtonText || t("el.popconfirm.confirmButtonText"); }); const cancelText = vue.computed(() => { return props2.cancelButtonText || t("el.popconfirm.cancelButtonText"); }); const hidePopper = () => { tooltipRef.value && tooltipRef.value.hide(); }; const confirm = (e) => { hidePopper(); emit("confirm", e); }; const cancel = (e) => { hidePopper(); emit("cancel", e); }; const handleUpdateVisible = (visible) => { emit("update:visible", visible); }; const handlePopBeforeEnter = () => { emit("before-enter"); }; const handlePopBeforeLeave = () => { emit("before-leave"); }; const handlePopAfterEnter = () => { emit("after-enter"); }; const handlePopAfterLeave = () => { emit("after-leave"); }; return { tooltipRef, tooltipProps, iconOptions, confirmText, cancelText, hidePopper, confirm, cancel, handleUpdateVisible, handlePopBeforeEnter, handlePopBeforeLeave, handlePopAfterEnter, handlePopAfterLeave }; } }); const _export_sfc = (sfc, props2) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props2) { target[key] = val; } return target; }; const _hoisted_1 = { class: "ele-popconfirm-main" }; const _hoisted_2 = { class: "ele-popconfirm-body" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_QuestionCircleFilled = vue.resolveComponent("QuestionCircleFilled"); const _component_ElIcon = vue.resolveComponent("ElIcon"); const _component_ElButton = vue.resolveComponent("ElButton"); const _component_EleTooltip = vue.resolveComponent("EleTooltip"); return vue.openBlock(), vue.createBlock(_component_EleTooltip, vue.mergeProps({ tabindex: _ctx.tabindex }, _ctx.tooltipProps, { ref: "tooltipRef", isPopover: true, "onUpdate:visible": _ctx.handleUpdateVisible, onBeforeShow: _ctx.handlePopBeforeEnter, onBeforeHide: _ctx.handlePopBeforeLeave, onShow: _ctx.handlePopAfterEnter, onHide: _ctx.handlePopAfterLeave }), { body: vue.withCtx(() => [ vue.createElementVNode("div", { class: vue.normalizeClass(["ele-popover-body", _ctx.bodyClass]), style: vue.normalizeStyle(_ctx.bodyStyle) }, [ vue.createElementVNode("div", _hoisted_1, [ !_ctx.hideIcon ? (vue.openBlock(), vue.createBlock(_component_ElIcon, vue.normalizeProps(vue.mergeProps({ key: 0 }, _ctx.iconOptions)), { default: vue.withCtx(() => [ _ctx.icon ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.icon), { key: 0, style: vue.normalizeStyle(_ctx.iconStyle) }, null, 8, ["style"])) : (vue.openBlock(), vue.createBlock(_component_QuestionCircleFilled, { key: 1, style: vue.normalizeStyle(_ctx.iconStyle) }, null, 8, ["style"])) ]), _: 1 }, 16)) : vue.createCommentVNode("", true), vue.createElementVNode("div", _hoisted_2, [ (_ctx.content || _ctx.$slots.content) && (_ctx.title || _ctx.$slots.title) ? (vue.openBlock(), vue.createElementBlock("div", { key: 0, class: "ele-popconfirm-title", style: vue.normalizeStyle(_ctx.titleStyle) }, [ vue.renderSlot(_ctx.$slots, "title", {}, () => [ vue.createTextVNode(vue.toDisplayString(_ctx.title), 1) ]) ], 4)) : vue.createCommentVNode("", true), vue.createElementVNode("div", { class: "ele-popconfirm-content", style: vue.normalizeStyle(_ctx.contentStyle) }, [ vue.renderSlot(_ctx.$slots, "content", {}, () => [ vue.createTextVNode(vue.toDisplayString(_ctx.content || _ctx.title), 1) ]) ], 4) ]) ]), vue.createElementVNode("div", { class: "ele-popconfirm-action", style: vue.normalizeStyle(_ctx.footerStyle) }, [ vue.renderSlot(_ctx.$slots, "actions", { cancel: _ctx.cancel, confirm: _ctx.confirm, cancelText: _ctx.cancelText, confirmText: _ctx.confirmText }, () => [ vue.renderSlot(_ctx.$slots, "action", { cancel: _ctx.cancel, confirm: _ctx.confirm, cancelText: _ctx.cancelText, confirmText: _ctx.confirmText }), !_ctx.hideCancelButton ? (vue.openBlock(), vue.createBlock(_component_ElButton, vue.mergeProps({ key: 0, size: "small", type: _ctx.cancelButtonType === "text" ? void 0 : _ctx.cancelButtonType, text: _ctx.cancelButtonType === "text" }, _ctx.cancelButtonProps || {}, { onClick: _ctx.cancel }), { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(_ctx.cancelText), 1) ]), _: 1 }, 16, ["type", "text", "onClick"])) : vue.createCommentVNode("", true), !_ctx.hideConfirmButton ? (vue.openBlock(), vue.createBlock(_component_ElButton, vue.mergeProps({ key: 1, size: "small", type: _ctx.confirmButtonType === "text" ? void 0 : _ctx.confirmButtonType, text: _ctx.confirmButtonType === "text" }, _ctx.confirmButtonProps || {}, { onClick: _ctx.confirm }), { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(_ctx.confirmText), 1) ]), _: 1 }, 16, ["type", "text", "onClick"])) : vue.createCommentVNode("", true) ]) ], 4) ], 6) ]), default: vue.withCtx(() => [ _ctx.$slots.reference ? vue.renderSlot(_ctx.$slots, "reference", { key: 0 }) : vue.createCommentVNode("", true) ]), _: 3 }, 16, ["tabindex", "onUpdate:visible", "onBeforeShow", "onBeforeHide", "onShow", "onHide"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); module.exports = index;