@ctsy/layui-vue
Version:
a component library for Vue 3 base on layui-vue
96 lines (95 loc) • 3.8 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__), {
props: {
space: { default: 0 }
},
setup(__props) {
const index = ref(-1);
const parents = inject("laySplitPanel");
const currentInstance = getCurrentInstance();
const moveStatus = ref(false);
const setIndex = (val) => {
index.value = val;
};
const mousedown = (event) => {
moveStatus.value = true;
parents.moveChange(event, true);
};
const mouseup = (event) => {
moveStatus.value = false;
};
const stepsCount = computed(() => {
return parents.steps.value.length;
});
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,
width: []
});
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 })), null, 16)) : createCommentVNode("", true),
unref(isVertical) ? (openBlock(), createElementBlock("div", {
key: 1,
class: normalizeClass(["lay-split-panel-item"]),
style: normalizeStyle({ height: `${__props.space ? __props.space : (100 + __props.space) / unref(stepsCount)}%` })
}, [
renderSlot(_ctx.$slots, "default")
], 4)) : (openBlock(), createElementBlock("div", {
key: 2,
class: normalizeClass(["lay-split-panel-item"]),
style: normalizeStyle({ width: `${__props.space ? __props.space : (100 + __props.space) / unref(stepsCount)}%` })
}, [
renderSlot(_ctx.$slots, "default")
], 4))
], 64);
};
}
}));
_sfc_main.install = (app) => {
app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };