@vaadin/message-input 23.3.3 → 24.0.0-alpha10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/message-input",
3
- "version": "23.3.3",
3
+ "version": "24.0.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,12 +36,12 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/button": "~23.3.3",
40
- "@vaadin/component-base": "~23.3.3",
41
- "@vaadin/text-area": "~23.3.3",
42
- "@vaadin/vaadin-lumo-styles": "~23.3.3",
43
- "@vaadin/vaadin-material-styles": "~23.3.3",
44
- "@vaadin/vaadin-themable-mixin": "~23.3.3"
39
+ "@vaadin/button": "24.0.0-alpha10",
40
+ "@vaadin/component-base": "24.0.0-alpha10",
41
+ "@vaadin/text-area": "24.0.0-alpha10",
42
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
43
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha10",
44
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
@@ -52,5 +52,5 @@
52
52
  "web-types.json",
53
53
  "web-types.lit.json"
54
54
  ],
55
- "gitHead": "1529ed623e053d28a3c1c66af55ebe402743ddd0"
55
+ "gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
56
56
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import './vaadin-message-input-text-area.js';
7
- import './vaadin-message-input-button.js';
6
+ import '@vaadin/button/src/vaadin-button.js';
7
+ import '@vaadin/text-area/src/vaadin-text-area.js';
8
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
9
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
10
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
11
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
11
12
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
12
13
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
14
 
@@ -23,16 +24,8 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
23
24
  * <vaadin-message-input></vaadin-message-input>
24
25
  * ```
25
26
  *
26
- * ### Internal components
27
- *
28
- * In addition to `<vaadin-message-input>` itself, the following internal
29
- * components are themable:
30
- *
31
- * - `<vaadin-message-input-button>` - has the same API as [`<vaadin-button>`](#/elements/vaadin-button).
32
- * - `<vaadin-message-input-text-area>` - has the same API as [`<vaadin-text-area>`](#/elements/vaadin-text-area).
33
- *
34
27
  * @extends HTMLElement
35
- * @mizes ControllerMixin
28
+ * @mixes ControllerMixin
36
29
  * @mixes ThemableMixin
37
30
  * @mixes ElementMixin
38
31
  */
@@ -44,10 +37,10 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
44
37
  */
45
38
  value: {
46
39
  type: String,
40
+ value: '',
47
41
  },
48
42
 
49
43
  /**
50
- *
51
44
  * The object used to localize this component.
52
45
  * For changing the default localization, change the entire
53
46
  * `i18n` object.
@@ -84,6 +77,16 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
84
77
  value: false,
85
78
  reflectToAttribute: true,
86
79
  },
80
+
81
+ /** @private */
82
+ _button: {
83
+ type: Object,
84
+ },
85
+
86
+ /** @private */
87
+ _textArea: {
88
+ type: Object,
89
+ },
87
90
  };
88
91
  }
89
92
 
@@ -102,17 +105,19 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
102
105
  :host([hidden]) {
103
106
  display: none !important;
104
107
  }
108
+
109
+ ::slotted([slot='button']) {
110
+ flex-shrink: 0;
111
+ }
112
+
113
+ ::slotted([slot='textarea']) {
114
+ align-self: stretch;
115
+ flex-grow: 1;
116
+ }
105
117
  </style>
106
- <vaadin-message-input-text-area
107
- disabled="[[disabled]]"
108
- value="{{value}}"
109
- placeholder="[[i18n.message]]"
110
- aria-label="[[i18n.message]]"
111
- on-enter="__submit"
112
- ></vaadin-message-input-text-area>
113
- <vaadin-message-input-button disabled="[[disabled]]" theme="primary contained" on-click="__submit"
114
- >[[i18n.send]]</vaadin-message-input-button
115
- >
118
+ <slot name="textarea"></slot>
119
+
120
+ <slot name="button"></slot>
116
121
 
117
122
  <slot name="tooltip"></slot>
118
123
  `;
@@ -122,14 +127,85 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
122
127
  return 'vaadin-message-input';
123
128
  }
124
129
 
130
+ static get observers() {
131
+ return [
132
+ '__buttonPropsChanged(_button, disabled, i18n)',
133
+ '__textAreaPropsChanged(_textArea, disabled, i18n, value)',
134
+ ];
135
+ }
136
+
125
137
  /** @protected */
126
138
  ready() {
127
139
  super.ready();
128
140
 
141
+ this._buttonController = new SlotController(this, 'button', 'vaadin-button', {
142
+ initializer: (btn) => {
143
+ btn.setAttribute('theme', 'primary contained');
144
+
145
+ btn.addEventListener('click', () => {
146
+ this.__submit();
147
+ });
148
+
149
+ this._button = btn;
150
+ },
151
+ });
152
+ this.addController(this._buttonController);
153
+
154
+ this._textAreaController = new SlotController(this, 'textarea', 'vaadin-text-area', {
155
+ initializer: (textarea) => {
156
+ textarea.addEventListener('value-changed', (event) => {
157
+ this.value = event.detail.value;
158
+ });
159
+
160
+ textarea.addEventListener('keydown', (event) => {
161
+ if (event.key === 'Enter' && !event.shiftKey) {
162
+ event.preventDefault();
163
+ event.stopImmediatePropagation();
164
+ this.__submit();
165
+ }
166
+ });
167
+
168
+ const input = textarea.inputElement;
169
+ input.removeAttribute('aria-labelledby');
170
+
171
+ // Set initial height to one row
172
+ input.setAttribute('rows', 1);
173
+ input.style.minHeight = '0';
174
+
175
+ this._textArea = textarea;
176
+ },
177
+ });
178
+ this.addController(this._textAreaController);
179
+
129
180
  this._tooltipController = new TooltipController(this);
130
181
  this.addController(this._tooltipController);
131
182
  }
132
183
 
184
+ /** @private */
185
+ __buttonPropsChanged(button, disabled, i18n) {
186
+ if (button) {
187
+ button.disabled = disabled;
188
+ button.textContent = i18n.send;
189
+ }
190
+ }
191
+
192
+ /** @private */
193
+ __textAreaPropsChanged(textArea, disabled, i18n, value) {
194
+ if (textArea) {
195
+ textArea.disabled = disabled;
196
+ textArea.value = value;
197
+
198
+ const message = i18n.message;
199
+ textArea.placeholder = message;
200
+
201
+ if (message) {
202
+ textArea.inputElement.setAttribute('aria-label', message);
203
+ } else {
204
+ textArea.inputElement.removeAttribute('aria-label');
205
+ }
206
+ }
207
+ }
208
+
133
209
  /**
134
210
  * Submits the current value as an custom event named 'submit'.
135
211
  * It also clears the text input and refocuses it for sending another message.
@@ -141,7 +217,7 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
141
217
  this.dispatchEvent(new CustomEvent('submit', { detail: { value: this.value } }));
142
218
  this.value = '';
143
219
  }
144
- this.shadowRoot.querySelector('vaadin-message-input-text-area').focus();
220
+ this._textArea.focus();
145
221
  }
146
222
 
147
223
  /**
@@ -10,6 +10,10 @@ registerStyles(
10
10
  :host {
11
11
  padding: var(--lumo-space-s) var(--lumo-space-m);
12
12
  }
13
+
14
+ ::slotted([slot='textarea']) {
15
+ margin-inline-end: var(--lumo-space-s);
16
+ }
13
17
  `,
14
18
  { moduleId: 'lumo-message-input' },
15
19
  );
@@ -1,4 +1,4 @@
1
+ import '@vaadin/button/theme/lumo/vaadin-button.js';
2
+ import '@vaadin/text-area/theme/lumo/vaadin-text-area.js';
1
3
  import './vaadin-message-input-styles.js';
2
- import './vaadin-message-input-text-area.js';
3
- import './vaadin-message-input-button.js';
4
4
  import '../../src/vaadin-message-input.js';
@@ -8,6 +8,11 @@ registerStyles(
8
8
  :host {
9
9
  padding: 0.5em 1em;
10
10
  }
11
+
12
+ ::slotted([slot='textarea']) {
13
+ margin: 0;
14
+ margin-inline-end: 0.5em;
15
+ }
11
16
  `,
12
17
  { moduleId: 'material-message-input' },
13
18
  );
@@ -1,4 +1,4 @@
1
+ import '@vaadin/button/theme/material/vaadin-button.js';
2
+ import '@vaadin/text-area/theme/material/vaadin-text-area.js';
1
3
  import './vaadin-message-input-styles.js';
2
- import './vaadin-message-input-text-area.js';
3
- import './vaadin-message-input-button.js';
4
4
  import '../../src/vaadin-message-input.js';
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": "23.3.3",
4
+ "version": "24.0.0-alpha10",
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### 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>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-button).\n- `<vaadin-message-input-text-area>` - has the same API as [`<vaadin-text-area>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-text-area).",
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```",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "value",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/message-input",
4
- "version": "23.3.3",
4
+ "version": "24.0.0-alpha10",
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### 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>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-button).\n- `<vaadin-message-input-text-area>` - has the same API as [`<vaadin-text-area>`](https://cdn.vaadin.com/vaadin-web-components/23.3.3/#/elements/vaadin-text-area).",
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```",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -1,20 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { Button } from '@vaadin/button/src/vaadin-button.js';
7
-
8
- /**
9
- * An element used internally by `<vaadin-message-input>`. Not intended to be used separately.
10
- *
11
- * @extends Button
12
- * @protected
13
- */
14
- declare class MessageInputButton extends Button {}
15
-
16
- declare global {
17
- interface HTMLElementTagNameMap {
18
- 'vaadin-message-input-button': MessageInputButton;
19
- }
20
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { Button } from '@vaadin/button/src/vaadin-button.js';
7
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
-
9
- registerStyles(
10
- 'vaadin-message-input-button',
11
- css`
12
- :host {
13
- flex-shrink: 0;
14
- }
15
- `,
16
- { moduleId: 'vaadin-message-input-button-styles' },
17
- );
18
-
19
- /**
20
- * An element used internally by `<vaadin-message-input>`. Not intended to be used separately.
21
- *
22
- * @extends Button
23
- * @protected
24
- */
25
- class MessageInputButton extends Button {
26
- static get is() {
27
- return 'vaadin-message-input-button';
28
- }
29
- }
30
-
31
- customElements.define(MessageInputButton.is, MessageInputButton);
@@ -1,21 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { TextArea } from '@vaadin/text-area/src/vaadin-text-area.js';
7
-
8
- /**
9
- * An element used internally by `<vaadin-message-input>`. Not intended to be used separately.
10
- *
11
- * @protected
12
- */
13
- declare class MessageInputTextArea extends TextArea {
14
- ariaLabel: string;
15
- }
16
-
17
- declare global {
18
- interface HTMLElementTagNameMap {
19
- 'vaadin-message-input-text-area': MessageInputTextArea;
20
- }
21
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { TextArea } from '@vaadin/text-area/src/vaadin-text-area.js';
7
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
-
9
- registerStyles(
10
- 'vaadin-message-input-text-area',
11
- css`
12
- :host {
13
- align-self: stretch;
14
- flex-grow: 1;
15
- }
16
-
17
- .textarea-wrapper {
18
- min-height: 0;
19
- }
20
- `,
21
- { moduleId: 'vaadin-message-input-text-area-styles' },
22
- );
23
-
24
- /**
25
- * An element used internally by `<vaadin-message-input>`. Not intended to be used separately.
26
- *
27
- * @extends TextArea
28
- * @protected
29
- */
30
- class MessageInputTextArea extends TextArea {
31
- static get is() {
32
- return 'vaadin-message-input-text-area';
33
- }
34
-
35
- static get properties() {
36
- return {
37
- ariaLabel: {
38
- type: String,
39
- observer: '__ariaLabelChanged',
40
- },
41
- };
42
- }
43
-
44
- /**
45
- * Override an observer from `InputMixin`.
46
- * @protected
47
- * @override
48
- */
49
- _inputElementChanged(input) {
50
- super._inputElementChanged(input);
51
-
52
- if (input) {
53
- input.removeAttribute('aria-labelledby');
54
-
55
- // Set initial height to one row
56
- input.setAttribute('rows', 1);
57
- input.style.minHeight = '0';
58
-
59
- this.__updateAriaLabel(this.ariaLabel);
60
- }
61
- }
62
-
63
- /**
64
- * Override an event listener from `InputControlMixin`
65
- * to dispatch a custom event on Enter key.
66
- * @param {!KeyboardEvent} event
67
- * @protected
68
- * @override
69
- */
70
- _onKeyDown(event) {
71
- if (event.key === 'Enter' && !event.shiftKey) {
72
- event.preventDefault();
73
- event.stopPropagation();
74
- this.dispatchEvent(new CustomEvent('enter'));
75
- }
76
-
77
- super._onKeyDown(event);
78
- }
79
-
80
- /** @private */
81
- __updateAriaLabel(ariaLabel) {
82
- if (ariaLabel) {
83
- this.inputElement.setAttribute('aria-label', ariaLabel);
84
- } else {
85
- this.inputElement.removeAttribute('aria-label');
86
- }
87
- }
88
-
89
- /** @private */
90
- __ariaLabelChanged(ariaLabel) {
91
- if (!this.inputElement) {
92
- return;
93
- }
94
-
95
- this.__updateAriaLabel(ariaLabel);
96
- }
97
- }
98
-
99
- customElements.define(MessageInputTextArea.is, MessageInputTextArea);
@@ -1,2 +0,0 @@
1
- import '@vaadin/button/theme/lumo/vaadin-button.js';
2
- import '../../src/vaadin-message-input-button.js';
@@ -1,15 +0,0 @@
1
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
-
3
- registerStyles(
4
- 'vaadin-message-input-text-area',
5
- css`
6
- :host {
7
- margin: 0 var(--lumo-space-s) 0 0;
8
- }
9
-
10
- :host([dir='rtl']) {
11
- margin: 0 0 0 var(--lumo-space-s);
12
- }
13
- `,
14
- { moduleId: 'lumo-message-input-text-area' },
15
- );
@@ -1,3 +0,0 @@
1
- import '@vaadin/text-area/theme/lumo/vaadin-text-area.js';
2
- import './vaadin-message-input-text-area-styles.js';
3
- import '../../src/vaadin-message-input-text-area.js';
@@ -1,2 +0,0 @@
1
- import '@vaadin/button/theme/material/vaadin-button.js';
2
- import '../../src/vaadin-message-input-button.js';
@@ -1,15 +0,0 @@
1
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
2
-
3
- registerStyles(
4
- 'vaadin-message-input-text-area',
5
- css`
6
- :host {
7
- margin: 0 0.5em 0 0;
8
- }
9
-
10
- :host([dir='rtl']) {
11
- margin: 0 0 0 0.5em;
12
- }
13
- `,
14
- { moduleId: 'material-message-input-text-area' },
15
- );
@@ -1,3 +0,0 @@
1
- import '@vaadin/text-area/theme/material/vaadin-text-area.js';
2
- import './vaadin-message-input-text-area-styles.js';
3
- import '../../src/vaadin-message-input-text-area.js';