@radix-ui/react-use-escape-keydown 1.0.2 → 1.0.3-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.
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Listens for when the escape key is down
3
+ */
4
+ export function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
5
+
6
+ //# sourceMappingURL=index.d.ts.map
@@ -24,4 +24,4 @@ import {useCallbackRef as $hPSQ5$useCallbackRef} from "@radix-ui/react-use-callb
24
24
 
25
25
 
26
26
  export {$addc16e1bbe58fd0$export$3a72a57244d6e765 as useEscapeKeydown};
27
- //# sourceMappingURL=index.module.js.map
27
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"mappings":";;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CACEG,mBADF,EAEEC,aAAuB,GAAGC,UAAH,KAAA,IAAA,IAAGA,UAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAGA,UAAU,CAAEC,QAFxC,EAGE;IACA,MAAMC,eAAe,GAAGL,qBAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,gBAAA,CAAgB,IAAM;QACpB,MAAMQ,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDH,aAAa,CAACQ,gBAAd,CAA+B,SAA/B,EAA0CH,aAA1C,CAAAL,CAAAA;QACA,OAAO,IAAMA,aAAa,CAACS,mBAAd,CAAkC,SAAlC,EAA6CJ,aAA7C,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;QAAkBH,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 = globalThis?.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","globalThis","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":";;;ACAA;;AAGA;;GAEA,CACA,SAASA,yCAAT,CACEG,mBADF,EAEEC,aAAuB,GAAGC,UAAH,KAAA,IAAA,IAAGA,UAAH,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAGA,UAAU,CAAEC,QAFxC,EAGE;IACA,MAAMC,eAAe,GAAGL,qBAAc,CAACC,mBAAD,CAAtC,AAAA;IAEAF,gBAAA,CAAgB,IAAM;QACpB,MAAMQ,aAAa,GAAIC,CAAAA,KAAD,GAA0B;YAC9C,IAAIA,KAAK,CAACC,GAAN,KAAc,QAAlB,EACEJ,eAAe,CAACG,KAAD,CAAf,CAAAH;SAFJ,AAIC;QACDH,aAAa,CAACQ,gBAAd,CAA+B,SAA/B,EAA0CH,aAA1C,CAAAL,CAAAA;QACA,OAAO,IAAMA,aAAa,CAACS,mBAAd,CAAkC,SAAlC,EAA6CJ,aAA7C,CAAb;QAAA,CAAA;KAPF,EAQG;QAACF,eAAD;QAAkBH,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 = globalThis?.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","globalThis","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"version":3,"file":"index.mjs.map"}
package/package.json CHANGED
@@ -1,11 +1,23 @@
1
1
  {
2
2
  "name": "@radix-ui/react-use-escape-keydown",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-rc.1",
4
4
  "license": "MIT",
5
- "source": "src/index.ts",
6
- "main": "dist/index.js",
7
- "module": "dist/index.module.js",
8
- "types": "dist/index.d.ts",
5
+ "exports": {
6
+ ".": {
7
+ "import": {
8
+ "types": "./dist/index.d.mts",
9
+ "default": "./dist/index.mjs"
10
+ },
11
+ "require": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ }
16
+ },
17
+ "source": "./src/index.ts",
18
+ "main": "./dist/index.js",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts",
9
21
  "files": [
10
22
  "dist",
11
23
  "README.md"
@@ -17,7 +29,7 @@
17
29
  },
18
30
  "dependencies": {
19
31
  "@babel/runtime": "^7.13.10",
20
- "@radix-ui/react-use-callback-ref": "1.0.0"
32
+ "@radix-ui/react-use-callback-ref": "1.0.1-rc.1"
21
33
  },
22
34
  "peerDependencies": {
23
35
  "react": "^16.8 || ^17.0 || ^18.0"
@@ -29,5 +41,6 @@
29
41
  },
30
42
  "bugs": {
31
43
  "url": "https://github.com/radix-ui/primitives/issues"
32
- }
44
+ },
45
+ "stableVersion": "1.0.2"
33
46
  }