@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
138 lines (135 loc) • 4.96 kB
JavaScript
import { defineComponent, ref, computed, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, normalizeClass, normalizeStyle, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, createVNode, renderSlot } from 'vue';
import { VsButton } from '../../button/index.mjs';
import { VsIcon } from '../../icon/index.mjs';
import { VsPopper } from '../../popper/index.mjs';
import '../../../hooks/index.mjs';
import '../../../utils/index.mjs';
import { popconfirmProps, popconfirmEmits } from './popconfirm.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useLocale } from '../../../hooks/use-locale/index.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { addUnit } from '../../../utils/dom/style.mjs';
const __default__ = defineComponent({
name: "VsPopconfirm"
});
const _sfc_main = defineComponent({
...__default__,
props: popconfirmProps,
emits: popconfirmEmits,
setup(__props, { emit }) {
const props = __props;
const { t } = useLocale();
const ns = useNamespace("popconfirm");
const tooltipRef = ref();
const hidePopper = () => {
var _a;
(_a = tooltipRef.value) == null ? void 0 : _a.hide();
};
const style = computed(() => {
return {
width: addUnit(props.width)
};
});
const confirm = (e) => {
emit("confirm", e);
hidePopper();
};
const cancel = (e) => {
emit("cancel", e);
hidePopper();
};
const finalConfirmButtonText = computed(
() => props.confirmButtonText || t("vs.popconfirm.confirmButtonText")
);
const finalCancelButtonText = computed(
() => props.cancelButtonText || t("vs.popconfirm.cancelButtonText")
);
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(VsPopper), mergeProps({
ref_key: "tooltipRef",
ref: tooltipRef,
trigger: "click",
color: "light"
}, _ctx.$attrs, {
animation: _ctx.animation,
"popper-class": `${unref(ns).namespace.value}-popconfirm`,
"popper-style": style.value,
teleported: _ctx.teleported,
"fallback-placements": ["bottom", "top", "right", "left"],
"hide-after": _ctx.hideAfter,
persistent: _ctx.persistent
}), {
content: withCtx(() => [
createElementVNode(
"div",
{
class: normalizeClass(unref(ns).e("main"))
},
[
!_ctx.hideIcon && _ctx.icon ? (openBlock(), createBlock(unref(VsIcon), {
key: 0,
class: normalizeClass(unref(ns).e("icon")),
style: normalizeStyle({ color: _ctx.iconColor }),
size: "26"
}, {
default: withCtx(() => [
(openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
]),
_: 1
}, 8, ["class", "style"])) : createCommentVNode("v-if", true),
createTextVNode(
" " + toDisplayString(_ctx.title),
1
)
],
2
),
createElementVNode(
"div",
{
class: normalizeClass(unref(ns).e("action"))
},
[
createVNode(unref(VsButton), {
size: _ctx.cancelButtonSize,
color: _ctx.cancelButtonColor,
type: _ctx.cancelButtonType,
onClick: cancel
}, {
default: withCtx(() => [
createTextVNode(
toDisplayString(finalCancelButtonText.value),
1
)
]),
_: 1
}, 8, ["size", "color", "type"]),
createVNode(unref(VsButton), {
size: _ctx.confirmButtonSize,
color: _ctx.confirmButtonColor,
type: _ctx.confirmButtonType,
onClick: confirm
}, {
default: withCtx(() => [
createTextVNode(
toDisplayString(finalConfirmButtonText.value),
1
)
]),
_: 1
}, 8, ["size", "color", "type"])
],
2
)
]),
default: withCtx(() => [
_ctx.$slots.reference ? renderSlot(_ctx.$slots, "reference", { key: 0 }) : createCommentVNode("v-if", true)
]),
_: 3
}, 16, ["animation", "popper-class", "popper-style", "teleported", "hide-after", "persistent"]);
};
}
});
var Popconfirm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/popconfirm/src/popconfirm.vue"]]);
export { Popconfirm as default };
//# sourceMappingURL=popconfirm2.mjs.map