2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2024-02-11 23:48:42 +00:00
|
|
|
<textarea :class="cx('root')" :value="modelValue" @input="onInput" v-bind="ptmi('root', ptmParams)"></textarea>
|
2022-09-06 12:03:37 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-24 14:15:21 +00:00
|
|
|
import BaseTextarea from './BaseTextarea.vue';
|
2023-05-07 06:29:10 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'Textarea',
|
2023-05-24 14:15:21 +00:00
|
|
|
extends: BaseTextarea,
|
2024-02-11 23:48:42 +00:00
|
|
|
inheritAttrs: false,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['update:modelValue'],
|
|
|
|
mounted() {
|
|
|
|
if (this.$el.offsetParent && this.autoResize) {
|
|
|
|
this.resize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
updated() {
|
|
|
|
if (this.$el.offsetParent && this.autoResize) {
|
|
|
|
this.resize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
resize() {
|
|
|
|
this.$el.style.height = 'auto';
|
2023-09-13 12:44:57 +00:00
|
|
|
this.$el.style.height = this.$el.scrollHeight + 'px';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
if (parseFloat(this.$el.style.height) >= parseFloat(this.$el.style.maxHeight)) {
|
2022-09-14 11:26:01 +00:00
|
|
|
this.$el.style.overflowY = 'scroll';
|
2022-09-06 12:03:37 +00:00
|
|
|
this.$el.style.height = this.$el.style.maxHeight;
|
2022-09-14 11:26:01 +00:00
|
|
|
} else {
|
|
|
|
this.$el.style.overflow = 'hidden';
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onInput(event) {
|
|
|
|
if (this.autoResize) {
|
|
|
|
this.resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('update:modelValue', event.target.value);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
filled() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return this.modelValue != null && this.modelValue.toString().length > 0;
|
2023-07-13 12:42:30 +00:00
|
|
|
},
|
|
|
|
ptmParams() {
|
|
|
|
return {
|
|
|
|
context: {
|
|
|
|
disabled: this.$attrs.disabled || this.$attrs.disabled === ''
|
|
|
|
}
|
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|