@react-aria/live-announcer 3.1.0 → 3.1.2

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/main.js CHANGED
@@ -1,30 +1,33 @@
1
- function $parcel$exportWildcard(dest, source) {
2
- Object.keys(source).forEach(function(key) {
3
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
4
- return;
5
- }
6
-
7
- Object.defineProperty(dest, key, {
8
- enumerable: true,
9
- get: function get() {
10
- return source[key];
11
- }
12
- });
13
- });
14
-
15
- return dest;
16
- }
17
1
  function $parcel$export(e, n, v, s) {
18
2
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
3
  }
20
- var $97cebfa4133ebec3$exports = {};
21
4
 
22
- $parcel$export($97cebfa4133ebec3$exports, "announce", () => $97cebfa4133ebec3$export$a9b970dcc4ae71a9);
23
- $parcel$export($97cebfa4133ebec3$exports, "clearAnnouncer", () => $97cebfa4133ebec3$export$d10ae4f68404609a);
24
- $parcel$export($97cebfa4133ebec3$exports, "destroyAnnouncer", () => $97cebfa4133ebec3$export$d8686216b8b81b2f);
25
- /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY = 7000;
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
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * 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;
26
29
  let $97cebfa4133ebec3$var$liveAnnouncer = null;
27
- function $97cebfa4133ebec3$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
30
+ function $97cebfa4133ebec3$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
28
31
  if (!$97cebfa4133ebec3$var$liveAnnouncer) $97cebfa4133ebec3$var$liveAnnouncer = new $97cebfa4133ebec3$var$LiveAnnouncer();
29
32
  $97cebfa4133ebec3$var$liveAnnouncer.announce(message, assertiveness, timeout);
30
33
  }
@@ -45,10 +48,10 @@ function $97cebfa4133ebec3$export$d8686216b8b81b2f() {
45
48
  // See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
46
49
  class $97cebfa4133ebec3$var$LiveAnnouncer {
47
50
  createLog(ariaLive) {
48
- let node = document.createElement('div');
49
- node.setAttribute('role', 'log');
50
- node.setAttribute('aria-live', ariaLive);
51
- node.setAttribute('aria-relevant', 'additions');
51
+ let node = document.createElement("div");
52
+ node.setAttribute("role", "log");
53
+ node.setAttribute("aria-live", ariaLive);
54
+ node.setAttribute("aria-relevant", "additions");
52
55
  return node;
53
56
  }
54
57
  destroy() {
@@ -56,47 +59,46 @@ class $97cebfa4133ebec3$var$LiveAnnouncer {
56
59
  document.body.removeChild(this.node);
57
60
  this.node = null;
58
61
  }
59
- announce(message, assertiveness = 'assertive', timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
62
+ announce(message, assertiveness = "assertive", timeout = $97cebfa4133ebec3$var$LIVEREGION_TIMEOUT_DELAY) {
60
63
  if (!this.node) return;
61
- let node = document.createElement('div');
64
+ let node = document.createElement("div");
62
65
  node.textContent = message;
63
- if (assertiveness === 'assertive') this.assertiveLog.appendChild(node);
66
+ if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
64
67
  else this.politeLog.appendChild(node);
65
- if (message !== '') setTimeout(()=>{
68
+ if (message !== "") setTimeout(()=>{
66
69
  node.remove();
67
70
  }, timeout);
68
71
  }
69
72
  clear(assertiveness) {
70
73
  if (!this.node) return;
71
- if (!assertiveness || assertiveness === 'assertive') this.assertiveLog.innerHTML = '';
72
- if (!assertiveness || assertiveness === 'polite') this.politeLog.innerHTML = '';
74
+ if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
75
+ if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
73
76
  }
74
77
  constructor(){
75
- this.node = document.createElement('div');
76
- this.node.dataset.liveAnnouncer = 'true';
78
+ this.node = document.createElement("div");
79
+ this.node.dataset.liveAnnouncer = "true";
77
80
  // copied from VisuallyHidden
78
81
  Object.assign(this.node.style, {
79
82
  border: 0,
80
- clip: 'rect(0 0 0 0)',
81
- clipPath: 'inset(50%)',
83
+ clip: "rect(0 0 0 0)",
84
+ clipPath: "inset(50%)",
82
85
  height: 1,
83
- margin: '0 -1px -1px 0',
84
- overflow: 'hidden',
86
+ margin: "0 -1px -1px 0",
87
+ overflow: "hidden",
85
88
  padding: 0,
86
- position: 'absolute',
89
+ position: "absolute",
87
90
  width: 1,
88
- whiteSpace: 'nowrap'
91
+ whiteSpace: "nowrap"
89
92
  });
90
- this.assertiveLog = this.createLog('assertive');
93
+ this.assertiveLog = this.createLog("assertive");
91
94
  this.node.appendChild(this.assertiveLog);
92
- this.politeLog = this.createLog('polite');
95
+ this.politeLog = this.createLog("polite");
93
96
  this.node.appendChild(this.politeLog);
94
97
  document.body.prepend(this.node);
95
98
  }
96
99
  }
97
100
 
98
101
 
99
- $parcel$exportWildcard(module.exports, $97cebfa4133ebec3$exports);
100
102
 
101
103
 
102
104
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACcA,EAAgE,AAAhE,4DAAgE,AAAhE,EAAgE,CAChE,KAAK,CAAC,8CAAwB,GAAG,IAAI;AAErC,GAAG,CAAC,mCAAa,GAAkB,IAAI;SAKvB,yCAAQ,CACtB,OAAe,EACf,aAA4B,GAAG,CAAW,YAC1C,OAAO,GAAG,8CAAwB,EAClC,CAAC;IACD,EAAE,GAAG,mCAAa,EAChB,mCAAa,GAAG,GAAG,CAAC,mCAAa;IAGnC,mCAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO;AACxD,CAAC;SAKe,yCAAc,CAAC,aAA4B,EAAE,CAAC;IAC5D,EAAE,EAAE,mCAAa,EACf,mCAAa,CAAC,KAAK,CAAC,aAAa;AAErC,CAAC;SAKe,yCAAgB,GAAG,CAAC;IAClC,EAAE,EAAE,mCAAa,EAAE,CAAC;QAClB,mCAAa,CAAC,OAAO;QACrB,mCAAa,GAAG,IAAI;IACtB,CAAC;AACH,CAAC;AAED,EAA2F,AAA3F,yFAA2F;AAC3F,EAA0F,AAA1F,wFAA0F;AAC1F,EAAmG,AAAnG,iGAAmG;AACnG,EAAiG,AAAjG,+FAAiG;AACjG,EAA0E,AAA1E,wEAA0E;AAC1E,EAAsH,AAAtH,oHAAsH;MAChH,mCAAa;IA+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AEjC,CAAC;iBA5Ea,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAK;QACxC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,CAAM;QACxC,EAA6B,AAA7B,2BAA6B;QAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,CAAe;YACrB,QAAQ,EAAE,CAAY;YACtB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAe;YACvB,QAAQ,EAAE,CAAQ;YAClB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,CAAU;YACpB,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,CAAQ;QACtB,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAW;QAC9C,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY;QAEvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAQ;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS;QAEpC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IACjC,CAAC","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 */\n\nexport * 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;\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;\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: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\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;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAEA,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAA+B,IAAI;AAKhC,SAAS,0CACd,OAAe,EACf,gBAA+B,WAAW,EAC1C,UAAU,8CAAwB,EAClC;IACA,IAAI,CAAC,qCACH,sCAAgB,IAAI;IAGtB,oCAAc,QAAQ,CAAC,SAAS,eAAe;AACjD;AAKO,SAAS,0CAAe,aAA4B,EAAE;IAC3D,IAAI,qCACF,oCAAc,KAAK,CAAC;AAExB;AAK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,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;;CDnIC,GACD","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;\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;\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: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\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"}
package/dist/module.js CHANGED
@@ -1,14 +1,26 @@
1
- function $parcel$export(e, n, v, s) {
2
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3
- }
4
- var $319e236875307eab$exports = {};
5
-
6
- $parcel$export($319e236875307eab$exports, "announce", () => $319e236875307eab$export$a9b970dcc4ae71a9);
7
- $parcel$export($319e236875307eab$exports, "clearAnnouncer", () => $319e236875307eab$export$d10ae4f68404609a);
8
- $parcel$export($319e236875307eab$exports, "destroyAnnouncer", () => $319e236875307eab$export$d8686216b8b81b2f);
9
- /* Inspired by https://github.com/AlmeroSteyn/react-aria-live */ const $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY = 7000;
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
+ */ /*
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;
10
22
  let $319e236875307eab$var$liveAnnouncer = null;
11
- function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
23
+ function $319e236875307eab$export$a9b970dcc4ae71a9(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
12
24
  if (!$319e236875307eab$var$liveAnnouncer) $319e236875307eab$var$liveAnnouncer = new $319e236875307eab$var$LiveAnnouncer();
13
25
  $319e236875307eab$var$liveAnnouncer.announce(message, assertiveness, timeout);
14
26
  }
@@ -29,10 +41,10 @@ function $319e236875307eab$export$d8686216b8b81b2f() {
29
41
  // See this discussion for more details: https://github.com/reactwg/react-18/discussions/125#discussioncomment-2382638
30
42
  class $319e236875307eab$var$LiveAnnouncer {
31
43
  createLog(ariaLive) {
32
- let node = document.createElement('div');
33
- node.setAttribute('role', 'log');
34
- node.setAttribute('aria-live', ariaLive);
35
- node.setAttribute('aria-relevant', 'additions');
44
+ let node = document.createElement("div");
45
+ node.setAttribute("role", "log");
46
+ node.setAttribute("aria-live", ariaLive);
47
+ node.setAttribute("aria-relevant", "additions");
36
48
  return node;
37
49
  }
38
50
  destroy() {
@@ -40,40 +52,40 @@ class $319e236875307eab$var$LiveAnnouncer {
40
52
  document.body.removeChild(this.node);
41
53
  this.node = null;
42
54
  }
43
- announce(message, assertiveness = 'assertive', timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
55
+ announce(message, assertiveness = "assertive", timeout = $319e236875307eab$var$LIVEREGION_TIMEOUT_DELAY) {
44
56
  if (!this.node) return;
45
- let node = document.createElement('div');
57
+ let node = document.createElement("div");
46
58
  node.textContent = message;
47
- if (assertiveness === 'assertive') this.assertiveLog.appendChild(node);
59
+ if (assertiveness === "assertive") this.assertiveLog.appendChild(node);
48
60
  else this.politeLog.appendChild(node);
49
- if (message !== '') setTimeout(()=>{
61
+ if (message !== "") setTimeout(()=>{
50
62
  node.remove();
51
63
  }, timeout);
52
64
  }
53
65
  clear(assertiveness) {
54
66
  if (!this.node) return;
55
- if (!assertiveness || assertiveness === 'assertive') this.assertiveLog.innerHTML = '';
56
- if (!assertiveness || assertiveness === 'polite') this.politeLog.innerHTML = '';
67
+ if (!assertiveness || assertiveness === "assertive") this.assertiveLog.innerHTML = "";
68
+ if (!assertiveness || assertiveness === "polite") this.politeLog.innerHTML = "";
57
69
  }
58
70
  constructor(){
59
- this.node = document.createElement('div');
60
- this.node.dataset.liveAnnouncer = 'true';
71
+ this.node = document.createElement("div");
72
+ this.node.dataset.liveAnnouncer = "true";
61
73
  // copied from VisuallyHidden
62
74
  Object.assign(this.node.style, {
63
75
  border: 0,
64
- clip: 'rect(0 0 0 0)',
65
- clipPath: 'inset(50%)',
76
+ clip: "rect(0 0 0 0)",
77
+ clipPath: "inset(50%)",
66
78
  height: 1,
67
- margin: '0 -1px -1px 0',
68
- overflow: 'hidden',
79
+ margin: "0 -1px -1px 0",
80
+ overflow: "hidden",
69
81
  padding: 0,
70
- position: 'absolute',
82
+ position: "absolute",
71
83
  width: 1,
72
- whiteSpace: 'nowrap'
84
+ whiteSpace: "nowrap"
73
85
  });
74
- this.assertiveLog = this.createLog('assertive');
86
+ this.assertiveLog = this.createLog("assertive");
75
87
  this.node.appendChild(this.assertiveLog);
76
- this.politeLog = this.createLog('polite');
88
+ this.politeLog = this.createLog("polite");
77
89
  this.node.appendChild(this.politeLog);
78
90
  document.body.prepend(this.node);
79
91
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;ACcA,EAAgE,AAAhE,4DAAgE,AAAhE,EAAgE,CAChE,KAAK,CAAC,8CAAwB,GAAG,IAAI;AAErC,GAAG,CAAC,mCAAa,GAAkB,IAAI;SAKvB,yCAAQ,CACtB,OAAe,EACf,aAA4B,GAAG,CAAW,YAC1C,OAAO,GAAG,8CAAwB,EAClC,CAAC;IACD,EAAE,GAAG,mCAAa,EAChB,mCAAa,GAAG,GAAG,CAAC,mCAAa;IAGnC,mCAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO;AACxD,CAAC;SAKe,yCAAc,CAAC,aAA4B,EAAE,CAAC;IAC5D,EAAE,EAAE,mCAAa,EACf,mCAAa,CAAC,KAAK,CAAC,aAAa;AAErC,CAAC;SAKe,yCAAgB,GAAG,CAAC;IAClC,EAAE,EAAE,mCAAa,EAAE,CAAC;QAClB,mCAAa,CAAC,OAAO;QACrB,mCAAa,GAAG,IAAI;IACtB,CAAC;AACH,CAAC;AAED,EAA2F,AAA3F,yFAA2F;AAC3F,EAA0F,AAA1F,wFAA0F;AAC1F,EAAmG,AAAnG,iGAAmG;AACnG,EAAiG,AAAjG,+FAAiG;AACjG,EAA0E,AAA1E,wEAA0E;AAC1E,EAAsH,AAAtH,oHAAsH;MAChH,mCAAa;IA+BjB,SAAS,CAAC,QAAgB,EAAE,CAAC;QAC3B,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAK;QACvC,IAAI,CAAC,YAAY,CAAC,CAAM,OAAE,CAAK;QAC/B,IAAI,CAAC,YAAY,CAAC,CAAW,YAAE,QAAQ;QACvC,IAAI,CAAC,YAAY,CAAC,CAAe,gBAA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EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,CAAe;YACrB,QAAQ,EAAE,CAAY;YACtB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAe;YACvB,QAAQ,EAAE,CAAQ;YAClB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,CAAU;YACpB,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,CAAQ;QACtB,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAW;QAC9C,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY;QAEvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAQ;QACxC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS;QAEpC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;IACjC,CAAC","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 */\n\nexport * 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;\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;\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: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\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;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAEA,8DAA8D,GAC9D,MAAM,iDAA2B;AAEjC,IAAI,sCAA+B,IAAI;AAKhC,SAAS,0CACd,OAAe,EACf,gBAA+B,WAAW,EAC1C,UAAU,8CAAwB,EAClC;IACA,IAAI,CAAC,qCACH,sCAAgB,IAAI;IAGtB,oCAAc,QAAQ,CAAC,SAAS,eAAe;AACjD;AAKO,SAAS,0CAAe,aAA4B,EAAE;IAC3D,IAAI,qCACF,oCAAc,KAAK,CAAC;AAExB;AAKO,SAAS,4CAAmB;IACjC,IAAI,qCAAe;QACjB,oCAAc,OAAO;QACrB,sCAAgB,IAAI;IACtB,CAAC;AACH;AAEA,2FAA2F;AAC3F,0FAA0F;AAC1F,mGAAmG;AACnG,iGAAiG;AACjG,0EAA0E;AAC1E,sHAAsH;AACtH,MAAM;IA+BJ,UAAU,QAAgB,EAAE;QAC1B,IAAI,OAAO,SAA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,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;;CDnIC,GACD","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;\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;\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: 1,\n margin: '0 -1px -1px 0',\n overflow: 'hidden',\n padding: 0,\n position: 'absolute',\n width: 1,\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 +1 @@
1
- {"mappings":"AAYA,qBAAqB,WAAW,GAAG,QAAQ,CAAC;AAO5C;;GAEG;AACH,yBACE,OAAO,EAAE,MAAM,EACf,aAAa,GAAE,aAA2B,EAC1C,OAAO,SAA2B,QAOnC;AAED;;GAEG;AACH,+BAA+B,aAAa,EAAE,aAAa,QAI1D;AAED;;GAEG;AACH,yCAKC","sources":["packages/@react-aria/live-announcer/src/packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx","packages/@react-aria/live-announcer/src/packages/@react-aria/live-announcer/src/index.ts","packages/@react-aria/live-announcer/src/index.ts"],"sourcesContent":[null,null,"/*\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\nexport * from './LiveAnnouncer';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":"AAYA,qBAAqB,WAAW,GAAG,QAAQ,CAAC;AAO5C;;GAEG;AACH,yBACE,OAAO,EAAE,MAAM,EACf,aAAa,GAAE,aAA2B,EAC1C,OAAO,SAA2B,QAOnC;AAED;;GAEG;AACH,+BAA+B,aAAa,EAAE,aAAa,QAI1D;AAED;;GAEG;AACH,yCAKC","sources":["packages/@react-aria/live-announcer/src/packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx","packages/@react-aria/live-announcer/src/packages/@react-aria/live-announcer/src/index.ts","packages/@react-aria/live-announcer/src/index.ts"],"sourcesContent":[null,null,"/*\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":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/live-announcer",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -17,10 +17,10 @@
17
17
  "url": "https://github.com/adobe/react-spectrum"
18
18
  },
19
19
  "dependencies": {
20
- "@babel/runtime": "^7.6.2"
20
+ "@swc/helpers": "^0.4.14"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
25
+ "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
26
26
  }
package/src/index.ts CHANGED
@@ -9,5 +9,4 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './LiveAnnouncer';
12
+ export {announce, clearAnnouncer, destroyAnnouncer} from './LiveAnnouncer';