-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseTextarea.vue
46 lines (42 loc) · 1.09 KB
/
BaseTextarea.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
<template>
<!-- Base Textarea -->
<div>
<label class="label-style" :for="label" v-if="label">{{ label }}</label>
<textarea
name="textarea"
:id="label"
cols="30"
rows="10"
v-bind="$attrs"
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
class="input-style textarea-style"
:class="{ err: error }"
></textarea>
<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
label?: string
placeholder?: string
error?: string | boolean
errorMessage?: string | boolean
}
const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
</script>
<style lang="scss" scoped></style>