UNPKG

@vuesax-alpha/nightly

Version:
97 lines (92 loc) 2.92 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var index$1 = require('../../collapse-transition/index.js'); require('../../../hooks/index.js'); var sidebarGroup = require('./sidebar-group.js'); var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js'); var index = require('../../../hooks/use-namespace/index.js'); const __default__ = vue.defineComponent({ name: "VsSidebarGroup" }); const _sfc_main = vue.defineComponent({ ...__default__, props: sidebarGroup.sidebarGroupProps, setup(__props) { const props = __props; const ns = index.useNamespace("sidebar-group"); const groupRef = vue.ref(); const contentRef = vue.ref(); const openState = vue.ref(false); const onClickHeader = () => { openState.value = !openState.value; }; vue.watch( () => props.open, (val) => { vue.nextTick(() => { if (!contentRef.value) return; const h = contentRef.value.scrollHeight || 0; const content = contentRef.value; if (val) { content.style.height = `${content.scrollHeight + h - 1}px`; } else { content.style.height = `${content.scrollHeight - h + 1}px`; } }); } ); vue.onMounted(() => { if (props.open) { openState.value = true; } }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock( "div", { ref_key: "groupRef", ref: groupRef, class: vue.normalizeClass([vue.unref(ns).b(), vue.unref(ns).is("open", openState.value)]) }, [ vue.createElementVNode( "div", { class: vue.normalizeClass(vue.unref(ns).e("header")), onClick: onClickHeader }, [ vue.renderSlot(_ctx.$slots, "header") ], 2 ), vue.createVNode(vue.unref(index$1["default"]), null, { default: vue.withCtx(() => [ vue.withDirectives(vue.createElementVNode( "div", { ref_key: "contentRef", ref: contentRef, class: vue.normalizeClass(vue.unref(ns).e("content")) }, [ vue.renderSlot(_ctx.$slots, "default") ], 2 ), [ [vue.vShow, openState.value] ]) ]), _: 3 }) ], 2 ); }; } }); var SidebarGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/sidebar/src/sidebar-group.vue"]]); exports["default"] = SidebarGroup; //# sourceMappingURL=sidebar-group2.js.map