@radix-ui/react-use-escape-keydown 1.0.0 → 1.0.1-rc.1

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Listens for when the escape key is down
3
3
  */
4
- export function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void): void;
4
+ export function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
5
5
 
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"AAGA;;GAEG;AACH,iCAA0B,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,QAY7E","sources":["packages/react/use-escape-keydown/src/packages/react/use-escape-keydown/src/useEscapeKeydown.tsx","packages/react/use-escape-keydown/src/packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/index.ts"],"sourcesContent":[null,null,"export { useEscapeKeydown } from './useEscapeKeydown';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
1
+ {"mappings":"AAGA;;GAEG;AACH,iCACE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACpD,aAAa,GAAE,QAAmB,QAanC","sources":["packages/react/use-escape-keydown/src/packages/react/use-escape-keydown/src/useEscapeKeydown.tsx","packages/react/use-escape-keydown/src/packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/index.ts"],"sourcesContent":[null,null,"export { useEscapeKeydown } from './useEscapeKeydown';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.js CHANGED
@@ -10,17 +10,18 @@ $parcel$export(module.exports, "useEscapeKeydown", () => $24c84e9f83c4454f$expor
10
10
 
11
11
  /**
12
12
  * Listens for when the escape key is down
13
- */ function $24c84e9f83c4454f$export$3a72a57244d6e765(onEscapeKeyDownProp) {
13
+ */ function $24c84e9f83c4454f$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = document) {
14
14
  const onEscapeKeyDown = $b0gz3$radixuireactusecallbackref.useCallbackRef(onEscapeKeyDownProp);
15
15
  $b0gz3$react.useEffect(()=>{
16
16
  const handleKeyDown = (event)=>{
17
17
  if (event.key === 'Escape') onEscapeKeyDown(event);
18
18
  };
19
- document.addEventListener('keydown', handleKeyDown);
20
- return ()=>document.removeEventListener('keydown', handleKeyDown)
19
+ ownerDocument.addEventListener('keydown', handleKeyDown);
20
+ return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
21
21
  ;
22
22
  }, [
23
- onEscapeKeyDown
23
+ onEscapeKeyDown,
24
+ ownerDocument
24
25
  ]);
25
26
  }
26
27
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CAA0BG,mBAA1B,EAAgF;IAC9E,MAAMC,eAAe,GAAGF,gDAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,sBAAA,CAAgB,IAAM;QACpB,MAAMK,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDK,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCJ,aAArC,CAAAG,CAAAA;QACA,OAAO,IAAMA,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCL,aAAxC,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;KARH,CAQC,CAAA;CACF;;ADlBD","sources":["packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/useEscapeKeydown.tsx"],"sourcesContent":["export { useEscapeKeydown } from './useEscapeKeydown';\n","import * as React from 'react';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/**\n * Listens for when the escape key is down\n */\nfunction useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscapeKeyDown(event);\n }\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [onEscapeKeyDown]);\n}\n\nexport { useEscapeKeydown };\n"],"names":["useEscapeKeydown","React","useCallbackRef","onEscapeKeyDownProp","onEscapeKeyDown","useEffect","handleKeyDown","event","key","document","addEventListener","removeEventListener"],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CACEG,mBADF,EAEEC,aAAuB,GAAGC,QAF5B,EAGE;IACA,MAAMC,eAAe,GAAGJ,gDAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,sBAAA,CAAgB,IAAM;QACpB,MAAMO,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDF,aAAa,CAACO,gBAAd,CAA+B,SAA/B,EAA0CH,aAA1C,CAAAJ,CAAAA;QACA,OAAO,IAAMA,aAAa,CAACQ,mBAAd,CAAkC,SAAlC,EAA6CJ,aAA7C,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;QAAkBF,aAAlB;KARH,CAQC,CAAA;CACF;;ADrBD","sources":["packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/useEscapeKeydown.tsx"],"sourcesContent":["export { useEscapeKeydown } from './useEscapeKeydown';\n","import * as React from 'react';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/**\n * Listens for when the escape key is down\n */\nfunction useEscapeKeydown(\n onEscapeKeyDownProp?: (event: KeyboardEvent) => void,\n ownerDocument: Document = document\n) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscapeKeyDown(event);\n }\n };\n ownerDocument.addEventListener('keydown', handleKeyDown);\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown);\n }, [onEscapeKeyDown, ownerDocument]);\n}\n\nexport { useEscapeKeydown };\n"],"names":["useEscapeKeydown","React","useCallbackRef","onEscapeKeyDownProp","ownerDocument","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"version":3,"file":"index.js.map"}
@@ -5,17 +5,18 @@ import {useCallbackRef as $hPSQ5$useCallbackRef} from "@radix-ui/react-use-callb
5
5
 
6
6
  /**
7
7
  * Listens for when the escape key is down
8
- */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp) {
8
+ */ function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = document) {
9
9
  const onEscapeKeyDown = $hPSQ5$useCallbackRef(onEscapeKeyDownProp);
10
10
  $hPSQ5$useEffect(()=>{
11
11
  const handleKeyDown = (event)=>{
12
12
  if (event.key === 'Escape') onEscapeKeyDown(event);
13
13
  };
14
- document.addEventListener('keydown', handleKeyDown);
15
- return ()=>document.removeEventListener('keydown', handleKeyDown)
14
+ ownerDocument.addEventListener('keydown', handleKeyDown);
15
+ return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
16
16
  ;
17
17
  }, [
18
- onEscapeKeyDown
18
+ onEscapeKeyDown,
19
+ ownerDocument
19
20
  ]);
20
21
  }
21
22
 
@@ -1 +1 @@
1
- {"mappings":";;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CAA0BG,mBAA1B,EAAgF;IAC9E,MAAMC,eAAe,GAAGF,qBAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,gBAAA,CAAgB,IAAM;QACpB,MAAMK,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDK,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCJ,aAArC,CAAAG,CAAAA;QACA,OAAO,IAAMA,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCL,aAAxC,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;KARH,CAQC,CAAA;CACF;;ADlBD","sources":["packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/useEscapeKeydown.tsx"],"sourcesContent":["export { useEscapeKeydown } from './useEscapeKeydown';\n","import * as React from 'react';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/**\n * Listens for when the escape key is down\n */\nfunction useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscapeKeyDown(event);\n }\n };\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [onEscapeKeyDown]);\n}\n\nexport { useEscapeKeydown };\n"],"names":["useEscapeKeydown","React","useCallbackRef","onEscapeKeyDownProp","onEscapeKeyDown","useEffect","handleKeyDown","event","key","document","addEventListener","removeEventListener"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":";;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CACEG,mBADF,EAEEC,aAAuB,GAAGC,QAF5B,EAGE;IACA,MAAMC,eAAe,GAAGJ,qBAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,gBAAA,CAAgB,IAAM;QACpB,MAAMO,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDF,aAAa,CAACO,gBAAd,CAA+B,SAA/B,EAA0CH,aAA1C,CAAAJ,CAAAA;QACA,OAAO,IAAMA,aAAa,CAACQ,mBAAd,CAAkC,SAAlC,EAA6CJ,aAA7C,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;QAAkBF,aAAlB;KARH,CAQC,CAAA;CACF;;ADrBD","sources":["packages/react/use-escape-keydown/src/index.ts","packages/react/use-escape-keydown/src/useEscapeKeydown.tsx"],"sourcesContent":["export { useEscapeKeydown } from './useEscapeKeydown';\n","import * as React from 'react';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\n\n/**\n * Listens for when the escape key is down\n */\nfunction useEscapeKeydown(\n onEscapeKeyDownProp?: (event: KeyboardEvent) => void,\n ownerDocument: Document = document\n) {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);\n\n React.useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscapeKeyDown(event);\n }\n };\n ownerDocument.addEventListener('keydown', handleKeyDown);\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown);\n }, [onEscapeKeyDown, ownerDocument]);\n}\n\nexport { useEscapeKeydown };\n"],"names":["useEscapeKeydown","React","useCallbackRef","onEscapeKeyDownProp","ownerDocument","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-use-escape-keydown",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-rc.1",
4
4
  "license": "MIT",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -29,5 +29,6 @@
29
29
  },
30
30
  "bugs": {
31
31
  "url": "https://github.com/radix-ui/primitives/issues"
32
- }
32
+ },
33
+ "stableVersion": "1.0.0"
33
34
  }