From 77eb2bd9cadbb306e66876237468a53690aac4ae Mon Sep 17 00:00:00 2001 From: John Leider Date: Mon, 29 Apr 2024 21:01:38 -0500 Subject: [PATCH] feat(VFileUpload): hook up disabled and clearable functionality --- .../src/labs/VFileUpload/VFileUpload.sass | 4 ++ .../src/labs/VFileUpload/VFileUpload.tsx | 10 +++- .../src/labs/VFileUpload/VFileUploadItem.tsx | 49 ++++++++++--------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/packages/vuetify/src/labs/VFileUpload/VFileUpload.sass b/packages/vuetify/src/labs/VFileUpload/VFileUpload.sass index fda6057451d..1dec64f3ee4 100644 --- a/packages/vuetify/src/labs/VFileUpload/VFileUpload.sass +++ b/packages/vuetify/src/labs/VFileUpload/VFileUpload.sass @@ -24,6 +24,10 @@ .v-overlay__scrim pointer-events: none + &--disabled + pointer-events: none + opacity: var(--v-disabled-opacity) + &--dragging > * pointer-events: none diff --git a/packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx b/packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx index 1a932dca1c8..a48a79b21cc 100644 --- a/packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx +++ b/packages/vuetify/src/labs/VFileUpload/VFileUpload.tsx @@ -66,6 +66,7 @@ export const makeVFileUploadProps = propsFactory({ return wrapInArray(val).every(v => v != null && typeof v === 'object') }, }, + clearable: Boolean, disabled: Boolean, hideBrowse: Boolean, multiple: Boolean, @@ -203,6 +204,7 @@ export const VFileUpload = genericComponent()({ 'v-file-upload', { 'v-file-upload--clickable': !hasBrowse, + 'v-file-upload--disabled': props.disabled, 'v-file-upload--dragging': dragOver.value, }, densityClasses.value, @@ -255,18 +257,20 @@ export const VFileUpload = genericComponent()({ <> { !slots.browse ? ( ) : ( @@ -309,6 +313,8 @@ export const VFileUpload = genericComponent()({ defaults={{ VFileUploadItem: { file, + clearable: props.clearable, + disabled: props.disabled, showSize: props.showSize, }, }} diff --git a/packages/vuetify/src/labs/VFileUpload/VFileUploadItem.tsx b/packages/vuetify/src/labs/VFileUpload/VFileUploadItem.tsx index dfd3b3ef683..24e5ea5ca30 100644 --- a/packages/vuetify/src/labs/VFileUpload/VFileUploadItem.tsx +++ b/packages/vuetify/src/labs/VFileUpload/VFileUploadItem.tsx @@ -19,6 +19,7 @@ export type VFileUploadItemSlots = { } & VListItemSlots export const makeVFileUploadItemProps = propsFactory({ + clearable: Boolean, file: { type: Object as PropType, default: null, @@ -98,28 +99,32 @@ export const VFileUploadItem = genericComponent()({ ), append: slotProps => ( <> - { !slots.clear ? ( - - ) : ( - - { slots.clear?.({ - ...slotProps, - props: { onClick: onClickRemove }, - }) ?? ()} - + { props.clearable && ( + <> + { !slots.clear ? ( + + ) : ( + + { slots.clear?.({ + ...slotProps, + props: { onClick: onClickRemove }, + }) ?? ()} + + )} + )} { slots.append?.(slotProps) }