@vaadin/message-list 23.2.0-dev.8a7678b70 → 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/README.md +5 -5
- package/package.json +14 -8
- package/src/vaadin-message-list.d.ts +3 -2
- package/src/vaadin-message-list.js +23 -53
- package/src/vaadin-message.d.ts +5 -1
- package/src/vaadin-message.js +5 -1
- package/web-types.json +177 -0
- package/web-types.lit.json +76 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A web component that allows you to show a list of messages, for example, a chat log.
|
|
4
4
|
|
|
5
|
-
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/
|
|
5
|
+
[Documentation + Live Demo ↗](https://vaadin.com/docs/latest/components/message-list)
|
|
6
6
|
|
|
7
7
|
```html
|
|
8
8
|
<vaadin-message-list></vaadin-message-list>
|
|
@@ -11,12 +11,12 @@ A web component that allows you to show a list of messages, for example, a chat
|
|
|
11
11
|
{ userName: 'Alice', time: '8 Minutes ago', text: 'Lunch at the usual place?' },
|
|
12
12
|
{ userName: 'Bob', time: '6 Minutes ago', text: `Yeah, let's go together.` },
|
|
13
13
|
{ userName: 'Alice', time: '2 Minutes ago', text: 'Great! What about you, Charlie?' },
|
|
14
|
-
{ userName: 'Charlie', time: 'A few seconds ago', text: 'I will meet you there.' }
|
|
14
|
+
{ userName: 'Charlie', time: 'A few seconds ago', text: 'I will meet you there.' },
|
|
15
15
|
];
|
|
16
16
|
</script>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/message-list/screenshot.png" width="504" alt="Screenshot of vaadin-message-list">](https://vaadin.com/docs/latest/
|
|
19
|
+
[<img src="https://raw.githubusercontent.com/vaadin/web-components/master/packages/message-list/screenshot.png" width="504" alt="Screenshot of vaadin-message-list">](https://vaadin.com/docs/latest/components/message-list)
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
@@ -34,7 +34,7 @@ import '@vaadin/message-list';
|
|
|
34
34
|
|
|
35
35
|
## Themes
|
|
36
36
|
|
|
37
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/
|
|
37
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
38
38
|
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/message-list/vaadin-message-list.js) of the package uses the Lumo theme.
|
|
39
39
|
|
|
40
40
|
To use the Material theme, import the component from the `theme/material` folder:
|
|
@@ -57,7 +57,7 @@ import '@vaadin/message-list/src/vaadin-message-list.js';
|
|
|
57
57
|
|
|
58
58
|
## Contributing
|
|
59
59
|
|
|
60
|
-
Read the [contributing guide](https://vaadin.com/docs/latest/
|
|
60
|
+
Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
|
61
61
|
|
|
62
62
|
## License
|
|
63
63
|
|
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
|
},
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"src",
|
|
24
24
|
"theme",
|
|
25
25
|
"vaadin-*.d.ts",
|
|
26
|
-
"vaadin-*.js"
|
|
26
|
+
"vaadin-*.js",
|
|
27
|
+
"web-types.json",
|
|
28
|
+
"web-types.lit.json"
|
|
27
29
|
],
|
|
28
30
|
"keywords": [
|
|
29
31
|
"Vaadin",
|
|
@@ -36,16 +38,20 @@
|
|
|
36
38
|
],
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/avatar": "23.
|
|
40
|
-
"@vaadin/component-base": "23.
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "23.
|
|
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"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
47
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
48
50
|
"sinon": "^13.0.2"
|
|
49
51
|
},
|
|
50
|
-
"
|
|
52
|
+
"web-types": [
|
|
53
|
+
"web-types.json",
|
|
54
|
+
"web-types.lit.json"
|
|
55
|
+
],
|
|
56
|
+
"gitHead": "beabc527d4b1274eb798ff701d406fed45cfe638"
|
|
51
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 {
|
|
@@ -41,9 +42,9 @@ export interface MessageListItem {
|
|
|
41
42
|
* ----------|----------------
|
|
42
43
|
* `list` | The container wrapping messages.
|
|
43
44
|
*
|
|
44
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
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
|
|
|
@@ -35,13 +36,14 @@ import { Message } from './vaadin-message.js';
|
|
|
35
36
|
* ----------|----------------
|
|
36
37
|
* `list` | The container wrapping messages.
|
|
37
38
|
*
|
|
38
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
39
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
39
40
|
*
|
|
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,10 +166,14 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
200
166
|
this._setTabIndexesByMessage(message);
|
|
201
167
|
}
|
|
202
168
|
|
|
169
|
+
/** @private */
|
|
203
170
|
_setTabIndexesByMessage(message) {
|
|
204
|
-
this._messages.forEach((e) =>
|
|
171
|
+
this._messages.forEach((e) => {
|
|
172
|
+
e.tabIndex = e === message ? 0 : -1;
|
|
173
|
+
});
|
|
205
174
|
}
|
|
206
175
|
|
|
176
|
+
/** @private */
|
|
207
177
|
_getIndexOfFocusableElement() {
|
|
208
178
|
const index = this._messages.findIndex((e) => e.tabIndex === 0);
|
|
209
179
|
return index !== -1 ? index : 0;
|
package/src/vaadin-message.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
35
35
|
* `focus-ring` | Set when the message is focused using the keyboard.
|
|
36
36
|
* `focused` | Set when the message is focused.
|
|
37
37
|
*
|
|
38
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
38
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
39
39
|
*
|
|
40
40
|
* ### Internal components
|
|
41
41
|
*
|
|
@@ -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
|
@@ -37,7 +37,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
37
37
|
* `focus-ring` | Set when the message is focused using the keyboard.
|
|
38
38
|
* `focused` | Set when the message is focused.
|
|
39
39
|
*
|
|
40
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
40
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
41
41
|
*
|
|
42
42
|
* ### Internal components
|
|
43
43
|
*
|
|
@@ -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
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/web-types",
|
|
3
|
+
"name": "@vaadin/message-list",
|
|
4
|
+
"version": "23.3.0-alpha1",
|
|
5
|
+
"description-markup": "markdown",
|
|
6
|
+
"contributions": {
|
|
7
|
+
"html": {
|
|
8
|
+
"elements": [
|
|
9
|
+
{
|
|
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.3.0-alpha1/#/elements/vaadin-avatar).",
|
|
12
|
+
"attributes": [
|
|
13
|
+
{
|
|
14
|
+
"name": "time",
|
|
15
|
+
"description": "Time of sending the message. It is rendered as-is to the part='time' slot,\nso the formatting is up to you.",
|
|
16
|
+
"value": {
|
|
17
|
+
"type": [
|
|
18
|
+
"string",
|
|
19
|
+
"null",
|
|
20
|
+
"undefined"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "user-name",
|
|
26
|
+
"description": "The name of the user posting the message.\nIt will be placed in the name part to indicate who has sent the message.\nIt is also used as a tooltip for the avatar.\nExample: `message.userName = \"Jessica Jacobs\";`",
|
|
27
|
+
"value": {
|
|
28
|
+
"type": [
|
|
29
|
+
"string",
|
|
30
|
+
"null",
|
|
31
|
+
"undefined"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "user-abbr",
|
|
37
|
+
"description": "The abbreviation of the user.\nThe abbreviation will be passed on to avatar of the message.\nIf the user does not have an avatar picture set with `userImg`, `userAbbr` will be shown in the avatar.\nExample: `message.userAbbr = \"JJ\";`",
|
|
38
|
+
"value": {
|
|
39
|
+
"type": [
|
|
40
|
+
"string",
|
|
41
|
+
"null",
|
|
42
|
+
"undefined"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "user-img",
|
|
48
|
+
"description": "An URL for a user image.\nThe image will be used in the avatar component to show who has sent the message.\nExample: `message.userImg = \"/static/img/avatar.jpg\";`",
|
|
49
|
+
"value": {
|
|
50
|
+
"type": [
|
|
51
|
+
"string",
|
|
52
|
+
"null",
|
|
53
|
+
"undefined"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "user-color-index",
|
|
59
|
+
"description": "A color index to be used to render the color of the avatar.\nWith no `userColorIndex` set, the basic avatar color will be used.\nBy setting a userColorIndex, the component will check if there exists a CSS variable defining the color, and uses it if there is one.\nIf now CSS variable is found for the color index, the property for the color will not be set.\n\nExample:\nCSS:\n```css\nhtml {\n --vaadin-user-color-1: red;\n}\n```\n\nJavaScript:\n```js\nmessage.userColorIndex = 1;\n```",
|
|
60
|
+
"value": {
|
|
61
|
+
"type": [
|
|
62
|
+
"number",
|
|
63
|
+
"null",
|
|
64
|
+
"undefined"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "theme",
|
|
70
|
+
"description": "The theme variants to apply to the component.",
|
|
71
|
+
"value": {
|
|
72
|
+
"type": [
|
|
73
|
+
"string",
|
|
74
|
+
"null",
|
|
75
|
+
"undefined"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"js": {
|
|
81
|
+
"properties": [
|
|
82
|
+
{
|
|
83
|
+
"name": "time",
|
|
84
|
+
"description": "Time of sending the message. It is rendered as-is to the part='time' slot,\nso the formatting is up to you.",
|
|
85
|
+
"value": {
|
|
86
|
+
"type": [
|
|
87
|
+
"string",
|
|
88
|
+
"null",
|
|
89
|
+
"undefined"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "userName",
|
|
95
|
+
"description": "The name of the user posting the message.\nIt will be placed in the name part to indicate who has sent the message.\nIt is also used as a tooltip for the avatar.\nExample: `message.userName = \"Jessica Jacobs\";`",
|
|
96
|
+
"value": {
|
|
97
|
+
"type": [
|
|
98
|
+
"string",
|
|
99
|
+
"null",
|
|
100
|
+
"undefined"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "userAbbr",
|
|
106
|
+
"description": "The abbreviation of the user.\nThe abbreviation will be passed on to avatar of the message.\nIf the user does not have an avatar picture set with `userImg`, `userAbbr` will be shown in the avatar.\nExample: `message.userAbbr = \"JJ\";`",
|
|
107
|
+
"value": {
|
|
108
|
+
"type": [
|
|
109
|
+
"string",
|
|
110
|
+
"null",
|
|
111
|
+
"undefined"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "userImg",
|
|
117
|
+
"description": "An URL for a user image.\nThe image will be used in the avatar component to show who has sent the message.\nExample: `message.userImg = \"/static/img/avatar.jpg\";`",
|
|
118
|
+
"value": {
|
|
119
|
+
"type": [
|
|
120
|
+
"string",
|
|
121
|
+
"null",
|
|
122
|
+
"undefined"
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "userColorIndex",
|
|
128
|
+
"description": "A color index to be used to render the color of the avatar.\nWith no `userColorIndex` set, the basic avatar color will be used.\nBy setting a userColorIndex, the component will check if there exists a CSS variable defining the color, and uses it if there is one.\nIf now CSS variable is found for the color index, the property for the color will not be set.\n\nExample:\nCSS:\n```css\nhtml {\n --vaadin-user-color-1: red;\n}\n```\n\nJavaScript:\n```js\nmessage.userColorIndex = 1;\n```",
|
|
129
|
+
"value": {
|
|
130
|
+
"type": [
|
|
131
|
+
"number",
|
|
132
|
+
"null",
|
|
133
|
+
"undefined"
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"events": []
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
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\nTo create a new message list, add the component to the page:\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the `items` property.\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 [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
144
|
+
"attributes": [
|
|
145
|
+
{
|
|
146
|
+
"name": "theme",
|
|
147
|
+
"description": "The theme variants to apply to the component.",
|
|
148
|
+
"value": {
|
|
149
|
+
"type": [
|
|
150
|
+
"string",
|
|
151
|
+
"null",
|
|
152
|
+
"undefined"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"js": {
|
|
158
|
+
"properties": [
|
|
159
|
+
{
|
|
160
|
+
"name": "items",
|
|
161
|
+
"description": "An array of objects which will be rendered as messages.\nThe message objects can have the following properties:\n```js\nArray<{\n text: string,\n time: string,\n userName: string,\n userAbbr: string,\n userImg: string,\n userColorIndex: number,\n theme: string\n}>\n```",
|
|
162
|
+
"value": {
|
|
163
|
+
"type": [
|
|
164
|
+
"Array",
|
|
165
|
+
"null",
|
|
166
|
+
"undefined"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"events": []
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/web-types",
|
|
3
|
+
"name": "@vaadin/message-list",
|
|
4
|
+
"version": "23.3.0-alpha1",
|
|
5
|
+
"description-markup": "markdown",
|
|
6
|
+
"framework": "lit",
|
|
7
|
+
"framework-config": {
|
|
8
|
+
"enable-when": {
|
|
9
|
+
"node-packages": [
|
|
10
|
+
"lit"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"contributions": {
|
|
15
|
+
"html": {
|
|
16
|
+
"elements": [
|
|
17
|
+
{
|
|
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.3.0-alpha1/#/elements/vaadin-avatar).",
|
|
20
|
+
"extension": true,
|
|
21
|
+
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": ".time",
|
|
24
|
+
"description": "Time of sending the message. It is rendered as-is to the part='time' slot,\nso the formatting is up to you.",
|
|
25
|
+
"value": {
|
|
26
|
+
"kind": "expression"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": ".userName",
|
|
31
|
+
"description": "The name of the user posting the message.\nIt will be placed in the name part to indicate who has sent the message.\nIt is also used as a tooltip for the avatar.\nExample: `message.userName = \"Jessica Jacobs\";`",
|
|
32
|
+
"value": {
|
|
33
|
+
"kind": "expression"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": ".userAbbr",
|
|
38
|
+
"description": "The abbreviation of the user.\nThe abbreviation will be passed on to avatar of the message.\nIf the user does not have an avatar picture set with `userImg`, `userAbbr` will be shown in the avatar.\nExample: `message.userAbbr = \"JJ\";`",
|
|
39
|
+
"value": {
|
|
40
|
+
"kind": "expression"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": ".userImg",
|
|
45
|
+
"description": "An URL for a user image.\nThe image will be used in the avatar component to show who has sent the message.\nExample: `message.userImg = \"/static/img/avatar.jpg\";`",
|
|
46
|
+
"value": {
|
|
47
|
+
"kind": "expression"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": ".userColorIndex",
|
|
52
|
+
"description": "A color index to be used to render the color of the avatar.\nWith no `userColorIndex` set, the basic avatar color will be used.\nBy setting a userColorIndex, the component will check if there exists a CSS variable defining the color, and uses it if there is one.\nIf now CSS variable is found for the color index, the property for the color will not be set.\n\nExample:\nCSS:\n```css\nhtml {\n --vaadin-user-color-1: red;\n}\n```\n\nJavaScript:\n```js\nmessage.userColorIndex = 1;\n```",
|
|
53
|
+
"value": {
|
|
54
|
+
"kind": "expression"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
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\nTo create a new message list, add the component to the page:\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the `items` property.\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 [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
62
|
+
"extension": true,
|
|
63
|
+
"attributes": [
|
|
64
|
+
{
|
|
65
|
+
"name": ".items",
|
|
66
|
+
"description": "An array of objects which will be rendered as messages.\nThe message objects can have the following properties:\n```js\nArray<{\n text: string,\n time: string,\n userName: string,\n userAbbr: string,\n userImg: string,\n userColorIndex: number,\n theme: string\n}>\n```",
|
|
67
|
+
"value": {
|
|
68
|
+
"kind": "expression"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|