2021-09-28 12:39:12 +02:00
|
|
|
<template>
|
|
|
|
<div class="custom-textarea">
|
|
|
|
<textarea
|
|
|
|
:id="name"
|
|
|
|
:name="name"
|
|
|
|
:maxLenght="charLimit"
|
2021-09-29 11:32:05 +02:00
|
|
|
:disabled="disabled"
|
2021-09-28 12:39:12 +02:00
|
|
|
v-model="text"
|
|
|
|
@input="updateText"
|
|
|
|
/>
|
|
|
|
<div class="remaining-chars">
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ $t('workouts.REMAINING_CHARS') }}: {{ text.length }}/{{ charLimit }}
|
2021-09-28 12:39:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, ref, watch } from 'vue'
|
|
|
|
|
|
|
|
export default defineComponent({
|
2021-10-23 15:29:39 +02:00
|
|
|
name: 'CustomTextArea',
|
2021-09-28 12:39:12 +02:00
|
|
|
props: {
|
|
|
|
charLimit: {
|
|
|
|
type: Number,
|
|
|
|
default: 500,
|
|
|
|
},
|
2021-09-29 11:32:05 +02:00
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-09-28 12:39:12 +02:00
|
|
|
input: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
emits: ['updateValue'],
|
|
|
|
setup(props, { emit }) {
|
|
|
|
let text = ref('')
|
|
|
|
|
|
|
|
function updateText(event: Event & { target: HTMLInputElement }) {
|
|
|
|
emit('updateValue', event.target.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.input,
|
|
|
|
(value) => {
|
|
|
|
text.value = value
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-10-20 17:38:25 +02:00
|
|
|
return { text, updateText }
|
2021-09-28 12:39:12 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~@/scss/base.scss';
|
|
|
|
.custom-textarea {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
.remaining-chars {
|
|
|
|
font-size: 0.8em;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|