collapse-item2.mjs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { defineComponent, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, withKeys, withModifiers, renderSlot, createTextVNode, toDisplayString, createVNode, withCtx, withDirectives, vShow } from 'vue';
  2. import _CollapseTransition from '../../collapse-transition/index.mjs';
  3. import { ElIcon } from '../../icon/index.mjs';
  4. import { ArrowRight } from '@element-plus/icons-vue';
  5. import { collapseItemProps } from './collapse-item.mjs';
  6. import { useCollapseItem, useCollapseItemDOM } from './use-collapse-item.mjs';
  7. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  8. const _hoisted_1 = ["aria-expanded", "aria-controls", "aria-describedby"];
  9. const _hoisted_2 = ["id", "tabindex"];
  10. const _hoisted_3 = ["id", "aria-hidden", "aria-labelledby"];
  11. const __default__ = defineComponent({
  12. name: "ElCollapseItem"
  13. });
  14. const _sfc_main = /* @__PURE__ */ defineComponent({
  15. ...__default__,
  16. props: collapseItemProps,
  17. setup(__props, { expose }) {
  18. const props = __props;
  19. const {
  20. focusing,
  21. id,
  22. isActive,
  23. handleFocus,
  24. handleHeaderClick,
  25. handleEnterClick
  26. } = useCollapseItem(props);
  27. const {
  28. arrowKls,
  29. headKls,
  30. rootKls,
  31. itemWrapperKls,
  32. itemContentKls,
  33. scopedContentId,
  34. scopedHeadId
  35. } = useCollapseItemDOM(props, { focusing, isActive, id });
  36. expose({
  37. isActive
  38. });
  39. return (_ctx, _cache) => {
  40. return openBlock(), createElementBlock("div", {
  41. class: normalizeClass(unref(rootKls))
  42. }, [
  43. createElementVNode("div", {
  44. role: "tab",
  45. "aria-expanded": unref(isActive),
  46. "aria-controls": unref(scopedContentId),
  47. "aria-describedby": unref(scopedContentId)
  48. }, [
  49. createElementVNode("div", {
  50. id: unref(scopedHeadId),
  51. class: normalizeClass(unref(headKls)),
  52. role: "button",
  53. tabindex: _ctx.disabled ? -1 : 0,
  54. onClick: _cache[0] || (_cache[0] = (...args) => unref(handleHeaderClick) && unref(handleHeaderClick)(...args)),
  55. onKeypress: _cache[1] || (_cache[1] = withKeys(withModifiers((...args) => unref(handleEnterClick) && unref(handleEnterClick)(...args), ["stop", "prevent"]), ["space", "enter"])),
  56. onFocus: _cache[2] || (_cache[2] = (...args) => unref(handleFocus) && unref(handleFocus)(...args)),
  57. onBlur: _cache[3] || (_cache[3] = ($event) => focusing.value = false)
  58. }, [
  59. renderSlot(_ctx.$slots, "title", {}, () => [
  60. createTextVNode(toDisplayString(_ctx.title), 1)
  61. ]),
  62. createVNode(unref(ElIcon), {
  63. class: normalizeClass(unref(arrowKls))
  64. }, {
  65. default: withCtx(() => [
  66. createVNode(unref(ArrowRight))
  67. ]),
  68. _: 1
  69. }, 8, ["class"])
  70. ], 42, _hoisted_2)
  71. ], 8, _hoisted_1),
  72. createVNode(unref(_CollapseTransition), null, {
  73. default: withCtx(() => [
  74. withDirectives(createElementVNode("div", {
  75. id: unref(scopedContentId),
  76. class: normalizeClass(unref(itemWrapperKls)),
  77. role: "tabpanel",
  78. "aria-hidden": !unref(isActive),
  79. "aria-labelledby": unref(scopedHeadId)
  80. }, [
  81. createElementVNode("div", {
  82. class: normalizeClass(unref(itemContentKls))
  83. }, [
  84. renderSlot(_ctx.$slots, "default")
  85. ], 2)
  86. ], 10, _hoisted_3), [
  87. [vShow, unref(isActive)]
  88. ])
  89. ]),
  90. _: 3
  91. })
  92. ], 2);
  93. };
  94. }
  95. });
  96. var CollapseItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/collapse/src/collapse-item.vue"]]);
  97. export { CollapseItem as default };
  98. //# sourceMappingURL=collapse-item2.mjs.map