@react-aria/live-announcer 3.3.1 → 3.3.3

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.
@@ -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.mjs.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,0FA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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,10 +1,13 @@
1
+ var $97cebfa4133ebec3$exports = require("./LiveAnnouncer.main.js");
2
+
3
+
1
4
  function $parcel$export(e, n, v, s) {
2
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3
6
  }
4
7
 
5
- $parcel$export(module.exports, "announce", () => $97cebfa4133ebec3$export$a9b970dcc4ae71a9);
6
- $parcel$export(module.exports, "clearAnnouncer", () => $97cebfa4133ebec3$export$d10ae4f68404609a);
7
- $parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$export$d8686216b8b81b2f);
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);
8
11
  /*
9
12
  * Copyright 2020 Adobe. All rights reserved.
10
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -15,90 +18,7 @@ $parcel$export(module.exports, "destroyAnnouncer", () => $97cebfa4133ebec3$expor
15
18
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
19
  * OF ANY KIND, either express or implied. See the License for the specific language
17
20
  * governing permissions and limitations under the License.
18
- */ /*
19
- * Copyright 2020 Adobe. All rights reserved.
20
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License. You may obtain a copy
22
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
23
- *
24
- * Unless required by applicable law or agreed to in writing, software distributed under
25
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
26
- * OF ANY KIND, either express or implied. See the License for the specific language
27
- * governing permissions and limitations under the License.
28
- */ /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY = 7000;
29
- let $97cebfa4133ebec3$var$liveAnnouncer = null;
30
- function $97cebfa4133ebec3$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
31
- if (!$97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer = new $97cebfa4133ebec3$var$LiveAnnouncer();
32
- $97cebfa4133ebec3$var$liveAnnouncer.announce(message, assertiveness, timeout);
33
- }
34
- function $97cebfa4133ebec3$export$d10ae4f68404609a(assertiveness) {
35
- if ($97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer.clear(assertiveness);
36
- }
37
- function $97cebfa4133ebec3$export$d8686216b8b81b2f() {
38
- if ($97cebfa4133ebec3$var$liveAnnouncer) {
39
- $97cebfa4133ebec3$var$liveAnnouncer.destroy();
40
- $97cebfa4133ebec3$var$liveAnnouncer = null;
41
- }
42
- }
43
- // LiveAnnouncer is implemented using vanilla DOM, not React. That's because as of React 18
44
- // ReactDOM.render is deprecated, and the replacement, ReactDOM.createRoot is moved into a
45
- // subpath import `react-dom/client`. That makes it hard for us to support multiple React versions.
46
- // As a global API, we can't use portals without introducing a breaking API change. LiveAnnouncer
47
- // is simple enough to implement without React, so that's what we do here.
48
- // See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
49
- class $97cebfa4133ebec3$var$LiveAnnouncer {
50
- createLog(ariaLive) {
51
- let node = document.createElement("div");
52
- node.setAttribute("role", "log");
53
- node.setAttribute("aria-live", ariaLive);
54
- node.setAttribute("aria-relevant", "additions");
55
- return node;
56
- }
57
- destroy() {
58
- if (!this.node) return;
59
- document.body.removeChild(this.node);
60
- this.node = null;
61
- }
62
- announce(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
63
- if (!this.node) return;
64
- let node = document.createElement("div");
65
- node.textContent = message;
66
- if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
67
- else this.politeLog.appendChild(node);
68
- if (message !== "") setTimeout(()=>{
69
- node.remove();
70
- }, timeout);
71
- }
72
- clear(assertiveness) {
73
- if (!this.node) return;
74
- if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
75
- if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
76
- }
77
- constructor(){
78
- this.node = document.createElement("div");
79
- this.node.dataset.liveAnnouncer = "true";
80
- // copied from VisuallyHidden
81
- Object.assign(this.node.style, {
82
- border: 0,
83
- clip: "rect(0 0 0 0)",
84
- clipPath: "inset(50%)",
85
- height: "1px",
86
- margin: "-1px",
87
- overflow: "hidden",
88
- padding: 0,
89
- position: "absolute",
90
- width: "1px",
91
- whiteSpace: "nowrap"
92
- });
93
- this.assertiveLog = this.createLog("assertive");
94
- this.node.appendChild(this.assertiveLog);
95
- this.politeLog = this.createLog("polite");
96
- this.node.appendChild(this.politeLog);
97
- document.body.prepend(this.node);
98
- }
99
- }
100
-
101
-
21
+ */
102
22
 
103
23
 
104
24
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAID,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAAsC;AAKnC,SAAS,0CACd,OAAe,EACf,gBAA+B,WAAW,EAC1C,UAAU,8CAAwB;IAElC,IAAI,CAAC,qCACH,sCA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ACR,QAAQ;YACR,UAAU;YACV,SAAS;YACT,UAAU;YACV,OAAO;YACP,YAAY;QACd;QAEA,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU;QACnC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC;QAE3B,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU;QAChC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC;QAE3B,SAAS,KAAK,QAAQ,IAAI,CAAC;IAC7B;AAqDF;;CDnIC","sources":["packages/@react-aria/live-announcer/src/index.ts","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 */\nexport {announce, clearAnnouncer, destroyAnnouncer} from './LiveAnnouncer';\n","/*\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":"main.js.map"}
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};
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAID,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAAsC;AAKnC,SAAS,0CACd,OAAe,EACf,gBAA+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K,OAAO;YAC7B,QAAQ;YACR,MAAM;YACN,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,SAAS;YACT,UAAU;YACV,OAAO;YACP,YAAY;QACd;QAEA,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU;QACnC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC;QAE3B,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU;QAChC,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC;QAE3B,SAAS,KAAK,QAAQ,IAAI,CAAC;IAC7B;AAqDF;;CDnIC","sources":["packages/@react-aria/live-announcer/src/index.ts","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 */\nexport {announce, clearAnnouncer, destroyAnnouncer} from './LiveAnnouncer';\n","/*\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":"module.js.map"}
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.1",
3
+ "version": "3.3.3",
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": "504e40e0a50c1b20ed0fb3ba9561a263b6d5565e"
30
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
31
31
  }