Files
routie/frontend/node_modules/.vite/deps/VImg-DaEUT7gG.js
T

363 lines
12 KiB
JavaScript

import { At as onBeforeMount, C as vShow, Cn as withDirectives, Dt as mergeProps, Kn as ref, M as Fragment, Ot as nextTick, Qn as toRef, U as computed, W as createBaseVNode, Yn as shallowRef, ar as normalizeClass, et as createVNode, gn as watch, jt as onBeforeUnmount, sr as normalizeStyle } from "./vue.runtime.esm-bundler-BvoXUmaf.js";
import { _ as convertToUnit, et as SUPPORTS_INTERSECTION, l as propsFactory, n as genericComponent, s as getCurrentInstance, w as filterInputAttrs } from "./defineComponent-DB6xIcDy.js";
import { t as makeComponentProps } from "./component-DdiwBe6i.js";
import { t as useRender } from "./useRender-fVtVsZgv.js";
import { t as useBackgroundColor } from "./color-B6vuQruj.js";
import { n as useDimension, t as makeDimensionProps } from "./dimensions-BDdmuRdK.js";
import { n as useRounded, t as makeRoundedProps } from "./rounded-BuPGKRa9.js";
import { n as makeTransitionProps, t as MaybeTransition } from "./transition-DqoZ8fA1.js";
import "/Users/thackmaster/Development/routie2/frontend/node_modules/vuetify/lib/components/VImg/VImg.css";
import "/Users/thackmaster/Development/routie2/frontend/node_modules/vuetify/lib/components/VResponsive/VResponsive.css";
//#region node_modules/vuetify/lib/components/VResponsive/VResponsive.js
function useAspectStyles(props) {
return { aspectStyles: computed(() => {
const ratio = Number(props.aspectRatio);
return ratio ? { paddingBottom: String(1 / ratio * 100) + "%" } : void 0;
}) };
}
var makeVResponsiveProps = propsFactory({
aspectRatio: [String, Number],
contentClass: null,
inline: Boolean,
...makeComponentProps(),
...makeDimensionProps()
}, "VResponsive");
var VResponsive = genericComponent()({
name: "VResponsive",
props: makeVResponsiveProps(),
setup(props, { slots }) {
const { aspectStyles } = useAspectStyles(props);
const { dimensionStyles } = useDimension(props);
useRender(() => createBaseVNode("div", {
"class": normalizeClass([
"v-responsive",
{ "v-responsive--inline": props.inline },
props.class
]),
"style": normalizeStyle([dimensionStyles.value, props.style])
}, [
createBaseVNode("div", {
"class": "v-responsive__sizer",
"style": normalizeStyle(aspectStyles.value)
}, null),
slots.additional?.(),
slots.default && createBaseVNode("div", { "class": normalizeClass(["v-responsive__content", props.contentClass]) }, [slots.default()])
]));
return {};
}
});
//#endregion
//#region node_modules/vuetify/lib/directives/intersect/index.js
function mounted(el, binding) {
if (!SUPPORTS_INTERSECTION) return;
const modifiers = binding.modifiers || {};
const value = binding.value;
const { handler, options } = typeof value === "object" ? value : {
handler: value,
options: {}
};
const observer = new IntersectionObserver((entries = [], observer) => {
const _observe = el._observe?.[binding.instance.$.uid];
if (!_observe) return;
const isIntersecting = entries.some((entry) => entry.isIntersecting);
if (handler && (!modifiers.quiet || _observe.init) && (!modifiers.once || isIntersecting || _observe.init)) handler(isIntersecting, entries, observer);
if (isIntersecting && modifiers.once) unmounted(el, binding);
else _observe.init = true;
}, options);
el._observe = Object(el._observe);
el._observe[binding.instance.$.uid] = {
init: false,
observer
};
observer.observe(el);
}
function unmounted(el, binding) {
const observe = el._observe?.[binding.instance.$.uid];
if (!observe) return;
observe.observer.unobserve(el);
delete el._observe[binding.instance.$.uid];
}
var Intersect = {
mounted,
unmounted,
updated: (el, binding) => {
if (el._observe?.[binding.instance.$.uid]) {
unmounted(el, binding);
mounted(el, binding);
}
}
};
//#endregion
//#region node_modules/vuetify/lib/components/VImg/VImg.js
var makeVImgProps = propsFactory({
absolute: Boolean,
alt: String,
cover: Boolean,
color: String,
draggable: {
type: [Boolean, String],
default: void 0
},
eager: Boolean,
gradient: String,
imageClass: null,
lazySrc: String,
options: {
type: Object,
default: () => ({
root: void 0,
rootMargin: void 0,
threshold: void 0
})
},
sizes: String,
src: {
type: [String, Object],
default: ""
},
crossorigin: String,
referrerpolicy: String,
srcset: String,
position: String,
...makeVResponsiveProps(),
...makeComponentProps(),
...makeRoundedProps(),
...makeTransitionProps()
}, "VImg");
var VImg = genericComponent()({
name: "VImg",
directives: { vIntersect: Intersect },
inheritAttrs: false,
props: makeVImgProps(),
emits: {
loadstart: (value) => true,
load: (value) => true,
error: (value) => true
},
setup(props, { attrs, emit, slots }) {
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(() => props.color);
const { roundedClasses } = useRounded(props);
const vm = getCurrentInstance("VImg");
const currentSrc = shallowRef("");
const image = ref();
const state = shallowRef(props.eager ? "loading" : "idle");
const naturalWidth = shallowRef();
const naturalHeight = shallowRef();
const normalisedSrc = computed(() => {
return props.src && typeof props.src === "object" ? {
src: props.src.src,
srcset: props.srcset || props.src.srcset,
lazySrc: props.lazySrc || props.src.lazySrc,
aspect: Number(props.aspectRatio || props.src.aspect || 0)
} : {
src: props.src,
srcset: props.srcset,
lazySrc: props.lazySrc,
aspect: Number(props.aspectRatio || 0)
};
});
const aspectRatio = computed(() => {
return normalisedSrc.value.aspect || naturalWidth.value / naturalHeight.value || 0;
});
watch(() => props.src, () => {
init(state.value !== "idle");
});
watch(aspectRatio, (val, oldVal) => {
if (!val && oldVal && image.value) pollForSize(image.value);
});
onBeforeMount(() => init());
function init(isIntersecting) {
if (props.eager && isIntersecting) return;
if (SUPPORTS_INTERSECTION && !isIntersecting && !props.eager) return;
state.value = "loading";
if (normalisedSrc.value.lazySrc) {
const lazyImg = new Image();
lazyImg.src = normalisedSrc.value.lazySrc;
pollForSize(lazyImg, null);
}
if (!normalisedSrc.value.src) return;
nextTick(() => {
emit("loadstart", image.value?.currentSrc || normalisedSrc.value.src);
setTimeout(() => {
if (vm.isUnmounted) return;
if (image.value?.complete) {
if (!image.value.naturalWidth) onError();
if (state.value === "error") return;
if (!aspectRatio.value) pollForSize(image.value, null);
if (state.value === "loading") onLoad();
} else {
if (!aspectRatio.value) pollForSize(image.value);
getSrc();
}
});
});
}
function onLoad() {
if (vm.isUnmounted) return;
getSrc();
pollForSize(image.value);
state.value = "loaded";
emit("load", image.value?.currentSrc || normalisedSrc.value.src);
}
function onError() {
if (vm.isUnmounted) return;
state.value = "error";
emit("error", image.value?.currentSrc || normalisedSrc.value.src);
}
function getSrc() {
const img = image.value;
if (img) currentSrc.value = img.currentSrc || img.src;
}
let timer = -1;
onBeforeUnmount(() => {
clearTimeout(timer);
});
function pollForSize(img, timeout = 100) {
const poll = () => {
clearTimeout(timer);
if (vm.isUnmounted) return;
const { naturalHeight: imgHeight, naturalWidth: imgWidth } = img;
if (imgHeight || imgWidth) {
naturalWidth.value = imgWidth;
naturalHeight.value = imgHeight;
} else if (!img.complete && state.value === "loading" && timeout != null) timer = window.setTimeout(poll, timeout);
else if (img.currentSrc.endsWith(".svg") || img.currentSrc.startsWith("data:image/svg+xml")) {
naturalWidth.value = 1;
naturalHeight.value = 1;
}
};
poll();
}
const containClasses = toRef(() => ({
"v-img__img--cover": props.cover,
"v-img__img--contain": !props.cover
}));
const __image = () => {
if (!normalisedSrc.value.src || state.value === "idle") return null;
const img = createBaseVNode("img", {
"class": normalizeClass([
"v-img__img",
containClasses.value,
props.imageClass
]),
"style": { objectPosition: props.position },
"crossorigin": props.crossorigin,
"src": normalisedSrc.value.src,
"srcset": normalisedSrc.value.srcset,
"alt": props.alt,
"referrerpolicy": props.referrerpolicy,
"draggable": props.draggable,
"sizes": props.sizes,
"ref": image,
"onLoad": onLoad,
"onError": onError
}, null);
const sources = slots.sources?.();
return createVNode(MaybeTransition, {
"transition": props.transition,
"appear": true
}, { default: () => [withDirectives(sources ? createBaseVNode("picture", { "class": "v-img__picture" }, [sources, img]) : img, [[vShow, state.value === "loaded"]])] });
};
const __preloadImage = () => createVNode(MaybeTransition, { "transition": props.transition }, { default: () => [normalisedSrc.value.lazySrc && state.value !== "loaded" && createBaseVNode("img", {
"class": normalizeClass([
"v-img__img",
"v-img__img--preload",
containClasses.value
]),
"style": { objectPosition: props.position },
"crossorigin": props.crossorigin,
"src": normalisedSrc.value.lazySrc,
"alt": props.alt,
"referrerpolicy": props.referrerpolicy,
"draggable": props.draggable
}, null)] });
const __placeholder = () => {
if (!slots.placeholder) return null;
return createVNode(MaybeTransition, {
"transition": props.transition,
"appear": true
}, { default: () => [(state.value === "loading" || state.value === "error" && !slots.error) && createBaseVNode("div", { "class": "v-img__placeholder" }, [slots.placeholder()])] });
};
const __error = () => {
if (!slots.error) return null;
return createVNode(MaybeTransition, {
"transition": props.transition,
"appear": true
}, { default: () => [state.value === "error" && createBaseVNode("div", { "class": "v-img__error" }, [slots.error()])] });
};
const __gradient = () => {
if (!props.gradient) return null;
return createBaseVNode("div", {
"class": "v-img__gradient",
"style": { backgroundImage: `linear-gradient(${props.gradient})` }
}, null);
};
const isBooted = shallowRef(false);
{
const stop = watch(aspectRatio, (val) => {
if (val) {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
isBooted.value = true;
});
});
stop();
}
});
}
useRender(() => {
const responsiveProps = VResponsive.filterProps(props);
const [rootAttrs, imageAttrs] = filterInputAttrs(attrs);
return withDirectives(createVNode(VResponsive, mergeProps({
"class": [
"v-img",
{
"v-img--absolute": props.absolute,
"v-img--booting": !isBooted.value,
"v-img--fit-content": props.width === "fit-content"
},
backgroundColorClasses.value,
roundedClasses.value,
props.class
],
"style": [
{ width: convertToUnit(props.width === "auto" ? naturalWidth.value : props.width) },
backgroundColorStyles.value,
props.style
]
}, responsiveProps, rootAttrs, {
"aspectRatio": aspectRatio.value,
"aria-label": props.alt,
"role": props.alt ? "img" : void 0
}), {
additional: () => createBaseVNode(Fragment, null, [
createVNode(__image, imageAttrs, null),
createVNode(__preloadImage, null, null),
createVNode(__gradient, null, null),
createVNode(__placeholder, null, null),
createVNode(__error, null, null)
]),
default: slots.default
}), [[
Intersect,
{
handler: init,
options: props.options
},
null,
{ once: true }
]]);
});
return {
currentSrc,
image,
state,
naturalWidth,
naturalHeight
};
}
});
//#endregion
export { Intersect as n, VImg as t };
//# sourceMappingURL=VImg-DaEUT7gG.js.map