764e842677718df67c170a35c01147915787e6ce522a3f17b6d6b08828dbce3ea90a89bd755115ec03183394ef74d1d92b13e8549e3e4508e7ff35d0c91c86 5.7 KB

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