@vaadin/component-base 23.0.0-beta1 → 23.0.0-beta2
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/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/a11y-announcer.d.ts +1 -1
- package/src/a11y-announcer.js +17 -1
- package/src/element-mixin.js +1 -1
- package/src/focus-trap-controller.js +2 -1
- package/src/focus-utils.js +3 -3
- package/src/slot-controller.js +6 -2
- package/src/tabindex-mixin.js +3 -1
package/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { ElementMixin } from './src/element-mixin.js';
|
|
|
6
6
|
export { FocusMixin } from './src/focus-mixin.js';
|
|
7
7
|
export { FocusTrapController } from './src/focus-trap-controller.js';
|
|
8
8
|
export { KeyboardMixin } from './src/keyboard-mixin.js';
|
|
9
|
+
export { ResizeMixin } from './src/resize-mixin.js';
|
|
9
10
|
export { SlotController } from './src/slot-controller.js';
|
|
10
11
|
export { SlotMixin } from './src/slot-mixin.js';
|
|
11
12
|
export { TabindexMixin } from './src/tabindex-mixin.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
43
43
|
"sinon": "^9.2.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a276f7a0fd00e5459b87267468e0dd0d4fb6f7f3"
|
|
46
46
|
}
|
package/src/a11y-announcer.d.ts
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Cause a text string to be announced by screen readers.
|
|
9
9
|
*/
|
|
10
|
-
export function announce(text: string, options?: { mode?: 'polite' | 'assertive'; timeout?: number }): void;
|
|
10
|
+
export function announce(text: string, options?: { mode?: 'polite' | 'assertive' | 'alert'; timeout?: number }): void;
|
package/src/a11y-announcer.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
8
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
|
+
|
|
7
10
|
const region = document.createElement('div');
|
|
8
11
|
|
|
9
12
|
region.style.position = 'fixed';
|
|
@@ -12,6 +15,7 @@ region.setAttribute('aria-live', 'polite');
|
|
|
12
15
|
|
|
13
16
|
document.body.appendChild(region);
|
|
14
17
|
|
|
18
|
+
let alertDebouncer;
|
|
15
19
|
/**
|
|
16
20
|
* Cause a text string to be announced by screen readers.
|
|
17
21
|
*
|
|
@@ -22,7 +26,19 @@ export function announce(text, options = {}) {
|
|
|
22
26
|
const mode = options.mode || 'polite';
|
|
23
27
|
const timeout = options.timeout === undefined ? 150 : options.timeout;
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
if (mode === 'alert') {
|
|
30
|
+
region.removeAttribute('aria-live');
|
|
31
|
+
region.removeAttribute('role');
|
|
32
|
+
alertDebouncer = Debouncer.debounce(alertDebouncer, animationFrame, () => {
|
|
33
|
+
region.setAttribute('role', 'alert');
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
if (alertDebouncer) {
|
|
37
|
+
alertDebouncer.cancel();
|
|
38
|
+
}
|
|
39
|
+
region.removeAttribute('role');
|
|
40
|
+
region.setAttribute('aria-live', mode);
|
|
41
|
+
}
|
|
26
42
|
|
|
27
43
|
region.textContent = '';
|
|
28
44
|
|
package/src/element-mixin.js
CHANGED
|
@@ -134,6 +134,7 @@ export class FocusTrapController {
|
|
|
134
134
|
* @private
|
|
135
135
|
*/
|
|
136
136
|
get __focusedElementIndex() {
|
|
137
|
-
|
|
137
|
+
const focusableElements = this.__focusableElements;
|
|
138
|
+
return focusableElements.indexOf(focusableElements.filter(isElementFocused).pop());
|
|
138
139
|
}
|
|
139
140
|
}
|
package/src/focus-utils.js
CHANGED
|
@@ -39,7 +39,7 @@ function isElementHiddenDirectly(element) {
|
|
|
39
39
|
* @return {number}
|
|
40
40
|
*/
|
|
41
41
|
function normalizeTabIndex(element) {
|
|
42
|
-
if (!isElementFocusable(element)
|
|
42
|
+
if (!isElementFocusable(element)) {
|
|
43
43
|
return -1;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -116,8 +116,8 @@ function sortElementsByTabIndex(elements) {
|
|
|
116
116
|
* @private
|
|
117
117
|
*/
|
|
118
118
|
function collectFocusableNodes(node, result) {
|
|
119
|
-
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
120
|
-
// Don't traverse children if the node is not an HTML element.
|
|
119
|
+
if (node.nodeType !== Node.ELEMENT_NODE || isElementHiddenDirectly(node)) {
|
|
120
|
+
// Don't traverse children if the node is not an HTML element or not visible.
|
|
121
121
|
return false;
|
|
122
122
|
}
|
|
123
123
|
|
package/src/slot-controller.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
6
7
|
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -30,10 +31,13 @@ export class SlotController extends EventTarget {
|
|
|
30
31
|
static generateId(slotName, host) {
|
|
31
32
|
const prefix = slotName || 'default';
|
|
32
33
|
|
|
34
|
+
// Support dash-case slot names e.g. "error-message"
|
|
35
|
+
const field = `${dashToCamelCase(prefix)}Id`;
|
|
36
|
+
|
|
33
37
|
// Maintain the unique ID counter for a given prefix.
|
|
34
|
-
this[
|
|
38
|
+
this[field] = 1 + this[field] || 0;
|
|
35
39
|
|
|
36
|
-
return `${prefix}-${host.localName}-${this[
|
|
40
|
+
return `${prefix}-${host.localName}-${this[field]}`;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
hostConnected() {
|
package/src/tabindex-mixin.js
CHANGED
|
@@ -56,7 +56,9 @@ export const TabindexMixin = (superclass) =>
|
|
|
56
56
|
super._disabledChanged(disabled, oldDisabled);
|
|
57
57
|
|
|
58
58
|
if (disabled) {
|
|
59
|
-
this.
|
|
59
|
+
if (this.tabindex !== undefined) {
|
|
60
|
+
this.__lastTabIndex = this.tabindex;
|
|
61
|
+
}
|
|
60
62
|
this.tabindex = -1;
|
|
61
63
|
} else if (oldDisabled) {
|
|
62
64
|
this.tabindex = this.__lastTabIndex;
|