@react-aria/live-announcer 3.3.2 → 3.3.4
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/LiveAnnouncer.main.js +93 -0
- package/dist/LiveAnnouncer.main.js.map +1 -0
- package/dist/LiveAnnouncer.mjs +86 -0
- package/dist/LiveAnnouncer.module.js +86 -0
- package/dist/LiveAnnouncer.module.js.map +1 -0
- package/dist/import.mjs +3 -84
- package/dist/main.js +6 -87
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -84
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
|
|
2
|
+
function $parcel$export(e, n, v, s) {
|
|
3
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
$parcel$export(module.exports, "announce", () => $97cebfa4133ebec3$export$a9b970dcc4ae71a9);
|
|
7
|
+
$parcel$export(module.exports, "clearAnnouncer", () => $97cebfa4133ebec3$export$d10ae4f68404609a);
|
|
8
|
+
$parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$export$d8686216b8b81b2f);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
20
|
+
let $97cebfa4133ebec3$var$liveAnnouncer = null;
|
|
21
|
+
function $97cebfa4133ebec3$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
22
|
+
if (!$97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer = new $97cebfa4133ebec3$var$LiveAnnouncer();
|
|
23
|
+
$97cebfa4133ebec3$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
24
|
+
}
|
|
25
|
+
function $97cebfa4133ebec3$export$d10ae4f68404609a(assertiveness) {
|
|
26
|
+
if ($97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer.clear(assertiveness);
|
|
27
|
+
}
|
|
28
|
+
function $97cebfa4133ebec3$export$d8686216b8b81b2f() {
|
|
29
|
+
if ($97cebfa4133ebec3$var$liveAnnouncer) {
|
|
30
|
+
$97cebfa4133ebec3$var$liveAnnouncer.destroy();
|
|
31
|
+
$97cebfa4133ebec3$var$liveAnnouncer = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
35
|
+
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
36
|
+
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
37
|
+
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
38
|
+
// is simple enough to implement without React, so that's what we do here.
|
|
39
|
+
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
40
|
+
class $97cebfa4133ebec3$var$LiveAnnouncer {
|
|
41
|
+
createLog(ariaLive) {
|
|
42
|
+
let node = document.createElement('div');
|
|
43
|
+
node.setAttribute('role', 'log');
|
|
44
|
+
node.setAttribute('aria-live', ariaLive);
|
|
45
|
+
node.setAttribute('aria-relevant', 'additions');
|
|
46
|
+
return node;
|
|
47
|
+
}
|
|
48
|
+
destroy() {
|
|
49
|
+
if (!this.node) return;
|
|
50
|
+
document.body.removeChild(this.node);
|
|
51
|
+
this.node = null;
|
|
52
|
+
}
|
|
53
|
+
announce(message, assertiveness = 'assertive', timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
54
|
+
if (!this.node) return;
|
|
55
|
+
let node = document.createElement('div');
|
|
56
|
+
node.textContent = message;
|
|
57
|
+
if (assertiveness === 'assertive') this.assertiveLog.appendChild(node);
|
|
58
|
+
else this.politeLog.appendChild(node);
|
|
59
|
+
if (message !== '') setTimeout(()=>{
|
|
60
|
+
node.remove();
|
|
61
|
+
}, timeout);
|
|
62
|
+
}
|
|
63
|
+
clear(assertiveness) {
|
|
64
|
+
if (!this.node) return;
|
|
65
|
+
if (!assertiveness || assertiveness === 'assertive') this.assertiveLog.innerHTML = '';
|
|
66
|
+
if (!assertiveness || assertiveness === 'polite') this.politeLog.innerHTML = '';
|
|
67
|
+
}
|
|
68
|
+
constructor(){
|
|
69
|
+
this.node = document.createElement('div');
|
|
70
|
+
this.node.dataset.liveAnnouncer = 'true';
|
|
71
|
+
// copied from VisuallyHidden
|
|
72
|
+
Object.assign(this.node.style, {
|
|
73
|
+
border: 0,
|
|
74
|
+
clip: 'rect(0 0 0 0)',
|
|
75
|
+
clipPath: 'inset(50%)',
|
|
76
|
+
height: '1px',
|
|
77
|
+
margin: '-1px',
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
padding: 0,
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
width: '1px',
|
|
82
|
+
whiteSpace: 'nowrap'
|
|
83
|
+
});
|
|
84
|
+
this.assertiveLog = this.createLog('assertive');
|
|
85
|
+
this.node.appendChild(this.assertiveLog);
|
|
86
|
+
this.politeLog = this.createLog('polite');
|
|
87
|
+
this.node.appendChild(this.politeLog);
|
|
88
|
+
document.body.prepend(this.node);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=LiveAnnouncer.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAID,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAAsC;AAKnC,SAAS,0CACd,OAAe,EACf,gBAA+B,WAAW,EAC1C,UAAU,8CAAwB;IAElC,IAAI,CAAC,qCACH,sCAAgB,IAAI;IAGtB,oCAAc,QAAQ,CAAC,SAAS,eAAe;AACjD;AAKO,SAAS,0CAAe,aAA4B;IACzD,IAAI,qCACF,oCAAc,KAAK,CAAC;AAExB;AAKO,SAAS;IACd,IAAI,qCAAe;QACjB,oCAAc,OAAO;QACrB,sCAAgB;IAClB;AACF;AAEA,2FAA2F;AAC3F,0FAA0F;AAC1F,mGAAmG;AACnG,iGAAiG;AACjG,0EAA0E;AAC1E,sHAAsH;AACtH,MAAM;IA+BJ,UAAU,QAAgB,EAAE;QAC1B,IAAI,OAAO,SAAS,aAAa,CAAC;QAClC,KAAK,YAAY,CAAC,QAAQ;QAC1B,KAAK,YAAY,CAAC,aAAa;QAC/B,KAAK,YAAY,CAAC,iBAAiB;QACnC,OAAO;IACT;IAEA,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI;QACnC,IAAI,CAAC,IAAI,GAAG;IACd;IAEA,SAAS,OAAe,EAAE,gBAAgB,WAAW,EAAE,UAAU,8CAAwB,EAAE;QACzF,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,IAAI,OAAO,SAAS,aAAa,CAAC;QAClC,KAAK,WAAW,GAAG;QAEnB,IAAI,kBAAkB,aACpB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;aAE9B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;QAG7B,IAAI,YAAY,IACd,WAAW;YACT,KAAK,MAAM;QACb,GAAG;IAEP;IAEA,MAAM,aAA4B,EAAE;QAClC,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,IAAI,CAAC,iBAAiB,kBAAkB,aACtC,IAAI,CAAC,YAAY,CAAC,SAAS,GAAG;QAGhC,IAAI,CAAC,iBAAiB,kBAAkB,UACtC,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG;IAE/B;IA5EA,aAAc;QACZ,IAAI,CAAC,IAAI,GAAG,SAAS,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG;QAClC,6BAA6B;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YAC7B,QAAQ;YACR,MAAM;YACN,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,SAAS;YACT,UAAU;YACV,OAAO;YACP,YAAY;QACd;QAEA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY;QAEvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS;QAEpC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IACjC;AAqDF","sources":["packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ntype Assertiveness = 'assertive' | 'polite';\n\n/* Inspired by https://github.com/AlmeroSteyn/react-aria-live */\nconst LIVEREGION_TIMEOUT_DELAY = 7000;\n\nlet liveAnnouncer: LiveAnnouncer | null = null;\n\n/**\n * Announces the message using screen reader technology.\n */\nexport function announce(\n message: string,\n assertiveness: Assertiveness = 'assertive',\n timeout = LIVEREGION_TIMEOUT_DELAY\n) {\n if (!liveAnnouncer) {\n liveAnnouncer = new LiveAnnouncer();\n }\n\n liveAnnouncer.announce(message, assertiveness, timeout);\n}\n\n/**\n * Stops all queued announcements.\n */\nexport function clearAnnouncer(assertiveness: Assertiveness) {\n if (liveAnnouncer) {\n liveAnnouncer.clear(assertiveness);\n }\n}\n\n/**\n * Removes the announcer from the DOM.\n */\nexport function destroyAnnouncer() {\n if (liveAnnouncer) {\n liveAnnouncer.destroy();\n liveAnnouncer = null;\n }\n}\n\n// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18\n// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a\n// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.\n// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer\n// is simple enough to implement without React, so that's what we do here.\n// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638\nclass LiveAnnouncer {\n node: HTMLElement | null;\n assertiveLog: HTMLElement;\n politeLog: HTMLElement;\n\n constructor() {\n this.node = document.createElement('div');\n this.node.dataset.liveAnnouncer = 'true';\n // copied from VisuallyHidden\n Object.assign(this.node.style, {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: '1px',\n whiteSpace: 'nowrap'\n });\n\n this.assertiveLog = this.createLog('assertive');\n this.node.appendChild(this.assertiveLog);\n\n this.politeLog = this.createLog('polite');\n this.node.appendChild(this.politeLog);\n\n document.body.prepend(this.node);\n }\n\n createLog(ariaLive: string) {\n let node = document.createElement('div');\n node.setAttribute('role', 'log');\n node.setAttribute('aria-live', ariaLive);\n node.setAttribute('aria-relevant', 'additions');\n return node;\n }\n\n destroy() {\n if (!this.node) {\n return;\n }\n\n document.body.removeChild(this.node);\n this.node = null;\n }\n\n announce(message: string, assertiveness = 'assertive', timeout = LIVEREGION_TIMEOUT_DELAY) {\n if (!this.node) {\n return;\n }\n\n let node = document.createElement('div');\n node.textContent = message;\n\n if (assertiveness === 'assertive') {\n this.assertiveLog.appendChild(node);\n } else {\n this.politeLog.appendChild(node);\n }\n\n if (message !== '') {\n setTimeout(() => {\n node.remove();\n }, timeout);\n }\n }\n\n clear(assertiveness: Assertiveness) {\n if (!this.node) {\n return;\n }\n\n if (!assertiveness || assertiveness === 'assertive') {\n this.assertiveLog.innerHTML = '';\n }\n\n if (!assertiveness || assertiveness === 'polite') {\n this.politeLog.innerHTML = '';\n }\n }\n}\n"],"names":[],"version":3,"file":"LiveAnnouncer.main.js.map"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
12
|
+
let $319e236875307eab$var$liveAnnouncer = null;
|
|
13
|
+
function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
14
|
+
if (!$319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
|
|
15
|
+
$319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
16
|
+
}
|
|
17
|
+
function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
|
|
18
|
+
if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
|
|
19
|
+
}
|
|
20
|
+
function $319e236875307eab$export$d8686216b8b81b2f() {
|
|
21
|
+
if ($319e236875307eab$var$liveAnnouncer) {
|
|
22
|
+
$319e236875307eab$var$liveAnnouncer.destroy();
|
|
23
|
+
$319e236875307eab$var$liveAnnouncer = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
27
|
+
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
28
|
+
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
29
|
+
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
30
|
+
// is simple enough to implement without React, so that's what we do here.
|
|
31
|
+
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
32
|
+
class $319e236875307eab$var$LiveAnnouncer {
|
|
33
|
+
createLog(ariaLive) {
|
|
34
|
+
let node = document.createElement('div');
|
|
35
|
+
node.setAttribute('role', 'log');
|
|
36
|
+
node.setAttribute('aria-live', ariaLive);
|
|
37
|
+
node.setAttribute('aria-relevant', 'additions');
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
if (!this.node) return;
|
|
42
|
+
document.body.removeChild(this.node);
|
|
43
|
+
this.node = null;
|
|
44
|
+
}
|
|
45
|
+
announce(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
46
|
+
if (!this.node) return;
|
|
47
|
+
let node = document.createElement('div');
|
|
48
|
+
node.textContent = message;
|
|
49
|
+
if (assertiveness === 'assertive') this.assertiveLog.appendChild(node);
|
|
50
|
+
else this.politeLog.appendChild(node);
|
|
51
|
+
if (message !== '') setTimeout(()=>{
|
|
52
|
+
node.remove();
|
|
53
|
+
}, timeout);
|
|
54
|
+
}
|
|
55
|
+
clear(assertiveness) {
|
|
56
|
+
if (!this.node) return;
|
|
57
|
+
if (!assertiveness || assertiveness === 'assertive') this.assertiveLog.innerHTML = '';
|
|
58
|
+
if (!assertiveness || assertiveness === 'polite') this.politeLog.innerHTML = '';
|
|
59
|
+
}
|
|
60
|
+
constructor(){
|
|
61
|
+
this.node = document.createElement('div');
|
|
62
|
+
this.node.dataset.liveAnnouncer = 'true';
|
|
63
|
+
// copied from VisuallyHidden
|
|
64
|
+
Object.assign(this.node.style, {
|
|
65
|
+
border: 0,
|
|
66
|
+
clip: 'rect(0 0 0 0)',
|
|
67
|
+
clipPath: 'inset(50%)',
|
|
68
|
+
height: '1px',
|
|
69
|
+
margin: '-1px',
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
padding: 0,
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
width: '1px',
|
|
74
|
+
whiteSpace: 'nowrap'
|
|
75
|
+
});
|
|
76
|
+
this.assertiveLog = this.createLog('assertive');
|
|
77
|
+
this.node.appendChild(this.assertiveLog);
|
|
78
|
+
this.politeLog = this.createLog('polite');
|
|
79
|
+
this.node.appendChild(this.politeLog);
|
|
80
|
+
document.body.prepend(this.node);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};
|
|
86
|
+
//# sourceMappingURL=LiveAnnouncer.module.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
12
|
+
let $319e236875307eab$var$liveAnnouncer = null;
|
|
13
|
+
function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
14
|
+
if (!$319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
|
|
15
|
+
$319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
16
|
+
}
|
|
17
|
+
function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
|
|
18
|
+
if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
|
|
19
|
+
}
|
|
20
|
+
function $319e236875307eab$export$d8686216b8b81b2f() {
|
|
21
|
+
if ($319e236875307eab$var$liveAnnouncer) {
|
|
22
|
+
$319e236875307eab$var$liveAnnouncer.destroy();
|
|
23
|
+
$319e236875307eab$var$liveAnnouncer = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
27
|
+
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
28
|
+
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
29
|
+
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
30
|
+
// is simple enough to implement without React, so that's what we do here.
|
|
31
|
+
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
32
|
+
class $319e236875307eab$var$LiveAnnouncer {
|
|
33
|
+
createLog(ariaLive) {
|
|
34
|
+
let node = document.createElement('div');
|
|
35
|
+
node.setAttribute('role', 'log');
|
|
36
|
+
node.setAttribute('aria-live', ariaLive);
|
|
37
|
+
node.setAttribute('aria-relevant', 'additions');
|
|
38
|
+
return node;
|
|
39
|
+
}
|
|
40
|
+
destroy() {
|
|
41
|
+
if (!this.node) return;
|
|
42
|
+
document.body.removeChild(this.node);
|
|
43
|
+
this.node = null;
|
|
44
|
+
}
|
|
45
|
+
announce(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
46
|
+
if (!this.node) return;
|
|
47
|
+
let node = document.createElement('div');
|
|
48
|
+
node.textContent = message;
|
|
49
|
+
if (assertiveness === 'assertive') this.assertiveLog.appendChild(node);
|
|
50
|
+
else this.politeLog.appendChild(node);
|
|
51
|
+
if (message !== '') setTimeout(()=>{
|
|
52
|
+
node.remove();
|
|
53
|
+
}, timeout);
|
|
54
|
+
}
|
|
55
|
+
clear(assertiveness) {
|
|
56
|
+
if (!this.node) return;
|
|
57
|
+
if (!assertiveness || assertiveness === 'assertive') this.assertiveLog.innerHTML = '';
|
|
58
|
+
if (!assertiveness || assertiveness === 'polite') this.politeLog.innerHTML = '';
|
|
59
|
+
}
|
|
60
|
+
constructor(){
|
|
61
|
+
this.node = document.createElement('div');
|
|
62
|
+
this.node.dataset.liveAnnouncer = 'true';
|
|
63
|
+
// copied from VisuallyHidden
|
|
64
|
+
Object.assign(this.node.style, {
|
|
65
|
+
border: 0,
|
|
66
|
+
clip: 'rect(0 0 0 0)',
|
|
67
|
+
clipPath: 'inset(50%)',
|
|
68
|
+
height: '1px',
|
|
69
|
+
margin: '-1px',
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
padding: 0,
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
width: '1px',
|
|
74
|
+
whiteSpace: 'nowrap'
|
|
75
|
+
});
|
|
76
|
+
this.assertiveLog = this.createLog('assertive');
|
|
77
|
+
this.node.appendChild(this.assertiveLog);
|
|
78
|
+
this.politeLog = this.createLog('polite');
|
|
79
|
+
this.node.appendChild(this.politeLog);
|
|
80
|
+
document.body.prepend(this.node);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};
|
|
86
|
+
//# sourceMappingURL=LiveAnnouncer.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAID,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAAsC;AAKnC,SAAS,0CACd,OAAe,EACf,gBAA+B,WAAW,EAC1C,UAAU,8CAAwB;IAElC,IAAI,CAAC,qCACH,sCAAgB,IAAI;IAGtB,oCAAc,QAAQ,CAAC,SAAS,eAAe;AACjD;AAKO,SAAS,0CAAe,aAA4B;IACzD,IAAI,qCACF,oCAAc,KAAK,CAAC;AAExB;AAKO,SAAS;IACd,IAAI,qCAAe;QACjB,oCAAc,OAAO;QACrB,sCAAgB;IAClB;AACF;AAEA,2FAA2F;AAC3F,0FAA0F;AAC1F,mGAAmG;AACnG,iGAAiG;AACjG,0EAA0E;AAC1E,sHAAsH;AACtH,MAAM;IA+BJ,UAAU,QAAgB,EAAE;QAC1B,IAAI,OAAO,SAAS,aAAa,CAAC;QAClC,KAAK,YAAY,CAAC,QAAQ;QAC1B,KAAK,YAAY,CAAC,aAAa;QAC/B,KAAK,YAAY,CAAC,iBAAiB;QACnC,OAAO;IACT;IAEA,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI;QACnC,IAAI,CAAC,IAAI,GAAG;IACd;IAEA,SAAS,OAAe,EAAE,gBAAgB,WAAW,EAAE,UAAU,8CAAwB,EAAE;QACzF,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,IAAI,OAAO,SAAS,aAAa,CAAC;QAClC,KAAK,WAAW,GAAG;QAEnB,IAAI,kBAAkB,aACpB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC;aAE9B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;QAG7B,IAAI,YAAY,IACd,WAAW;YACT,KAAK,MAAM;QACb,GAAG;IAEP;IAEA,MAAM,aAA4B,EAAE;QAClC,IAAI,CAAC,IAAI,CAAC,IAAI,EACZ;QAGF,IAAI,CAAC,iBAAiB,kBAAkB,aACtC,IAAI,CAAC,YAAY,CAAC,SAAS,GAAG;QAGhC,IAAI,CAAC,iBAAiB,kBAAkB,UACtC,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG;IAE/B;IA5EA,aAAc;QACZ,IAAI,CAAC,IAAI,GAAG,SAAS,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG;QAClC,6BAA6B;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YAC7B,QAAQ;YACR,MAAM;YACN,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,SAAS;YACT,UAAU;YACV,OAAO;YACP,YAAY;QACd;QAEA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY;QAEvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS;QAEpC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IACjC;AAqDF","sources":["packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ntype Assertiveness = 'assertive' | 'polite';\n\n/* Inspired by https://github.com/AlmeroSteyn/react-aria-live */\nconst LIVEREGION_TIMEOUT_DELAY = 7000;\n\nlet liveAnnouncer: LiveAnnouncer | null = null;\n\n/**\n * Announces the message using screen reader technology.\n */\nexport function announce(\n message: string,\n assertiveness: Assertiveness = 'assertive',\n timeout = LIVEREGION_TIMEOUT_DELAY\n) {\n if (!liveAnnouncer) {\n liveAnnouncer = new LiveAnnouncer();\n }\n\n liveAnnouncer.announce(message, assertiveness, timeout);\n}\n\n/**\n * Stops all queued announcements.\n */\nexport function clearAnnouncer(assertiveness: Assertiveness) {\n if (liveAnnouncer) {\n liveAnnouncer.clear(assertiveness);\n }\n}\n\n/**\n * Removes the announcer from the DOM.\n */\nexport function destroyAnnouncer() {\n if (liveAnnouncer) {\n liveAnnouncer.destroy();\n liveAnnouncer = null;\n }\n}\n\n// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18\n// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a\n// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.\n// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer\n// is simple enough to implement without React, so that's what we do here.\n// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638\nclass LiveAnnouncer {\n node: HTMLElement | null;\n assertiveLog: HTMLElement;\n politeLog: HTMLElement;\n\n constructor() {\n this.node = document.createElement('div');\n this.node.dataset.liveAnnouncer = 'true';\n // copied from VisuallyHidden\n Object.assign(this.node.style, {\n border: 0,\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: '1px',\n margin: '-1px',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: '1px',\n whiteSpace: 'nowrap'\n });\n\n this.assertiveLog = this.createLog('assertive');\n this.node.appendChild(this.assertiveLog);\n\n this.politeLog = this.createLog('polite');\n this.node.appendChild(this.politeLog);\n\n document.body.prepend(this.node);\n }\n\n createLog(ariaLive: string) {\n let node = document.createElement('div');\n node.setAttribute('role', 'log');\n node.setAttribute('aria-live', ariaLive);\n node.setAttribute('aria-relevant', 'additions');\n return node;\n }\n\n destroy() {\n if (!this.node) {\n return;\n }\n\n document.body.removeChild(this.node);\n this.node = null;\n }\n\n announce(message: string, assertiveness = 'assertive', timeout = LIVEREGION_TIMEOUT_DELAY) {\n if (!this.node) {\n return;\n }\n\n let node = document.createElement('div');\n node.textContent = message;\n\n if (assertiveness === 'assertive') {\n this.assertiveLog.appendChild(node);\n } else {\n this.politeLog.appendChild(node);\n }\n\n if (message !== '') {\n setTimeout(() => {\n node.remove();\n }, timeout);\n }\n }\n\n clear(assertiveness: Assertiveness) {\n if (!this.node) {\n return;\n }\n\n if (!assertiveness || assertiveness === 'assertive') {\n this.assertiveLog.innerHTML = '';\n }\n\n if (!assertiveness || assertiveness === 'polite') {\n this.politeLog.innerHTML = '';\n }\n }\n}\n"],"names":[],"version":3,"file":"LiveAnnouncer.module.js.map"}
|
package/dist/import.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {announce as $319e236875307eab$export$a9b970dcc4ae71a9, clearAnnouncer as $319e236875307eab$export$d10ae4f68404609a, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f} from "./LiveAnnouncer.mjs";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
3
5
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -8,90 +10,7 @@
|
|
|
8
10
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
11
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
12
|
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
22
|
-
let $319e236875307eab$var$liveAnnouncer = null;
|
|
23
|
-
function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
24
|
-
if (!$319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
|
|
25
|
-
$319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
26
|
-
}
|
|
27
|
-
function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
|
|
28
|
-
if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
|
|
29
|
-
}
|
|
30
|
-
function $319e236875307eab$export$d8686216b8b81b2f() {
|
|
31
|
-
if ($319e236875307eab$var$liveAnnouncer) {
|
|
32
|
-
$319e236875307eab$var$liveAnnouncer.destroy();
|
|
33
|
-
$319e236875307eab$var$liveAnnouncer = null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
37
|
-
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
38
|
-
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
39
|
-
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
40
|
-
// is simple enough to implement without React, so that's what we do here.
|
|
41
|
-
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
42
|
-
class $319e236875307eab$var$LiveAnnouncer {
|
|
43
|
-
createLog(ariaLive) {
|
|
44
|
-
let node = document.createElement("div");
|
|
45
|
-
node.setAttribute("role", "log");
|
|
46
|
-
node.setAttribute("aria-live", ariaLive);
|
|
47
|
-
node.setAttribute("aria-relevant", "additions");
|
|
48
|
-
return node;
|
|
49
|
-
}
|
|
50
|
-
destroy() {
|
|
51
|
-
if (!this.node) return;
|
|
52
|
-
document.body.removeChild(this.node);
|
|
53
|
-
this.node = null;
|
|
54
|
-
}
|
|
55
|
-
announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
56
|
-
if (!this.node) return;
|
|
57
|
-
let node = document.createElement("div");
|
|
58
|
-
node.textContent = message;
|
|
59
|
-
if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
|
|
60
|
-
else this.politeLog.appendChild(node);
|
|
61
|
-
if (message !== "") setTimeout(()=>{
|
|
62
|
-
node.remove();
|
|
63
|
-
}, timeout);
|
|
64
|
-
}
|
|
65
|
-
clear(assertiveness) {
|
|
66
|
-
if (!this.node) return;
|
|
67
|
-
if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
|
|
68
|
-
if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
|
|
69
|
-
}
|
|
70
|
-
constructor(){
|
|
71
|
-
this.node = document.createElement("div");
|
|
72
|
-
this.node.dataset.liveAnnouncer = "true";
|
|
73
|
-
// copied from VisuallyHidden
|
|
74
|
-
Object.assign(this.node.style, {
|
|
75
|
-
border: 0,
|
|
76
|
-
clip: "rect(0 0 0 0)",
|
|
77
|
-
clipPath: "inset(50%)",
|
|
78
|
-
height: "1px",
|
|
79
|
-
margin: "-1px",
|
|
80
|
-
overflow: "hidden",
|
|
81
|
-
padding: 0,
|
|
82
|
-
position: "absolute",
|
|
83
|
-
width: "1px",
|
|
84
|
-
whiteSpace: "nowrap"
|
|
85
|
-
});
|
|
86
|
-
this.assertiveLog = this.createLog("assertive");
|
|
87
|
-
this.node.appendChild(this.assertiveLog);
|
|
88
|
-
this.politeLog = this.createLog("polite");
|
|
89
|
-
this.node.appendChild(this.politeLog);
|
|
90
|
-
document.body.prepend(this.node);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
13
|
+
*/
|
|
95
14
|
|
|
96
15
|
|
|
97
16
|
export {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
var $97cebfa4133ebec3$exports = require("./LiveAnnouncer.main.js");
|
|
2
|
+
|
|
1
3
|
|
|
2
4
|
function $parcel$export(e, n, v, s) {
|
|
3
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
$parcel$export(module.exports, "announce", () => $97cebfa4133ebec3$
|
|
7
|
-
$parcel$export(module.exports, "clearAnnouncer", () => $97cebfa4133ebec3$
|
|
8
|
-
$parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$
|
|
8
|
+
$parcel$export(module.exports, "announce", () => $97cebfa4133ebec3$exports.announce);
|
|
9
|
+
$parcel$export(module.exports, "clearAnnouncer", () => $97cebfa4133ebec3$exports.clearAnnouncer);
|
|
10
|
+
$parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$exports.destroyAnnouncer);
|
|
9
11
|
/*
|
|
10
12
|
* Copyright 2020 Adobe. All rights reserved.
|
|
11
13
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -16,90 +18,7 @@ $parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$expor
|
|
|
16
18
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
19
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
20
|
* governing permissions and limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
21
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
22
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
23
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
-
*
|
|
25
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
26
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
27
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
28
|
-
* governing permissions and limitations under the License.
|
|
29
|
-
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
30
|
-
let $97cebfa4133ebec3$var$liveAnnouncer = null;
|
|
31
|
-
function $97cebfa4133ebec3$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
32
|
-
if (!$97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer = new $97cebfa4133ebec3$var$LiveAnnouncer();
|
|
33
|
-
$97cebfa4133ebec3$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
34
|
-
}
|
|
35
|
-
function $97cebfa4133ebec3$export$d10ae4f68404609a(assertiveness) {
|
|
36
|
-
if ($97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer.clear(assertiveness);
|
|
37
|
-
}
|
|
38
|
-
function $97cebfa4133ebec3$export$d8686216b8b81b2f() {
|
|
39
|
-
if ($97cebfa4133ebec3$var$liveAnnouncer) {
|
|
40
|
-
$97cebfa4133ebec3$var$liveAnnouncer.destroy();
|
|
41
|
-
$97cebfa4133ebec3$var$liveAnnouncer = null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
45
|
-
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
46
|
-
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
47
|
-
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
48
|
-
// is simple enough to implement without React, so that's what we do here.
|
|
49
|
-
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
50
|
-
class $97cebfa4133ebec3$var$LiveAnnouncer {
|
|
51
|
-
createLog(ariaLive) {
|
|
52
|
-
let node = document.createElement("div");
|
|
53
|
-
node.setAttribute("role", "log");
|
|
54
|
-
node.setAttribute("aria-live", ariaLive);
|
|
55
|
-
node.setAttribute("aria-relevant", "additions");
|
|
56
|
-
return node;
|
|
57
|
-
}
|
|
58
|
-
destroy() {
|
|
59
|
-
if (!this.node) return;
|
|
60
|
-
document.body.removeChild(this.node);
|
|
61
|
-
this.node = null;
|
|
62
|
-
}
|
|
63
|
-
announce(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
64
|
-
if (!this.node) return;
|
|
65
|
-
let node = document.createElement("div");
|
|
66
|
-
node.textContent = message;
|
|
67
|
-
if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
|
|
68
|
-
else this.politeLog.appendChild(node);
|
|
69
|
-
if (message !== "") setTimeout(()=>{
|
|
70
|
-
node.remove();
|
|
71
|
-
}, timeout);
|
|
72
|
-
}
|
|
73
|
-
clear(assertiveness) {
|
|
74
|
-
if (!this.node) return;
|
|
75
|
-
if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
|
|
76
|
-
if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
|
|
77
|
-
}
|
|
78
|
-
constructor(){
|
|
79
|
-
this.node = document.createElement("div");
|
|
80
|
-
this.node.dataset.liveAnnouncer = "true";
|
|
81
|
-
// copied from VisuallyHidden
|
|
82
|
-
Object.assign(this.node.style, {
|
|
83
|
-
border: 0,
|
|
84
|
-
clip: "rect(0 0 0 0)",
|
|
85
|
-
clipPath: "inset(50%)",
|
|
86
|
-
height: "1px",
|
|
87
|
-
margin: "-1px",
|
|
88
|
-
overflow: "hidden",
|
|
89
|
-
padding: 0,
|
|
90
|
-
position: "absolute",
|
|
91
|
-
width: "1px",
|
|
92
|
-
whiteSpace: "nowrap"
|
|
93
|
-
});
|
|
94
|
-
this.assertiveLog = this.createLog("assertive");
|
|
95
|
-
this.node.appendChild(this.assertiveLog);
|
|
96
|
-
this.politeLog = this.createLog("polite");
|
|
97
|
-
this.node.appendChild(this.politeLog);
|
|
98
|
-
document.body.prepend(this.node);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
21
|
+
*/
|
|
103
22
|
|
|
104
23
|
|
|
105
24
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/live-announcer/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {announce, clearAnnouncer, destroyAnnouncer} from './LiveAnnouncer';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {announce as $319e236875307eab$export$a9b970dcc4ae71a9, clearAnnouncer as $319e236875307eab$export$d10ae4f68404609a, destroyAnnouncer as $319e236875307eab$export$d8686216b8b81b2f} from "./LiveAnnouncer.module.js";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
3
5
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -8,90 +10,7 @@
|
|
|
8
10
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
11
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
12
|
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;
|
|
22
|
-
let $319e236875307eab$var$liveAnnouncer = null;
|
|
23
|
-
function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
24
|
-
if (!$319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
|
|
25
|
-
$319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
|
|
26
|
-
}
|
|
27
|
-
function $319e236875307eab$export$d10ae4f68404609a(assertiveness) {
|
|
28
|
-
if ($319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer.clear(assertiveness);
|
|
29
|
-
}
|
|
30
|
-
function $319e236875307eab$export$d8686216b8b81b2f() {
|
|
31
|
-
if ($319e236875307eab$var$liveAnnouncer) {
|
|
32
|
-
$319e236875307eab$var$liveAnnouncer.destroy();
|
|
33
|
-
$319e236875307eab$var$liveAnnouncer = null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
|
|
37
|
-
// ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
|
|
38
|
-
// subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
|
|
39
|
-
// As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
|
|
40
|
-
// is simple enough to implement without React, so that's what we do here.
|
|
41
|
-
// See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
|
|
42
|
-
class $319e236875307eab$var$LiveAnnouncer {
|
|
43
|
-
createLog(ariaLive) {
|
|
44
|
-
let node = document.createElement("div");
|
|
45
|
-
node.setAttribute("role", "log");
|
|
46
|
-
node.setAttribute("aria-live", ariaLive);
|
|
47
|
-
node.setAttribute("aria-relevant", "additions");
|
|
48
|
-
return node;
|
|
49
|
-
}
|
|
50
|
-
destroy() {
|
|
51
|
-
if (!this.node) return;
|
|
52
|
-
document.body.removeChild(this.node);
|
|
53
|
-
this.node = null;
|
|
54
|
-
}
|
|
55
|
-
announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
|
|
56
|
-
if (!this.node) return;
|
|
57
|
-
let node = document.createElement("div");
|
|
58
|
-
node.textContent = message;
|
|
59
|
-
if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
|
|
60
|
-
else this.politeLog.appendChild(node);
|
|
61
|
-
if (message !== "") setTimeout(()=>{
|
|
62
|
-
node.remove();
|
|
63
|
-
}, timeout);
|
|
64
|
-
}
|
|
65
|
-
clear(assertiveness) {
|
|
66
|
-
if (!this.node) return;
|
|
67
|
-
if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
|
|
68
|
-
if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
|
|
69
|
-
}
|
|
70
|
-
constructor(){
|
|
71
|
-
this.node = document.createElement("div");
|
|
72
|
-
this.node.dataset.liveAnnouncer = "true";
|
|
73
|
-
// copied from VisuallyHidden
|
|
74
|
-
Object.assign(this.node.style, {
|
|
75
|
-
border: 0,
|
|
76
|
-
clip: "rect(0 0 0 0)",
|
|
77
|
-
clipPath: "inset(50%)",
|
|
78
|
-
height: "1px",
|
|
79
|
-
margin: "-1px",
|
|
80
|
-
overflow: "hidden",
|
|
81
|
-
padding: 0,
|
|
82
|
-
position: "absolute",
|
|
83
|
-
width: "1px",
|
|
84
|
-
whiteSpace: "nowrap"
|
|
85
|
-
});
|
|
86
|
-
this.assertiveLog = this.createLog("assertive");
|
|
87
|
-
this.node.appendChild(this.assertiveLog);
|
|
88
|
-
this.politeLog = this.createLog("polite");
|
|
89
|
-
this.node.appendChild(this.politeLog);
|
|
90
|
-
document.body.prepend(this.node);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
13
|
+
*/
|
|
95
14
|
|
|
96
15
|
|
|
97
16
|
export {$319e236875307eab$export$a9b970dcc4ae71a9 as announce, $319e236875307eab$export$d10ae4f68404609a as clearAnnouncer, $319e236875307eab$export$d8686216b8b81b2f as destroyAnnouncer};
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/live-announcer/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {announce, clearAnnouncer, destroyAnnouncer} from './LiveAnnouncer';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/live-announcer",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
|
|
31
31
|
}
|