plus-pro-components
Version:
Page level components developed based on Element Plus.
98 lines (95 loc) • 3.03 kB
JavaScript
import { defineComponent, ref, watch, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, renderSlot, createElementBlock, createVNode, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
import '../../../hooks/index.mjs';
import { ElPopover, ElButton } from 'element-plus';
import { useLocale } from '../../../hooks/useLocale.mjs';
const _hoisted_1 = {
key: 0,
style: { "padding-top": "12px" }
};
var _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "PlusPopover"
},
__name: "index",
props: {
hasShowBottomButton: { type: Boolean, default: false },
confirmLoading: { type: Boolean, default: false },
cancelText: { default: "" },
confirmText: { default: "" }
},
emits: ["cancel", "confirm"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const subVisible = ref(false);
const { t } = useLocale();
watch(
() => props.visible,
(val) => {
subVisible.value = val;
},
{
immediate: true
}
);
const handleCancelPopover = () => {
subVisible.value = false;
emit("cancel");
};
const handleConfirmPopover = () => {
subVisible.value = false;
emit("confirm");
};
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(ElPopover), mergeProps({
visible: subVisible.value,
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => subVisible.value = $event)
}, _ctx.$attrs), {
reference: withCtx(() => [
createElementVNode("span", null, [
renderSlot(_ctx.$slots, "reference")
])
]),
default: withCtx(() => [
renderSlot(_ctx.$slots, "default"),
_ctx.hasShowBottomButton ? (openBlock(), createElementBlock("div", _hoisted_1, [
createVNode(unref(ElButton), {
size: "small",
plain: "",
onClick: handleCancelPopover
}, {
default: withCtx(() => [
createTextVNode(
toDisplayString(_ctx.cancelText || unref(t)("plus.popover.cancelText")),
1
/* TEXT */
)
]),
_: 1
/* STABLE */
}),
createVNode(unref(ElButton), {
size: "small",
type: "primary",
loading: _ctx.confirmLoading,
onClick: handleConfirmPopover
}, {
default: withCtx(() => [
createTextVNode(
toDisplayString(_ctx.confirmText || unref(t)("plus.popover.confirmText")),
1
/* TEXT */
)
]),
_: 1
/* STABLE */
}, 8, ["loading"])
])) : createCommentVNode("v-if", true)
]),
_: 3
/* FORWARDED */
}, 16, ["visible"]);
};
}
});
export { _sfc_main as default };