/** * @license * Copyright (c) 2021 - 2026 Vaadin Ltd. * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ */ import '@vaadin/text-area/src/vaadin-text-area.js'; import './vaadin-message-input-button.js'; import { html, LitElement } from 'lit'; import { defineCustomElement } from '@vaadin/component-base/src/define.js'; import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js'; import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js'; import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; import { messageInputStyles } from './styles/vaadin-message-input-base-styles.js'; import { MessageInputMixin } from './vaadin-message-input-mixin.js'; /** * `` is a Web Component for sending messages. * It consists of a text area that grows on along with the content, and a send button to send message. * * The message can be sent by one of the following actions: * - by pressing Enter (use Shift + Enter to add a new line) * - by clicking `submit` button. * * ```html * * ``` * * ### Slots * * The following slots are available for adding content to the message input: * * Name | Description * -----------|------------- * `header` | Content displayed above the text area and controls * `prefix` | Content displayed before the text area * `button` | Button that submits the message, replacing the default one * `footer` | Content displayed below the text area and controls * * When a custom button has no text content or accessible label, `aria-label` attribute * is set based on the [`i18n`](#/elements/vaadin-message-input#property-i18n) property. * * ### Styling * * The following state attributes are available for styling: * * Attribute | Description * ---------------|--------------------------------- * `disabled` | Set when the element is disabled * `focused` | Set when the text area is focused * `focus-ring` | Set when the text area is focused using the keyboard * `has-header` | Set when the element has content in the header slot * `has-prefix` | Set when the element has content in the prefix slot * `has-footer` | Set when the element has content in the footer slot * `has-tooltip` | Set when the element has a slotted tooltip * * ### Internal components * * In addition to `` itself, the following internal * components are themable: * * - `` - has the same API as `` * - `` * * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation. * * @fires {CustomEvent} submit - Fired when a new message is submitted, either by clicking the "send" button, or pressing the Enter key. * * @attr {string} theme - The theme variants to apply to the component. * @customElement vaadin-message-input * @extends HTMLElement */ class MessageInput extends MessageInputMixin( ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement)))), ) { static get is() { return 'vaadin-message-input'; } static get styles() { return messageInputStyles; } /** @protected */ render() { return html` `; } } defineCustomElement(MessageInput); export { MessageInput };