@vaadin/message-list 25.3.0-alpha9 → 25.3.0-beta2
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/custom-elements.json +6 -6
- package/package.json +11 -11
- package/src/styles/vaadin-message-base-styles.js +7 -0
- package/src/styles/vaadin-message-list-base-styles.d.ts +8 -0
- package/src/styles/vaadin-message-list-base-styles.js +72 -0
- package/src/vaadin-message-list-mixin.js +36 -14
- package/src/vaadin-message-list.d.ts +17 -1
- package/src/vaadin-message-list.js +38 -21
- package/src/vaadin-message-mixin.d.ts +1 -0
- package/src/vaadin-message-mixin.js +15 -0
- package/src/vaadin-message.d.ts +15 -0
- package/src/vaadin-message.js +15 -0
- package/web-types.json +5 -5
- package/web-types.lit.json +4 -4
package/custom-elements.json
CHANGED
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"declarations": [
|
|
137
137
|
{
|
|
138
138
|
"kind": "class",
|
|
139
|
-
"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`](#/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>`](#/elements/vaadin-message) documentation for the available\
|
|
139
|
+
"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`](#/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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:--------------------------------- |\n`--vaadin-message-list-max-width` |\n`--vaadin-message-list-padding` |\n\n### Built-in Theme Variants\n\n`<vaadin-message-list>` supports the following theme variants:\n\nTheme variant | Description\n---------------------|---------------\n`theme=\"bubble\"` | Shows the messages as chat bubbles\n`theme=\"one-to-one\"` | Hides the avatar and name of every message, for a chat between two participants. Works together with `bubble`\n\nSee the [`<vaadin-message>`](#/elements/vaadin-message) documentation for the available\ntheme variants, state attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
140
140
|
"name": "MessageList",
|
|
141
141
|
"members": [
|
|
142
142
|
{
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
"type": {
|
|
328
328
|
"text": "number"
|
|
329
329
|
},
|
|
330
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
330
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
331
331
|
"attribute": "user-color-index"
|
|
332
332
|
},
|
|
333
333
|
{
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
"type": {
|
|
382
382
|
"text": "number"
|
|
383
383
|
},
|
|
384
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
384
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
385
385
|
"fieldName": "userColorIndex"
|
|
386
386
|
},
|
|
387
387
|
{
|
|
@@ -431,7 +431,7 @@
|
|
|
431
431
|
"declarations": [
|
|
432
432
|
{
|
|
433
433
|
"kind": "class",
|
|
434
|
-
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
434
|
+
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-attachments-alignment` |\n`--vaadin-message-content-background` |\n`--vaadin-message-content-border-radius` |\n`--vaadin-message-content-padding` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n`--vaadin-message-user-color` |\n\n### Built-in Theme Variants\n\n`<vaadin-message>` supports the following theme variants. Both of them require the parent\n[`<vaadin-message-list>`](#/elements/vaadin-message-list) to use `theme=\"bubble\"`:\n\nTheme variant | Description\n----------------------|---------------\n`theme=\"self\"` | Shows the message as sent by the current user, hides the avatar and name\n`theme=\"full-width\"` | Removes the bubble and the width restriction, for an assistant or AI response\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
435
435
|
"name": "Message",
|
|
436
436
|
"members": [
|
|
437
437
|
{
|
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
"type": {
|
|
484
484
|
"text": "number"
|
|
485
485
|
},
|
|
486
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
486
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
487
487
|
"attribute": "user-color-index",
|
|
488
488
|
"inheritedFrom": {
|
|
489
489
|
"name": "MessageMixin",
|
|
@@ -569,7 +569,7 @@
|
|
|
569
569
|
"type": {
|
|
570
570
|
"text": "number"
|
|
571
571
|
},
|
|
572
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
572
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
573
573
|
"fieldName": "userColorIndex",
|
|
574
574
|
"inheritedFrom": {
|
|
575
575
|
"name": "MessageMixin",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/message-list",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/a11y-base": "25.3.0-
|
|
41
|
-
"@vaadin/avatar": "25.3.0-
|
|
42
|
-
"@vaadin/component-base": "25.3.0-
|
|
43
|
-
"@vaadin/markdown": "25.3.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
40
|
+
"@vaadin/a11y-base": "25.3.0-beta2",
|
|
41
|
+
"@vaadin/avatar": "25.3.0-beta2",
|
|
42
|
+
"@vaadin/component-base": "25.3.0-beta2",
|
|
43
|
+
"@vaadin/markdown": "25.3.0-beta2",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-beta2",
|
|
45
45
|
"lit": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vaadin/aura": "25.3.0-
|
|
49
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
50
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
48
|
+
"@vaadin/aura": "25.3.0-beta2",
|
|
49
|
+
"@vaadin/chai-plugins": "25.3.0-beta2",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.3.0-beta2",
|
|
51
51
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-beta2",
|
|
53
53
|
"sinon": "^22.0.0"
|
|
54
54
|
},
|
|
55
55
|
"customElements": "custom-elements.json",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"web-types.json",
|
|
58
58
|
"web-types.lit.json"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "d97ccbec217b60c39f3c8b2dd52473c79a48c8c1"
|
|
61
61
|
}
|
|
@@ -10,6 +10,7 @@ export const messageStyles = css`
|
|
|
10
10
|
:host {
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: row;
|
|
13
|
+
box-sizing: border-box;
|
|
13
14
|
padding: var(--vaadin-message-padding, var(--vaadin-padding-s) var(--vaadin-padding-m));
|
|
14
15
|
gap: var(--vaadin-message-gap, var(--vaadin-gap-xs) var(--vaadin-gap-s));
|
|
15
16
|
outline-offset: calc(var(--vaadin-focus-ring-width) * -1);
|
|
@@ -29,6 +30,9 @@ export const messageStyles = css`
|
|
|
29
30
|
flex-direction: column;
|
|
30
31
|
flex-grow: 1;
|
|
31
32
|
gap: inherit;
|
|
33
|
+
background: var(--vaadin-message-content-background, transparent);
|
|
34
|
+
padding: var(--vaadin-message-content-padding, 0);
|
|
35
|
+
border-radius: var(--vaadin-message-content-border-radius, 0);
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
[part='header'] {
|
|
@@ -62,6 +66,8 @@ export const messageStyles = css`
|
|
|
62
66
|
|
|
63
67
|
::slotted([slot='avatar']) {
|
|
64
68
|
flex: none;
|
|
69
|
+
visibility: var(--_vaadin-message-avatar-visibility, revert-layer);
|
|
70
|
+
display: var(--_vaadin-message-avatar-display, revert-layer);
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
::slotted(vaadin-markdown) {
|
|
@@ -73,6 +79,7 @@ export const messageStyles = css`
|
|
|
73
79
|
flex-wrap: wrap;
|
|
74
80
|
gap: var(--vaadin-gap-s);
|
|
75
81
|
padding-bottom: var(--vaadin-gap-xs);
|
|
82
|
+
justify-content: var(--vaadin-message-attachments-alignment, start);
|
|
76
83
|
}
|
|
77
84
|
|
|
78
85
|
[part~='attachment'] {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/component-base/src/styles/style-props.js';
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
|
|
9
|
+
export const messageListStyles = css`
|
|
10
|
+
:host {
|
|
11
|
+
display: block;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
padding: var(--vaadin-message-list-padding, var(--vaadin-padding-xs) 0);
|
|
15
|
+
scroll-padding: var(--vaadin-message-list-padding, var(--vaadin-padding-xs) 0);
|
|
16
|
+
scroll-snap-type: y proximity;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([hidden]) {
|
|
20
|
+
display: none !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part='list'] {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
width: 100%;
|
|
28
|
+
min-height: 100%;
|
|
29
|
+
max-width: var(--vaadin-message-list-max-width, none);
|
|
30
|
+
margin-inline: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part='list']::after {
|
|
34
|
+
content: '';
|
|
35
|
+
display: block;
|
|
36
|
+
scroll-snap-align: var(--_vaadin-message-list-scroll-snap-align, none);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([theme~='bubble']) {
|
|
40
|
+
& ::slotted(vaadin-message) {
|
|
41
|
+
--vaadin-message-name-font-size: 0.9em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& ::slotted(vaadin-message[theme~='full-width']) {
|
|
45
|
+
padding-block: var(--vaadin-padding-xl);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
& ::slotted(vaadin-message:not([theme~='full-width'])) {
|
|
49
|
+
--vaadin-message-content-background: var(--vaadin-background-container);
|
|
50
|
+
--vaadin-message-content-padding: var(--vaadin-padding-s) var(--vaadin-padding-m);
|
|
51
|
+
--vaadin-message-content-border-radius: var(--vaadin-radius-l);
|
|
52
|
+
|
|
53
|
+
width: fit-content;
|
|
54
|
+
max-width: calc(100% - 2em);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
& ::slotted(vaadin-message[theme~='self']) {
|
|
58
|
+
--_vaadin-message-avatar-visibility: hidden;
|
|
59
|
+
--vaadin-message-content-background: linear-gradient(
|
|
60
|
+
color-mix(in srgb, var(--vaadin-message-user-color, var(--vaadin-user-color-0)) 10%, transparent)
|
|
61
|
+
)
|
|
62
|
+
var(--vaadin-background-color);
|
|
63
|
+
--vaadin-message-attachments-alignment: end;
|
|
64
|
+
align-items: end;
|
|
65
|
+
align-self: end;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:host([theme~='bubble'][theme~='one-to-one']) ::slotted(vaadin-message) {
|
|
70
|
+
--_vaadin-message-avatar-display: none;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
@@ -42,7 +42,6 @@ export const MessageListMixin = (superClass) =>
|
|
|
42
42
|
items: {
|
|
43
43
|
type: Array,
|
|
44
44
|
value: () => [],
|
|
45
|
-
observer: '_itemsChanged',
|
|
46
45
|
sync: true,
|
|
47
46
|
},
|
|
48
47
|
|
|
@@ -51,7 +50,6 @@ export const MessageListMixin = (superClass) =>
|
|
|
51
50
|
*/
|
|
52
51
|
markdown: {
|
|
53
52
|
type: Boolean,
|
|
54
|
-
observer: '__markdownChanged',
|
|
55
53
|
reflectToAttribute: true,
|
|
56
54
|
},
|
|
57
55
|
|
|
@@ -82,6 +80,19 @@ export const MessageListMixin = (superClass) =>
|
|
|
82
80
|
this.setAttribute('role', 'region');
|
|
83
81
|
}
|
|
84
82
|
|
|
83
|
+
/** @protected */
|
|
84
|
+
updated(props) {
|
|
85
|
+
super.updated(props);
|
|
86
|
+
|
|
87
|
+
if (props.has('items')) {
|
|
88
|
+
this._itemsChanged(this.items, props.get('items'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (props.has('markdown')) {
|
|
92
|
+
this.__markdownChanged(this.markdown);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
/**
|
|
86
97
|
* Handles attachment-click events from child messages and dispatches
|
|
87
98
|
* a new event enriched with the item.
|
|
@@ -142,12 +153,25 @@ export const MessageListMixin = (superClass) =>
|
|
|
142
153
|
this.__enableScrollSnapping();
|
|
143
154
|
}
|
|
144
155
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
if (items.length > oldItems.length && closeToBottom) {
|
|
157
|
+
this.__scrollToLastMessagePending = true;
|
|
158
|
+
this.__flushScrollToLastMessage();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Scrolls to the last message, unless the markdown component is still loading,
|
|
165
|
+
* in which case the final height of the messages is not yet known.
|
|
166
|
+
* @private
|
|
167
|
+
*/
|
|
168
|
+
__flushScrollToLastMessage() {
|
|
169
|
+
if (!this.__scrollToLastMessagePending || (this.markdown && !customElements.get('vaadin-markdown'))) {
|
|
170
|
+
return;
|
|
150
171
|
}
|
|
172
|
+
|
|
173
|
+
this.__scrollToLastMessagePending = false;
|
|
174
|
+
requestAnimationFrame(() => this._scrollToLastMessage());
|
|
151
175
|
}
|
|
152
176
|
|
|
153
177
|
/** @private */
|
|
@@ -157,17 +181,14 @@ export const MessageListMixin = (superClass) =>
|
|
|
157
181
|
import('@vaadin/markdown/src/vaadin-markdown.js')
|
|
158
182
|
// Wait until the component is defined
|
|
159
183
|
.then(() => customElements.whenDefined('vaadin-markdown'))
|
|
160
|
-
//
|
|
161
|
-
.then(() => this.
|
|
184
|
+
// The messages grow once the markdown content is rendered
|
|
185
|
+
.then(() => this.__flushScrollToLastMessage());
|
|
162
186
|
}
|
|
163
187
|
this._renderMessages(this.items);
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
/** @private */
|
|
167
191
|
_renderMessages(items) {
|
|
168
|
-
// Check if markdown component is still loading
|
|
169
|
-
const loadingMarkdown = this.markdown && !customElements.get('vaadin-markdown');
|
|
170
|
-
|
|
171
192
|
render(
|
|
172
193
|
html`
|
|
173
194
|
${items.map(
|
|
@@ -184,9 +205,10 @@ export const MessageListMixin = (superClass) =>
|
|
|
184
205
|
class="${ifDefined(item.className)}"
|
|
185
206
|
@focusin="${this._onMessageFocusIn}"
|
|
186
207
|
@attachment-click="${(e) => this.__onAttachmentClick(e, item)}"
|
|
187
|
-
style="${ifDefined(loadingMarkdown ? 'visibility: hidden' : undefined)}"
|
|
188
208
|
>${
|
|
189
|
-
this.markdown
|
|
209
|
+
this.markdown
|
|
210
|
+
? html`<vaadin-markdown .content=${item.text} line-breaks></vaadin-markdown>`
|
|
211
|
+
: item.text
|
|
190
212
|
}<vaadin-avatar slot="avatar"></vaadin-avatar
|
|
191
213
|
></vaadin-message>
|
|
192
214
|
`,
|
|
@@ -47,8 +47,24 @@ export type MessageListEventMap = HTMLElementEventMap & {
|
|
|
47
47
|
* ----------|----------------
|
|
48
48
|
* `list` | The container wrapping messages.
|
|
49
49
|
*
|
|
50
|
+
* The following custom CSS properties are available for styling:
|
|
51
|
+
*
|
|
52
|
+
* Custom CSS property |
|
|
53
|
+
* :--------------------------------- |
|
|
54
|
+
* `--vaadin-message-list-max-width` |
|
|
55
|
+
* `--vaadin-message-list-padding` |
|
|
56
|
+
*
|
|
57
|
+
* ### Built-in Theme Variants
|
|
58
|
+
*
|
|
59
|
+
* `<vaadin-message-list>` supports the following theme variants:
|
|
60
|
+
*
|
|
61
|
+
* Theme variant | Description
|
|
62
|
+
* ---------------------|---------------
|
|
63
|
+
* `theme="bubble"` | Shows the messages as chat bubbles
|
|
64
|
+
* `theme="one-to-one"` | Hides the avatar and name of every message, for a chat between two participants. Works together with `bubble`
|
|
65
|
+
*
|
|
50
66
|
* See the [`<vaadin-message>`](#/elements/vaadin-message) documentation for the available
|
|
51
|
-
* state attributes and stylable shadow parts of message elements.
|
|
67
|
+
* theme variants, state attributes and stylable shadow parts of message elements.
|
|
52
68
|
*
|
|
53
69
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
54
70
|
*
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-message.js';
|
|
7
|
-
import {
|
|
7
|
+
import { html, LitElement } from 'lit';
|
|
8
8
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
9
9
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
10
10
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
11
11
|
import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
|
|
12
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { messageListStyles } from './styles/vaadin-message-list-base-styles.js';
|
|
13
14
|
import { MessageListMixin } from './vaadin-message-list-mixin.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -40,8 +41,24 @@ import { MessageListMixin } from './vaadin-message-list-mixin.js';
|
|
|
40
41
|
* ----------|----------------
|
|
41
42
|
* `list` | The container wrapping messages.
|
|
42
43
|
*
|
|
44
|
+
* The following custom CSS properties are available for styling:
|
|
45
|
+
*
|
|
46
|
+
* Custom CSS property |
|
|
47
|
+
* :--------------------------------- |
|
|
48
|
+
* `--vaadin-message-list-max-width` |
|
|
49
|
+
* `--vaadin-message-list-padding` |
|
|
50
|
+
*
|
|
51
|
+
* ### Built-in Theme Variants
|
|
52
|
+
*
|
|
53
|
+
* `<vaadin-message-list>` supports the following theme variants:
|
|
54
|
+
*
|
|
55
|
+
* Theme variant | Description
|
|
56
|
+
* ---------------------|---------------
|
|
57
|
+
* `theme="bubble"` | Shows the messages as chat bubbles
|
|
58
|
+
* `theme="one-to-one"` | Hides the avatar and name of every message, for a chat between two participants. Works together with `bubble`
|
|
59
|
+
*
|
|
43
60
|
* See the [`<vaadin-message>`](#/elements/vaadin-message) documentation for the available
|
|
44
|
-
* state attributes and stylable shadow parts of message elements.
|
|
61
|
+
* theme variants, state attributes and stylable shadow parts of message elements.
|
|
45
62
|
*
|
|
46
63
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
47
64
|
*
|
|
@@ -57,25 +74,7 @@ class MessageList extends SlotStylesMixin(MessageListMixin(ElementMixin(Themable
|
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
static get styles() {
|
|
60
|
-
return
|
|
61
|
-
:host {
|
|
62
|
-
display: block;
|
|
63
|
-
overflow: auto;
|
|
64
|
-
padding: var(--vaadin-message-list-padding, var(--vaadin-padding-xs) 0);
|
|
65
|
-
scroll-padding: var(--vaadin-message-list-padding, var(--vaadin-padding-xs) 0);
|
|
66
|
-
scroll-snap-type: y proximity;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
:host([hidden]) {
|
|
70
|
-
display: none !important;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[part='list']::after {
|
|
74
|
-
content: '';
|
|
75
|
-
display: block;
|
|
76
|
-
scroll-snap-align: var(--_vaadin-message-list-scroll-snap-align, none);
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
77
|
+
return messageListStyles;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
/** @protected */
|
|
@@ -92,6 +91,10 @@ class MessageList extends SlotStylesMixin(MessageListMixin(ElementMixin(Themable
|
|
|
92
91
|
const tag = this.localName;
|
|
93
92
|
return [
|
|
94
93
|
`
|
|
94
|
+
${tag} vaadin-message:has(> vaadin-markdown:not(:defined)) {
|
|
95
|
+
visibility: hidden;
|
|
96
|
+
}
|
|
97
|
+
|
|
95
98
|
${tag} :where(vaadin-markdown > :is(h1, h2, h3, h4, h5, h6, p, ul, ol):first-child) {
|
|
96
99
|
margin-top: 0;
|
|
97
100
|
}
|
|
@@ -99,6 +102,20 @@ class MessageList extends SlotStylesMixin(MessageListMixin(ElementMixin(Themable
|
|
|
99
102
|
${tag} :where(vaadin-markdown > :is(h1, h2, h3, h4, h5, h6, p, ul, ol):last-child) {
|
|
100
103
|
margin-bottom: 0;
|
|
101
104
|
}
|
|
105
|
+
|
|
106
|
+
${tag}[theme~='bubble'] :where(vaadin-message[theme~='self'])::part(name),
|
|
107
|
+
${tag}[theme~='bubble'][theme~='one-to-one'] :where(vaadin-message)::part(name) {
|
|
108
|
+
border: 0 !important;
|
|
109
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
110
|
+
clip-path: inset(50%) !important;
|
|
111
|
+
height: 1px !important;
|
|
112
|
+
margin: -1px !important;
|
|
113
|
+
overflow: hidden !important;
|
|
114
|
+
padding: 0 !important;
|
|
115
|
+
position: absolute !important;
|
|
116
|
+
width: 1px !important;
|
|
117
|
+
white-space: nowrap !important;
|
|
118
|
+
}
|
|
102
119
|
`,
|
|
103
120
|
];
|
|
104
121
|
}
|
|
@@ -54,6 +54,7 @@ export const MessageMixin = (superClass) =>
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* A color index to be used to render the color of the avatar.
|
|
57
|
+
* Also sets `--vaadin-message-user-color` custom CSS property.
|
|
57
58
|
*
|
|
58
59
|
* @attr {number} user-color-index
|
|
59
60
|
*/
|
|
@@ -101,6 +102,20 @@ export const MessageMixin = (superClass) =>
|
|
|
101
102
|
this.addController(this._avatarController);
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
/** @protected */
|
|
106
|
+
updated(props) {
|
|
107
|
+
super.updated(props);
|
|
108
|
+
|
|
109
|
+
if (props.has('userColorIndex')) {
|
|
110
|
+
const index = this.userColorIndex;
|
|
111
|
+
if (index != null) {
|
|
112
|
+
this.style.setProperty('--vaadin-message-user-color', `var(--vaadin-user-color-${index})`);
|
|
113
|
+
} else {
|
|
114
|
+
this.style.removeProperty('--vaadin-message-user-color');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
104
119
|
/** @private */
|
|
105
120
|
__avatarChanged(avatar, userName, userAbbr, userImg, userColorIndex) {
|
|
106
121
|
if (avatar) {
|
package/src/vaadin-message.d.ts
CHANGED
|
@@ -65,6 +65,10 @@ export type MessageEventMap = HTMLElementEventMap & {
|
|
|
65
65
|
* `--vaadin-message-attachment-line-height` |
|
|
66
66
|
* `--vaadin-message-attachment-padding` |
|
|
67
67
|
* `--vaadin-message-attachment-text-color` |
|
|
68
|
+
* `--vaadin-message-attachments-alignment` |
|
|
69
|
+
* `--vaadin-message-content-background` |
|
|
70
|
+
* `--vaadin-message-content-border-radius` |
|
|
71
|
+
* `--vaadin-message-content-padding` |
|
|
68
72
|
* `--vaadin-message-font-size` |
|
|
69
73
|
* `--vaadin-message-font-weight` |
|
|
70
74
|
* `--vaadin-message-gap` |
|
|
@@ -78,6 +82,17 @@ export type MessageEventMap = HTMLElementEventMap & {
|
|
|
78
82
|
* `--vaadin-message-time-color` |
|
|
79
83
|
* `--vaadin-message-time-font-size` |
|
|
80
84
|
* `--vaadin-message-time-font-weight` |
|
|
85
|
+
* `--vaadin-message-user-color` |
|
|
86
|
+
*
|
|
87
|
+
* ### Built-in Theme Variants
|
|
88
|
+
*
|
|
89
|
+
* `<vaadin-message>` supports the following theme variants. Both of them require the parent
|
|
90
|
+
* [`<vaadin-message-list>`](#/elements/vaadin-message-list) to use `theme="bubble"`:
|
|
91
|
+
*
|
|
92
|
+
* Theme variant | Description
|
|
93
|
+
* ----------------------|---------------
|
|
94
|
+
* `theme="self"` | Shows the message as sent by the current user, hides the avatar and name
|
|
95
|
+
* `theme="full-width"` | Removes the bubble and the width restriction, for an assistant or AI response
|
|
81
96
|
*
|
|
82
97
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
83
98
|
*
|
package/src/vaadin-message.js
CHANGED
|
@@ -65,6 +65,10 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
65
65
|
* `--vaadin-message-attachment-line-height` |
|
|
66
66
|
* `--vaadin-message-attachment-padding` |
|
|
67
67
|
* `--vaadin-message-attachment-text-color` |
|
|
68
|
+
* `--vaadin-message-attachments-alignment` |
|
|
69
|
+
* `--vaadin-message-content-background` |
|
|
70
|
+
* `--vaadin-message-content-border-radius` |
|
|
71
|
+
* `--vaadin-message-content-padding` |
|
|
68
72
|
* `--vaadin-message-font-size` |
|
|
69
73
|
* `--vaadin-message-font-weight` |
|
|
70
74
|
* `--vaadin-message-gap` |
|
|
@@ -78,6 +82,17 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
78
82
|
* `--vaadin-message-time-color` |
|
|
79
83
|
* `--vaadin-message-time-font-size` |
|
|
80
84
|
* `--vaadin-message-time-font-weight` |
|
|
85
|
+
* `--vaadin-message-user-color` |
|
|
86
|
+
*
|
|
87
|
+
* ### Built-in Theme Variants
|
|
88
|
+
*
|
|
89
|
+
* `<vaadin-message>` supports the following theme variants. Both of them require the parent
|
|
90
|
+
* [`<vaadin-message-list>`](#/elements/vaadin-message-list) to use `theme="bubble"`:
|
|
91
|
+
*
|
|
92
|
+
* Theme variant | Description
|
|
93
|
+
* ----------------------|---------------
|
|
94
|
+
* `theme="self"` | Shows the message as sent by the current user, hides the avatar and name
|
|
95
|
+
* `theme="full-width"` | Removes the bubble and the width restriction, for an assistant or AI response
|
|
81
96
|
*
|
|
82
97
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
83
98
|
*
|
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": "25.3.0-
|
|
4
|
+
"version": "25.3.0-beta2",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-message-list",
|
|
11
|
-
"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/25.3.0-
|
|
11
|
+
"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/25.3.0-beta2/#/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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:--------------------------------- |\n`--vaadin-message-list-max-width` |\n`--vaadin-message-list-padding` |\n\n### Built-in Theme Variants\n\n`<vaadin-message-list>` supports the following theme variants:\n\nTheme variant | Description\n---------------------|---------------\n`theme=\"bubble\"` | Shows the messages as chat bubbles\n`theme=\"one-to-one\"` | Hides the avatar and name of every message, for a chat between two participants. Works together with `bubble`\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-beta2/#/elements/vaadin-message) documentation for the available\ntheme variants, state attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "announce-messages",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"name": "vaadin-message",
|
|
81
|
-
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
81
|
+
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-attachments-alignment` |\n`--vaadin-message-content-background` |\n`--vaadin-message-content-border-radius` |\n`--vaadin-message-content-padding` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n`--vaadin-message-user-color` |\n\n### Built-in Theme Variants\n\n`<vaadin-message>` supports the following theme variants. Both of them require the parent\n[`<vaadin-message-list>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-beta2/#/elements/vaadin-message-list) to use `theme=\"bubble\"`:\n\nTheme variant | Description\n----------------------|---------------\n`theme=\"self\"` | Shows the message as sent by the current user, hides the avatar and name\n`theme=\"full-width\"` | Removes the bubble and the width restriction, for an assistant or AI response\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
82
82
|
"attributes": [
|
|
83
83
|
{
|
|
84
84
|
"name": "theme",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"name": "user-color-index",
|
|
112
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
112
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
113
113
|
"value": {
|
|
114
114
|
"type": [
|
|
115
115
|
"number"
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
168
|
"name": "userColorIndex",
|
|
169
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
169
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
170
170
|
"value": {
|
|
171
171
|
"type": [
|
|
172
172
|
"number"
|
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": "25.3.0-
|
|
4
|
+
"version": "25.3.0-beta2",
|
|
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-list",
|
|
19
|
-
"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/25.3.0-
|
|
19
|
+
"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/25.3.0-beta2/#/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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:--------------------------------- |\n`--vaadin-message-list-max-width` |\n`--vaadin-message-list-padding` |\n\n### Built-in Theme Variants\n\n`<vaadin-message-list>` supports the following theme variants:\n\nTheme variant | Description\n---------------------|---------------\n`theme=\"bubble\"` | Shows the messages as chat bubbles\n`theme=\"one-to-one\"` | Hides the avatar and name of every message, for a chat between two participants. Works together with `bubble`\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-beta2/#/elements/vaadin-message) documentation for the available\ntheme variants, state attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"name": "vaadin-message",
|
|
54
|
-
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
54
|
+
"description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message\n time=\"2021-01-28 10:43\"\n user-name=\"Bob Ross\"\n user-abbr=\"BR\"\n user-img=\"/static/img/avatar.jpg\"\n>\n There is no real ending. It's just the place where you stop the story.\n</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n--------------------|----------------\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n`attachments` | Container for the attachments\n`attachment` | Individual attachment button\n`attachment-image` | Image attachment button (in addition to `attachment`)\n`attachment-file` | File attachment button (in addition to `attachment`)\n`attachment-preview`| Image preview inside an image attachment\n`attachment-icon` | File icon inside a file attachment\n`attachment-name` | File name inside a file attachment\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\nThe following custom CSS properties are available for styling:\n\nCustom CSS property |\n:------------------------------------------- |\n`--vaadin-message-attachment-background` |\n`--vaadin-message-attachment-border-color` |\n`--vaadin-message-attachment-border-radius` |\n`--vaadin-message-attachment-border-width` |\n`--vaadin-message-attachment-font-size` |\n`--vaadin-message-attachment-font-weight` |\n`--vaadin-message-attachment-gap` |\n`--vaadin-message-attachment-line-height` |\n`--vaadin-message-attachment-padding` |\n`--vaadin-message-attachment-text-color` |\n`--vaadin-message-attachments-alignment` |\n`--vaadin-message-content-background` |\n`--vaadin-message-content-border-radius` |\n`--vaadin-message-content-padding` |\n`--vaadin-message-font-size` |\n`--vaadin-message-font-weight` |\n`--vaadin-message-gap` |\n`--vaadin-message-header-line-height` |\n`--vaadin-message-line-height` |\n`--vaadin-message-name-color` |\n`--vaadin-message-name-font-size` |\n`--vaadin-message-name-font-weight` |\n`--vaadin-message-padding` |\n`--vaadin-message-text-color` |\n`--vaadin-message-time-color` |\n`--vaadin-message-time-font-size` |\n`--vaadin-message-time-font-weight` |\n`--vaadin-message-user-color` |\n\n### Built-in Theme Variants\n\n`<vaadin-message>` supports the following theme variants. Both of them require the parent\n[`<vaadin-message-list>`](https://cdn.vaadin.com/vaadin-web-components/25.3.0-beta2/#/elements/vaadin-message-list) to use `theme=\"bubble\"`:\n\nTheme variant | Description\n----------------------|---------------\n`theme=\"self\"` | Shows the message as sent by the current user, hides the avatar and name\n`theme=\"full-width\"` | Removes the bubble and the width restriction, for an assistant or AI response\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
55
55
|
"extension": true,
|
|
56
56
|
"attributes": [
|
|
57
57
|
{
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
"name": ".userColorIndex",
|
|
80
|
-
"description": "A color index to be used to render the color of the avatar.",
|
|
80
|
+
"description": "A color index to be used to render the color of the avatar.\nAlso sets `--vaadin-message-user-color` custom CSS property.",
|
|
81
81
|
"value": {
|
|
82
82
|
"kind": "expression"
|
|
83
83
|
}
|