GitHub

Original file line numberDiff line numberDiff line change

@@ -93,6 +93,11 @@ export interface FileUploadProps<M extends boolean = false> extends /** @vue-ign

9393

* @IconifyIcon

9494

*/

9595

fileDeleteIcon?: IconProps['name']

96+

/**

97+

* Show the file preview/list after upload.

98+

* @defaultValue true

99+

*/

100+

preview?: boolean

96101

class?: any

97102

ui?: FileUpload['slots']

98103

}

@@ -146,7 +151,8 @@ const props = withDefaults(defineProps<FileUploadProps<M>>(), {

146151

interactive: true,

147152

fileDelete: true,

148153

layout: 'grid',

149-

position: 'outside'

154+

position: 'outside',

155+

preview: true

150156

})

151157

const emits = defineEmits<FileUploadEmits>()

152158

const slots = defineSlots<FileUploadSlots<M>>()

@@ -268,7 +274,7 @@ defineExpose({

268274
269275

<template>

270276

<DefineFilesTemplate>

271-

<template v-if="modelValue && (Array.isArray(modelValue) ? modelValue.length : true)">

277+

<template v-if="props.preview && modelValue && (Array.isArray(modelValue) ? modelValue.length : true)">

272278

<slot name="files-top" :files="modelValue" :open="open" :remove-file="removeFile" />

273279
274280

<div :class="ui.files({ class: props.ui?.files })">

Original file line numberDiff line numberDiff line change

@@ -63,6 +63,7 @@ describe('FileUpload', () => {

6363

['with multiple', { props: { ...props, multiple: true } }],

6464

['without dropzone', { props: { dropzone: false } }],

6565

['without interactive', { props: { interactive: false } }],

66+

['without preview', { props: { ...props, preview: false } }],

6667

['with required', { props: { required: true } }],

6768

['with disabled', { props: { disabled: true } }],

6869

['with fileIcon', { props: { ...props, fileIcon: 'i-lucide-house' } }],

Original file line numberDiff line numberDiff line change

@@ -960,3 +960,17 @@ exports[`FileUpload > renders without interactive correctly 1`] = `

960960

<!--v-if--><input data-hidden="" tabindex="-1" style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; word-wrap: normal; top: -1px; left: -1px;" type="file" accept="*">

961961

</div>"

962962

`;

963+
964+

exports[`FileUpload > renders without preview correctly 1`] = `

965+

"<div class="relative flex flex-col">

966+

<div role="button" data-dragging="false" class="w-full flex-1 bg-default border border-default flex flex-col gap-2 items-stretch justify-center rounded-lg focus-visible:outline-2 transition-[background] p-4 text-sm border-dashed data-[dragging=true]:bg-elevated/25 focus-visible:outline-primary hover:bg-elevated/25" tabindex="0">

967+

<!--v-if-->

968+

<div class="flex flex-col items-center justify-center text-center px-4 py-3"><span class="inline-flex items-center justify-center select-none rounded-full align-middle bg-elevated size-8 text-base shrink-0"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 16 16" class="text-muted shrink-0"></svg></span>

969+

<!--v-if-->

970+

<!--v-if-->

971+

<!--v-if-->

972+

</div>

973+

</div>

974+

<!--v-if--><input data-hidden="" tabindex="-1" style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; word-wrap: normal; top: -1px; left: -1px;" type="file" accept="*">

975+

</div>"

976+

`;

Original file line numberDiff line numberDiff line change

@@ -960,3 +960,17 @@ exports[`FileUpload > renders without interactive correctly 1`] = `

960960

<!--v-if--><input data-hidden="" tabindex="-1" style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; word-wrap: normal; top: -1px; left: -1px;" type="file" accept="*">

961961

</div>"

962962

`;

963+
964+

exports[`FileUpload > renders without preview correctly 1`] = `

965+

"<div class="relative flex flex-col">

966+

<div role="button" data-dragging="false" class="w-full flex-1 bg-default border border-default flex flex-col gap-2 items-stretch justify-center rounded-lg focus-visible:outline-2 transition-[background] p-4 text-sm border-dashed data-[dragging=true]:bg-elevated/25 focus-visible:outline-primary hover:bg-elevated/25" tabindex="0">

967+

<!--v-if-->

968+

<div class="flex flex-col items-center justify-center text-center px-4 py-3"><span class="inline-flex items-center justify-center select-none rounded-full align-middle bg-elevated size-8 text-base shrink-0"><span class="iconify i-lucide:upload text-muted shrink-0" aria-hidden="true"></span></span>

969+

<!--v-if-->

970+

<!--v-if-->

971+

<!--v-if-->

972+

</div>

973+

</div>

974+

<!--v-if--><input data-hidden="" tabindex="-1" style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; word-wrap: normal; top: -1px; left: -1px;" type="file" accept="*">

975+

</div>"

976+

`;

Read the original on github.com ↗