@vaadin/message-list 25.1.0-alpha4 → 25.1.0-alpha6
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 +11 -11
- package/src/styles/vaadin-message-base-styles.js +46 -0
- package/src/vaadin-message-list-mixin.d.ts +20 -1
- package/src/vaadin-message-list-mixin.js +31 -1
- package/src/vaadin-message-list.d.ts +26 -3
- package/src/vaadin-message-list.js +2 -0
- package/src/vaadin-message-mixin.d.ts +23 -0
- package/src/vaadin-message-mixin.js +75 -0
- package/src/vaadin-message.d.ts +34 -7
- package/src/vaadin-message.js +15 -5
- package/web-types.json +15 -4
- package/web-types.lit.json +11 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/message-list",
|
|
3
|
-
"version": "25.1.0-
|
|
3
|
+
"version": "25.1.0-alpha6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@vaadin/a11y-base": "25.1.0-
|
|
40
|
-
"@vaadin/avatar": "25.1.0-
|
|
41
|
-
"@vaadin/component-base": "25.1.0-
|
|
42
|
-
"@vaadin/markdown": "25.1.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "25.1.0-
|
|
39
|
+
"@vaadin/a11y-base": "25.1.0-alpha6",
|
|
40
|
+
"@vaadin/avatar": "25.1.0-alpha6",
|
|
41
|
+
"@vaadin/component-base": "25.1.0-alpha6",
|
|
42
|
+
"@vaadin/markdown": "25.1.0-alpha6",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.1.0-alpha6",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/aura": "25.1.0-
|
|
48
|
-
"@vaadin/chai-plugins": "25.1.0-
|
|
49
|
-
"@vaadin/test-runner-commands": "25.1.0-
|
|
47
|
+
"@vaadin/aura": "25.1.0-alpha6",
|
|
48
|
+
"@vaadin/chai-plugins": "25.1.0-alpha6",
|
|
49
|
+
"@vaadin/test-runner-commands": "25.1.0-alpha6",
|
|
50
50
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
51
|
-
"@vaadin/vaadin-lumo-styles": "25.1.0-
|
|
51
|
+
"@vaadin/vaadin-lumo-styles": "25.1.0-alpha6",
|
|
52
52
|
"sinon": "^21.0.0"
|
|
53
53
|
},
|
|
54
54
|
"web-types": [
|
|
55
55
|
"web-types.json",
|
|
56
56
|
"web-types.lit.json"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "da6f4194492cbd77d18c6c1cd8d4d9f072e9ce8d"
|
|
59
59
|
}
|
|
@@ -66,4 +66,50 @@ export const messageStyles = css`
|
|
|
66
66
|
::slotted(vaadin-markdown) {
|
|
67
67
|
white-space: normal;
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
[part='attachments'] {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
gap: 6px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[part~='attachment'] {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
color: inherit;
|
|
80
|
+
background: none;
|
|
81
|
+
border: none;
|
|
82
|
+
padding: 0;
|
|
83
|
+
margin: 0;
|
|
84
|
+
font: inherit;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
text-align: start;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[part~='attachment-image'] [part='attachment-preview'] {
|
|
90
|
+
display: block;
|
|
91
|
+
max-width: 200px;
|
|
92
|
+
max-height: 150px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[part~='attachment-file'] {
|
|
96
|
+
gap: 6px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[part='attachment-icon'] {
|
|
100
|
+
display: inline-block;
|
|
101
|
+
width: 1em;
|
|
102
|
+
height: 1em;
|
|
103
|
+
background: currentColor;
|
|
104
|
+
mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg>');
|
|
105
|
+
mask-size: contain;
|
|
106
|
+
mask-repeat: no-repeat;
|
|
107
|
+
flex-shrink: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[part='attachment-name'] {
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
text-overflow: ellipsis;
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
}
|
|
69
115
|
`;
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { KeyboardDirectionMixinClass } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
|
|
8
|
+
import type { MessageAttachment, MessageAttachmentClickEvent } from './vaadin-message-mixin.js';
|
|
9
|
+
|
|
10
|
+
export { MessageAttachment, MessageAttachmentClickEvent };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Fired when an attachment is clicked in a message list item.
|
|
14
|
+
*/
|
|
15
|
+
export type MessageListAttachmentClickEvent = CustomEvent<{ attachment: MessageAttachment; item: MessageListItem }>;
|
|
8
16
|
|
|
9
17
|
export interface MessageListItem {
|
|
10
18
|
text?: string;
|
|
@@ -15,6 +23,7 @@ export interface MessageListItem {
|
|
|
15
23
|
userColorIndex?: number;
|
|
16
24
|
theme?: string;
|
|
17
25
|
className?: string;
|
|
26
|
+
attachments?: MessageAttachment[];
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
export declare function MessageListMixin<T extends Constructor<HTMLElement>>(
|
|
@@ -34,9 +43,19 @@ export declare class MessageListMixinClass {
|
|
|
34
43
|
* userImg: string,
|
|
35
44
|
* userColorIndex: number,
|
|
36
45
|
* className: string,
|
|
37
|
-
* theme: string
|
|
46
|
+
* theme: string,
|
|
47
|
+
* attachments: Array<{
|
|
48
|
+
* name: string,
|
|
49
|
+
* url: string,
|
|
50
|
+
* type: string
|
|
51
|
+
* }>
|
|
38
52
|
* }>
|
|
39
53
|
* ```
|
|
54
|
+
*
|
|
55
|
+
* When a message has attachments, they are rendered in the message's shadow DOM.
|
|
56
|
+
* Image attachments (type starting with "image/") show a thumbnail preview,
|
|
57
|
+
* while other attachments show a document icon with the file name.
|
|
58
|
+
* Clicking an attachment dispatches an `attachment-click` event.
|
|
40
59
|
*/
|
|
41
60
|
items: MessageListItem[] | null | undefined;
|
|
42
61
|
|
|
@@ -29,9 +29,19 @@ export const MessageListMixin = (superClass) =>
|
|
|
29
29
|
* userImg: string,
|
|
30
30
|
* userColorIndex: number,
|
|
31
31
|
* className: string,
|
|
32
|
-
* theme: string
|
|
32
|
+
* theme: string,
|
|
33
|
+
* attachments: Array<{
|
|
34
|
+
* name: string,
|
|
35
|
+
* url: string,
|
|
36
|
+
* type: string
|
|
37
|
+
* }>
|
|
33
38
|
* }>
|
|
34
39
|
* ```
|
|
40
|
+
*
|
|
41
|
+
* When a message has attachments, they are rendered in the message's shadow DOM.
|
|
42
|
+
* Image attachments (type starting with "image/") show a thumbnail preview,
|
|
43
|
+
* while other attachments show a document icon with the file name.
|
|
44
|
+
* Clicking an attachment dispatches an `attachment-click` event.
|
|
35
45
|
*/
|
|
36
46
|
items: {
|
|
37
47
|
type: Array,
|
|
@@ -78,6 +88,24 @@ export const MessageListMixin = (superClass) =>
|
|
|
78
88
|
this.setAttribute('role', 'region');
|
|
79
89
|
}
|
|
80
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Handles attachment-click events from child messages and dispatches
|
|
93
|
+
* a new event enriched with the item.
|
|
94
|
+
* @param {CustomEvent} e
|
|
95
|
+
* @param {Object} item
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
__onAttachmentClick(e, item) {
|
|
99
|
+
this.dispatchEvent(
|
|
100
|
+
new CustomEvent('attachment-click', {
|
|
101
|
+
detail: {
|
|
102
|
+
...e.detail,
|
|
103
|
+
item,
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
81
109
|
/**
|
|
82
110
|
* Override method inherited from `KeyboardDirectionMixin`
|
|
83
111
|
* to use the list of message elements as items.
|
|
@@ -142,9 +170,11 @@ export const MessageListMixin = (superClass) =>
|
|
|
142
170
|
.userName="${item.userName}"
|
|
143
171
|
.userImg="${item.userImg}"
|
|
144
172
|
.userColorIndex="${item.userColorIndex}"
|
|
173
|
+
.attachments="${item.attachments}"
|
|
145
174
|
theme="${ifDefined(item.theme)}"
|
|
146
175
|
class="${ifDefined(item.className)}"
|
|
147
176
|
@focusin="${this._onMessageFocusIn}"
|
|
177
|
+
@attachment-click="${(e) => this.__onAttachmentClick(e, item)}"
|
|
148
178
|
style="${ifDefined(loadingMarkdown ? 'visibility: hidden' : undefined)}"
|
|
149
179
|
>${this.markdown
|
|
150
180
|
? html`<vaadin-markdown .content=${item.text}></vaadin-markdown>`
|
|
@@ -6,9 +6,18 @@
|
|
|
6
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
7
|
import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin.js';
|
|
8
8
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
|
-
import { MessageListMixin } from './vaadin-message-list-mixin.js';
|
|
9
|
+
import { type MessageListAttachmentClickEvent, MessageListMixin } from './vaadin-message-list-mixin.js';
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
MessageAttachment,
|
|
13
|
+
MessageAttachmentClickEvent,
|
|
14
|
+
MessageListAttachmentClickEvent,
|
|
15
|
+
MessageListItem,
|
|
16
|
+
} from './vaadin-message-list-mixin.js';
|
|
17
|
+
|
|
18
|
+
export type MessageListEventMap = HTMLElementEventMap & {
|
|
19
|
+
'attachment-click': MessageListAttachmentClickEvent;
|
|
20
|
+
};
|
|
12
21
|
|
|
13
22
|
/**
|
|
14
23
|
* `<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>
|
|
@@ -42,8 +51,22 @@ export { MessageListItem } from './vaadin-message-list-mixin.js';
|
|
|
42
51
|
* state attributes and stylable shadow parts of message elements.
|
|
43
52
|
*
|
|
44
53
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
54
|
+
*
|
|
55
|
+
* @fires {CustomEvent} attachment-click - Fired when an attachment is clicked.
|
|
45
56
|
*/
|
|
46
|
-
declare class MessageList extends SlotStylesMixin(MessageListMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
|
|
57
|
+
declare class MessageList extends SlotStylesMixin(MessageListMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
|
|
58
|
+
addEventListener<K extends keyof MessageListEventMap>(
|
|
59
|
+
type: K,
|
|
60
|
+
listener: (this: MessageList, ev: MessageListEventMap[K]) => void,
|
|
61
|
+
options?: AddEventListenerOptions | boolean,
|
|
62
|
+
): void;
|
|
63
|
+
|
|
64
|
+
removeEventListener<K extends keyof MessageListEventMap>(
|
|
65
|
+
type: K,
|
|
66
|
+
listener: (this: MessageList, ev: MessageListEventMap[K]) => void,
|
|
67
|
+
options?: EventListenerOptions | boolean,
|
|
68
|
+
): void;
|
|
69
|
+
}
|
|
47
70
|
|
|
48
71
|
declare global {
|
|
49
72
|
interface HTMLElementTagNameMap {
|
|
@@ -45,6 +45,8 @@ import { MessageListMixin } from './vaadin-message-list-mixin.js';
|
|
|
45
45
|
*
|
|
46
46
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
47
47
|
*
|
|
48
|
+
* @fires {CustomEvent} attachment-click - Fired when an attachment is clicked.
|
|
49
|
+
*
|
|
48
50
|
* @customElement
|
|
49
51
|
* @extends HTMLElement
|
|
50
52
|
* @mixes ThemableMixin
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
8
8
|
|
|
9
|
+
export interface MessageAttachment {
|
|
10
|
+
name?: string;
|
|
11
|
+
url?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Fired when an attachment is clicked.
|
|
17
|
+
*/
|
|
18
|
+
export type MessageAttachmentClickEvent = CustomEvent<{ attachment: MessageAttachment }>;
|
|
19
|
+
|
|
9
20
|
export declare function MessageMixin<T extends Constructor<HTMLElement>>(
|
|
10
21
|
base: T,
|
|
11
22
|
): Constructor<FocusMixinClass> & Constructor<MessageMixinClass> & T;
|
|
@@ -64,4 +75,16 @@ export declare class MessageMixinClass {
|
|
|
64
75
|
* @attr {number} user-color-index
|
|
65
76
|
*/
|
|
66
77
|
userColorIndex: number | null | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An array of attachment objects to display with the message.
|
|
81
|
+
* Each attachment object can have the following properties:
|
|
82
|
+
* - `name`: The name of the attachment file
|
|
83
|
+
* - `url`: The URL of the attachment
|
|
84
|
+
* - `type`: The MIME type of the attachment (e.g., 'image/png', 'application/pdf')
|
|
85
|
+
*
|
|
86
|
+
* Image attachments (type starting with "image/") show a thumbnail preview,
|
|
87
|
+
* while other attachments show a document icon with the file name.
|
|
88
|
+
*/
|
|
89
|
+
attachments: MessageAttachment[] | null | undefined;
|
|
67
90
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 2026 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
8
|
import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
|
|
7
9
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
8
10
|
|
|
@@ -78,6 +80,22 @@ export const MessageMixin = (superClass) =>
|
|
|
78
80
|
type: Number,
|
|
79
81
|
},
|
|
80
82
|
|
|
83
|
+
/**
|
|
84
|
+
* An array of attachment objects to display with the message.
|
|
85
|
+
* Each attachment object can have the following properties:
|
|
86
|
+
* - `name`: The name of the attachment file
|
|
87
|
+
* - `url`: The URL of the attachment
|
|
88
|
+
* - `type`: The MIME type of the attachment (e.g., 'image/png', 'application/pdf')
|
|
89
|
+
*
|
|
90
|
+
* Image attachments (type starting with "image/") show a thumbnail preview,
|
|
91
|
+
* while other attachments show a document icon with the file name.
|
|
92
|
+
*
|
|
93
|
+
* @type {Array<{name?: string, url?: string, type?: string}>}
|
|
94
|
+
*/
|
|
95
|
+
attachments: {
|
|
96
|
+
type: Array,
|
|
97
|
+
},
|
|
98
|
+
|
|
81
99
|
/** @private */
|
|
82
100
|
_avatar: {
|
|
83
101
|
type: Object,
|
|
@@ -113,4 +131,61 @@ export const MessageMixin = (superClass) =>
|
|
|
113
131
|
});
|
|
114
132
|
}
|
|
115
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Renders attachments for the message.
|
|
137
|
+
* @private
|
|
138
|
+
*/
|
|
139
|
+
__renderAttachments() {
|
|
140
|
+
const attachments = this.attachments;
|
|
141
|
+
if (!attachments || attachments.length === 0) {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return html`
|
|
146
|
+
<div part="attachments">${attachments.map((attachment) => this.__renderAttachment(attachment))}</div>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Renders a single attachment.
|
|
152
|
+
* @param {Object} attachment - The attachment object with name, url, and type properties
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
__renderAttachment(attachment) {
|
|
156
|
+
const isImage = attachment.type && attachment.type.startsWith('image/');
|
|
157
|
+
|
|
158
|
+
if (isImage) {
|
|
159
|
+
return html`
|
|
160
|
+
<button
|
|
161
|
+
type="button"
|
|
162
|
+
part="attachment attachment-image"
|
|
163
|
+
aria-label="${attachment.name || ''}"
|
|
164
|
+
@click="${() => this.__onAttachmentClick(attachment)}"
|
|
165
|
+
>
|
|
166
|
+
<img part="attachment-preview" src="${ifDefined(attachment.url)}" alt="" />
|
|
167
|
+
</button>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return html`
|
|
172
|
+
<button type="button" part="attachment attachment-file" @click="${() => this.__onAttachmentClick(attachment)}">
|
|
173
|
+
<span part="attachment-icon" aria-hidden="true"></span>
|
|
174
|
+
<span part="attachment-name">${attachment.name || ''}</span>
|
|
175
|
+
</button>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Dispatches an event when an attachment is clicked.
|
|
181
|
+
* @param {Object} attachment - The attachment that was clicked
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
__onAttachmentClick(attachment) {
|
|
185
|
+
this.dispatchEvent(
|
|
186
|
+
new CustomEvent('attachment-click', {
|
|
187
|
+
detail: { attachment },
|
|
188
|
+
}),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
116
191
|
};
|
package/src/vaadin-message.d.ts
CHANGED
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
7
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
|
-
import { MessageMixin } from './vaadin-message-mixin.js';
|
|
8
|
+
import { type MessageAttachmentClickEvent, MessageMixin } from './vaadin-message-mixin.js';
|
|
9
|
+
|
|
10
|
+
export { MessageAttachment, MessageAttachmentClickEvent } from './vaadin-message-mixin.js';
|
|
11
|
+
|
|
12
|
+
export type MessageEventMap = HTMLElementEventMap & {
|
|
13
|
+
'attachment-click': MessageAttachmentClickEvent;
|
|
14
|
+
};
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* `<vaadin-message>` is a Web Component for showing a single message with an author, message and time.
|
|
@@ -21,11 +27,18 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
21
27
|
*
|
|
22
28
|
* The following shadow DOM parts are available for styling:
|
|
23
29
|
*
|
|
24
|
-
* Part name
|
|
25
|
-
*
|
|
26
|
-
* `name`
|
|
27
|
-
* `time`
|
|
28
|
-
* `content`
|
|
30
|
+
* Part name | Description
|
|
31
|
+
* --------------------|----------------
|
|
32
|
+
* `name` | Author's name
|
|
33
|
+
* `time` | When the message was posted
|
|
34
|
+
* `content` | The message itself as a slotted content
|
|
35
|
+
* `attachments` | Container for the attachments
|
|
36
|
+
* `attachment` | Individual attachment button
|
|
37
|
+
* `attachment-image` | Image attachment button (in addition to `attachment`)
|
|
38
|
+
* `attachment-file` | File attachment button (in addition to `attachment`)
|
|
39
|
+
* `attachment-preview`| Image preview inside an image attachment
|
|
40
|
+
* `attachment-icon` | File icon inside a file attachment
|
|
41
|
+
* `attachment-name` | File name inside a file attachment
|
|
29
42
|
*
|
|
30
43
|
* The following state attributes are available for styling:
|
|
31
44
|
*
|
|
@@ -35,8 +48,22 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
35
48
|
* `focused` | Set when the message is focused.
|
|
36
49
|
*
|
|
37
50
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
51
|
+
*
|
|
52
|
+
* @fires {CustomEvent} attachment-click - Fired when an attachment is clicked.
|
|
38
53
|
*/
|
|
39
|
-
declare class Message extends MessageMixin(ThemableMixin(ElementMixin(HTMLElement))) {
|
|
54
|
+
declare class Message extends MessageMixin(ThemableMixin(ElementMixin(HTMLElement))) {
|
|
55
|
+
addEventListener<K extends keyof MessageEventMap>(
|
|
56
|
+
type: K,
|
|
57
|
+
listener: (this: Message, ev: MessageEventMap[K]) => void,
|
|
58
|
+
options?: AddEventListenerOptions | boolean,
|
|
59
|
+
): void;
|
|
60
|
+
|
|
61
|
+
removeEventListener<K extends keyof MessageEventMap>(
|
|
62
|
+
type: K,
|
|
63
|
+
listener: (this: Message, ev: MessageEventMap[K]) => void,
|
|
64
|
+
options?: EventListenerOptions | boolean,
|
|
65
|
+
): void;
|
|
66
|
+
}
|
|
40
67
|
|
|
41
68
|
declare global {
|
|
42
69
|
interface HTMLElementTagNameMap {
|
package/src/vaadin-message.js
CHANGED
|
@@ -27,11 +27,18 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
27
27
|
*
|
|
28
28
|
* The following shadow DOM parts are available for styling:
|
|
29
29
|
*
|
|
30
|
-
* Part name
|
|
31
|
-
*
|
|
32
|
-
* `name`
|
|
33
|
-
* `time`
|
|
34
|
-
* `content`
|
|
30
|
+
* Part name | Description
|
|
31
|
+
* --------------------|----------------
|
|
32
|
+
* `name` | Author's name
|
|
33
|
+
* `time` | When the message was posted
|
|
34
|
+
* `content` | The message itself as a slotted content
|
|
35
|
+
* `attachments` | Container for the attachments
|
|
36
|
+
* `attachment` | Individual attachment button
|
|
37
|
+
* `attachment-image` | Image attachment button (in addition to `attachment`)
|
|
38
|
+
* `attachment-file` | File attachment button (in addition to `attachment`)
|
|
39
|
+
* `attachment-preview`| Image preview inside an image attachment
|
|
40
|
+
* `attachment-icon` | File icon inside a file attachment
|
|
41
|
+
* `attachment-name` | File name inside a file attachment
|
|
35
42
|
*
|
|
36
43
|
* The following state attributes are available for styling:
|
|
37
44
|
*
|
|
@@ -42,6 +49,8 @@ import { MessageMixin } from './vaadin-message-mixin.js';
|
|
|
42
49
|
*
|
|
43
50
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
44
51
|
*
|
|
52
|
+
* @fires {CustomEvent} attachment-click - Fired when an attachment is clicked.
|
|
53
|
+
*
|
|
45
54
|
* @customElement
|
|
46
55
|
* @extends HTMLElement
|
|
47
56
|
* @mixes MessageMixin
|
|
@@ -70,6 +79,7 @@ class Message extends MessageMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoI
|
|
|
70
79
|
<span part="name">${this.userName}</span>
|
|
71
80
|
<span part="time">${this.time}</span>
|
|
72
81
|
</div>
|
|
82
|
+
${this.__renderAttachments()}
|
|
73
83
|
<div part="message"><slot></slot></div>
|
|
74
84
|
</div>
|
|
75
85
|
`;
|
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.1.0-
|
|
4
|
+
"version": "25.1.0-alpha6",
|
|
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
|
|
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`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\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "time",
|
|
@@ -133,6 +133,17 @@
|
|
|
133
133
|
"undefined"
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "attachments",
|
|
139
|
+
"description": "An array of attachment objects to display with the message.\nEach attachment object can have the following properties:\n- `name`: The name of the attachment file\n- `url`: The URL of the attachment\n- `type`: The MIME type of the attachment (e.g., 'image/png', 'application/pdf')\n\nImage attachments (type starting with \"image/\") show a thumbnail preview,\nwhile other attachments show a document icon with the file name.",
|
|
140
|
+
"value": {
|
|
141
|
+
"type": [
|
|
142
|
+
"Array",
|
|
143
|
+
"null",
|
|
144
|
+
"undefined"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
136
147
|
}
|
|
137
148
|
],
|
|
138
149
|
"events": []
|
|
@@ -140,7 +151,7 @@
|
|
|
140
151
|
},
|
|
141
152
|
{
|
|
142
153
|
"name": "vaadin-message-list",
|
|
143
|
-
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-
|
|
154
|
+
"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.1.0-alpha6/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-alpha6/#/elements/vaadin-message) documentation for the available\nstate attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
144
155
|
"attributes": [
|
|
145
156
|
{
|
|
146
157
|
"name": "markdown",
|
|
@@ -176,7 +187,7 @@
|
|
|
176
187
|
"properties": [
|
|
177
188
|
{
|
|
178
189
|
"name": "items",
|
|
179
|
-
"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 className: string,\n theme: string\n}>\n
|
|
190
|
+
"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 className: string,\n theme: string,\n attachments: Array<{\n name: string,\n url: string,\n type: string\n }>\n}>\n```\n\nWhen a message has attachments, they are rendered in the message's shadow DOM.\nImage attachments (type starting with \"image/\") show a thumbnail preview,\nwhile other attachments show a document icon with the file name.\nClicking an attachment dispatches an `attachment-click` event.",
|
|
180
191
|
"value": {
|
|
181
192
|
"type": [
|
|
182
193
|
"Array",
|
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.1.0-
|
|
4
|
+
"version": "25.1.0-alpha6",
|
|
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
|
|
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`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\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|
|
@@ -53,12 +53,19 @@
|
|
|
53
53
|
"value": {
|
|
54
54
|
"kind": "expression"
|
|
55
55
|
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": ".attachments",
|
|
59
|
+
"description": "An array of attachment objects to display with the message.\nEach attachment object can have the following properties:\n- `name`: The name of the attachment file\n- `url`: The URL of the attachment\n- `type`: The MIME type of the attachment (e.g., 'image/png', 'application/pdf')\n\nImage attachments (type starting with \"image/\") show a thumbnail preview,\nwhile other attachments show a document icon with the file name.",
|
|
60
|
+
"value": {
|
|
61
|
+
"kind": "expression"
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
64
|
]
|
|
58
65
|
},
|
|
59
66
|
{
|
|
60
67
|
"name": "vaadin-message-list",
|
|
61
|
-
"description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-
|
|
68
|
+
"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.1.0-alpha6/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/25.1.0-alpha6/#/elements/vaadin-message) documentation for the available\nstate attributes and stylable shadow parts of message elements.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
62
69
|
"extension": true,
|
|
63
70
|
"attributes": [
|
|
64
71
|
{
|
|
@@ -77,7 +84,7 @@
|
|
|
77
84
|
},
|
|
78
85
|
{
|
|
79
86
|
"name": ".items",
|
|
80
|
-
"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 className: string,\n theme: string\n}>\n
|
|
87
|
+
"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 className: string,\n theme: string,\n attachments: Array<{\n name: string,\n url: string,\n type: string\n }>\n}>\n```\n\nWhen a message has attachments, they are rendered in the message's shadow DOM.\nImage attachments (type starting with \"image/\") show a thumbnail preview,\nwhile other attachments show a document icon with the file name.\nClicking an attachment dispatches an `attachment-click` event.",
|
|
81
88
|
"value": {
|
|
82
89
|
"kind": "expression"
|
|
83
90
|
}
|