@vaadin/message-list 24.0.0-alpha1 → 24.0.0-alpha3
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 +8 -7
- package/src/vaadin-message-list.js +28 -52
- package/src/vaadin-message.js +3 -6
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/message-list",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@polymer/polymer": "^3.0.0",
|
|
41
|
-
"@vaadin/avatar": "24.0.0-
|
|
42
|
-
"@vaadin/component-base": "24.0.0-
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
44
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
41
|
+
"@vaadin/avatar": "24.0.0-alpha3",
|
|
42
|
+
"@vaadin/component-base": "24.0.0-alpha3",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha3",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha3",
|
|
46
|
+
"lit": "^2.0.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"web-types.json",
|
|
54
55
|
"web-types.lit.json"
|
|
55
56
|
],
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "7a013a3c5a56abd61dd4f7773c6ec77c3541bdf2"
|
|
57
58
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
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 { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
6
|
+
import { html as legacyHtml, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
7
|
+
import { html, render } from 'lit';
|
|
8
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
7
9
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
10
|
import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
9
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -78,7 +80,7 @@ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(Poly
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
static get template() {
|
|
81
|
-
return
|
|
83
|
+
return legacyHtml`
|
|
82
84
|
<style>
|
|
83
85
|
:host {
|
|
84
86
|
display: block;
|
|
@@ -130,20 +132,7 @@ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(Poly
|
|
|
130
132
|
const focusedIndex = this._getIndexOfFocusableElement();
|
|
131
133
|
const closeToBottom = this.scrollHeight < this.clientHeight + this.scrollTop + 50;
|
|
132
134
|
|
|
133
|
-
|
|
134
|
-
const added = [...items];
|
|
135
|
-
|
|
136
|
-
this._messages.forEach((message) => {
|
|
137
|
-
const item = message._item;
|
|
138
|
-
if (removed.includes(item)) {
|
|
139
|
-
message.remove();
|
|
140
|
-
} else if (added.includes(item)) {
|
|
141
|
-
added.splice(added.indexOf(item), 1);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
this.__addMessages(added, items);
|
|
146
|
-
|
|
135
|
+
this._renderMessages(items);
|
|
147
136
|
this._setTabIndexesByIndex(focusedIndex);
|
|
148
137
|
|
|
149
138
|
requestAnimationFrame(() => {
|
|
@@ -155,42 +144,29 @@ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(Poly
|
|
|
155
144
|
}
|
|
156
145
|
|
|
157
146
|
/** @private */
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
message.userColorIndex = item.userColorIndex;
|
|
182
|
-
|
|
183
|
-
message._item = item;
|
|
184
|
-
|
|
185
|
-
if (item.theme) {
|
|
186
|
-
message.setAttribute('theme', item.theme);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
message.addEventListener('focusin', (e) => {
|
|
190
|
-
this._onMessageFocusIn(e);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
return message;
|
|
147
|
+
_renderMessages(items) {
|
|
148
|
+
render(
|
|
149
|
+
html`
|
|
150
|
+
${items.map(
|
|
151
|
+
(item) =>
|
|
152
|
+
html`
|
|
153
|
+
<vaadin-message
|
|
154
|
+
role="listitem"
|
|
155
|
+
.time="${item.time}"
|
|
156
|
+
.userAbbr="${item.userAbbr}"
|
|
157
|
+
.userName="${item.userName}"
|
|
158
|
+
.userImg="${item.userImg}"
|
|
159
|
+
.userColorIndex="${item.userColorIndex}"
|
|
160
|
+
theme="${ifDefined(item.theme)}"
|
|
161
|
+
@focusin="${this._onMessageFocusIn}"
|
|
162
|
+
>${item.text}</vaadin-message
|
|
163
|
+
>
|
|
164
|
+
`,
|
|
165
|
+
)}
|
|
166
|
+
`,
|
|
167
|
+
this,
|
|
168
|
+
{ host: this },
|
|
169
|
+
);
|
|
194
170
|
}
|
|
195
171
|
|
|
196
172
|
/** @private */
|
package/src/vaadin-message.js
CHANGED
|
@@ -182,16 +182,13 @@ class Message extends FocusMixin(ElementMixin(ThemableMixin(ControllerMixin(Poly
|
|
|
182
182
|
ready() {
|
|
183
183
|
super.ready();
|
|
184
184
|
|
|
185
|
-
this._avatarController = new SlotController(
|
|
186
|
-
|
|
187
|
-
'avatar',
|
|
188
|
-
() => document.createElement('vaadin-avatar'),
|
|
189
|
-
(_, avatar) => {
|
|
185
|
+
this._avatarController = new SlotController(this, 'avatar', 'vaadin-avatar', {
|
|
186
|
+
initializer: (avatar) => {
|
|
190
187
|
avatar.setAttribute('tabindex', '-1');
|
|
191
188
|
avatar.setAttribute('aria-hidden', 'true');
|
|
192
189
|
this._avatar = avatar;
|
|
193
190
|
},
|
|
194
|
-
);
|
|
191
|
+
});
|
|
195
192
|
this.addController(this._avatarController);
|
|
196
193
|
}
|
|
197
194
|
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/message-list",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-alpha3",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
"name": "vaadin-message-list",
|
|
143
|
-
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-
|
|
143
|
+
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-message) documentation for the available\nstate attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
144
144
|
"attributes": [
|
|
145
145
|
{
|
|
146
146
|
"name": "theme",
|
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-list",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-alpha3",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "vaadin-message-list",
|
|
61
|
-
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-
|
|
61
|
+
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha3/#/elements/vaadin-message) documentation for the available\nstate attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
62
62
|
"extension": true,
|
|
63
63
|
"attributes": [
|
|
64
64
|
{
|