generated from blade-01/vueboost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseFile.vue
52 lines (49 loc) · 1.26 KB
/
BaseFile.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
<!-- Base File -->
<div>
<label class="label-style" :for="label" v-if="label">{{ label }}</label>
<input
:id="label"
type="file"
:multiple="multiple"
:placeholder="placeholder"
v-bind="{
...$attrs,
onChange: ($event) => {
$emit('update:modelValue', multiple ? ($event.target as HTMLFormElement).files : ($event.target as HTMLFormElement).files[0])
}
}"
class="input-style"
:class="{ err: error }"
:accept="fileType"
/>
<small
:class="{ 'err-message': error }"
v-if="error && errorMessage"
aria-live="assertive"
:id="`${label}-error`"
>{{ errorMessage }}</small
>
<small
:class="{ 'err-message': error }"
v-else-if="error && !errorMessage"
aria-live="assertive"
:id="`${label}-error`"
>{{ label }} is required</small
>
</div>
</template>
<script setup lang="ts">
interface Props {
modelValue: string | number | object
fileType: string
label?: string
placeholder?: string
error?: string | boolean
errorMessage?: string | boolean
multiple?: boolean
}
const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
</script>
<style lang="scss" scoped></style>