@dnd-kit/accessibility 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @dnd-kit/accessibility
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`a9d92cf`](https://github.com/clauderic/dnd-kit/commit/a9d92cf1fa35dd957e6c5915a13dfd2af134c103) [#174](https://github.com/clauderic/dnd-kit/pull/174) Thanks [@clauderic](https://github.com/clauderic)! - Distributed assets now only target modern browsers. [Browserlist](https://github.com/browserslist/browserslist) config:
8
+
9
+ ```
10
+ defaults
11
+ last 2 version
12
+ not IE 11
13
+ not dead
14
+ ```
15
+
16
+ If you need to support older browsers, include the appropriate polyfills in your project's build process.
17
+
18
+ ### Patch Changes
19
+
20
+ - [`b406cb9`](https://github.com/clauderic/dnd-kit/commit/b406cb9251beef8677d05c45ec42bab7581a86dc) [#187](https://github.com/clauderic/dnd-kit/pull/187) Thanks [@clauderic](https://github.com/clauderic)! - Introduced the `useDndMonitor` hook. The `useDndMonitor` hook can be used within components wrapped in a `DndContext` provider to monitor the different drag and drop events that happen for that `DndContext`.
21
+
22
+ Example usage:
23
+
24
+ ```tsx
25
+ import {DndContext, useDndMonitor} from '@dnd-kit/core';
26
+
27
+ function App() {
28
+ return (
29
+ <DndContext>
30
+ <Component />
31
+ </DndContext>
32
+ );
33
+ }
34
+
35
+ function Component() {
36
+ useDndMonitor({
37
+ onDragStart(event) {},
38
+ onDragMove(event) {},
39
+ onDragOver(event) {},
40
+ onDragEnd(event) {},
41
+ onDragCancel(event) {},
42
+ });
43
+ }
44
+ ```
45
+
3
46
  ## 2.0.0
4
47
 
5
48
  ### Major Changes
@@ -7,19 +7,20 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var React = require('react');
8
8
  var React__default = _interopDefault(React);
9
9
 
10
- var hiddenStyles = {
10
+ const hiddenStyles = {
11
11
  display: 'none'
12
12
  };
13
- function HiddenText(_ref) {
14
- var id = _ref.id,
15
- value = _ref.value;
13
+ function HiddenText({
14
+ id,
15
+ value
16
+ }) {
16
17
  return React__default.createElement("div", {
17
18
  id: id,
18
19
  style: hiddenStyles
19
20
  }, value);
20
21
  }
21
22
 
22
- var visuallyHidden = {
23
+ const visuallyHidden = {
23
24
  position: 'absolute',
24
25
  width: 1,
25
26
  height: 1,
@@ -31,9 +32,10 @@ var visuallyHidden = {
31
32
  clipPath: 'inset(100%)',
32
33
  whiteSpace: 'nowrap'
33
34
  };
34
- function LiveRegion(_ref) {
35
- var id = _ref.id,
36
- announcement = _ref.announcement;
35
+ function LiveRegion({
36
+ id,
37
+ announcement
38
+ }) {
37
39
  return React__default.createElement("div", {
38
40
  id: id,
39
41
  style: visuallyHidden,
@@ -44,13 +46,15 @@ function LiveRegion(_ref) {
44
46
  }
45
47
 
46
48
  function useAnnouncement() {
47
- var _useState = React.useState(''),
48
- announcement = _useState[0],
49
- setAnnouncement = _useState[1];
50
-
49
+ const [announcement, setAnnouncement] = React.useState('');
50
+ const announce = React.useCallback(value => {
51
+ if (value != null) {
52
+ setAnnouncement(value);
53
+ }
54
+ }, []);
51
55
  return {
52
- announce: setAnnouncement,
53
- announcement: announcement
56
+ announce,
57
+ announcement
54
58
  };
55
59
  }
56
60
 
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.cjs.development.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n\n return {announce: setAnnouncement, announcement} as const;\n}\n"],"names":["hiddenStyles","display","HiddenText","id","value","React","style","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","LiveRegion","announcement","role","useAnnouncement","useState","setAnnouncement","announce"],"mappings":";;;;;;;;;AAOA,IAAMA,YAAY,GAAwB;AACxCC,EAAAA,OAAO,EAAE;AAD+B,CAA1C;SAIgBC;MAAYC,UAAAA;MAAIC,aAAAA;AAC9B,SACEC,4BAAA,MAAA;AAAKF,IAAAA,EAAE,EAAEA;AAAIG,IAAAA,KAAK,EAAEN;GAApB,EACGI,KADH,CADF;AAKD;;ACTD,IAAMG,cAAc,GAAwB;AAC1CC,EAAAA,QAAQ,EAAE,UADgC;AAE1CC,EAAAA,KAAK,EAAE,CAFmC;AAG1CC,EAAAA,MAAM,EAAE,CAHkC;AAI1CC,EAAAA,MAAM,EAAE,CAAC,CAJiC;AAK1CC,EAAAA,MAAM,EAAE,CALkC;AAM1CC,EAAAA,OAAO,EAAE,CANiC;AAO1CC,EAAAA,QAAQ,EAAE,QAPgC;AAQ1CC,EAAAA,IAAI,EAAE,eARoC;AAS1CC,EAAAA,QAAQ,EAAE,aATgC;AAU1CC,EAAAA,UAAU,EAAE;AAV8B,CAA5C;AAaA,SAAgBC;MAAYf,UAAAA;MAAIgB,oBAAAA;AAC9B,SACEd,4BAAA,MAAA;AACEF,IAAAA,EAAE,EAAEA;AACJG,IAAAA,KAAK,EAAEC;AACPa,IAAAA,IAAI,EAAC;iBACK;;GAJZ,EAOGD,YAPH,CADF;AAWD;;SC/BeE;kBAC0BC,cAAQ,CAAC,EAAD;MAAzCH;MAAcI;;AAErB,SAAO;AAACC,IAAAA,QAAQ,EAAED,eAAX;AAA4BJ,IAAAA,YAAY,EAAZA;AAA5B,GAAP;AACD;;;;;;"}
1
+ {"version":3,"file":"accessibility.cjs.development.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useCallback, useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n const announce = useCallback((value: string | undefined) => {\n if (value != null) {\n setAnnouncement(value);\n }\n }, []);\n\n return {announce, announcement} as const;\n}\n"],"names":["hiddenStyles","display","HiddenText","id","value","React","style","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","LiveRegion","announcement","role","useAnnouncement","setAnnouncement","useState","announce","useCallback"],"mappings":";;;;;;;;;AAOA,MAAMA,YAAY,GAAwB;AACxCC,EAAAA,OAAO,EAAE;AAD+B,CAA1C;SAIgBC,WAAW;AAACC,EAAAA,EAAD;AAAKC,EAAAA;AAAL;AACzB,SACEC,4BAAA,MAAA;AAAKF,IAAAA,EAAE,EAAEA;AAAIG,IAAAA,KAAK,EAAEN;GAApB,EACGI,KADH,CADF;AAKD;;ACTD,MAAMG,cAAc,GAAwB;AAC1CC,EAAAA,QAAQ,EAAE,UADgC;AAE1CC,EAAAA,KAAK,EAAE,CAFmC;AAG1CC,EAAAA,MAAM,EAAE,CAHkC;AAI1CC,EAAAA,MAAM,EAAE,CAAC,CAJiC;AAK1CC,EAAAA,MAAM,EAAE,CALkC;AAM1CC,EAAAA,OAAO,EAAE,CANiC;AAO1CC,EAAAA,QAAQ,EAAE,QAPgC;AAQ1CC,EAAAA,IAAI,EAAE,eARoC;AAS1CC,EAAAA,QAAQ,EAAE,aATgC;AAU1CC,EAAAA,UAAU,EAAE;AAV8B,CAA5C;AAaA,SAAgBC,WAAW;AAACf,EAAAA,EAAD;AAAKgB,EAAAA;AAAL;AACzB,SACEd,4BAAA,MAAA;AACEF,IAAAA,EAAE,EAAEA;AACJG,IAAAA,KAAK,EAAEC;AACPa,IAAAA,IAAI,EAAC;iBACK;;GAJZ,EAOGD,YAPH,CADF;AAWD;;SC/BeE;AACd,QAAM,CAACF,YAAD,EAAeG,eAAf,IAAkCC,cAAQ,CAAC,EAAD,CAAhD;AACA,QAAMC,QAAQ,GAAGC,iBAAW,CAAErB,KAAD;AAC3B,QAAIA,KAAK,IAAI,IAAb,EAAmB;AACjBkB,MAAAA,eAAe,CAAClB,KAAD,CAAf;AACD;AACF,GAJ2B,EAIzB,EAJyB,CAA5B;AAMA,SAAO;AAACoB,IAAAA,QAAD;AAAWL,IAAAA;AAAX,GAAP;AACD;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i={display:"none"},r={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};exports.HiddenText=function(e){return n.createElement("div",{id:e.id,style:i},e.value)},exports.LiveRegion=function(e){return n.createElement("div",{id:e.id,style:r,role:"status","aria-live":"assertive","aria-atomic":!0},e.announcement)},exports.useAnnouncement=function(){var e=t.useState("");return{announce:e[1],announcement:e[0]}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;const i={display:"none"},r={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};exports.HiddenText=function({id:e,value:t}){return n.createElement("div",{id:e,style:i},t)},exports.LiveRegion=function({id:e,announcement:t}){return n.createElement("div",{id:e,style:r,role:"status","aria-live":"assertive","aria-atomic":!0},t)},exports.useAnnouncement=function(){const[e,n]=t.useState("");return{announce:t.useCallback(e=>{null!=e&&n(e)},[]),announcement:e}};
2
2
  //# sourceMappingURL=accessibility.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.cjs.production.min.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n\n return {announce: setAnnouncement, announcement} as const;\n}\n"],"names":["hiddenStyles","display","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","React","id","style","value","role","announcement","useState","announce"],"mappings":"oJAOMA,EAAoC,CACxCC,QAAS,QCALC,EAAsC,CAC1CC,SAAU,WACVC,MAAO,EACPC,OAAQ,EACRC,QAAS,EACTC,OAAQ,EACRC,QAAS,EACTC,SAAU,SACVC,KAAM,gBACNC,SAAU,cACVC,WAAY,gDDLVC,uBAAKC,KAFmBA,GAEXC,MAAOf,KAFQgB,8CCY5BH,uBACEC,KAHsBA,GAItBC,MAAOb,EACPe,KAAK,qBACK,gCANgBC,wDClBUC,WAAS,UAE1C,CAACC,cAA2BF"}
1
+ {"version":3,"file":"accessibility.cjs.production.min.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useCallback, useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n const announce = useCallback((value: string | undefined) => {\n if (value != null) {\n setAnnouncement(value);\n }\n }, []);\n\n return {announce, announcement} as const;\n}\n"],"names":["hiddenStyles","display","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","id","value","React","style","announcement","role","setAnnouncement","useState","announce","useCallback"],"mappings":"oJAOA,MAAMA,EAAoC,CACxCC,QAAS,QCALC,EAAsC,CAC1CC,SAAU,WACVC,MAAO,EACPC,OAAQ,EACRC,QAAS,EACTC,OAAQ,EACRC,QAAS,EACTC,SAAU,SACVC,KAAM,gBACNC,SAAU,cACVC,WAAY,uCDPaC,GAACA,EAADC,MAAKA,WAE5BC,uBAAKF,GAAIA,EAAIG,MAAOhB,GACjBc,uBCOP,UAA2BD,GAACA,EAADI,aAAKA,WAE5BF,uBACEF,GAAIA,EACJG,MAAOd,EACPgB,KAAK,qBACK,8BAGTD,6CC3BEA,EAAcE,GAAmBC,WAAS,UAO1C,CAACC,SANSC,cAAaR,IACf,MAATA,GACFK,EAAgBL,IAEjB,IAEeG,aAAAA"}
@@ -1,18 +1,19 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
2
 
3
- var hiddenStyles = {
3
+ const hiddenStyles = {
4
4
  display: 'none'
5
5
  };
6
- function HiddenText(_ref) {
7
- var id = _ref.id,
8
- value = _ref.value;
6
+ function HiddenText({
7
+ id,
8
+ value
9
+ }) {
9
10
  return React.createElement("div", {
10
11
  id: id,
11
12
  style: hiddenStyles
12
13
  }, value);
13
14
  }
14
15
 
15
- var visuallyHidden = {
16
+ const visuallyHidden = {
16
17
  position: 'absolute',
17
18
  width: 1,
18
19
  height: 1,
@@ -24,9 +25,10 @@ var visuallyHidden = {
24
25
  clipPath: 'inset(100%)',
25
26
  whiteSpace: 'nowrap'
26
27
  };
27
- function LiveRegion(_ref) {
28
- var id = _ref.id,
29
- announcement = _ref.announcement;
28
+ function LiveRegion({
29
+ id,
30
+ announcement
31
+ }) {
30
32
  return React.createElement("div", {
31
33
  id: id,
32
34
  style: visuallyHidden,
@@ -37,13 +39,15 @@ function LiveRegion(_ref) {
37
39
  }
38
40
 
39
41
  function useAnnouncement() {
40
- var _useState = useState(''),
41
- announcement = _useState[0],
42
- setAnnouncement = _useState[1];
43
-
42
+ const [announcement, setAnnouncement] = useState('');
43
+ const announce = useCallback(value => {
44
+ if (value != null) {
45
+ setAnnouncement(value);
46
+ }
47
+ }, []);
44
48
  return {
45
- announce: setAnnouncement,
46
- announcement: announcement
49
+ announce,
50
+ announcement
47
51
  };
48
52
  }
49
53
 
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.esm.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n\n return {announce: setAnnouncement, announcement} as const;\n}\n"],"names":["hiddenStyles","display","HiddenText","id","value","React","style","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","LiveRegion","announcement","role","useAnnouncement","useState","setAnnouncement","announce"],"mappings":";;AAOA,IAAMA,YAAY,GAAwB;AACxCC,EAAAA,OAAO,EAAE;AAD+B,CAA1C;SAIgBC;MAAYC,UAAAA;MAAIC,aAAAA;AAC9B,SACEC,mBAAA,MAAA;AAAKF,IAAAA,EAAE,EAAEA;AAAIG,IAAAA,KAAK,EAAEN;GAApB,EACGI,KADH,CADF;AAKD;;ACTD,IAAMG,cAAc,GAAwB;AAC1CC,EAAAA,QAAQ,EAAE,UADgC;AAE1CC,EAAAA,KAAK,EAAE,CAFmC;AAG1CC,EAAAA,MAAM,EAAE,CAHkC;AAI1CC,EAAAA,MAAM,EAAE,CAAC,CAJiC;AAK1CC,EAAAA,MAAM,EAAE,CALkC;AAM1CC,EAAAA,OAAO,EAAE,CANiC;AAO1CC,EAAAA,QAAQ,EAAE,QAPgC;AAQ1CC,EAAAA,IAAI,EAAE,eARoC;AAS1CC,EAAAA,QAAQ,EAAE,aATgC;AAU1CC,EAAAA,UAAU,EAAE;AAV8B,CAA5C;AAaA,SAAgBC;MAAYf,UAAAA;MAAIgB,oBAAAA;AAC9B,SACEd,mBAAA,MAAA;AACEF,IAAAA,EAAE,EAAEA;AACJG,IAAAA,KAAK,EAAEC;AACPa,IAAAA,IAAI,EAAC;iBACK;;GAJZ,EAOGD,YAPH,CADF;AAWD;;SC/BeE;kBAC0BC,QAAQ,CAAC,EAAD;MAAzCH;MAAcI;;AAErB,SAAO;AAACC,IAAAA,QAAQ,EAAED,eAAX;AAA4BJ,IAAAA,YAAY,EAAZA;AAA5B,GAAP;AACD;;;;"}
1
+ {"version":3,"file":"accessibility.esm.js","sources":["../src/components/HiddenText/HiddenText.tsx","../src/components/LiveRegion/LiveRegion.tsx","../src/hooks/useAnnouncement.ts"],"sourcesContent":["import React from 'react';\n\ninterface Props {\n id: string;\n value: string;\n}\n\nconst hiddenStyles: React.CSSProperties = {\n display: 'none',\n};\n\nexport function HiddenText({id, value}: Props) {\n return (\n <div id={id} style={hiddenStyles}>\n {value}\n </div>\n );\n}\n","import React from 'react';\n\nexport interface Props {\n id: string;\n announcement: string;\n}\n\n// Hide element visually but keep it readable by screen readers\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n border: 0,\n padding: 0,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(100%)',\n whiteSpace: 'nowrap',\n};\n\nexport function LiveRegion({id, announcement}: Props) {\n return (\n <div\n id={id}\n style={visuallyHidden}\n role=\"status\"\n aria-live=\"assertive\"\n aria-atomic\n >\n {announcement}\n </div>\n );\n}\n","import {useCallback, useState} from 'react';\n\nexport function useAnnouncement() {\n const [announcement, setAnnouncement] = useState('');\n const announce = useCallback((value: string | undefined) => {\n if (value != null) {\n setAnnouncement(value);\n }\n }, []);\n\n return {announce, announcement} as const;\n}\n"],"names":["hiddenStyles","display","HiddenText","id","value","React","style","visuallyHidden","position","width","height","margin","border","padding","overflow","clip","clipPath","whiteSpace","LiveRegion","announcement","role","useAnnouncement","setAnnouncement","useState","announce","useCallback"],"mappings":";;AAOA,MAAMA,YAAY,GAAwB;AACxCC,EAAAA,OAAO,EAAE;AAD+B,CAA1C;SAIgBC,WAAW;AAACC,EAAAA,EAAD;AAAKC,EAAAA;AAAL;AACzB,SACEC,mBAAA,MAAA;AAAKF,IAAAA,EAAE,EAAEA;AAAIG,IAAAA,KAAK,EAAEN;GAApB,EACGI,KADH,CADF;AAKD;;ACTD,MAAMG,cAAc,GAAwB;AAC1CC,EAAAA,QAAQ,EAAE,UADgC;AAE1CC,EAAAA,KAAK,EAAE,CAFmC;AAG1CC,EAAAA,MAAM,EAAE,CAHkC;AAI1CC,EAAAA,MAAM,EAAE,CAAC,CAJiC;AAK1CC,EAAAA,MAAM,EAAE,CALkC;AAM1CC,EAAAA,OAAO,EAAE,CANiC;AAO1CC,EAAAA,QAAQ,EAAE,QAPgC;AAQ1CC,EAAAA,IAAI,EAAE,eARoC;AAS1CC,EAAAA,QAAQ,EAAE,aATgC;AAU1CC,EAAAA,UAAU,EAAE;AAV8B,CAA5C;AAaA,SAAgBC,WAAW;AAACf,EAAAA,EAAD;AAAKgB,EAAAA;AAAL;AACzB,SACEd,mBAAA,MAAA;AACEF,IAAAA,EAAE,EAAEA;AACJG,IAAAA,KAAK,EAAEC;AACPa,IAAAA,IAAI,EAAC;iBACK;;GAJZ,EAOGD,YAPH,CADF;AAWD;;SC/BeE;AACd,QAAM,CAACF,YAAD,EAAeG,eAAf,IAAkCC,QAAQ,CAAC,EAAD,CAAhD;AACA,QAAMC,QAAQ,GAAGC,WAAW,CAAErB,KAAD;AAC3B,QAAIA,KAAK,IAAI,IAAb,EAAmB;AACjBkB,MAAAA,eAAe,CAAClB,KAAD,CAAf;AACD;AACF,GAJ2B,EAIzB,EAJyB,CAA5B;AAMA,SAAO;AAACoB,IAAAA,QAAD;AAAWL,IAAAA;AAAX,GAAP;AACD;;;;"}
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  export declare function useAnnouncement(): {
3
- readonly announce: import("react").Dispatch<import("react").SetStateAction<string>>;
2
+ readonly announce: (value: string | undefined) => void;
4
3
  readonly announcement: string;
5
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnd-kit/accessibility",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "A generic toolkit to help with accessibility",
5
5
  "author": "Claudéric Demers",
6
6
  "license": "MIT",