@vaadin/a11y-base 24.7.0-alpha1 → 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/a11y-base",
3
- "version": "24.7.0-alpha1",
3
+ "version": "24.7.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,13 +32,14 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "24.7.0-alpha1",
35
+ "@vaadin/component-base": "24.7.0-alpha10",
36
36
  "lit": "^3.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vaadin/chai-plugins": "24.7.0-alpha1",
40
- "@vaadin/testing-helpers": "^1.0.0",
39
+ "@vaadin/chai-plugins": "24.7.0-alpha10",
40
+ "@vaadin/test-runner-commands": "24.7.0-alpha10",
41
+ "@vaadin/testing-helpers": "^1.1.0",
41
42
  "sinon": "^18.0.0"
42
43
  },
43
- "gitHead": "04be941c9a7b659871c97f31b9cc3ffd7528087b"
44
+ "gitHead": "c0f8933df2a6a40648d3fb9cfbae6bbf86a8aa90"
44
45
  }
@@ -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';
@@ -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 { addListener } from '@vaadin/component-base/src/gestures.js';
package/src/announce.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 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
 
package/src/announce.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 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 { animationFrame } from '@vaadin/component-base/src/async.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 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
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2023 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2023 - 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 {
@@ -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 { ReactiveController } 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 { hideOthers } from './aria-hidden.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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -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 { dedupingMixin } from '@polymer/polymer/lib/utils/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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -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 { dedupingMixin } from '@polymer/polymer/lib/utils/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
 
@@ -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 { removeAriaIDReference, restoreGeneratedAriaIDReference, setAriaIDReference } from './aria-id-reference.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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -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 { dedupingMixin } from '@polymer/polymer/lib/utils/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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -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 { getDeepActiveElement } from './focus-utils.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 type { ReactiveController } 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 { getFocusableElements, isElementFocused } from './focus-utils.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
 
@@ -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
 
@@ -145,6 +145,13 @@ function sortElementsByTabIndex(elements) {
145
145
  * @return {boolean}
146
146
  */
147
147
  export function isElementHidden(element) {
148
+ if (element.checkVisibility) {
149
+ return !element.checkVisibility({ visibilityProperty: true });
150
+ }
151
+
152
+ // TODO: checkVisibility is supported only from Safari 17.4, so we still need to
153
+ // keep the custom implementation as a fallback for older versions until Vaadin 25:
154
+
148
155
  // `offsetParent` is `null` when the element itself
149
156
  // or one of its ancestors is hidden with `display: none`.
150
157
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 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';
@@ -38,4 +38,10 @@ export declare class KeyboardDirectionMixinClass {
38
38
  * Focus the given item. Override this method to add custom logic.
39
39
  */
40
40
  protected _focusItem(item: Element, navigating: boolean): void;
41
+
42
+ /**
43
+ * Returns whether the item is focusable. By default,
44
+ * returns true if the item is not disabled.
45
+ */
46
+ protected _isItemFocusable(item: Element): boolean;
41
47
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 - 2024 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 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 { isElementFocused, isElementHidden } from './focus-utils.js';
@@ -171,7 +171,7 @@ export const KeyboardDirectionMixin = (superclass) =>
171
171
 
172
172
  const item = items[idx];
173
173
 
174
- if (!item.hasAttribute('disabled') && this.__isMatchingItem(item, condition)) {
174
+ if (this._isItemFocusable(item) && this.__isMatchingItem(item, condition)) {
175
175
  return idx;
176
176
  }
177
177
  }
@@ -189,4 +189,16 @@ export const KeyboardDirectionMixin = (superclass) =>
189
189
  __isMatchingItem(item, condition) {
190
190
  return typeof condition === 'function' ? condition(item) : true;
191
191
  }
192
+
193
+ /**
194
+ * Returns whether the item is focusable. By default,
195
+ * returns true if the item is not disabled.
196
+ *
197
+ * @param {Element} item
198
+ * @return {boolean}
199
+ * @protected
200
+ */
201
+ _isItemFocusable(item) {
202
+ return !item.hasAttribute('disabled');
203
+ }
192
204
  };
@@ -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';
@@ -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 { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.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 type { Constructor } from '@open-wc/dedupe-mixin';
package/src/list-mixin.js CHANGED
@@ -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 { timeOut } from '@vaadin/component-base/src/async.js';
@@ -40,6 +40,7 @@ export const ListMixin = (superClass) =>
40
40
  type: Number,
41
41
  reflectToAttribute: true,
42
42
  notify: true,
43
+ sync: true,
43
44
  },
44
45
 
45
46
  /**
@@ -265,15 +266,6 @@ export const ListMixin = (superClass) =>
265
266
  super._onKeyDown(event);
266
267
  }
267
268
 
268
- /**
269
- * @param {!Element} item
270
- * @return {boolean}
271
- * @protected
272
- */
273
- _isItemHidden(item) {
274
- return getComputedStyle(item).display === 'none';
275
- }
276
-
277
269
  /**
278
270
  * @param {number} idx
279
271
  * @protected
@@ -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 { CSSResult } 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
 
@@ -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';
@@ -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 { DisabledMixin } from './disabled-mixin.js';
@@ -52,6 +52,10 @@ export const TabindexMixin = (superclass) =>
52
52
  _disabledChanged(disabled, oldDisabled) {
53
53
  super._disabledChanged(disabled, oldDisabled);
54
54
 
55
+ if (this.__shouldAllowFocusWhenDisabled()) {
56
+ return;
57
+ }
58
+
55
59
  if (disabled) {
56
60
  if (this.tabindex !== undefined) {
57
61
  this._lastTabIndex = this.tabindex;
@@ -70,9 +74,39 @@ export const TabindexMixin = (superclass) =>
70
74
  * @protected
71
75
  */
72
76
  _tabindexChanged(tabindex) {
77
+ if (this.__shouldAllowFocusWhenDisabled()) {
78
+ return;
79
+ }
80
+
73
81
  if (this.disabled && tabindex !== -1) {
74
82
  this._lastTabIndex = tabindex;
75
83
  this.tabindex = -1;
76
84
  }
77
85
  }
86
+
87
+ /**
88
+ * Overrides the native `focus` method in order to prevent
89
+ * focusing the element when it is disabled. Note, setting
90
+ * `tabindex` to -1 does not prevent the element from being
91
+ * programmatically focusable.
92
+ *
93
+ * @protected
94
+ * @override
95
+ */
96
+ focus() {
97
+ if (!this.disabled || this.__shouldAllowFocusWhenDisabled()) {
98
+ super.focus();
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Returns whether the component should be focusable when disabled.
104
+ * Returns false by default.
105
+ *
106
+ * @private
107
+ * @return {boolean}
108
+ */
109
+ __shouldAllowFocusWhenDisabled() {
110
+ return false;
111
+ }
78
112
  };