page-header2.mjs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { defineComponent, useSlots, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createCommentVNode, createElementVNode, createBlock, withCtx, resolveDynamicComponent, createTextVNode, toDisplayString, createVNode } from 'vue';
  2. import { ElIcon } from '../../icon/index.mjs';
  3. import { ElDivider } from '../../divider/index.mjs';
  4. import '../../../hooks/index.mjs';
  5. import { pageHeaderProps, pageHeaderEmits } from './page-header.mjs';
  6. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useLocale } from '../../../hooks/use-locale/index.mjs';
  8. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  9. const _hoisted_1 = ["aria-label"];
  10. const __default__ = defineComponent({
  11. name: "ElPageHeader"
  12. });
  13. const _sfc_main = /* @__PURE__ */ defineComponent({
  14. ...__default__,
  15. props: pageHeaderProps,
  16. emits: pageHeaderEmits,
  17. setup(__props, { emit }) {
  18. const slots = useSlots();
  19. const { t } = useLocale();
  20. const ns = useNamespace("page-header");
  21. const kls = computed(() => {
  22. return [
  23. ns.b(),
  24. {
  25. [ns.m("has-breadcrumb")]: !!slots.breadcrumb,
  26. [ns.m("has-extra")]: !!slots.extra,
  27. [ns.is("contentful")]: !!slots.default
  28. }
  29. ];
  30. });
  31. function handleClick() {
  32. emit("back");
  33. }
  34. return (_ctx, _cache) => {
  35. return openBlock(), createElementBlock("div", {
  36. class: normalizeClass(unref(kls))
  37. }, [
  38. _ctx.$slots.breadcrumb ? (openBlock(), createElementBlock("div", {
  39. key: 0,
  40. class: normalizeClass(unref(ns).e("breadcrumb"))
  41. }, [
  42. renderSlot(_ctx.$slots, "breadcrumb")
  43. ], 2)) : createCommentVNode("v-if", true),
  44. createElementVNode("div", {
  45. class: normalizeClass(unref(ns).e("header"))
  46. }, [
  47. createElementVNode("div", {
  48. class: normalizeClass(unref(ns).e("left"))
  49. }, [
  50. createElementVNode("div", {
  51. class: normalizeClass(unref(ns).e("back")),
  52. role: "button",
  53. tabindex: "0",
  54. onClick: handleClick
  55. }, [
  56. _ctx.icon || _ctx.$slots.icon ? (openBlock(), createElementBlock("div", {
  57. key: 0,
  58. "aria-label": _ctx.title || unref(t)("el.pageHeader.title"),
  59. class: normalizeClass(unref(ns).e("icon"))
  60. }, [
  61. renderSlot(_ctx.$slots, "icon", {}, () => [
  62. _ctx.icon ? (openBlock(), createBlock(unref(ElIcon), { key: 0 }, {
  63. default: withCtx(() => [
  64. (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
  65. ]),
  66. _: 1
  67. })) : createCommentVNode("v-if", true)
  68. ])
  69. ], 10, _hoisted_1)) : createCommentVNode("v-if", true),
  70. createElementVNode("div", {
  71. class: normalizeClass(unref(ns).e("title"))
  72. }, [
  73. renderSlot(_ctx.$slots, "title", {}, () => [
  74. createTextVNode(toDisplayString(_ctx.title || unref(t)("el.pageHeader.title")), 1)
  75. ])
  76. ], 2)
  77. ], 2),
  78. createVNode(unref(ElDivider), { direction: "vertical" }),
  79. createElementVNode("div", {
  80. class: normalizeClass(unref(ns).e("content"))
  81. }, [
  82. renderSlot(_ctx.$slots, "content", {}, () => [
  83. createTextVNode(toDisplayString(_ctx.content), 1)
  84. ])
  85. ], 2)
  86. ], 2),
  87. _ctx.$slots.extra ? (openBlock(), createElementBlock("div", {
  88. key: 0,
  89. class: normalizeClass(unref(ns).e("extra"))
  90. }, [
  91. renderSlot(_ctx.$slots, "extra")
  92. ], 2)) : createCommentVNode("v-if", true)
  93. ], 2),
  94. _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
  95. key: 1,
  96. class: normalizeClass(unref(ns).e("main"))
  97. }, [
  98. renderSlot(_ctx.$slots, "default")
  99. ], 2)) : createCommentVNode("v-if", true)
  100. ], 2);
  101. };
  102. }
  103. });
  104. var PageHeader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/page-header/src/page-header.vue"]]);
  105. export { PageHeader as default };
  106. //# sourceMappingURL=page-header2.mjs.map