You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.8 KiB

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