@momentum-design/components 0.46.0 → 0.47.0
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/dist/browser/index.js +156 -141
- package/dist/browser/index.js.map +4 -4
- package/dist/components/screenreaderannouncer/index.d.ts +7 -0
- package/dist/components/screenreaderannouncer/index.js +4 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.component.d.ts +110 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.component.js +212 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.constants.d.ts +13 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.constants.js +14 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.d.ts +2 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.js +8 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.types.d.ts +3 -0
- package/dist/components/screenreaderannouncer/screenreaderannouncer.types.js +1 -0
- package/dist/custom-elements.json +179 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/screenreaderannouncer/index.d.ts +34 -0
- package/dist/react/screenreaderannouncer/index.js +43 -0
- package/package.json +2 -1
@@ -0,0 +1,110 @@
|
|
1
|
+
import type { CSSResult, PropertyValueMap } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
import { AriaLive } from './screenreaderannouncer.types';
|
4
|
+
/**
|
5
|
+
* `mdc-screenreaderannouncer` can be used to announce messages with the screen reader.
|
6
|
+
*
|
7
|
+
* To make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.
|
8
|
+
*
|
9
|
+
* **Internal logic**
|
10
|
+
*
|
11
|
+
* When the screenreader announcer is connected to the DOM, if the `identity` attribute is not
|
12
|
+
* provided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created
|
13
|
+
* in the DOM. If the `identity` attribute is provided, the identity element is used and no new element
|
14
|
+
* is created in the DOM.
|
15
|
+
*
|
16
|
+
* When the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with
|
17
|
+
* `aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.
|
18
|
+
* After delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.
|
19
|
+
*
|
20
|
+
* The announcement `<div>` element is removed from the DOM after `timeout` milliseconds.
|
21
|
+
*
|
22
|
+
* When the screen announcer component is disconnected from the DOM, all the timeouts are cleared and
|
23
|
+
* all the announcement elements added are removed from the DOM and timeouts cleared.
|
24
|
+
*
|
25
|
+
* **Note**
|
26
|
+
* 1. The default delay of 150 miliseconds is used as we dynamically generate the
|
27
|
+
* aria-live region in the DOM and add the announcement text to it.
|
28
|
+
* 3. If no `identity` is provided, all the screen reader components will create and use only one
|
29
|
+
* `<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.
|
30
|
+
*
|
31
|
+
* Reference: https://patrickhlauke.github.io/aria/tests/live-regions/
|
32
|
+
*
|
33
|
+
* @tagname mdc-screenreaderannouncer
|
34
|
+
*/
|
35
|
+
declare class ScreenreaderAnnouncer extends Component {
|
36
|
+
/**
|
37
|
+
* The announcement attribute is a string that is used to announce messages to the screen reader.
|
38
|
+
* The announcement is made when the announcement attribute is set to a non-empty string.
|
39
|
+
*
|
40
|
+
* @default ''
|
41
|
+
*/
|
42
|
+
announcement: string;
|
43
|
+
/**
|
44
|
+
* The id of the element in the light dom, to which announcement elements will be appended.
|
45
|
+
*
|
46
|
+
* If id is not provided, it will be set to `mdc-screenreaderannouncer-identity` and
|
47
|
+
* a div element with this id will be created in the light dom.
|
48
|
+
*/
|
49
|
+
identity: string;
|
50
|
+
/**
|
51
|
+
* Aria live value for announcement.
|
52
|
+
*
|
53
|
+
* @default 'polite'
|
54
|
+
*/
|
55
|
+
dataAriaLive: AriaLive;
|
56
|
+
/**
|
57
|
+
* Milliseconds to wait before adding the announcement to the identiy region in
|
58
|
+
* DOM, which will announce the message to the screen reader.
|
59
|
+
*
|
60
|
+
* @default 150
|
61
|
+
*/
|
62
|
+
delay: number;
|
63
|
+
/**
|
64
|
+
* Milliseconds to wait after which the announcement element will be removed from
|
65
|
+
* identity region in DOM, causing the screen reader to not announcing the message.
|
66
|
+
* @default 20_000
|
67
|
+
*/
|
68
|
+
timeout: number;
|
69
|
+
/**
|
70
|
+
* Array to store timeOutIds for clearing timeouts later.
|
71
|
+
* @internal
|
72
|
+
*/
|
73
|
+
private timeOutIds;
|
74
|
+
/**
|
75
|
+
* Array to store the ids of the announcement elements.
|
76
|
+
* @internal
|
77
|
+
*/
|
78
|
+
private ariaLiveAnnouncementIds;
|
79
|
+
/**
|
80
|
+
* Announces the given announcement to the screen reader.
|
81
|
+
*
|
82
|
+
* A div element with aria-live attribute set to the given ariaLive value is created
|
83
|
+
* and a p element with the announcement text is appended to it.
|
84
|
+
*
|
85
|
+
* The div element is appended to the element in the DOM identified with id as
|
86
|
+
* identity attribute.
|
87
|
+
*
|
88
|
+
* @param announcement - The announcement to be made.
|
89
|
+
* @param delay - The delay in milliseconds before announcing the message.
|
90
|
+
* @param timeout - The timeout in milliseconds before removing the announcement.
|
91
|
+
* @param ariaLive - The aria live value for the announcement.
|
92
|
+
*/
|
93
|
+
announce(announcement: string, delay: number, timeout: number, ariaLive: AriaLive): void;
|
94
|
+
/**
|
95
|
+
* Clears all timeouts and removes all announcements from the screen reader.
|
96
|
+
*/
|
97
|
+
private clearTimeOutsAndAnnouncements;
|
98
|
+
/**
|
99
|
+
* Creates a div element with id as identity attribute in the DOM.
|
100
|
+
*
|
101
|
+
* If the identity attribute is not provided, it is set internally to
|
102
|
+
* `mdc-screenreaderannouncer-identity`.
|
103
|
+
*/
|
104
|
+
private createAnnouncementAriaLiveRegion;
|
105
|
+
connectedCallback(): void;
|
106
|
+
disconnectedCallback(): void;
|
107
|
+
protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
108
|
+
static styles: Array<CSSResult>;
|
109
|
+
}
|
110
|
+
export default ScreenreaderAnnouncer;
|
@@ -0,0 +1,212 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { property } from 'lit/decorators.js';
|
11
|
+
import { v4 as uuidv4 } from 'uuid';
|
12
|
+
import { Component } from '../../models';
|
13
|
+
import { DEFAULTS } from './screenreaderannouncer.constants';
|
14
|
+
import styles from './screenreaderannouncer.styles';
|
15
|
+
/**
|
16
|
+
* `mdc-screenreaderannouncer` can be used to announce messages with the screen reader.
|
17
|
+
*
|
18
|
+
* To make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.
|
19
|
+
*
|
20
|
+
* **Internal logic**
|
21
|
+
*
|
22
|
+
* When the screenreader announcer is connected to the DOM, if the `identity` attribute is not
|
23
|
+
* provided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created
|
24
|
+
* in the DOM. If the `identity` attribute is provided, the identity element is used and no new element
|
25
|
+
* is created in the DOM.
|
26
|
+
*
|
27
|
+
* When the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with
|
28
|
+
* `aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.
|
29
|
+
* After delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.
|
30
|
+
*
|
31
|
+
* The announcement `<div>` element is removed from the DOM after `timeout` milliseconds.
|
32
|
+
*
|
33
|
+
* When the screen announcer component is disconnected from the DOM, all the timeouts are cleared and
|
34
|
+
* all the announcement elements added are removed from the DOM and timeouts cleared.
|
35
|
+
*
|
36
|
+
* **Note**
|
37
|
+
* 1. The default delay of 150 miliseconds is used as we dynamically generate the
|
38
|
+
* aria-live region in the DOM and add the announcement text to it.
|
39
|
+
* 3. If no `identity` is provided, all the screen reader components will create and use only one
|
40
|
+
* `<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.
|
41
|
+
*
|
42
|
+
* Reference: https://patrickhlauke.github.io/aria/tests/live-regions/
|
43
|
+
*
|
44
|
+
* @tagname mdc-screenreaderannouncer
|
45
|
+
*/
|
46
|
+
class ScreenreaderAnnouncer extends Component {
|
47
|
+
constructor() {
|
48
|
+
super(...arguments);
|
49
|
+
/**
|
50
|
+
* The announcement attribute is a string that is used to announce messages to the screen reader.
|
51
|
+
* The announcement is made when the announcement attribute is set to a non-empty string.
|
52
|
+
*
|
53
|
+
* @default ''
|
54
|
+
*/
|
55
|
+
this.announcement = '';
|
56
|
+
/**
|
57
|
+
* The id of the element in the light dom, to which announcement elements will be appended.
|
58
|
+
*
|
59
|
+
* If id is not provided, it will be set to `mdc-screenreaderannouncer-identity` and
|
60
|
+
* a div element with this id will be created in the light dom.
|
61
|
+
*/
|
62
|
+
this.identity = '';
|
63
|
+
/**
|
64
|
+
* Aria live value for announcement.
|
65
|
+
*
|
66
|
+
* @default 'polite'
|
67
|
+
*/
|
68
|
+
this.dataAriaLive = DEFAULTS.ARIA_LIVE;
|
69
|
+
/**
|
70
|
+
* Milliseconds to wait before adding the announcement to the identiy region in
|
71
|
+
* DOM, which will announce the message to the screen reader.
|
72
|
+
*
|
73
|
+
* @default 150
|
74
|
+
*/
|
75
|
+
this.delay = DEFAULTS.DELAY;
|
76
|
+
/**
|
77
|
+
* Milliseconds to wait after which the announcement element will be removed from
|
78
|
+
* identity region in DOM, causing the screen reader to not announcing the message.
|
79
|
+
* @default 20_000
|
80
|
+
*/
|
81
|
+
this.timeout = DEFAULTS.TIMEOUT;
|
82
|
+
/**
|
83
|
+
* Array to store timeOutIds for clearing timeouts later.
|
84
|
+
* @internal
|
85
|
+
*/
|
86
|
+
this.timeOutIds = [];
|
87
|
+
/**
|
88
|
+
* Array to store the ids of the announcement elements.
|
89
|
+
* @internal
|
90
|
+
*/
|
91
|
+
this.ariaLiveAnnouncementIds = [];
|
92
|
+
}
|
93
|
+
/**
|
94
|
+
* Announces the given announcement to the screen reader.
|
95
|
+
*
|
96
|
+
* A div element with aria-live attribute set to the given ariaLive value is created
|
97
|
+
* and a p element with the announcement text is appended to it.
|
98
|
+
*
|
99
|
+
* The div element is appended to the element in the DOM identified with id as
|
100
|
+
* identity attribute.
|
101
|
+
*
|
102
|
+
* @param announcement - The announcement to be made.
|
103
|
+
* @param delay - The delay in milliseconds before announcing the message.
|
104
|
+
* @param timeout - The timeout in milliseconds before removing the announcement.
|
105
|
+
* @param ariaLive - The aria live value for the announcement.
|
106
|
+
*/
|
107
|
+
announce(announcement, delay, timeout, ariaLive) {
|
108
|
+
var _a;
|
109
|
+
if (announcement.length > 0) {
|
110
|
+
const announcementId = `mdc-screenreaderannouncer-announcement-${uuidv4()}`;
|
111
|
+
const announcementContainer = document.createElement('div');
|
112
|
+
announcementContainer.id = announcementId;
|
113
|
+
announcementContainer.ariaLive = ariaLive;
|
114
|
+
(_a = document.getElementById(this.identity)) === null || _a === void 0 ? void 0 : _a.appendChild(announcementContainer);
|
115
|
+
const timeOutId = window.setTimeout(() => {
|
116
|
+
const announcementElement = document.createElement('p');
|
117
|
+
announcementElement.textContent = announcement;
|
118
|
+
announcementContainer.appendChild(announcementElement);
|
119
|
+
this.ariaLiveAnnouncementIds.push(announcementId);
|
120
|
+
const timeOutId = window.setTimeout(() => {
|
121
|
+
var _a;
|
122
|
+
(_a = document.getElementById(announcementId)) === null || _a === void 0 ? void 0 : _a.remove();
|
123
|
+
}, timeout);
|
124
|
+
this.timeOutIds.push(timeOutId);
|
125
|
+
}, delay);
|
126
|
+
this.timeOutIds.push(timeOutId);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
/**
|
130
|
+
* Clears all timeouts and removes all announcements from the screen reader.
|
131
|
+
*/
|
132
|
+
clearTimeOutsAndAnnouncements() {
|
133
|
+
this.timeOutIds.forEach((timeOutId) => {
|
134
|
+
window.clearTimeout(timeOutId);
|
135
|
+
});
|
136
|
+
this.ariaLiveAnnouncementIds.forEach((announcementId) => {
|
137
|
+
var _a;
|
138
|
+
(_a = document.getElementById(announcementId)) === null || _a === void 0 ? void 0 : _a.remove();
|
139
|
+
});
|
140
|
+
}
|
141
|
+
/**
|
142
|
+
* Creates a div element with id as identity attribute in the DOM.
|
143
|
+
*
|
144
|
+
* If the identity attribute is not provided, it is set internally to
|
145
|
+
* `mdc-screenreaderannouncer-identity`.
|
146
|
+
*/
|
147
|
+
createAnnouncementAriaLiveRegion() {
|
148
|
+
let liveRegionLightDom = document.getElementById(this.identity);
|
149
|
+
if (!liveRegionLightDom) {
|
150
|
+
liveRegionLightDom = document.createElement('div');
|
151
|
+
liveRegionLightDom.id = this.identity;
|
152
|
+
const styleElement = document.createElement('style');
|
153
|
+
styleElement.textContent = `
|
154
|
+
.mdc-screenreaderannouncer__visually-hidden {
|
155
|
+
clip: rect(0 0 0 0);
|
156
|
+
clip-path: inset(50%);
|
157
|
+
height: 1px;
|
158
|
+
overflow: hidden;
|
159
|
+
position: absolute;
|
160
|
+
white-space: nowrap;
|
161
|
+
width: 1px;
|
162
|
+
}
|
163
|
+
`;
|
164
|
+
liveRegionLightDom.appendChild(styleElement);
|
165
|
+
liveRegionLightDom.classList.add('mdc-screenreaderannouncer__visually-hidden');
|
166
|
+
document.body.appendChild(liveRegionLightDom);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
connectedCallback() {
|
170
|
+
super.connectedCallback();
|
171
|
+
if (this.identity.length === 0) {
|
172
|
+
this.identity = DEFAULTS.IDENTITY;
|
173
|
+
}
|
174
|
+
this.createAnnouncementAriaLiveRegion();
|
175
|
+
}
|
176
|
+
disconnectedCallback() {
|
177
|
+
super.disconnectedCallback();
|
178
|
+
this.clearTimeOutsAndAnnouncements();
|
179
|
+
}
|
180
|
+
updated(changedProperties) {
|
181
|
+
if (changedProperties.has('identity') && this.identity.length === 0) {
|
182
|
+
this.identity = DEFAULTS.IDENTITY;
|
183
|
+
this.createAnnouncementAriaLiveRegion();
|
184
|
+
}
|
185
|
+
if (changedProperties.has('announcement') && this.announcement.length > 0) {
|
186
|
+
this.announce(this.announcement, this.delay, this.timeout, this.dataAriaLive);
|
187
|
+
this.announcement = '';
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
ScreenreaderAnnouncer.styles = [...Component.styles, ...styles];
|
192
|
+
__decorate([
|
193
|
+
property({ type: String, reflect: true }),
|
194
|
+
__metadata("design:type", String)
|
195
|
+
], ScreenreaderAnnouncer.prototype, "announcement", void 0);
|
196
|
+
__decorate([
|
197
|
+
property({ type: String, reflect: true }),
|
198
|
+
__metadata("design:type", String)
|
199
|
+
], ScreenreaderAnnouncer.prototype, "identity", void 0);
|
200
|
+
__decorate([
|
201
|
+
property({ type: String, reflect: true, attribute: 'data-aria-live' }),
|
202
|
+
__metadata("design:type", String)
|
203
|
+
], ScreenreaderAnnouncer.prototype, "dataAriaLive", void 0);
|
204
|
+
__decorate([
|
205
|
+
property({ type: Number, reflect: true }),
|
206
|
+
__metadata("design:type", Number)
|
207
|
+
], ScreenreaderAnnouncer.prototype, "delay", void 0);
|
208
|
+
__decorate([
|
209
|
+
property({ type: Number, reflect: true }),
|
210
|
+
__metadata("design:type", Number)
|
211
|
+
], ScreenreaderAnnouncer.prototype, "timeout", void 0);
|
212
|
+
export default ScreenreaderAnnouncer;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-screenreaderannouncer";
|
2
|
+
declare const ARIA_LIVE_VALUES: {
|
3
|
+
readonly ASSERTIVE: "assertive";
|
4
|
+
readonly POLITE: "polite";
|
5
|
+
readonly OFF: "off";
|
6
|
+
};
|
7
|
+
declare const DEFAULTS: {
|
8
|
+
readonly ARIA_LIVE: "polite";
|
9
|
+
readonly DELAY: 150;
|
10
|
+
readonly IDENTITY: "mdc-screenreaderannouncer-identity";
|
11
|
+
readonly TIMEOUT: 20000;
|
12
|
+
};
|
13
|
+
export { ARIA_LIVE_VALUES, DEFAULTS, TAG_NAME };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('screenreaderannouncer');
|
3
|
+
const ARIA_LIVE_VALUES = {
|
4
|
+
ASSERTIVE: 'assertive',
|
5
|
+
POLITE: 'polite',
|
6
|
+
OFF: 'off',
|
7
|
+
};
|
8
|
+
const DEFAULTS = {
|
9
|
+
ARIA_LIVE: ARIA_LIVE_VALUES.POLITE,
|
10
|
+
DELAY: 150,
|
11
|
+
IDENTITY: 'mdc-screenreaderannouncer-identity',
|
12
|
+
TIMEOUT: 20000,
|
13
|
+
};
|
14
|
+
export { ARIA_LIVE_VALUES, DEFAULTS, TAG_NAME };
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -13179,6 +13179,185 @@
|
|
13179
13179
|
}
|
13180
13180
|
]
|
13181
13181
|
},
|
13182
|
+
{
|
13183
|
+
"kind": "javascript-module",
|
13184
|
+
"path": "components/screenreaderannouncer/screenreaderannouncer.component.js",
|
13185
|
+
"declarations": [
|
13186
|
+
{
|
13187
|
+
"kind": "class",
|
13188
|
+
"description": "`mdc-screenreaderannouncer` can be used to announce messages with the screen reader.\n\nTo make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.\n\n**Internal logic**\n\nWhen the screenreader announcer is connected to the DOM, if the `identity` attribute is not\nprovided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created\nin the DOM. If the `identity` attribute is provided, the identity element is used and no new element\nis created in the DOM.\n\nWhen the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with\n`aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.\nAfter delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.\n\nThe announcement `<div>` element is removed from the DOM after `timeout` milliseconds.\n\nWhen the screen announcer component is disconnected from the DOM, all the timeouts are cleared and\nall the announcement elements added are removed from the DOM and timeouts cleared.\n\n**Note**\n1. The default delay of 150 miliseconds is used as we dynamically generate the\naria-live region in the DOM and add the announcement text to it.\n3. If no `identity` is provided, all the screen reader components will create and use only one\n`<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.\n\nReference: https://patrickhlauke.github.io/aria/tests/live-regions/",
|
13189
|
+
"name": "ScreenreaderAnnouncer",
|
13190
|
+
"members": [
|
13191
|
+
{
|
13192
|
+
"kind": "field",
|
13193
|
+
"name": "announcement",
|
13194
|
+
"type": {
|
13195
|
+
"text": "string"
|
13196
|
+
},
|
13197
|
+
"default": "''",
|
13198
|
+
"description": "The announcement attribute is a string that is used to announce messages to the screen reader.\nThe announcement is made when the announcement attribute is set to a non-empty string.",
|
13199
|
+
"attribute": "announcement",
|
13200
|
+
"reflects": true
|
13201
|
+
},
|
13202
|
+
{
|
13203
|
+
"kind": "field",
|
13204
|
+
"name": "identity",
|
13205
|
+
"type": {
|
13206
|
+
"text": "string"
|
13207
|
+
},
|
13208
|
+
"default": "''",
|
13209
|
+
"description": "The id of the element in the light dom, to which announcement elements will be appended.\n\nIf id is not provided, it will be set to `mdc-screenreaderannouncer-identity` and\na div element with this id will be created in the light dom.",
|
13210
|
+
"attribute": "identity",
|
13211
|
+
"reflects": true
|
13212
|
+
},
|
13213
|
+
{
|
13214
|
+
"kind": "field",
|
13215
|
+
"name": "dataAriaLive",
|
13216
|
+
"type": {
|
13217
|
+
"text": "AriaLive"
|
13218
|
+
},
|
13219
|
+
"description": "Aria live value for announcement.",
|
13220
|
+
"default": "'polite'",
|
13221
|
+
"attribute": "data-aria-live",
|
13222
|
+
"reflects": true
|
13223
|
+
},
|
13224
|
+
{
|
13225
|
+
"kind": "field",
|
13226
|
+
"name": "delay",
|
13227
|
+
"type": {
|
13228
|
+
"text": "number"
|
13229
|
+
},
|
13230
|
+
"description": "Milliseconds to wait before adding the announcement to the identiy region in\nDOM, which will announce the message to the screen reader.",
|
13231
|
+
"default": "150",
|
13232
|
+
"attribute": "delay",
|
13233
|
+
"reflects": true
|
13234
|
+
},
|
13235
|
+
{
|
13236
|
+
"kind": "field",
|
13237
|
+
"name": "timeout",
|
13238
|
+
"type": {
|
13239
|
+
"text": "number"
|
13240
|
+
},
|
13241
|
+
"description": "Milliseconds to wait after which the announcement element will be removed from\nidentity region in DOM, causing the screen reader to not announcing the message.",
|
13242
|
+
"default": "20_000",
|
13243
|
+
"attribute": "timeout",
|
13244
|
+
"reflects": true
|
13245
|
+
},
|
13246
|
+
{
|
13247
|
+
"kind": "method",
|
13248
|
+
"name": "announce",
|
13249
|
+
"parameters": [
|
13250
|
+
{
|
13251
|
+
"name": "announcement",
|
13252
|
+
"type": {
|
13253
|
+
"text": "string"
|
13254
|
+
},
|
13255
|
+
"description": "The announcement to be made."
|
13256
|
+
},
|
13257
|
+
{
|
13258
|
+
"name": "delay",
|
13259
|
+
"type": {
|
13260
|
+
"text": "number"
|
13261
|
+
},
|
13262
|
+
"description": "The delay in milliseconds before announcing the message."
|
13263
|
+
},
|
13264
|
+
{
|
13265
|
+
"name": "timeout",
|
13266
|
+
"type": {
|
13267
|
+
"text": "number"
|
13268
|
+
},
|
13269
|
+
"description": "The timeout in milliseconds before removing the announcement."
|
13270
|
+
},
|
13271
|
+
{
|
13272
|
+
"name": "ariaLive",
|
13273
|
+
"type": {
|
13274
|
+
"text": "AriaLive"
|
13275
|
+
},
|
13276
|
+
"description": "The aria live value for the announcement."
|
13277
|
+
}
|
13278
|
+
],
|
13279
|
+
"description": "Announces the given announcement to the screen reader.\n\nA div element with aria-live attribute set to the given ariaLive value is created\nand a p element with the announcement text is appended to it.\n\nThe div element is appended to the element in the DOM identified with id as\nidentity attribute."
|
13280
|
+
},
|
13281
|
+
{
|
13282
|
+
"kind": "method",
|
13283
|
+
"name": "clearTimeOutsAndAnnouncements",
|
13284
|
+
"privacy": "private",
|
13285
|
+
"description": "Clears all timeouts and removes all announcements from the screen reader."
|
13286
|
+
},
|
13287
|
+
{
|
13288
|
+
"kind": "method",
|
13289
|
+
"name": "createAnnouncementAriaLiveRegion",
|
13290
|
+
"privacy": "private",
|
13291
|
+
"description": "Creates a div element with id as identity attribute in the DOM.\n\nIf the identity attribute is not provided, it is set internally to\n`mdc-screenreaderannouncer-identity`."
|
13292
|
+
}
|
13293
|
+
],
|
13294
|
+
"attributes": [
|
13295
|
+
{
|
13296
|
+
"name": "announcement",
|
13297
|
+
"type": {
|
13298
|
+
"text": "string"
|
13299
|
+
},
|
13300
|
+
"default": "''",
|
13301
|
+
"description": "The announcement attribute is a string that is used to announce messages to the screen reader.\nThe announcement is made when the announcement attribute is set to a non-empty string.",
|
13302
|
+
"fieldName": "announcement"
|
13303
|
+
},
|
13304
|
+
{
|
13305
|
+
"name": "identity",
|
13306
|
+
"type": {
|
13307
|
+
"text": "string"
|
13308
|
+
},
|
13309
|
+
"default": "''",
|
13310
|
+
"description": "The id of the element in the light dom, to which announcement elements will be appended.\n\nIf id is not provided, it will be set to `mdc-screenreaderannouncer-identity` and\na div element with this id will be created in the light dom.",
|
13311
|
+
"fieldName": "identity"
|
13312
|
+
},
|
13313
|
+
{
|
13314
|
+
"name": "data-aria-live",
|
13315
|
+
"type": {
|
13316
|
+
"text": "AriaLive"
|
13317
|
+
},
|
13318
|
+
"description": "Aria live value for announcement.",
|
13319
|
+
"default": "'polite'",
|
13320
|
+
"fieldName": "dataAriaLive"
|
13321
|
+
},
|
13322
|
+
{
|
13323
|
+
"name": "delay",
|
13324
|
+
"type": {
|
13325
|
+
"text": "number"
|
13326
|
+
},
|
13327
|
+
"description": "Milliseconds to wait before adding the announcement to the identiy region in\nDOM, which will announce the message to the screen reader.",
|
13328
|
+
"default": "150",
|
13329
|
+
"fieldName": "delay"
|
13330
|
+
},
|
13331
|
+
{
|
13332
|
+
"name": "timeout",
|
13333
|
+
"type": {
|
13334
|
+
"text": "number"
|
13335
|
+
},
|
13336
|
+
"description": "Milliseconds to wait after which the announcement element will be removed from\nidentity region in DOM, causing the screen reader to not announcing the message.",
|
13337
|
+
"default": "20_000",
|
13338
|
+
"fieldName": "timeout"
|
13339
|
+
}
|
13340
|
+
],
|
13341
|
+
"superclass": {
|
13342
|
+
"name": "Component",
|
13343
|
+
"module": "/src/models"
|
13344
|
+
},
|
13345
|
+
"tagName": "mdc-screenreaderannouncer",
|
13346
|
+
"jsDoc": "/**\n * `mdc-screenreaderannouncer` can be used to announce messages with the screen reader.\n *\n * To make an announcement set `announcement` attribute on the `mdc-screenreaderannouncer` element.\n *\n * **Internal logic**\n *\n * When the screenreader announcer is connected to the DOM, if the `identity` attribute is not\n * provided, it is set to `mdc-screenreaderannouncer-identity` and a `<div>` element with this id is created\n * in the DOM. If the `identity` attribute is provided, the identity element is used and no new element\n * is created in the DOM.\n *\n * When the `announcement` attribute is set, the screenreader announcer will create a `<div>` element with\n * `aria-live` attribute set to the value of `data-aria-live` attribute and append it to the `identity` element.\n * After delay of `delay` milliseconds, a <p> element with the announcement text is appended to the `<div>` element.\n *\n * The announcement `<div>` element is removed from the DOM after `timeout` milliseconds.\n *\n * When the screen announcer component is disconnected from the DOM, all the timeouts are cleared and\n * all the announcement elements added are removed from the DOM and timeouts cleared.\n *\n * **Note**\n * 1. The default delay of 150 miliseconds is used as we dynamically generate the\n * aria-live region in the DOM and add the announcement text to it.\n * 3. If no `identity` is provided, all the screen reader components will create and use only one\n * `<div>` element with id `mdc-screenreaderannouncer-identity` in the DOM.\n *\n * Reference: https://patrickhlauke.github.io/aria/tests/live-regions/\n *\n * @tagname mdc-screenreaderannouncer\n */",
|
13347
|
+
"customElement": true
|
13348
|
+
}
|
13349
|
+
],
|
13350
|
+
"exports": [
|
13351
|
+
{
|
13352
|
+
"kind": "js",
|
13353
|
+
"name": "default",
|
13354
|
+
"declaration": {
|
13355
|
+
"name": "ScreenreaderAnnouncer",
|
13356
|
+
"module": "components/screenreaderannouncer/screenreaderannouncer.component.js"
|
13357
|
+
}
|
13358
|
+
}
|
13359
|
+
]
|
13360
|
+
},
|
13182
13361
|
{
|
13183
13362
|
"kind": "javascript-module",
|
13184
13363
|
"path": "components/searchfield/searchfield.component.js",
|
package/dist/index.d.ts
CHANGED
@@ -36,6 +36,7 @@ import Textarea from './components/textarea';
|
|
36
36
|
import Searchfield from './components/searchfield';
|
37
37
|
import Brandvisual from './components/brandvisual';
|
38
38
|
import Appheader from './components/appheader';
|
39
|
+
import ScreenreaderAnnouncer from './components/screenreaderannouncer';
|
39
40
|
import type { SpinnerSize, SpinnerVariant } from './components/spinner/spinner.types';
|
40
41
|
import type { TextType } from './components/text/text.types';
|
41
42
|
import type { PopoverPlacement } from './components/popover/popover.types';
|
@@ -43,6 +44,6 @@ import type { BadgeType } from './components/badge/badge.types';
|
|
43
44
|
import type { IconButtonSize, PillButtonSize, ButtonVariant, ButtonColor } from './components/button/button.types';
|
44
45
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from './components/button/button.constants';
|
45
46
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
46
|
-
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, Textarea, Tooltip, Searchfield, Brandvisual, Appheader, };
|
47
|
+
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, Textarea, Tooltip, Searchfield, Brandvisual, Appheader, };
|
47
48
|
export type { TextType, SpinnerSize, SpinnerVariant, PopoverPlacement, BadgeType, IconButtonSize, PillButtonSize, ButtonVariant, ButtonColor, };
|
48
49
|
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
|
package/dist/index.js
CHANGED
@@ -37,10 +37,11 @@ import Textarea from './components/textarea';
|
|
37
37
|
import Searchfield from './components/searchfield';
|
38
38
|
import Brandvisual from './components/brandvisual';
|
39
39
|
import Appheader from './components/appheader';
|
40
|
+
import ScreenreaderAnnouncer from './components/screenreaderannouncer';
|
40
41
|
// Constants / Utils Imports
|
41
42
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './components/button/button.constants';
|
42
43
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
43
44
|
// Components Exports
|
44
|
-
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, Textarea, Tooltip, Searchfield, Brandvisual, Appheader, };
|
45
|
+
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, Textarea, Tooltip, Searchfield, Brandvisual, Appheader, };
|
45
46
|
// Constants / Utils Exports
|
46
47
|
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
|
package/dist/react/index.d.ts
CHANGED
@@ -29,6 +29,7 @@ export { default as Presence } from './presence';
|
|
29
29
|
export { default as Progressbar } from './progressbar';
|
30
30
|
export { default as Radio } from './radio';
|
31
31
|
export { default as RadioGroup } from './radiogroup';
|
32
|
+
export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
32
33
|
export { default as Searchfield } from './searchfield';
|
33
34
|
export { default as Spinner } from './spinner';
|
34
35
|
export { default as Tab } from './tab';
|
package/dist/react/index.js
CHANGED
@@ -29,6 +29,7 @@ export { default as Presence } from './presence';
|
|
29
29
|
export { default as Progressbar } from './progressbar';
|
30
30
|
export { default as Radio } from './radio';
|
31
31
|
export { default as RadioGroup } from './radiogroup';
|
32
|
+
export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
|
32
33
|
export { default as Searchfield } from './searchfield';
|
33
34
|
export { default as Spinner } from './spinner';
|
34
35
|
export { default as Tab } from './tab';
|