import { w as withInstall } from "../badge/index2.js"; import { defineComponent, ref, inject, getCurrentInstance, computed, reactive, onMounted, onBeforeUnmount, openBlock, createElementBlock, Fragment, unref, mergeProps, toHandlers, createCommentVNode, normalizeClass, normalizeStyle, renderSlot } from "vue"; const __default__ = { name: "LaySplitPanelItem" }; const _sfc_main = defineComponent({ ...__default__, props: { space: { default: 0 } }, setup(__props) { const props = __props; const index = ref(-1); const parents = inject("laySplitPanel"); const currentInstance = getCurrentInstance(); const moveStatus = ref(false); const setIndex = (val) => { index.value = val; }; const mouseup = (event) => { moveStatus.value = false; }; const stepsCount = computed(() => { return parents.steps.value.length; }); const initSpace = (parentSpace, key) => { const childList = Array.from(parentElement.value.children); childList.forEach((item, index2) => { if (index2 === 0 || index2 % 2 === 0) { item.style.flexBasis = item[key] / parentSpace * 100 + "%"; item.style.flexGrow = 0; } }); }; const mousedown = (event) => { let parentSpace = 0; if (!isVertical.value) { parentSpace = parentElement.value.offsetWidth; initSpace(parentSpace, "offsetWidth"); } else { parentSpace = parentElement.value.offsetHeight; initSpace(parentSpace, "offsetHeight"); } moveStatus.value = true; parents.moveChange(event, true, isVertical.value); }; const parentElement = computed(() => { return parents.target.value; }); const isVertical = computed(() => { return parents.props.vertical; }); computed(() => { var _a; return ((_a = parents.steps.value[stepsCount.value - 1]) == null ? void 0 : _a.itemId) === currentInstance.uid; }); const isStart = computed(() => { var _a; return ((_a = parents.steps.value[0]) == null ? void 0 : _a.itemId) === currentInstance.uid; }); const stepItemState = reactive({ itemId: computed(() => currentInstance == null ? void 0 : currentInstance.uid), setIndex, space: props.space }); parents.steps.value = [...parents.steps.value, stepItemState]; onMounted(() => { }); onBeforeUnmount(() => { parents.steps.value = parents.steps.value.filter( (instance) => instance.itemId !== currentInstance.uid ); }); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [ !unref(isStart) ? (openBlock(), createElementBlock("div", mergeProps({ key: 0, class: [!unref(isStart) ? "lay-split-panel-line" : ""], ref: "el" }, toHandlers({ mousedown, mouseup }, true)), null, 16)) : createCommentVNode("", true), unref(isVertical) ? (openBlock(), createElementBlock("div", { key: 1, ref: "laySplitPanelItem", class: normalizeClass(["lay-split-panel-item"]), style: normalizeStyle({ flexBasis: `${__props.space}px`, flexGrow: __props.space ? 0 : 1 }) }, [ renderSlot(_ctx.$slots, "default") ], 4)) : (openBlock(), createElementBlock("div", { key: 2, class: normalizeClass(["lay-split-panel-item"]), style: normalizeStyle({ flexBasis: `${__props.space}px`, flexGrow: __props.space ? 0 : 1 }) }, [ renderSlot(_ctx.$slots, "default") ], 4)) ], 64); }; } }); const component = withInstall(_sfc_main); export { component as default };