@vaadin/message-list 23.2.0 → 23.3.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 +7 -7
- package/src/vaadin-message-list.d.ts +2 -1
- package/src/vaadin-message-list.js +19 -51
- package/src/vaadin-message.d.ts +4 -0
- package/src/vaadin-message.js +4 -0
- 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": "23.
|
|
3
|
+
"version": "23.3.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@polymer/polymer": "^3.0.0",
|
|
41
|
-
"@vaadin/avatar": "
|
|
42
|
-
"@vaadin/component-base": "
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
44
|
-
"@vaadin/vaadin-material-styles": "
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
41
|
+
"@vaadin/avatar": "23.3.0-alpha1",
|
|
42
|
+
"@vaadin/component-base": "23.3.0-alpha1",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "23.3.0-alpha1",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "23.3.0-alpha1",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "23.3.0-alpha1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"web-types.json",
|
|
54
54
|
"web-types.lit.json"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
|
|
57
57
|
}
|
|
@@ -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 { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
|
+
import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
7
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
9
|
|
|
9
10
|
export interface MessageListItem {
|
|
@@ -43,7 +44,7 @@ export interface MessageListItem {
|
|
|
43
44
|
*
|
|
44
45
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
45
46
|
*/
|
|
46
|
-
declare class MessageList extends ThemableMixin(ElementMixin(HTMLElement)) {
|
|
47
|
+
declare class MessageList extends KeyboardDirectionMixin(ThemableMixin(ElementMixin(HTMLElement))) {
|
|
47
48
|
/**
|
|
48
49
|
* An array of objects which will be rendered as messages.
|
|
49
50
|
* The message objects can have the following properties:
|
|
@@ -7,6 +7,7 @@ import '@polymer/polymer/lib/elements/dom-repeat.js';
|
|
|
7
7
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
8
|
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
9
9
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
10
|
+
import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
|
|
10
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
12
|
import { Message } from './vaadin-message.js';
|
|
12
13
|
|
|
@@ -40,8 +41,9 @@ import { Message } from './vaadin-message.js';
|
|
|
40
41
|
* @extends HTMLElement
|
|
41
42
|
* @mixes ThemableMixin
|
|
42
43
|
* @mixes ElementMixin
|
|
44
|
+
* @mixes KeyboardDirectionMixin
|
|
43
45
|
*/
|
|
44
|
-
class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
46
|
+
class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
45
47
|
static get is() {
|
|
46
48
|
return 'vaadin-message-list';
|
|
47
49
|
}
|
|
@@ -108,9 +110,18 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
108
110
|
// Make screen readers announce new messages
|
|
109
111
|
this.setAttribute('aria-relevant', 'additions');
|
|
110
112
|
this.setAttribute('role', 'log');
|
|
113
|
+
}
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Override method inherited from `KeyboardDirectionMixin`
|
|
117
|
+
* to use the list of message elements as items.
|
|
118
|
+
*
|
|
119
|
+
* @return {Element[]}
|
|
120
|
+
* @protected
|
|
121
|
+
* @override
|
|
122
|
+
*/
|
|
123
|
+
_getItems() {
|
|
124
|
+
return this._messages;
|
|
114
125
|
}
|
|
115
126
|
|
|
116
127
|
/** @protected */
|
|
@@ -118,6 +129,7 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
118
129
|
return Array.from(this.shadowRoot.querySelectorAll('vaadin-message'));
|
|
119
130
|
}
|
|
120
131
|
|
|
132
|
+
/** @private */
|
|
121
133
|
_itemsChanged(newVal, oldVal) {
|
|
122
134
|
const focusedIndex = this._getIndexOfFocusableElement();
|
|
123
135
|
if (newVal && newVal.length) {
|
|
@@ -132,60 +144,14 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
132
144
|
}
|
|
133
145
|
}
|
|
134
146
|
|
|
147
|
+
/** @private */
|
|
135
148
|
_scrollToLastMessage() {
|
|
136
149
|
if (this.items.length > 0) {
|
|
137
150
|
this.scrollTop = this.scrollHeight - this.clientHeight;
|
|
138
151
|
}
|
|
139
152
|
}
|
|
140
153
|
|
|
141
|
-
/**
|
|
142
|
-
* @param {!KeyboardEvent} event
|
|
143
|
-
* @protected
|
|
144
|
-
*/
|
|
145
|
-
_onKeydown(event) {
|
|
146
|
-
if (event.metaKey || event.ctrlKey) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Get index of the item that was focused when event happened
|
|
151
|
-
const target = event.composedPath()[0];
|
|
152
|
-
let currentIndex = this._messages.indexOf(target);
|
|
153
|
-
|
|
154
|
-
switch (event.key) {
|
|
155
|
-
case 'ArrowUp':
|
|
156
|
-
currentIndex -= 1;
|
|
157
|
-
break;
|
|
158
|
-
case 'ArrowDown':
|
|
159
|
-
currentIndex += 1;
|
|
160
|
-
break;
|
|
161
|
-
case 'Home':
|
|
162
|
-
currentIndex = 0;
|
|
163
|
-
break;
|
|
164
|
-
case 'End':
|
|
165
|
-
currentIndex = this._messages.length - 1;
|
|
166
|
-
break;
|
|
167
|
-
default:
|
|
168
|
-
return; // Nothing to do
|
|
169
|
-
}
|
|
170
|
-
if (currentIndex < 0) {
|
|
171
|
-
currentIndex = this._messages.length - 1;
|
|
172
|
-
}
|
|
173
|
-
if (currentIndex > this._messages.length - 1) {
|
|
174
|
-
currentIndex = 0;
|
|
175
|
-
}
|
|
176
|
-
this._focus(currentIndex);
|
|
177
|
-
event.preventDefault();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @param {number} idx
|
|
182
|
-
* @protected
|
|
183
|
-
*/
|
|
184
|
-
_focus(idx) {
|
|
185
|
-
const target = this._messages[idx];
|
|
186
|
-
target.focus();
|
|
187
|
-
}
|
|
188
|
-
|
|
154
|
+
/** @private */
|
|
189
155
|
_handleFocusEvent(e) {
|
|
190
156
|
const target = e.composedPath().find((node) => node instanceof Message);
|
|
191
157
|
this._setTabIndexesByMessage(target);
|
|
@@ -200,12 +166,14 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
200
166
|
this._setTabIndexesByMessage(message);
|
|
201
167
|
}
|
|
202
168
|
|
|
169
|
+
/** @private */
|
|
203
170
|
_setTabIndexesByMessage(message) {
|
|
204
171
|
this._messages.forEach((e) => {
|
|
205
172
|
e.tabIndex = e === message ? 0 : -1;
|
|
206
173
|
});
|
|
207
174
|
}
|
|
208
175
|
|
|
176
|
+
/** @private */
|
|
209
177
|
_getIndexOfFocusableElement() {
|
|
210
178
|
const index = this._messages.findIndex((e) => e.tabIndex === 0);
|
|
211
179
|
return index !== -1 ? index : 0;
|
package/src/vaadin-message.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ declare class Message extends FocusMixin(ThemableMixin(ElementMixin(HTMLElement)
|
|
|
56
56
|
* It will be placed in the name part to indicate who has sent the message.
|
|
57
57
|
* It is also used as a tooltip for the avatar.
|
|
58
58
|
* Example: `message.userName = "Jessica Jacobs";`
|
|
59
|
+
* @attr {string} user-name
|
|
59
60
|
*/
|
|
60
61
|
userName: string | null | undefined;
|
|
61
62
|
|
|
@@ -64,6 +65,7 @@ declare class Message extends FocusMixin(ThemableMixin(ElementMixin(HTMLElement)
|
|
|
64
65
|
* The abbreviation will be passed on to avatar of the message.
|
|
65
66
|
* If the user does not have an avatar picture set with `userImg`, `userAbbr` will be shown in the avatar.
|
|
66
67
|
* Example: `message.userAbbr = "JJ";`
|
|
68
|
+
* @attr {string} user-abbr
|
|
67
69
|
*/
|
|
68
70
|
userAbbr: string | null | undefined;
|
|
69
71
|
|
|
@@ -71,6 +73,7 @@ declare class Message extends FocusMixin(ThemableMixin(ElementMixin(HTMLElement)
|
|
|
71
73
|
* An URL for a user image.
|
|
72
74
|
* The image will be used in the avatar component to show who has sent the message.
|
|
73
75
|
* Example: `message.userImg = "/static/img/avatar.jpg";`
|
|
76
|
+
* @attr {string} user-img
|
|
74
77
|
*/
|
|
75
78
|
userImg: string | null | undefined;
|
|
76
79
|
|
|
@@ -92,6 +95,7 @@ declare class Message extends FocusMixin(ThemableMixin(ElementMixin(HTMLElement)
|
|
|
92
95
|
* ```js
|
|
93
96
|
* message.userColorIndex = 1;
|
|
94
97
|
* ```
|
|
98
|
+
* @attr {number} user-color-index
|
|
95
99
|
*/
|
|
96
100
|
userColorIndex: number | null | undefined;
|
|
97
101
|
}
|
package/src/vaadin-message.js
CHANGED
|
@@ -67,6 +67,7 @@ class Message extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
|
67
67
|
* It will be placed in the name part to indicate who has sent the message.
|
|
68
68
|
* It is also used as a tooltip for the avatar.
|
|
69
69
|
* Example: `message.userName = "Jessica Jacobs";`
|
|
70
|
+
* @attr {string} user-name
|
|
70
71
|
*/
|
|
71
72
|
userName: {
|
|
72
73
|
type: String,
|
|
@@ -77,6 +78,7 @@ class Message extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
|
77
78
|
* The abbreviation will be passed on to avatar of the message.
|
|
78
79
|
* If the user does not have an avatar picture set with `userImg`, `userAbbr` will be shown in the avatar.
|
|
79
80
|
* Example: `message.userAbbr = "JJ";`
|
|
81
|
+
* @attr {string} user-abbr
|
|
80
82
|
*/
|
|
81
83
|
userAbbr: {
|
|
82
84
|
type: String,
|
|
@@ -86,6 +88,7 @@ class Message extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
|
86
88
|
* An URL for a user image.
|
|
87
89
|
* The image will be used in the avatar component to show who has sent the message.
|
|
88
90
|
* Example: `message.userImg = "/static/img/avatar.jpg";`
|
|
91
|
+
* @attr {string} user-img
|
|
89
92
|
*/
|
|
90
93
|
userImg: {
|
|
91
94
|
type: String,
|
|
@@ -109,6 +112,7 @@ class Message extends FocusMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
|
109
112
|
* ```js
|
|
110
113
|
* message.userColorIndex = 1;
|
|
111
114
|
* ```
|
|
115
|
+
* @attr {number} user-color-index
|
|
112
116
|
*/
|
|
113
117
|
userColorIndex: {
|
|
114
118
|
type: Number,
|
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-list",
|
|
4
|
-
"version": "23.
|
|
4
|
+
"version": "23.3.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-message",
|
|
11
|
-
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.
|
|
11
|
+
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-avatar).",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "time",
|
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": "23.
|
|
4
|
+
"version": "23.3.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",
|
|
19
|
-
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.
|
|
19
|
+
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha1/#/elements/vaadin-avatar).",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|