@vaadin/message-input 25.3.0-dev.3a3c2d7d2a → 25.3.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +41 -52
- package/package.json +11 -10
- package/src/button-controller.d.ts +18 -0
- package/src/button-controller.js +65 -0
- package/src/styles/vaadin-message-input-base-styles.js +37 -3
- package/src/styles/vaadin-message-input-button-styles.js +10 -5
- package/src/vaadin-message-input-button.js +2 -1
- package/src/vaadin-message-input-mixin.d.ts +5 -1
- package/src/vaadin-message-input-mixin.js +55 -10
- package/src/vaadin-message-input.d.ts +19 -0
- package/src/vaadin-message-input.js +26 -0
- package/web-types.json +3 -5
- package/web-types.lit.json +2 -2
package/custom-elements.json
CHANGED
|
@@ -36,15 +36,6 @@
|
|
|
36
36
|
"description": "Set to true to disable this element.",
|
|
37
37
|
"attribute": "disabled"
|
|
38
38
|
},
|
|
39
|
-
{
|
|
40
|
-
"kind": "method",
|
|
41
|
-
"name": "focus",
|
|
42
|
-
"parameters": [
|
|
43
|
-
{
|
|
44
|
-
"name": "options"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
39
|
{
|
|
49
40
|
"kind": "field",
|
|
50
41
|
"name": "i18n",
|
|
@@ -112,6 +103,10 @@
|
|
|
112
103
|
{
|
|
113
104
|
"name": "I18nMixin",
|
|
114
105
|
"package": "@vaadin/component-base/src/i18n-mixin.js"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "FocusMixin",
|
|
109
|
+
"package": "@vaadin/a11y-base/src/focus-mixin.js"
|
|
115
110
|
}
|
|
116
111
|
],
|
|
117
112
|
"parameters": [
|
|
@@ -138,7 +133,7 @@
|
|
|
138
133
|
"declarations": [
|
|
139
134
|
{
|
|
140
135
|
"kind": "class",
|
|
141
|
-
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
136
|
+
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Slots\n\nThe following slots are available for adding content to the message input:\n\nName | Description\n-----------|-------------\n`header` | Content displayed above the text area and controls\n`prefix` | Content displayed before the text area\n`button` | Button that submits the message, replacing the default one\n`footer` | Content displayed below the text area and controls\n\nWhen a custom button has no text content or accessible label, `aria-label` attribute\nis set based on the [`i18n`](#/elements/vaadin-message-input#property-i18n) property.\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`focused` | Set when the text area is focused\n`focus-ring` | Set when the text area is focused using the keyboard\n`has-header` | Set when the element has content in the header slot\n`has-prefix` | Set when the element has content in the prefix slot\n`has-footer` | Set when the element has content in the footer slot\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
142
137
|
"name": "MessageInput",
|
|
143
138
|
"members": [
|
|
144
139
|
{
|
|
@@ -155,19 +150,6 @@
|
|
|
155
150
|
"module": "src/vaadin-message-input-mixin.js"
|
|
156
151
|
}
|
|
157
152
|
},
|
|
158
|
-
{
|
|
159
|
-
"kind": "method",
|
|
160
|
-
"name": "focus",
|
|
161
|
-
"parameters": [
|
|
162
|
-
{
|
|
163
|
-
"name": "options"
|
|
164
|
-
}
|
|
165
|
-
],
|
|
166
|
-
"inheritedFrom": {
|
|
167
|
-
"name": "MessageInputMixin",
|
|
168
|
-
"module": "src/vaadin-message-input-mixin.js"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
153
|
{
|
|
172
154
|
"kind": "field",
|
|
173
155
|
"name": "i18n",
|
|
@@ -210,34 +192,6 @@
|
|
|
210
192
|
}
|
|
211
193
|
}
|
|
212
194
|
],
|
|
213
|
-
"mixins": [
|
|
214
|
-
{
|
|
215
|
-
"name": "MessageInputMixin",
|
|
216
|
-
"module": "src/vaadin-message-input-mixin.js"
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"name": "ElementMixin",
|
|
220
|
-
"package": "@vaadin/component-base/src/element-mixin.js"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"name": "ThemableMixin",
|
|
224
|
-
"package": "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js"
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"name": "PolylitMixin",
|
|
228
|
-
"package": "@vaadin/component-base/src/polylit-mixin.js"
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
"name": "LumoInjectionMixin",
|
|
232
|
-
"package": "@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js"
|
|
233
|
-
}
|
|
234
|
-
],
|
|
235
|
-
"superclass": {
|
|
236
|
-
"name": "LitElement",
|
|
237
|
-
"package": "lit"
|
|
238
|
-
},
|
|
239
|
-
"tagName": "vaadin-message-input",
|
|
240
|
-
"customElement": true,
|
|
241
195
|
"attributes": [
|
|
242
196
|
{
|
|
243
197
|
"name": "disabled",
|
|
@@ -263,6 +217,13 @@
|
|
|
263
217
|
"package": "@vaadin/component-base/src/i18n-mixin.js"
|
|
264
218
|
}
|
|
265
219
|
},
|
|
220
|
+
{
|
|
221
|
+
"type": {
|
|
222
|
+
"text": "string"
|
|
223
|
+
},
|
|
224
|
+
"description": "The theme variants to apply to the component.",
|
|
225
|
+
"name": "theme"
|
|
226
|
+
},
|
|
266
227
|
{
|
|
267
228
|
"name": "value",
|
|
268
229
|
"type": {
|
|
@@ -275,7 +236,35 @@
|
|
|
275
236
|
"module": "src/vaadin-message-input-mixin.js"
|
|
276
237
|
}
|
|
277
238
|
}
|
|
278
|
-
]
|
|
239
|
+
],
|
|
240
|
+
"mixins": [
|
|
241
|
+
{
|
|
242
|
+
"name": "MessageInputMixin",
|
|
243
|
+
"module": "src/vaadin-message-input-mixin.js"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "ElementMixin",
|
|
247
|
+
"package": "@vaadin/component-base/src/element-mixin.js"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"name": "ThemableMixin",
|
|
251
|
+
"package": "@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"name": "PolylitMixin",
|
|
255
|
+
"package": "@vaadin/component-base/src/polylit-mixin.js"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "LumoInjectionMixin",
|
|
259
|
+
"package": "@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"superclass": {
|
|
263
|
+
"name": "LitElement",
|
|
264
|
+
"package": "lit"
|
|
265
|
+
},
|
|
266
|
+
"tagName": "vaadin-message-input",
|
|
267
|
+
"customElement": true
|
|
279
268
|
}
|
|
280
269
|
],
|
|
281
270
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/message-input",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,18 +35,19 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/
|
|
39
|
-
"@vaadin/
|
|
40
|
-
"@vaadin/
|
|
41
|
-
"@vaadin/
|
|
38
|
+
"@vaadin/a11y-base": "25.3.0-rc1",
|
|
39
|
+
"@vaadin/button": "25.3.0-rc1",
|
|
40
|
+
"@vaadin/component-base": "25.3.0-rc1",
|
|
41
|
+
"@vaadin/text-area": "25.3.0-rc1",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-rc1",
|
|
42
43
|
"lit": "^3.0.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@vaadin/aura": "25.3.0-
|
|
46
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
47
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
46
|
+
"@vaadin/aura": "25.3.0-rc1",
|
|
47
|
+
"@vaadin/chai-plugins": "25.3.0-rc1",
|
|
48
|
+
"@vaadin/test-runner-commands": "25.3.0-rc1",
|
|
48
49
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
49
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-rc1",
|
|
50
51
|
"sinon": "^22.0.0"
|
|
51
52
|
},
|
|
52
53
|
"customElements": "custom-elements.json",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"web-types.json",
|
|
55
56
|
"web-types.lit.json"
|
|
56
57
|
],
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "d4809590b2f61bd607e376ab3dec84f4bfb059a7"
|
|
58
59
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A controller to manage the send button element.
|
|
10
|
+
*/
|
|
11
|
+
export class ButtonController extends SlotController {
|
|
12
|
+
constructor(host: HTMLElement, initializer: (node: HTMLElement, host: HTMLElement) => void);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Applies localized text to the button.
|
|
16
|
+
*/
|
|
17
|
+
setLabel(label: string): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { isEmptyTextNode, setOrRemoveAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
7
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if the element has text exposed to assistive technologies.
|
|
11
|
+
* Ignores content in named slots: tooltip text, button prefix and suffix.
|
|
12
|
+
*
|
|
13
|
+
* @param {Element} element
|
|
14
|
+
* @return {boolean}
|
|
15
|
+
*/
|
|
16
|
+
function hasAccessibleText(element) {
|
|
17
|
+
return Array.from(element.childNodes).some((node) => {
|
|
18
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
19
|
+
return !isEmptyTextNode(node);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Ignore anything that is not an element, such as the comment nodes Lit renders.
|
|
23
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return !node.slot && node.getAttribute('aria-hidden') !== 'true' && node.textContent.trim() !== '';
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A controller to manage the send button element.
|
|
33
|
+
*/
|
|
34
|
+
export class ButtonController extends SlotController {
|
|
35
|
+
#label;
|
|
36
|
+
|
|
37
|
+
constructor(host, initializer) {
|
|
38
|
+
super(host, 'button', 'vaadin-message-input-button', { initializer });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Applies localized text to the button.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} label
|
|
45
|
+
*/
|
|
46
|
+
setLabel(label) {
|
|
47
|
+
const { node } = this;
|
|
48
|
+
|
|
49
|
+
if (node === this.defaultNode) {
|
|
50
|
+
node.textContent = label;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Do not override custom `aria-label` set by the application.
|
|
55
|
+
const currentLabel = node.getAttribute('aria-label');
|
|
56
|
+
if (currentLabel !== null && currentLabel !== this.#label) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Use generated label if the button doesn't have own accessible name.
|
|
61
|
+
const needsLabel = !hasAccessibleText(node) && !node.hasAttribute('aria-labelledby');
|
|
62
|
+
this.#label = needsLabel ? label : undefined;
|
|
63
|
+
setOrRemoveAttribute(node, 'aria-label', this.#label);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -10,19 +10,40 @@ export const messageInputStyles = css`
|
|
|
10
10
|
:host {
|
|
11
11
|
box-sizing: border-box;
|
|
12
12
|
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
13
14
|
max-height: 50vh;
|
|
14
15
|
flex-shrink: 0;
|
|
15
16
|
border: var(--vaadin-input-field-border-width, 1px) solid
|
|
16
17
|
var(--vaadin-input-field-border-color, var(--vaadin-border-color));
|
|
17
|
-
|
|
18
|
+
--_radius: var(--vaadin-input-field-border-radius, var(--vaadin-radius-m));
|
|
19
|
+
border-radius:
|
|
20
|
+
/* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
|
|
21
|
+
var(--vaadin-input-field-top-start-radius, var(--_radius))
|
|
22
|
+
var(--vaadin-input-field-top-end-radius, var(--_radius))
|
|
23
|
+
var(--vaadin-input-field-bottom-end-radius, var(--_radius))
|
|
24
|
+
var(--vaadin-input-field-bottom-start-radius, var(--_radius));
|
|
18
25
|
background: var(--vaadin-input-field-background, var(--vaadin-background-color));
|
|
26
|
+
padding: var(
|
|
27
|
+
--vaadin-input-field-padding,
|
|
28
|
+
var(--vaadin-padding-block-container) var(--vaadin-padding-inline-container)
|
|
29
|
+
);
|
|
30
|
+
gap: var(--vaadin-input-field-gap, var(--vaadin-gap-s));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([dir='rtl']) {
|
|
34
|
+
border-radius:
|
|
35
|
+
/* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
36
|
+
var(--vaadin-input-field-top-end-radius, var(--_radius))
|
|
37
|
+
var(--vaadin-input-field-top-start-radius, var(--_radius))
|
|
38
|
+
var(--vaadin-input-field-bottom-start-radius, var(--_radius))
|
|
39
|
+
var(--vaadin-input-field-bottom-end-radius, var(--_radius));
|
|
19
40
|
}
|
|
20
41
|
|
|
21
42
|
:host([hidden]) {
|
|
22
43
|
display: none !important;
|
|
23
44
|
}
|
|
24
45
|
|
|
25
|
-
:host(
|
|
46
|
+
:host([focused]) {
|
|
26
47
|
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
|
|
27
48
|
outline-offset: calc(var(--vaadin-input-field-border-width, 1px) * -1);
|
|
28
49
|
}
|
|
@@ -38,8 +59,21 @@ export const messageInputStyles = css`
|
|
|
38
59
|
|
|
39
60
|
::slotted([slot='textarea']) {
|
|
40
61
|
flex: 1;
|
|
41
|
-
--vaadin-input-field-
|
|
62
|
+
--vaadin-input-field-padding: 0px !important;
|
|
63
|
+
--vaadin-input-field-border-width: 0px !important;
|
|
42
64
|
--vaadin-focus-ring-width: 0;
|
|
43
65
|
--vaadin-input-field-background: transparent !important;
|
|
66
|
+
--vaadin-input-field-disabled-background: transparent !important;
|
|
67
|
+
--vaadin-input-field-border-radius: 0px !important;
|
|
68
|
+
--vaadin-field-default-width: 8em;
|
|
69
|
+
align-self: center;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
::slotted([slot='button']) {
|
|
73
|
+
margin-inline-start: auto;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
slot:is([name='header'], [name='footer'])::slotted(*) {
|
|
77
|
+
width: 100%;
|
|
44
78
|
}
|
|
45
79
|
`;
|
|
@@ -10,13 +10,18 @@ export const messageInputButtonStyles = css`
|
|
|
10
10
|
:host {
|
|
11
11
|
flex: none;
|
|
12
12
|
align-self: end;
|
|
13
|
-
margin: var(
|
|
14
|
-
--vaadin-input-field-padding,
|
|
15
|
-
var(--vaadin-padding-block-container) var(--vaadin-padding-inline-container)
|
|
16
|
-
);
|
|
17
13
|
--vaadin-button-border-width: 0;
|
|
18
14
|
--vaadin-button-background: transparent;
|
|
19
|
-
--vaadin-button-text-color: var(--vaadin-text-color);
|
|
15
|
+
--vaadin-button-text-color: var(--vaadin-text-color-secondary);
|
|
20
16
|
--vaadin-button-padding: 0;
|
|
17
|
+
--vaadin-button-border-radius: var(--vaadin-radius-s);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host(:is([focus-ring], :focus-visible)) {
|
|
21
|
+
outline-offset: 0.125em;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:host(:hover) {
|
|
25
|
+
--vaadin-button-text-color: var(--vaadin-text-color);
|
|
21
26
|
}
|
|
22
27
|
`;
|
|
@@ -16,6 +16,7 @@ import { messageInputButtonStyles } from './styles/vaadin-message-input-button-s
|
|
|
16
16
|
/**
|
|
17
17
|
* An element used internally by `<vaadin-message-input>`. Not intended to be used separately.
|
|
18
18
|
*
|
|
19
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
19
20
|
* @customElement vaadin-message-input-button
|
|
20
21
|
* @extends HTMLElement
|
|
21
22
|
* @private
|
|
@@ -32,7 +33,7 @@ class MessageInputButton extends ButtonMixin(DirMixin(ThemableMixin(PolylitMixin
|
|
|
32
33
|
/** @protected */
|
|
33
34
|
render() {
|
|
34
35
|
return html`
|
|
35
|
-
<div class="vaadin-button-container">
|
|
36
|
+
<div class="vaadin-button-container" role="presentation">
|
|
36
37
|
<span part="label">
|
|
37
38
|
<slot></slot>
|
|
38
39
|
</span>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
8
|
import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
8
9
|
|
|
9
10
|
export interface MessageInputI18n {
|
|
@@ -13,7 +14,10 @@ export interface MessageInputI18n {
|
|
|
13
14
|
|
|
14
15
|
export declare function MessageInputMixin<T extends Constructor<HTMLElement>>(
|
|
15
16
|
base: T,
|
|
16
|
-
): Constructor<
|
|
17
|
+
): Constructor<FocusMixinClass> &
|
|
18
|
+
Constructor<I18nMixinClass<MessageInputI18n>> &
|
|
19
|
+
Constructor<MessageInputMixinClass> &
|
|
20
|
+
T;
|
|
17
21
|
|
|
18
22
|
export declare class MessageInputMixinClass {
|
|
19
23
|
/**
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
6
7
|
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
7
8
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
9
|
+
import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
|
|
8
10
|
import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
|
|
11
|
+
import { ButtonController } from './button-controller.js';
|
|
9
12
|
|
|
10
13
|
const DEFAULT_I18N = {
|
|
11
14
|
send: 'Send',
|
|
12
15
|
message: 'Message',
|
|
13
16
|
};
|
|
14
17
|
|
|
18
|
+
const CONTENT_SLOTS = ['header', 'prefix', 'footer'];
|
|
19
|
+
|
|
15
20
|
export const MessageInputMixin = (superClass) =>
|
|
16
|
-
class MessageInputMixinClass extends I18nMixin(superClass) {
|
|
21
|
+
class MessageInputMixinClass extends I18nMixin(FocusMixin(superClass)) {
|
|
17
22
|
static get properties() {
|
|
18
23
|
return {
|
|
19
24
|
/**
|
|
@@ -89,14 +94,12 @@ export const MessageInputMixin = (superClass) =>
|
|
|
89
94
|
ready() {
|
|
90
95
|
super.ready();
|
|
91
96
|
|
|
92
|
-
this._buttonController = new
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
+
this._buttonController = new ButtonController(this, (btn) => {
|
|
98
|
+
btn.addEventListener('click', () => {
|
|
99
|
+
this.__submit();
|
|
100
|
+
});
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
},
|
|
102
|
+
this._button = btn;
|
|
100
103
|
});
|
|
101
104
|
this.addController(this._buttonController);
|
|
102
105
|
|
|
@@ -124,19 +127,61 @@ export const MessageInputMixin = (superClass) =>
|
|
|
124
127
|
|
|
125
128
|
this._tooltipController = new TooltipController(this);
|
|
126
129
|
this.addController(this._tooltipController);
|
|
130
|
+
|
|
131
|
+
this.__slotObserver = new SlotObserver(
|
|
132
|
+
this.shadowRoot,
|
|
133
|
+
() => {
|
|
134
|
+
CONTENT_SLOTS.forEach((name) => {
|
|
135
|
+
this.toggleAttribute(`has-${name}`, !!this.querySelector(`:scope > [slot="${name}"]`));
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
{ syncInitial: true },
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
this.addEventListener('mousedown', (event) => {
|
|
142
|
+
// Focus the text area when clicking the space around it.
|
|
143
|
+
if (event.target === this) {
|
|
144
|
+
// Prevent mousedown to avoid blur and re-focus if already focused.
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
this.focus({ focusVisible: false });
|
|
147
|
+
}
|
|
148
|
+
});
|
|
127
149
|
}
|
|
128
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Override method inherited from `FocusMixin` to forward focus
|
|
153
|
+
* to the text area, which is the focusable part of the component.
|
|
154
|
+
*
|
|
155
|
+
* @param {FocusOptions=} options
|
|
156
|
+
* @protected
|
|
157
|
+
* @override
|
|
158
|
+
*/
|
|
129
159
|
focus(options) {
|
|
130
|
-
if (this._textArea) {
|
|
160
|
+
if (this._textArea && !this.disabled) {
|
|
131
161
|
this._textArea.focus(options);
|
|
162
|
+
super.focus(options);
|
|
132
163
|
}
|
|
133
164
|
}
|
|
134
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Override method inherited from `FocusMixin` to only set the `focused`
|
|
168
|
+
* attribute when the text area is focused.
|
|
169
|
+
*
|
|
170
|
+
* @param {FocusEvent} event
|
|
171
|
+
* @return {boolean}
|
|
172
|
+
* @protected
|
|
173
|
+
* @override
|
|
174
|
+
*/
|
|
175
|
+
_shouldSetFocus(event) {
|
|
176
|
+
return event.composedPath().includes(this._textArea);
|
|
177
|
+
}
|
|
178
|
+
|
|
135
179
|
/** @private */
|
|
136
180
|
__buttonPropsChanged(button, disabled, effectiveI18n, value) {
|
|
137
181
|
if (button) {
|
|
138
182
|
button.disabled = disabled || !value;
|
|
139
|
-
|
|
183
|
+
|
|
184
|
+
this._buttonController.setLabel(effectiveI18n.send);
|
|
140
185
|
}
|
|
141
186
|
}
|
|
142
187
|
|
|
@@ -33,6 +33,20 @@ export type MessageInputEventMap = HTMLElementEventMap & MessageInputCustomEvent
|
|
|
33
33
|
* <vaadin-message-input></vaadin-message-input>
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
+
* ### Slots
|
|
37
|
+
*
|
|
38
|
+
* The following slots are available for adding content to the message input:
|
|
39
|
+
*
|
|
40
|
+
* Name | Description
|
|
41
|
+
* -----------|-------------
|
|
42
|
+
* `header` | Content displayed above the text area and controls
|
|
43
|
+
* `prefix` | Content displayed before the text area
|
|
44
|
+
* `button` | Button that submits the message, replacing the default one
|
|
45
|
+
* `footer` | Content displayed below the text area and controls
|
|
46
|
+
*
|
|
47
|
+
* When a custom button has no text content or accessible label, `aria-label` attribute
|
|
48
|
+
* is set based on the [`i18n`](#/elements/vaadin-message-input#property-i18n) property.
|
|
49
|
+
*
|
|
36
50
|
* ### Styling
|
|
37
51
|
*
|
|
38
52
|
* The following state attributes are available for styling:
|
|
@@ -40,6 +54,11 @@ export type MessageInputEventMap = HTMLElementEventMap & MessageInputCustomEvent
|
|
|
40
54
|
* Attribute | Description
|
|
41
55
|
* ---------------|---------------------------------
|
|
42
56
|
* `disabled` | Set when the element is disabled
|
|
57
|
+
* `focused` | Set when the text area is focused
|
|
58
|
+
* `focus-ring` | Set when the text area is focused using the keyboard
|
|
59
|
+
* `has-header` | Set when the element has content in the header slot
|
|
60
|
+
* `has-prefix` | Set when the element has content in the prefix slot
|
|
61
|
+
* `has-footer` | Set when the element has content in the footer slot
|
|
43
62
|
* `has-tooltip` | Set when the element has a slotted tooltip
|
|
44
63
|
*
|
|
45
64
|
* ### Internal components
|
|
@@ -26,6 +26,20 @@ import { MessageInputMixin } from './vaadin-message-input-mixin.js';
|
|
|
26
26
|
* <vaadin-message-input></vaadin-message-input>
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
+
* ### Slots
|
|
30
|
+
*
|
|
31
|
+
* The following slots are available for adding content to the message input:
|
|
32
|
+
*
|
|
33
|
+
* Name | Description
|
|
34
|
+
* -----------|-------------
|
|
35
|
+
* `header` | Content displayed above the text area and controls
|
|
36
|
+
* `prefix` | Content displayed before the text area
|
|
37
|
+
* `button` | Button that submits the message, replacing the default one
|
|
38
|
+
* `footer` | Content displayed below the text area and controls
|
|
39
|
+
*
|
|
40
|
+
* When a custom button has no text content or accessible label, `aria-label` attribute
|
|
41
|
+
* is set based on the [`i18n`](#/elements/vaadin-message-input#property-i18n) property.
|
|
42
|
+
*
|
|
29
43
|
* ### Styling
|
|
30
44
|
*
|
|
31
45
|
* The following state attributes are available for styling:
|
|
@@ -33,6 +47,11 @@ import { MessageInputMixin } from './vaadin-message-input-mixin.js';
|
|
|
33
47
|
* Attribute | Description
|
|
34
48
|
* ---------------|---------------------------------
|
|
35
49
|
* `disabled` | Set when the element is disabled
|
|
50
|
+
* `focused` | Set when the text area is focused
|
|
51
|
+
* `focus-ring` | Set when the text area is focused using the keyboard
|
|
52
|
+
* `has-header` | Set when the element has content in the header slot
|
|
53
|
+
* `has-prefix` | Set when the element has content in the prefix slot
|
|
54
|
+
* `has-footer` | Set when the element has content in the footer slot
|
|
36
55
|
* `has-tooltip` | Set when the element has a slotted tooltip
|
|
37
56
|
*
|
|
38
57
|
* ### Internal components
|
|
@@ -47,6 +66,7 @@ import { MessageInputMixin } from './vaadin-message-input-mixin.js';
|
|
|
47
66
|
*
|
|
48
67
|
* @fires {CustomEvent} submit - Fired when a new message is submitted, either by clicking the "send" button, or pressing the Enter key.
|
|
49
68
|
*
|
|
69
|
+
* @attr {string} theme - The theme variants to apply to the component.
|
|
50
70
|
* @customElement vaadin-message-input
|
|
51
71
|
* @extends HTMLElement
|
|
52
72
|
*/
|
|
@@ -64,10 +84,16 @@ class MessageInput extends MessageInputMixin(
|
|
|
64
84
|
/** @protected */
|
|
65
85
|
render() {
|
|
66
86
|
return html`
|
|
87
|
+
<slot name="header"></slot>
|
|
88
|
+
|
|
89
|
+
<slot name="prefix"></slot>
|
|
90
|
+
|
|
67
91
|
<slot name="textarea"></slot>
|
|
68
92
|
|
|
69
93
|
<slot name="button"></slot>
|
|
70
94
|
|
|
95
|
+
<slot name="footer"></slot>
|
|
96
|
+
|
|
71
97
|
<slot name="tooltip"></slot>
|
|
72
98
|
`;
|
|
73
99
|
}
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/message-input",
|
|
4
|
-
"version": "25.3.0-
|
|
4
|
+
"version": "25.3.0-rc1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-message-input",
|
|
11
|
-
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
11
|
+
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Slots\n\nThe following slots are available for adding content to the message input:\n\nName | Description\n-----------|-------------\n`header` | Content displayed above the text area and controls\n`prefix` | Content displayed before the text area\n`button` | Button that submits the message, replacing the default one\n`footer` | Content displayed below the text area and controls\n\nWhen a custom button has no text content or accessible label, `aria-label` attribute\nis set based on the [`i18n`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-rc1/#/elements/vaadin-message-input#property-i18n) property.\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`focused` | Set when the text area is focused\n`focus-ring` | Set when the text area is focused using the keyboard\n`has-header` | Set when the element has content in the header slot\n`has-prefix` | Set when the element has content in the prefix slot\n`has-footer` | Set when the element has content in the footer slot\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
"description": "The theme variants to apply to the component.",
|
|
25
25
|
"value": {
|
|
26
26
|
"type": [
|
|
27
|
-
"string"
|
|
28
|
-
"null",
|
|
29
|
-
"undefined"
|
|
27
|
+
"string"
|
|
30
28
|
]
|
|
31
29
|
}
|
|
32
30
|
},
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/message-input",
|
|
4
|
-
"version": "25.3.0-
|
|
4
|
+
"version": "25.3.0-rc1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-message-input",
|
|
19
|
-
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
19
|
+
"description": "`<vaadin-message-input>` is a Web Component for sending messages.\nIt consists of a text area that grows on along with the content, and a send button to send message.\n\nThe message can be sent by one of the following actions:\n- by pressing Enter (use Shift + Enter to add a new line)\n- by clicking `submit` button.\n\n```html\n<vaadin-message-input></vaadin-message-input>\n```\n\n### Slots\n\nThe following slots are available for adding content to the message input:\n\nName | Description\n-----------|-------------\n`header` | Content displayed above the text area and controls\n`prefix` | Content displayed before the text area\n`button` | Button that submits the message, replacing the default one\n`footer` | Content displayed below the text area and controls\n\nWhen a custom button has no text content or accessible label, `aria-label` attribute\nis set based on the [`i18n`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-rc1/#/elements/vaadin-message-input#property-i18n) property.\n\n### Styling\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|---------------------------------\n`disabled` | Set when the element is disabled\n`focused` | Set when the text area is focused\n`focus-ring` | Set when the text area is focused using the keyboard\n`has-header` | Set when the element has content in the header slot\n`has-prefix` | Set when the element has content in the prefix slot\n`has-footer` | Set when the element has content in the footer slot\n`has-tooltip` | Set when the element has a slotted tooltip\n\n### Internal components\n\nIn addition to `<vaadin-message-input>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-input-button>` - has the same API as `<vaadin-button>`\n- `<vaadin-text-area>`\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|