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>
|
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, watch, withDefaults } from 'vue'
|
2021-09-28 12:39:12 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
interface Props {
|
|
|
|
name: string
|
|
|
|
charLimit?: number
|
|
|
|
disabled?: boolean
|
2022-09-18 15:23:24 +02:00
|
|
|
input?: string | null
|
2021-11-10 21:19:27 +01:00
|
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
charLimit: 500,
|
|
|
|
disabled: false,
|
|
|
|
input: '',
|
|
|
|
})
|
2021-09-28 12:39:12 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
const emit = defineEmits(['updateValue'])
|
2021-09-28 12:39:12 +02:00
|
|
|
|
2022-06-22 17:53:59 +02:00
|
|
|
const text = ref('')
|
2021-09-28 12:39:12 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
function updateText(event: Event & { target: HTMLInputElement }) {
|
|
|
|
emit('updateValue', event.target.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.input,
|
|
|
|
(value) => {
|
2022-09-18 15:23:24 +02:00
|
|
|
text.value = value === null ? '' : value
|
2021-11-10 21:19:27 +01:00
|
|
|
}
|
|
|
|
)
|
2021-09-28 12:39:12 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.custom-textarea {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
.remaining-chars {
|
|
|
|
font-size: 0.8em;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|