@radix-ui/react-use-escape-keydown 1.0.4-rc.6 → 1.1.0-rc.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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +47 -34
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +17 -29
- package/dist/index.mjs.map +7 -1
- package/package.json +2 -3
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Listens for when the escape key is down
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export { useEscapeKeydown };
|
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
|
-
|
|
4
|
+
declare function useEscapeKeydown(onEscapeKeyDownProp?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export { useEscapeKeydown };
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
// packages/react/use-escape-keydown/src/useEscapeKeydown.tsx
|
|
33
|
+
var React = __toESM(__require("react"));
|
|
34
|
+
var import_react_use_callback_ref = __require("@radix-ui/react-use-callback-ref");
|
|
35
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
36
|
+
const onEscapeKeyDown = (0, import_react_use_callback_ref.useCallbackRef)(onEscapeKeyDownProp);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
const handleKeyDown = (event) => {
|
|
39
|
+
if (event.key === "Escape") {
|
|
40
|
+
onEscapeKeyDown(event);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
44
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
45
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
35
48
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useEscapeKeydown.tsx"],
|
|
4
|
+
"sourcesContent": ["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, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [onEscapeKeyDown, ownerDocument]);\n}\n\nexport { useEscapeKeydown };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,sCAA+B;AAK/B,WAAS,iBACP,qBACA,gBAA0B,YAAY,UACtC;AACA,UAAM,sBAAkB,8CAAe,mBAAmB;AAE1D,IAAM,gBAAU,MAAM;AACpB,YAAM,gBAAgB,CAAC,UAAyB;AAC9C,YAAI,MAAM,QAAQ,UAAU;AAC1B,0BAAgB,KAAK;AAAA,QACvB;AAAA,MACF;AACA,oBAAc,iBAAiB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;AAC1E,aAAO,MAAM,cAAc,oBAAoB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;AAAA,IAC5F,GAAG,CAAC,iBAAiB,aAAa,CAAC;AAAA,EACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
capture: true
|
|
16
|
-
});
|
|
17
|
-
return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown, {
|
|
18
|
-
capture: true
|
|
19
|
-
})
|
|
20
|
-
;
|
|
21
|
-
}, [
|
|
22
|
-
onEscapeKeyDown,
|
|
23
|
-
ownerDocument
|
|
24
|
-
]);
|
|
1
|
+
// packages/react/use-escape-keydown/src/useEscapeKeydown.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
|
4
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
5
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const handleKeyDown = (event) => {
|
|
8
|
+
if (event.key === "Escape") {
|
|
9
|
+
onEscapeKeyDown(event);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
13
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
14
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export {$addc16e1bbe58fd0$export$3a72a57244d6e765 as useEscapeKeydown};
|
|
16
|
+
export {
|
|
17
|
+
useEscapeKeydown
|
|
18
|
+
};
|
|
31
19
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/useEscapeKeydown.tsx"],
|
|
4
|
+
"sourcesContent": ["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, { capture: true });\n return () => ownerDocument.removeEventListener('keydown', handleKeyDown, { capture: true });\n }, [onEscapeKeyDown, ownerDocument]);\n}\n\nexport { useEscapeKeydown };\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,sBAAsB;AAK/B,SAAS,iBACP,qBACA,gBAA0B,YAAY,UACtC;AACA,QAAM,kBAAkB,eAAe,mBAAmB;AAE1D,EAAM,gBAAU,MAAM;AACpB,UAAM,gBAAgB,CAAC,UAAyB;AAC9C,UAAI,MAAM,QAAQ,UAAU;AAC1B,wBAAgB,KAAK;AAAA,MACvB;AAAA,IACF;AACA,kBAAc,iBAAiB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;AAC1E,WAAO,MAAM,cAAc,oBAAoB,WAAW,eAAe,EAAE,SAAS,KAAK,CAAC;AAAA,EAC5F,GAAG,CAAC,iBAAiB,aAAa,CAAC;AACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-use-escape-keydown",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"version": "yarn version"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@radix-ui/react-use-callback-ref": "1.0.1"
|
|
31
|
+
"@radix-ui/react-use-callback-ref": "1.1.0-rc.2"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"@types/react": "*",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAGA;;GAEG;AACH,iCACE,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACpD,aAAa,GAAE,QAA+B,QAa/C","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"}
|