popconfirm2.mjs 4.7 KB

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