// static/js/components/ChatInput.js export const ChatInput = { name: 'ChatInput', props: { currentMessage: { type: String, default: '' }, isLoading: { type: Boolean, default: false }, placeholder: { type: String, default: 'Typ je bericht hier... (Enter om te verzenden, Shift+Enter voor nieuwe regel)' }, maxLength: { type: Number, default: 2000 }, }, emits: ['send-message', 'update-message'], data() { return { localMessage: this.currentMessage, }; }, computed: { characterCount() { return this.localMessage.length; }, isOverLimit() { return this.characterCount > this.maxLength; }, canSend() { return this.localMessage.trim() && !this.isLoading && !this.isOverLimit; } }, watch: { currentMessage(newVal) { this.localMessage = newVal; }, localMessage(newVal) { this.$emit('update-message', newVal); this.autoResize(); } }, mounted() { this.autoResize(); }, methods: { handleKeydown(event) { if (event.key === 'Enter' && !event.shiftKey) { event.preventDefault(); this.sendMessage(); } else if (event.key === 'Escape') { this.localMessage = ''; } }, sendMessage() { if (this.canSend) { this.$emit('send-message'); } }, autoResize() { this.$nextTick(() => { const textarea = this.$refs.messageInput; if (textarea) { textarea.style.height = 'auto'; textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px'; } }); }, focusInput() { this.$refs.messageInput?.focus(); }, clearInput() { this.localMessage = ''; this.focusInput(); } }, template: `