@ark-ui/vue
Version:
A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.
28 lines (25 loc) • 1.2 kB
JavaScript
import { defineComponent, ref, watchEffect, createBlock, createCommentVNode, openBlock, unref, normalizeProps, mergeProps } from 'vue';
import { ark } from '../factory.js';
import { useFileUploadContext } from './use-file-upload-context.js';
import { useFileUploadItemPropsContext } from './use-file-upload-item-props-context.js';
import { useForwardExpose } from '../../utils/use-forward-expose.js';
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "file-upload-item-preview-image",
props: {
asChild: { type: Boolean }
},
setup(__props) {
const fileUpload = useFileUploadContext();
const itemProps = useFileUploadItemPropsContext();
const url = ref("");
watchEffect((onCleanup) => {
const cleanup = fileUpload.value.createFileUrl(itemProps.value.file, (src) => url.value = src);
onCleanup(cleanup);
});
useForwardExpose();
return (_ctx, _cache) => {
return url.value ? (openBlock(), createBlock(unref(ark).img, normalizeProps(mergeProps({ key: 0 }, unref(fileUpload).getItemPreviewImageProps({ ...unref(itemProps), url: url.value }))), null, 16)) : createCommentVNode("", true);
};
}
});
export { _sfc_main as default };