popconfirm2.mjs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { defineComponent, ref, computed, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, normalizeClass, normalizeStyle, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, renderSlot, createVNode } from 'vue';
  2. import { ElButton } from '../../button/index.mjs';
  3. import { ElIcon } from '../../icon/index.mjs';
  4. import { ElTooltip } from '../../tooltip/index.mjs';
  5. import { popconfirmProps, popconfirmEmits } from './popconfirm.mjs';
  6. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useLocale } from '../../../hooks/use-locale/index.mjs';
  8. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  9. import { addUnit } from '../../../utils/dom/style.mjs';
  10. const __default__ = defineComponent({
  11. name: "ElPopconfirm"
  12. });
  13. const _sfc_main = /* @__PURE__ */ defineComponent({
  14. ...__default__,
  15. props: popconfirmProps,
  16. emits: popconfirmEmits,
  17. setup(__props, { emit }) {
  18. const props = __props;
  19. const { t } = useLocale();
  20. const ns = useNamespace("popconfirm");
  21. const tooltipRef = ref();
  22. const hidePopper = () => {
  23. var _a, _b;
  24. (_b = (_a = tooltipRef.value) == null ? void 0 : _a.onClose) == null ? void 0 : _b.call(_a);
  25. };
  26. const style = computed(() => {
  27. return {
  28. width: addUnit(props.width)
  29. };
  30. });
  31. const confirm = (e) => {
  32. emit("confirm", e);
  33. hidePopper();
  34. };
  35. const cancel = (e) => {
  36. emit("cancel", e);
  37. hidePopper();
  38. };
  39. const finalConfirmButtonText = computed(() => props.confirmButtonText || t("el.popconfirm.confirmButtonText"));
  40. const finalCancelButtonText = computed(() => props.cancelButtonText || t("el.popconfirm.cancelButtonText"));
  41. return (_ctx, _cache) => {
  42. return openBlock(), createBlock(unref(ElTooltip), mergeProps({
  43. ref_key: "tooltipRef",
  44. ref: tooltipRef,
  45. trigger: "click",
  46. effect: "light"
  47. }, _ctx.$attrs, {
  48. "popper-class": `${unref(ns).namespace.value}-popover`,
  49. "popper-style": unref(style),
  50. teleported: _ctx.teleported,
  51. "fallback-placements": ["bottom", "top", "right", "left"],
  52. "hide-after": _ctx.hideAfter,
  53. persistent: _ctx.persistent
  54. }), {
  55. content: withCtx(() => [
  56. createElementVNode("div", {
  57. class: normalizeClass(unref(ns).b())
  58. }, [
  59. createElementVNode("div", {
  60. class: normalizeClass(unref(ns).e("main"))
  61. }, [
  62. !_ctx.hideIcon && _ctx.icon ? (openBlock(), createBlock(unref(ElIcon), {
  63. key: 0,
  64. class: normalizeClass(unref(ns).e("icon")),
  65. style: normalizeStyle({ color: _ctx.iconColor })
  66. }, {
  67. default: withCtx(() => [
  68. (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
  69. ]),
  70. _: 1
  71. }, 8, ["class", "style"])) : createCommentVNode("v-if", true),
  72. createTextVNode(" " + toDisplayString(_ctx.title), 1)
  73. ], 2),
  74. createElementVNode("div", {
  75. class: normalizeClass(unref(ns).e("action"))
  76. }, [
  77. renderSlot(_ctx.$slots, "actions", {
  78. confirm,
  79. cancel
  80. }, () => [
  81. createVNode(unref(ElButton), {
  82. size: "small",
  83. type: _ctx.cancelButtonType === "text" ? "" : _ctx.cancelButtonType,
  84. text: _ctx.cancelButtonType === "text",
  85. onClick: cancel
  86. }, {
  87. default: withCtx(() => [
  88. createTextVNode(toDisplayString(unref(finalCancelButtonText)), 1)
  89. ]),
  90. _: 1
  91. }, 8, ["type", "text"]),
  92. createVNode(unref(ElButton), {
  93. size: "small",
  94. type: _ctx.confirmButtonType === "text" ? "" : _ctx.confirmButtonType,
  95. text: _ctx.confirmButtonType === "text",
  96. onClick: confirm
  97. }, {
  98. default: withCtx(() => [
  99. createTextVNode(toDisplayString(unref(finalConfirmButtonText)), 1)
  100. ]),
  101. _: 1
  102. }, 8, ["type", "text"])
  103. ])
  104. ], 2)
  105. ], 2)
  106. ]),
  107. default: withCtx(() => [
  108. _ctx.$slots.reference ? renderSlot(_ctx.$slots, "reference", { key: 0 }) : createCommentVNode("v-if", true)
  109. ]),
  110. _: 3
  111. }, 16, ["popper-class", "popper-style", "teleported", "hide-after", "persistent"]);
  112. };
  113. }
  114. });
  115. var Popconfirm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "popconfirm.vue"]]);
  116. export { Popconfirm as default };
  117. //# sourceMappingURL=popconfirm2.mjs.map