import { CocoComponent } from "@js/coco"; export default CocoComponent("appSeamlessTextarea", () => { return { height: null, observer: null, value: null, options: ["multiline", "focus"], init() { this.value = this.$refs.textarea.value; this.$nextTick(() => { this.onResize(); if (this.$options.focus) { this.$refs.textarea.focus(); this.$refs.textarea.selectionStart = this.$refs.textarea.value.length; } }); }, onResize() { const textarea = this.$refs.textarea; if (textarea) { textarea.style.height = "4px"; const newHeight = textarea.scrollHeight; textarea.style.height = `${newHeight}px`; if (this.height !== newHeight) { this.height = newHeight; } } }, }; });