@vaadin/message-list 24.8.0-alpha2 → 24.8.0-alpha20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/message-list",
3
- "version": "24.8.0-alpha2",
3
+ "version": "24.8.0-alpha20",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,17 +39,18 @@
39
39
  "dependencies": {
40
40
  "@open-wc/dedupe-mixin": "^1.3.0",
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/a11y-base": "24.8.0-alpha2",
43
- "@vaadin/avatar": "24.8.0-alpha2",
44
- "@vaadin/component-base": "24.8.0-alpha2",
45
- "@vaadin/vaadin-lumo-styles": "24.8.0-alpha2",
46
- "@vaadin/vaadin-material-styles": "24.8.0-alpha2",
47
- "@vaadin/vaadin-themable-mixin": "24.8.0-alpha2",
42
+ "@vaadin/a11y-base": "24.8.0-alpha20",
43
+ "@vaadin/avatar": "24.8.0-alpha20",
44
+ "@vaadin/component-base": "24.8.0-alpha20",
45
+ "@vaadin/markdown": "24.8.0-alpha20",
46
+ "@vaadin/vaadin-lumo-styles": "24.8.0-alpha20",
47
+ "@vaadin/vaadin-material-styles": "24.8.0-alpha20",
48
+ "@vaadin/vaadin-themable-mixin": "24.8.0-alpha20",
48
49
  "lit": "^3.0.0"
49
50
  },
50
51
  "devDependencies": {
51
- "@vaadin/chai-plugins": "24.8.0-alpha2",
52
- "@vaadin/test-runner-commands": "24.8.0-alpha2",
52
+ "@vaadin/chai-plugins": "24.8.0-alpha20",
53
+ "@vaadin/test-runner-commands": "24.8.0-alpha20",
53
54
  "@vaadin/testing-helpers": "^1.1.0",
54
55
  "sinon": "^18.0.0"
55
56
  },
@@ -57,5 +58,5 @@
57
58
  "web-types.json",
58
59
  "web-types.lit.json"
59
60
  ],
60
- "gitHead": "f48777a6e3dcf605b700305a7142145e197bb416"
61
+ "gitHead": "f091548b1f079f0c9de4be2a8ded77fb18671a2e"
61
62
  }
@@ -5,6 +5,7 @@
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 { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
8
9
 
9
10
  export interface MessageListItem {
10
11
  text?: string;
@@ -19,7 +20,10 @@ export interface MessageListItem {
19
20
 
20
21
  export declare function MessageListMixin<T extends Constructor<HTMLElement>>(
21
22
  base: T,
22
- ): Constructor<KeyboardDirectionMixinClass> & Constructor<MessageListMixinClass> & T;
23
+ ): Constructor<KeyboardDirectionMixinClass> &
24
+ Constructor<MessageListMixinClass> &
25
+ Constructor<SlotStylesMixinClass> &
26
+ T;
23
27
 
24
28
  export declare class MessageListMixinClass {
25
29
  /**
@@ -39,4 +43,15 @@ export declare class MessageListMixinClass {
39
43
  * ```
40
44
  */
41
45
  items: MessageListItem[] | null | undefined;
46
+
47
+ /**
48
+ * When set to `true`, the message text is parsed as Markdown.
49
+ */
50
+ markdown: boolean | undefined;
51
+
52
+ /**
53
+ * When set to `true`, new messages are announced to assistive technologies using ARIA live regions.
54
+ * @attr {boolean} announce-messages
55
+ */
56
+ announceMessages: boolean | undefined;
42
57
  }
@@ -6,13 +6,15 @@
6
6
  import { html, render } from 'lit';
7
7
  import { ifDefined } from 'lit/directives/if-defined.js';
8
8
  import { KeyboardDirectionMixin } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
9
+ import { SlotStylesMixin } from '@vaadin/component-base/src/slot-styles-mixin';
9
10
 
10
11
  /**
11
12
  * @polymerMixin
12
13
  * @mixes KeyboardDirectionMixin
14
+ * @mixes SlotStylesMixin
13
15
  */
14
16
  export const MessageListMixin = (superClass) =>
15
- class MessageListMixinClass extends KeyboardDirectionMixin(superClass) {
17
+ class MessageListMixinClass extends SlotStylesMixin(KeyboardDirectionMixin(superClass)) {
16
18
  static get properties() {
17
19
  return {
18
20
  /**
@@ -37,6 +39,28 @@ export const MessageListMixin = (superClass) =>
37
39
  observer: '_itemsChanged',
38
40
  sync: true,
39
41
  },
42
+
43
+ /**
44
+ * When set to `true`, the message text is parsed as Markdown.
45
+ * @type {boolean}
46
+ */
47
+ markdown: {
48
+ type: Boolean,
49
+ observer: '__markdownChanged',
50
+ reflectToAttribute: true,
51
+ },
52
+
53
+ /**
54
+ * When set to `true`, new messages are announced to assistive technologies using ARIA live regions.
55
+ * @attr {boolean} announce-messages
56
+ * @type {boolean}
57
+ */
58
+ announceMessages: {
59
+ type: Boolean,
60
+ value: false,
61
+ observer: '__announceChanged',
62
+ sync: true,
63
+ },
40
64
  };
41
65
  }
42
66
 
@@ -51,7 +75,23 @@ export const MessageListMixin = (superClass) =>
51
75
 
52
76
  // Make screen readers announce new messages
53
77
  this.setAttribute('aria-relevant', 'additions');
54
- this.setAttribute('role', 'log');
78
+ this.setAttribute('role', 'region');
79
+ }
80
+
81
+ /** @protected */
82
+ get slotStyles() {
83
+ const tag = this.localName;
84
+ return [
85
+ `
86
+ ${tag} :where(vaadin-markdown > :is(h1, h2, h3, h4, h5, h6, p, ul, ol):first-child) {
87
+ margin-top: 0;
88
+ }
89
+
90
+ ${tag} :where(vaadin-markdown > :is(h1, h2, h3, h4, h5, h6, p, ul, ol):last-child) {
91
+ margin-bottom: 0;
92
+ }
93
+ `,
94
+ ];
55
95
  }
56
96
 
57
97
  /**
@@ -86,8 +126,24 @@ export const MessageListMixin = (superClass) =>
86
126
  }
87
127
  }
88
128
 
129
+ /** @private */
130
+ __markdownChanged(markdown) {
131
+ if (markdown && !customElements.get('vaadin-markdown')) {
132
+ // Dynamically import the markdown component
133
+ import('@vaadin/markdown/src/vaadin-markdown.js')
134
+ // Wait until the component is defined
135
+ .then(() => customElements.whenDefined('vaadin-markdown'))
136
+ // Render the messages again
137
+ .then(() => this._renderMessages(this.items));
138
+ }
139
+ this._renderMessages(this.items);
140
+ }
141
+
89
142
  /** @private */
90
143
  _renderMessages(items) {
144
+ // Check if markdown component is still loading
145
+ const loadingMarkdown = this.markdown && !customElements.get('vaadin-markdown');
146
+
91
147
  render(
92
148
  html`
93
149
  ${items.map(
@@ -102,7 +158,10 @@ export const MessageListMixin = (superClass) =>
102
158
  theme="${ifDefined(item.theme)}"
103
159
  class="${ifDefined(item.className)}"
104
160
  @focusin="${this._onMessageFocusIn}"
105
- >${item.text}<vaadin-avatar slot="avatar"></vaadin-avatar
161
+ style="${ifDefined(loadingMarkdown ? 'visibility: hidden' : undefined)}"
162
+ >${this.markdown
163
+ ? html`<vaadin-markdown .content=${item.text}></vaadin-markdown>`
164
+ : item.text}<vaadin-avatar slot="avatar"></vaadin-avatar
106
165
  ></vaadin-message>
107
166
  `,
108
167
  )}
@@ -146,4 +205,9 @@ export const MessageListMixin = (superClass) =>
146
205
  const index = this._messages.findIndex((e) => e.tabIndex === 0);
147
206
  return index !== -1 ? index : 0;
148
207
  }
208
+
209
+ /** @private */
210
+ __announceChanged(announceMessages) {
211
+ this.ariaLive = announceMessages ? 'polite' : null;
212
+ }
149
213
  };
@@ -40,4 +40,8 @@ export const messageStyles = css`
40
40
  --vaadin-avatar-outline-width: 0;
41
41
  flex-shrink: 0;
42
42
  }
43
+
44
+ ::slotted(vaadin-markdown) {
45
+ white-space: normal;
46
+ }
43
47
  `;
@@ -1,2 +1,3 @@
1
+ import '@vaadin/markdown/theme/lumo/vaadin-markdown-styles.js';
1
2
  import './vaadin-message-list-styles.js';
2
3
  import '../../src/vaadin-message-list.js';
@@ -1,2 +1,3 @@
1
+ import '@vaadin/markdown/theme/lumo/vaadin-markdown-styles.js';
1
2
  import './vaadin-message-list-styles.js';
2
3
  import '../../src/vaadin-message-list.js';
@@ -1,2 +1,3 @@
1
+ import '@vaadin/markdown/theme/material/vaadin-markdown-styles.js';
1
2
  import './vaadin-message-list-styles.js';
2
3
  import '../../src/vaadin-message-list.js';
@@ -1,2 +1,3 @@
1
+ import '@vaadin/markdown/theme/material/vaadin-markdown-styles.js';
1
2
  import './vaadin-message-list-styles.js';
2
3
  import '../../src/vaadin-message-list.js';
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/message-list",
4
- "version": "24.8.0-alpha2",
4
+ "version": "24.8.0-alpha20",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -140,8 +140,26 @@
140
140
  },
141
141
  {
142
142
  "name": "vaadin-message-list",
143
- "description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha2/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha2/#/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.",
143
+ "description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha20/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha20/#/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
144
  "attributes": [
145
+ {
146
+ "name": "markdown",
147
+ "description": "When set to `true`, the message text is parsed as Markdown.",
148
+ "value": {
149
+ "type": [
150
+ "boolean"
151
+ ]
152
+ }
153
+ },
154
+ {
155
+ "name": "announce-messages",
156
+ "description": "When set to `true`, new messages are announced to assistive technologies using ARIA live regions.",
157
+ "value": {
158
+ "type": [
159
+ "boolean"
160
+ ]
161
+ }
162
+ },
145
163
  {
146
164
  "name": "theme",
147
165
  "description": "The theme variants to apply to the component.",
@@ -166,6 +184,24 @@
166
184
  "undefined"
167
185
  ]
168
186
  }
187
+ },
188
+ {
189
+ "name": "markdown",
190
+ "description": "When set to `true`, the message text is parsed as Markdown.",
191
+ "value": {
192
+ "type": [
193
+ "boolean"
194
+ ]
195
+ }
196
+ },
197
+ {
198
+ "name": "announceMessages",
199
+ "description": "When set to `true`, new messages are announced to assistive technologies using ARIA live regions.",
200
+ "value": {
201
+ "type": [
202
+ "boolean"
203
+ ]
204
+ }
169
205
  }
170
206
  ],
171
207
  "events": []
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/message-list",
4
- "version": "24.8.0-alpha2",
4
+ "version": "24.8.0-alpha20",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -58,9 +58,23 @@
58
58
  },
59
59
  {
60
60
  "name": "vaadin-message-list",
61
- "description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha2/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha2/#/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.",
61
+ "description": "`<vaadin-message-list>` is a Web Component for showing an ordered list of messages. The messages are rendered as <vaadin-message>\n\n### Example\n\nTo create a new message list, add the component to the page:\n\n```html\n<vaadin-message-list></vaadin-message-list>\n```\n\nProvide the messages to the message list with the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha20/#/elements/vaadin-message-list#property-items) property.\n\n```js\ndocument.querySelector('vaadin-message-list').items = [\n { text: 'Hello list', time: 'yesterday', userName: 'Matt Mambo', userAbbr: 'MM', userColorIndex: 1 },\n { text: 'Another message', time: 'right now', userName: 'Linsey Listy', userAbbr: 'LL', userColorIndex: 2, userImg: '/static/img/avatar.jpg' }\n];\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`list` | The container wrapping messages.\n\nSee the [`<vaadin-message>`](https://cdn.vaadin.com/vaadin-web-components/24.8.0-alpha20/#/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
62
  "extension": true,
63
63
  "attributes": [
64
+ {
65
+ "name": "?markdown",
66
+ "description": "When set to `true`, the message text is parsed as Markdown.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ },
71
+ {
72
+ "name": "?announceMessages",
73
+ "description": "When set to `true`, new messages are announced to assistive technologies using ARIA live regions.",
74
+ "value": {
75
+ "kind": "expression"
76
+ }
77
+ },
64
78
  {
65
79
  "name": ".items",
66
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```",
@@ -1 +0,0 @@
1
- export * from './vaadin-message-list.js';
@@ -1 +0,0 @@
1
- export * from './vaadin-message.js';