@vaadin/virtual-list 24.6.5 → 24.7.0-alpha10

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/virtual-list",
3
- "version": "24.6.5",
3
+ "version": "24.7.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,16 +39,16 @@
39
39
  "dependencies": {
40
40
  "@open-wc/dedupe-mixin": "^1.3.0",
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/component-base": "~24.6.5",
43
- "@vaadin/lit-renderer": "~24.6.5",
44
- "@vaadin/vaadin-lumo-styles": "~24.6.5",
45
- "@vaadin/vaadin-material-styles": "~24.6.5",
46
- "@vaadin/vaadin-themable-mixin": "~24.6.5",
42
+ "@vaadin/component-base": "24.7.0-alpha10",
43
+ "@vaadin/lit-renderer": "24.7.0-alpha10",
44
+ "@vaadin/vaadin-lumo-styles": "24.7.0-alpha10",
45
+ "@vaadin/vaadin-material-styles": "24.7.0-alpha10",
46
+ "@vaadin/vaadin-themable-mixin": "24.7.0-alpha10",
47
47
  "lit": "^3.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@vaadin/chai-plugins": "~24.6.5",
51
- "@vaadin/test-runner-commands": "~24.6.5",
50
+ "@vaadin/chai-plugins": "24.7.0-alpha10",
51
+ "@vaadin/test-runner-commands": "24.7.0-alpha10",
52
52
  "@vaadin/testing-helpers": "^1.1.0",
53
53
  "sinon": "^18.0.0"
54
54
  },
@@ -56,5 +56,5 @@
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "fc109a4234a1f60e89717ab1c0dc8fb4451aa418"
59
+ "gitHead": "c0f8933df2a6a40648d3fb9cfbae6bbf86a8aa90"
60
60
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { DirectiveResult } from 'lit/directive.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { directive } from 'lit/directive.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  export * from './vaadin-virtual-list.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, LitElement } from 'lit';
@@ -29,6 +29,7 @@ class VirtualList extends VirtualListMixin(ThemableMixin(ElementMixin(PolylitMix
29
29
  return [virtualListStyles];
30
30
  }
31
31
 
32
+ /** @protected */
32
33
  render() {
33
34
  return html`
34
35
  <div id="items">
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
@@ -53,6 +53,15 @@ export declare class VirtualListMixinClass<TItem = VirtualListDefaultItem> {
53
53
  */
54
54
  items: TItem[] | undefined;
55
55
 
56
+ /**
57
+ * A function that generates accessible names for virtual list items.
58
+ * The function gets the item as an argument and the
59
+ * return value should be a string representing that item. The
60
+ * result gets applied to the corresponding virtual list child element
61
+ * as an `aria-label` attribute.
62
+ */
63
+ itemAccessibleNameGenerator?: (item: TItem) => string;
64
+
56
65
  /**
57
66
  * Scroll to a specific index in the virtual list.
58
67
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { isChrome, isSafari } from '@vaadin/component-base/src/browser-utils.js';
@@ -37,13 +37,25 @@ export const VirtualListMixin = (superClass) =>
37
37
  */
38
38
  renderer: { type: Function, sync: true },
39
39
 
40
+ /**
41
+ * A function that generates accessible names for virtual list items.
42
+ * The function gets the item as an argument and the
43
+ * return value should be a string representing that item. The
44
+ * result gets applied to the corresponding virtual list child element
45
+ * as an `aria-label` attribute.
46
+ */
47
+ itemAccessibleNameGenerator: {
48
+ type: Function,
49
+ sync: true,
50
+ },
51
+
40
52
  /** @private */
41
53
  __virtualizer: Object,
42
54
  };
43
55
  }
44
56
 
45
57
  static get observers() {
46
- return ['__itemsOrRendererChanged(items, renderer, __virtualizer)'];
58
+ return ['__itemsOrRendererChanged(items, renderer, __virtualizer, itemAccessibleNameGenerator)'];
47
59
  }
48
60
 
49
61
  /**
@@ -85,6 +97,7 @@ export const VirtualListMixin = (superClass) =>
85
97
  this.addController(this.__overflowController);
86
98
 
87
99
  processTemplates(this);
100
+ this.__updateAria();
88
101
  }
89
102
 
90
103
  /** @protected */
@@ -113,18 +126,34 @@ export const VirtualListMixin = (superClass) =>
113
126
  return [...Array(count)].map(() => document.createElement('div'));
114
127
  }
115
128
 
129
+ /** @private */
130
+ __updateAria() {
131
+ this.role = 'list';
132
+ }
133
+
116
134
  /** @private */
117
135
  __updateElement(el, index) {
136
+ const item = this.items[index];
137
+ el.ariaSetSize = String(this.items.length);
138
+ el.ariaPosInSet = String(index + 1);
139
+ el.ariaLabel = this.itemAccessibleNameGenerator ? this.itemAccessibleNameGenerator(item) : null;
140
+ this.__updateElementRole(el);
141
+
118
142
  if (el.__renderer !== this.renderer) {
119
143
  el.__renderer = this.renderer;
120
144
  this.__clearRenderTargetContent(el);
121
145
  }
122
146
 
123
147
  if (this.renderer) {
124
- this.renderer(el, this, { item: this.items[index], index });
148
+ this.renderer(el, this, { item, index });
125
149
  }
126
150
  }
127
151
 
152
+ /** @private */
153
+ __updateElementRole(el) {
154
+ el.role = 'listitem';
155
+ }
156
+
128
157
  /**
129
158
  * Clears the content of a render target.
130
159
  * @private
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { CSSResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { css } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.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/virtual-list",
4
- "version": "24.6.5",
4
+ "version": "24.7.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -43,6 +43,17 @@
43
43
  "undefined"
44
44
  ]
45
45
  }
46
+ },
47
+ {
48
+ "name": "itemAccessibleNameGenerator",
49
+ "description": "A function that generates accessible names for virtual list items.\nThe function gets the item as an argument and the\nreturn value should be a string representing that item. The\nresult gets applied to the corresponding virtual list child element\nas an `aria-label` attribute.",
50
+ "value": {
51
+ "type": [
52
+ "Function",
53
+ "null",
54
+ "undefined"
55
+ ]
56
+ }
46
57
  }
47
58
  ],
48
59
  "events": []
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/virtual-list",
4
- "version": "24.6.5",
4
+ "version": "24.7.0-alpha10",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -32,6 +32,13 @@
32
32
  "value": {
33
33
  "kind": "expression"
34
34
  }
35
+ },
36
+ {
37
+ "name": ".itemAccessibleNameGenerator",
38
+ "description": "A function that generates accessible names for virtual list items.\nThe function gets the item as an argument and the\nreturn value should be a string representing that item. The\nresult gets applied to the corresponding virtual list child element\nas an `aria-label` attribute.",
39
+ "value": {
40
+ "kind": "expression"
41
+ }
35
42
  }
36
43
  ]
37
44
  }