vuetify
Version:
Vue Material Component Framework
50 lines • 1.72 kB
JavaScript
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
// Composables
import { makeComponentProps } from "../../composables/component.mjs";
import { useResizeObserver } from "../../composables/resizeObserver.mjs";
import { useToggleScope } from "../../composables/toggleScope.mjs"; // Utilities
import { onUpdated, watch } from 'vue';
import { genericComponent, propsFactory, useRender } from "../../util/index.mjs";
export const makeVVirtualScrollItemProps = propsFactory({
dynamicHeight: Boolean,
renderless: Boolean,
...makeComponentProps()
}, 'VVirtualScrollItem');
export const VVirtualScrollItem = genericComponent()({
name: 'VVirtualScrollItem',
props: makeVVirtualScrollItemProps(),
emits: {
'update:height': height => true
},
setup(props, _ref) {
let {
emit,
slots
} = _ref;
const {
resizeRef,
contentRect
} = useResizeObserver();
useToggleScope(() => props.dynamicHeight, () => {
watch(() => contentRect.value?.height, height => {
if (height != null) emit('update:height', height);
});
});
function updateHeight() {
if (props.dynamicHeight && contentRect.value) {
emit('update:height', contentRect.value.height);
}
}
onUpdated(updateHeight);
useRender(() => props.renderless ? _createVNode(_Fragment, null, [slots.default?.({
props: {
ref: props.dynamicHeight ? resizeRef : undefined
}
})]) : _createVNode("div", {
"ref": props.dynamicHeight ? resizeRef : undefined,
"class": ['v-virtual-scroll__item', props.class],
"style": props.style
}, [slots.default?.()]));
}
});
//# sourceMappingURL=VVirtualScrollItem.mjs.map