@vaadin/message-input 23.3.0-alpha3 → 24.0.0-alpha1

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.0-alpha3",
3
+ "version": "24.0.0-alpha1",
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.0-alpha3",
40
- "@vaadin/component-base": "23.3.0-alpha3",
41
- "@vaadin/text-area": "23.3.0-alpha3",
42
- "@vaadin/vaadin-lumo-styles": "23.3.0-alpha3",
43
- "@vaadin/vaadin-material-styles": "23.3.0-alpha3",
44
- "@vaadin/vaadin-themable-mixin": "23.3.0-alpha3"
39
+ "@vaadin/button": "24.0.0-alpha1",
40
+ "@vaadin/component-base": "24.0.0-alpha1",
41
+ "@vaadin/text-area": "24.0.0-alpha1",
42
+ "@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
43
+ "@vaadin/vaadin-material-styles": "24.0.0-alpha1",
44
+ "@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
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": "e86cd2abf3e28bade37711291331415d92c454ec"
55
+ "gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
56
56
  }
@@ -3,11 +3,12 @@
3
3
  * Copyright (c) 2021 - 2022 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
 
@@ -98,17 +101,23 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
98
101
  overflow: hidden;
99
102
  flex-shrink: 0;
100
103
  }
104
+
105
+ :host([hidden]) {
106
+ display: none !important;
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
+ }
101
117
  </style>
102
- <vaadin-message-input-text-area
103
- disabled="[[disabled]]"
104
- value="{{value}}"
105
- placeholder="[[i18n.message]]"
106
- aria-label="[[i18n.message]]"
107
- on-enter="__submit"
108
- ></vaadin-message-input-text-area>
109
- <vaadin-message-input-button disabled="[[disabled]]" theme="primary contained" on-click="__submit"
110
- >[[i18n.send]]</vaadin-message-input-button
111
- >
118
+ <slot name="textarea"></slot>
119
+
120
+ <slot name="button"></slot>
112
121
 
113
122
  <slot name="tooltip"></slot>
114
123
  `;
@@ -118,14 +127,91 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
118
127
  return 'vaadin-message-input';
119
128
  }
120
129
 
130
+ static get observers() {
131
+ return [
132
+ '__buttonPropsChanged(_button, disabled, i18n)',
133
+ '__textAreaPropsChanged(_textArea, disabled, i18n, value)',
134
+ ];
135
+ }
136
+
121
137
  /** @protected */
122
138
  ready() {
123
139
  super.ready();
124
140
 
141
+ this._buttonController = new SlotController(
142
+ this,
143
+ 'button',
144
+ () => document.createElement('vaadin-button'),
145
+ (_, btn) => {
146
+ btn.setAttribute('theme', 'primary contained');
147
+
148
+ btn.addEventListener('click', () => {
149
+ this.__submit();
150
+ });
151
+
152
+ this._button = btn;
153
+ },
154
+ );
155
+ this.addController(this._buttonController);
156
+
157
+ this._textAreaController = new SlotController(
158
+ this,
159
+ 'textarea',
160
+ () => document.createElement('vaadin-text-area'),
161
+ (_, textarea) => {
162
+ textarea.addEventListener('value-changed', (event) => {
163
+ this.value = event.detail.value;
164
+ });
165
+
166
+ textarea.addEventListener('keydown', (event) => {
167
+ if (event.key === 'Enter' && !event.shiftKey) {
168
+ event.preventDefault();
169
+ event.stopImmediatePropagation();
170
+ this.__submit();
171
+ }
172
+ });
173
+
174
+ const input = textarea.inputElement;
175
+ input.removeAttribute('aria-labelledby');
176
+
177
+ // Set initial height to one row
178
+ input.setAttribute('rows', 1);
179
+ input.style.minHeight = '0';
180
+
181
+ this._textArea = textarea;
182
+ },
183
+ );
184
+ this.addController(this._textAreaController);
185
+
125
186
  this._tooltipController = new TooltipController(this);
126
187
  this.addController(this._tooltipController);
127
188
  }
128
189
 
190
+ /** @private */
191
+ __buttonPropsChanged(button, disabled, i18n) {
192
+ if (button) {
193
+ button.disabled = disabled;
194
+ button.textContent = i18n.send;
195
+ }
196
+ }
197
+
198
+ /** @private */
199
+ __textAreaPropsChanged(textArea, disabled, i18n, value) {
200
+ if (textArea) {
201
+ textArea.disabled = disabled;
202
+ textArea.value = value;
203
+
204
+ const message = i18n.message;
205
+ textArea.placeholder = message;
206
+
207
+ if (message) {
208
+ textArea.inputElement.setAttribute('aria-label', message);
209
+ } else {
210
+ textArea.inputElement.removeAttribute('aria-label');
211
+ }
212
+ }
213
+ }
214
+
129
215
  /**
130
216
  * Submits the current value as an custom event named 'submit'.
131
217
  * It also clears the text input and refocuses it for sending another message.
@@ -137,7 +223,7 @@ class MessageInput extends ElementMixin(ThemableMixin(ControllerMixin(PolymerEle
137
223
  this.dispatchEvent(new CustomEvent('submit', { detail: { value: this.value } }));
138
224
  this.value = '';
139
225
  }
140
- this.shadowRoot.querySelector('vaadin-message-input-text-area').focus();
226
+ this._textArea.focus();
141
227
  }
142
228
  }
143
229
 
@@ -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.0-alpha3",
4
+ "version": "24.0.0-alpha1",
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.0-alpha3/#/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.0-alpha3/#/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.0-alpha3",
4
+ "version": "24.0.0-alpha1",
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.0-alpha3/#/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.0-alpha3/#/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';