@opensig/opendesign
Version:
49 lines (48 loc) • 1.3 kB
JavaScript
import { defineComponent, ref, computed, createElementBlock, openBlock, normalizeStyle, renderSlot } from "vue";
import { useResizeObserver } from "@vueuse/core";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "VirtualListItem",
props: {
index: {},
mainSize: {},
layout: {},
observeResize: { type: Boolean }
},
emits: ["resize"],
setup(__props, { emit: __emit }) {
const props = __props;
const emits = __emit;
const itemRef = ref();
const itemStyle = computed(() => {
if (props.mainSize == null) {
return void 0;
}
const sizeProp = props.layout === "horizontal" ? "width" : "height";
return { [sizeProp]: `${props.mainSize}px` };
});
useResizeObserver(itemRef, (entries) => {
if (props.observeResize && entries[0]) {
emits("resize", entries[0], props.index);
}
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock(
"div",
{
ref_key: "itemRef",
ref: itemRef,
style: normalizeStyle(itemStyle.value),
class: "o-virtual-render-item"
},
[
renderSlot(_ctx.$slots, "default")
],
4
/* STYLE */
);
};
}
});
export {
_sfc_main as default
};