diff --git a/app/src/components/globals/formItems/FileItem.vue b/app/src/components/globals/formItems/FileItem.vue index c4ce4c9b..61c96f71 100644 --- a/app/src/components/globals/formItems/FileItem.vue +++ b/app/src/components/globals/formItems/FileItem.vue @@ -2,46 +2,39 @@ import type { BFormFile } from 'bootstrap-vue-next' import { computed, inject, ref } from 'vue' +import { ValidationTouchSymbol } from '@/composables/form' import { getFileContent } from '@/helpers/commons' - -type CustomFile = { - file: File | null - content?: string | null - current?: boolean - removed?: boolean -} +import type { + BaseItemComputedProps, + FileItemProps, + FileModelValue, +} from '@/types/form' const props = withDefaults( - defineProps<{ - id?: string - modelValue?: CustomFile - placeholder?: string - dropPlaceholder?: string - accept?: string - state?: string - required?: boolean - name?: string - }>(), + defineProps>(), { id: undefined, - modelValue: () => ({ file: null }), - placeholder: 'Choose a file or drop it here...', - dropPlaceholder: undefined, - accept: '', - state: undefined, - required: false, name: undefined, + placeholder: 'Choose a file or drop it here...', + touchKey: undefined, + accept: '', + dropPlaceholder: undefined, + + ariaDescribedby: undefined, + modelValue: () => ({ file: null }), + state: undefined, + validation: undefined, }, ) const emit = defineEmits<{ - 'update:modelValue': [value: CustomFile] + 'update:modelValue': [value: FileModelValue] }>() -const touch = inject('touch') +const touch = inject(ValidationTouchSymbol) const inputElem = ref | null>(null) -const _placeholder = computed(() => { +const placeholder = computed(() => { return props.modelValue.file === null ? props.placeholder : props.modelValue.file.name @@ -72,34 +65,34 @@ function clearFiles() { removed: true, }) } + +const required = computed(() => 'required' in (props.validation ?? {}))