1cc0d53ee8a69c22f2560a3c23d6ec659d2118841f41b90c0f42bdd51e999128460804dcec5bad0d5f0d21ac7f88e2829afaeebf8a011e0070bdce1a162db7 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var core = require('@vueuse/core');
  5. var constants = require('./constants.js');
  6. var tabPane = require('./tab-pane2.js');
  7. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  8. var error = require('../../../utils/error.js');
  9. var index = require('../../../hooks/use-namespace/index.js');
  10. const COMPONENT_NAME = "ElTabPane";
  11. const __default__ = vue.defineComponent({
  12. name: COMPONENT_NAME
  13. });
  14. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  15. ...__default__,
  16. props: tabPane.tabPaneProps,
  17. setup(__props) {
  18. const props = __props;
  19. const instance = vue.getCurrentInstance();
  20. const slots = vue.useSlots();
  21. const tabsRoot = vue.inject(constants.tabsRootContextKey);
  22. if (!tabsRoot)
  23. error.throwError(COMPONENT_NAME, "usage: <el-tabs><el-tab-pane /></el-tabs/>");
  24. const ns = index.useNamespace("tab-pane");
  25. const paneRef = vue.ref();
  26. const index$1 = vue.ref();
  27. const isClosable = vue.computed(() => {
  28. var _a;
  29. return (_a = props.closable) != null ? _a : tabsRoot.props.closable;
  30. });
  31. const active = core.eagerComputed(() => {
  32. var _a;
  33. return tabsRoot.currentName.value === ((_a = props.name) != null ? _a : index$1.value);
  34. });
  35. const loaded = vue.ref(active.value);
  36. const paneName = vue.computed(() => {
  37. var _a;
  38. return (_a = props.name) != null ? _a : index$1.value;
  39. });
  40. const shouldBeRender = core.eagerComputed(() => !props.lazy || loaded.value || active.value);
  41. const isFocusInsidePane = () => {
  42. var _a;
  43. return (_a = paneRef.value) == null ? void 0 : _a.contains(document.activeElement);
  44. };
  45. vue.watch(active, (val) => {
  46. if (val)
  47. loaded.value = true;
  48. });
  49. const pane = vue.reactive({
  50. uid: instance.uid,
  51. getVnode: () => instance.vnode,
  52. slots,
  53. props,
  54. paneName,
  55. active,
  56. index: index$1,
  57. isClosable,
  58. isFocusInsidePane
  59. });
  60. tabsRoot.registerPane(pane);
  61. vue.onBeforeUnmount(() => {
  62. tabsRoot.unregisterPane(pane);
  63. });
  64. vue.onBeforeUpdate(() => {
  65. var _a;
  66. if (slots.label)
  67. (_a = tabsRoot.nav$.value) == null ? void 0 : _a.scheduleRender();
  68. });
  69. return (_ctx, _cache) => {
  70. return vue.unref(shouldBeRender) ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
  71. key: 0,
  72. id: `pane-${vue.unref(paneName)}`,
  73. ref_key: "paneRef",
  74. ref: paneRef,
  75. class: vue.normalizeClass(vue.unref(ns).b()),
  76. role: "tabpanel",
  77. "aria-hidden": !vue.unref(active),
  78. "aria-labelledby": `tab-${vue.unref(paneName)}`
  79. }, [
  80. vue.renderSlot(_ctx.$slots, "default")
  81. ], 10, ["id", "aria-hidden", "aria-labelledby"])), [
  82. [vue.vShow, vue.unref(active)]
  83. ]) : vue.createCommentVNode("v-if", true);
  84. };
  85. }
  86. });
  87. var TabPane = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "tab-pane.vue"]]);
  88. exports["default"] = TabPane;
  89. //# sourceMappingURL=tab-pane.js.map