e8b5496f06f0025311356c48b8548e93627aa32b53898970c41e2cfe5d1ae84950b8700dcb2e8d874d0418a2d0858bd422f2b94b4fc1411495c6c2eb4d1d5a 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { defineComponent, inject, computed, openBlock, createElementBlock, unref, normalizeClass, normalizeStyle, createElementVNode, renderSlot, toDisplayString, createVNode, withCtx, createBlock, resolveDynamicComponent, createCommentVNode } from 'vue';
  2. import { ElIcon } from '../../icon/index.mjs';
  3. import { dialogInjectionKey } from './constants.mjs';
  4. import { dialogContentProps, dialogContentEmits } from './dialog-content.mjs';
  5. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  6. import { FOCUS_TRAP_INJECTION_KEY } from '../../focus-trap/src/tokens.mjs';
  7. import { useDraggable } from '../../../hooks/use-draggable/index.mjs';
  8. import { CloseComponents } from '../../../utils/vue/icon.mjs';
  9. import { composeRefs } from '../../../utils/vue/refs.mjs';
  10. import { useLocale } from '../../../hooks/use-locale/index.mjs';
  11. const __default__ = defineComponent({ name: "ElDialogContent" });
  12. const _sfc_main = /* @__PURE__ */ defineComponent({
  13. ...__default__,
  14. props: dialogContentProps,
  15. emits: dialogContentEmits,
  16. setup(__props, { expose }) {
  17. const props = __props;
  18. const { t } = useLocale();
  19. const { Close } = CloseComponents;
  20. const { dialogRef, headerRef, bodyId, ns, style } = inject(dialogInjectionKey);
  21. const { focusTrapRef } = inject(FOCUS_TRAP_INJECTION_KEY);
  22. const composedDialogRef = composeRefs(focusTrapRef, dialogRef);
  23. const draggable = computed(() => !!props.draggable);
  24. const overflow = computed(() => !!props.overflow);
  25. const { resetPosition, updatePosition, isDragging } = useDraggable(dialogRef, headerRef, draggable, overflow);
  26. const dialogKls = computed(() => [
  27. ns.b(),
  28. ns.is("fullscreen", props.fullscreen),
  29. ns.is("draggable", draggable.value),
  30. ns.is("dragging", isDragging.value),
  31. ns.is("align-center", !!props.alignCenter),
  32. { [ns.m("center")]: props.center }
  33. ]);
  34. expose({
  35. resetPosition,
  36. updatePosition
  37. });
  38. return (_ctx, _cache) => {
  39. return openBlock(), createElementBlock("div", {
  40. ref: unref(composedDialogRef),
  41. class: normalizeClass(unref(dialogKls)),
  42. style: normalizeStyle(unref(style)),
  43. tabindex: "-1"
  44. }, [
  45. createElementVNode("header", {
  46. ref_key: "headerRef",
  47. ref: headerRef,
  48. class: normalizeClass([unref(ns).e("header"), _ctx.headerClass, { "show-close": _ctx.showClose }])
  49. }, [
  50. renderSlot(_ctx.$slots, "header", {}, () => [
  51. createElementVNode("span", {
  52. role: "heading",
  53. "aria-level": _ctx.ariaLevel,
  54. class: normalizeClass(unref(ns).e("title"))
  55. }, toDisplayString(_ctx.title), 11, ["aria-level"])
  56. ]),
  57. _ctx.showClose ? (openBlock(), createElementBlock("button", {
  58. key: 0,
  59. "aria-label": unref(t)("el.dialog.close"),
  60. class: normalizeClass(unref(ns).e("headerbtn")),
  61. type: "button",
  62. onClick: ($event) => _ctx.$emit("close")
  63. }, [
  64. createVNode(unref(ElIcon), {
  65. class: normalizeClass(unref(ns).e("close"))
  66. }, {
  67. default: withCtx(() => [
  68. (openBlock(), createBlock(resolveDynamicComponent(_ctx.closeIcon || unref(Close))))
  69. ]),
  70. _: 1
  71. }, 8, ["class"])
  72. ], 10, ["aria-label", "onClick"])) : createCommentVNode("v-if", true)
  73. ], 2),
  74. createElementVNode("div", {
  75. id: unref(bodyId),
  76. class: normalizeClass([unref(ns).e("body"), _ctx.bodyClass])
  77. }, [
  78. renderSlot(_ctx.$slots, "default")
  79. ], 10, ["id"]),
  80. _ctx.$slots.footer ? (openBlock(), createElementBlock("footer", {
  81. key: 0,
  82. class: normalizeClass([unref(ns).e("footer"), _ctx.footerClass])
  83. }, [
  84. renderSlot(_ctx.$slots, "footer")
  85. ], 2)) : createCommentVNode("v-if", true)
  86. ], 6);
  87. };
  88. }
  89. });
  90. var ElDialogContent = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "dialog-content.vue"]]);
  91. export { ElDialogContent as default };
  92. //# sourceMappingURL=dialog-content2.mjs.map