@vaadin/message-list 23.2.2 → 23.3.0-alpha2

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": "23.2.2",
3
+ "version": "23.3.0-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,11 +38,11 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/avatar": "~23.2.2",
42
- "@vaadin/component-base": "~23.2.2",
43
- "@vaadin/vaadin-lumo-styles": "~23.2.2",
44
- "@vaadin/vaadin-material-styles": "~23.2.2",
45
- "@vaadin/vaadin-themable-mixin": "~23.2.2"
41
+ "@vaadin/avatar": "23.3.0-alpha2",
42
+ "@vaadin/component-base": "23.3.0-alpha2",
43
+ "@vaadin/vaadin-lumo-styles": "23.3.0-alpha2",
44
+ "@vaadin/vaadin-material-styles": "23.3.0-alpha2",
45
+ "@vaadin/vaadin-themable-mixin": "23.3.0-alpha2"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
@@ -53,5 +53,5 @@
53
53
  "web-types.json",
54
54
  "web-types.lit.json"
55
55
  ],
56
- "gitHead": "a98818979098f4542ce557a58858fb6dad910a25"
56
+ "gitHead": "ae61027c62ffa7f7d70cfc50e43f333addfc74b6"
57
57
  }
@@ -4,6 +4,7 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
+ import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
7
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
8
9
 
9
10
  export interface MessageListItem {
@@ -43,7 +44,7 @@ export interface MessageListItem {
43
44
  *
44
45
  * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
45
46
  */
46
- declare class MessageList extends ThemableMixin(ElementMixin(HTMLElement)) {
47
+ declare class MessageList extends KeyboardDirectionMixin(ThemableMixin(ElementMixin(HTMLElement))) {
47
48
  /**
48
49
  * An array of objects which will be rendered as messages.
49
50
  * The message objects can have the following properties:
@@ -7,6 +7,7 @@ import '@polymer/polymer/lib/elements/dom-repeat.js';
7
7
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
8
8
  import { microTask } from '@vaadin/component-base/src/async.js';
9
9
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
+ import { KeyboardDirectionMixin } from '@vaadin/component-base/src/keyboard-direction-mixin.js';
10
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
12
  import { Message } from './vaadin-message.js';
12
13
 
@@ -40,8 +41,9 @@ import { Message } from './vaadin-message.js';
40
41
  * @extends HTMLElement
41
42
  * @mixes ThemableMixin
42
43
  * @mixes ElementMixin
44
+ * @mixes KeyboardDirectionMixin
43
45
  */
44
- class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
46
+ class MessageList extends KeyboardDirectionMixin(ElementMixin(ThemableMixin(PolymerElement))) {
45
47
  static get is() {
46
48
  return 'vaadin-message-list';
47
49
  }
@@ -108,9 +110,18 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
108
110
  // Make screen readers announce new messages
109
111
  this.setAttribute('aria-relevant', 'additions');
110
112
  this.setAttribute('role', 'log');
113
+ }
111
114
 
112
- // Keyboard navi
113
- this.addEventListener('keydown', (e) => this._onKeydown(e));
115
+ /**
116
+ * Override method inherited from `KeyboardDirectionMixin`
117
+ * to use the list of message elements as items.
118
+ *
119
+ * @return {Element[]}
120
+ * @protected
121
+ * @override
122
+ */
123
+ _getItems() {
124
+ return this._messages;
114
125
  }
115
126
 
116
127
  /** @protected */
@@ -140,54 +151,6 @@ class MessageList extends ElementMixin(ThemableMixin(PolymerElement)) {
140
151
  }
141
152
  }
142
153
 
143
- /**
144
- * @param {!KeyboardEvent} event
145
- * @protected
146
- */
147
- _onKeydown(event) {
148
- if (event.metaKey || event.ctrlKey) {
149
- return;
150
- }
151
-
152
- // Get index of the item that was focused when event happened
153
- const target = event.composedPath()[0];
154
- let currentIndex = this._messages.indexOf(target);
155
-
156
- switch (event.key) {
157
- case 'ArrowUp':
158
- currentIndex -= 1;
159
- break;
160
- case 'ArrowDown':
161
- currentIndex += 1;
162
- break;
163
- case 'Home':
164
- currentIndex = 0;
165
- break;
166
- case 'End':
167
- currentIndex = this._messages.length - 1;
168
- break;
169
- default:
170
- return; // Nothing to do
171
- }
172
- if (currentIndex < 0) {
173
- currentIndex = this._messages.length - 1;
174
- }
175
- if (currentIndex > this._messages.length - 1) {
176
- currentIndex = 0;
177
- }
178
- this._focus(currentIndex);
179
- event.preventDefault();
180
- }
181
-
182
- /**
183
- * @param {number} idx
184
- * @protected
185
- */
186
- _focus(idx) {
187
- const target = this._messages[idx];
188
- target.focus();
189
- }
190
-
191
154
  /** @private */
192
155
  _handleFocusEvent(e) {
193
156
  const target = e.composedPath().find((node) => node instanceof Message);
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/message-list",
4
- "version": "23.2.2",
4
+ "version": "23.3.0-alpha2",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-message",
11
- "description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/elements/vaadin-avatar).",
11
+ "description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-avatar).",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "time",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/message-list",
4
- "version": "23.2.2",
4
+ "version": "23.3.0-alpha2",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-message",
19
- "description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.2.2/#/elements/vaadin-avatar).",
19
+ "description": "`<vaadin-message>` is a Web Component for showing a single message with an author, message and time.\n\n```html\n<vaadin-message time=\"2021-01-28 10:43\"\n user-name = \"Bob Ross\"\n user-abbr = \"BR\"\n user-img = \"/static/img/avatar.jpg\">There is no real ending. It's just the place where you stop the story.</vaadin-message>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------|----------------\n`avatar` | The author's avatar\n`name` | Author's name\n`time` | When the message was posted\n`content` | The message itself as a slotted content\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-------------|-------------\n`focus-ring` | Set when the message is focused using the keyboard.\n`focused` | Set when the message is focused.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-message>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-message-avatar>` - has the same API as [`<vaadin-avatar>`](https://cdn.vaadin.com/vaadin-web-components/23.3.0-alpha2/#/elements/vaadin-avatar).",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {