popconfirm2.js 4.9 KB

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