@hanzogui/use-escape-keydown 8.3.0 → 8.3.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/cjs/index.js +29 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/index.js +24 -21
- package/dist/esm/index.js.map +1 -1
- package/package.json +14 -14
- package/types/index.d.ts +3 -4
- package/types/index.d.ts.map +1 -11
- package/dist/cjs/index.cjs +0 -58
- package/dist/cjs/index.native.js +0 -65
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -22
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -26
- package/dist/esm/index.native.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEscapeKeydown = useEscapeKeydown;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// via radix-ui
|
|
6
|
+
const use_callback_ref_1 = require("@hanzogui/use-callback-ref");
|
|
7
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
8
|
+
/**
|
|
9
|
+
* Listens for when the escape key is down
|
|
10
|
+
*/
|
|
11
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
12
|
+
const onEscapeKeyDown = (0, use_callback_ref_1.useCallbackRef)(onEscapeKeyDownProp);
|
|
13
|
+
react_1.default.useEffect(() => {
|
|
14
|
+
const handleKeyDown = (event) => {
|
|
15
|
+
if (event.key === 'Escape') {
|
|
16
|
+
onEscapeKeyDown(event);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
ownerDocument.addEventListener('keydown',
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
handleKeyDown);
|
|
22
|
+
return () => {
|
|
23
|
+
ownerDocument.removeEventListener('keydown',
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
handleKeyDown);
|
|
26
|
+
};
|
|
27
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,eAAe;AACf,iEAA2D;AAC3D,0DAAyB;AAEzB;;GAEG;AACH,0BACE,mBAAgD,EAChD,aAAa,GAAa,UAAU,EAAE,QAAQ;IAE9C,MAAM,eAAe,GAAG,IAAA,iCAAc,EAAC,mBAAmB,CAAC,CAAA;IAE3D,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAE,EAAE;YACnD,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,eAAe,CAAC,KAAK,CAAC,CAAA;YACxB,CAAC;QACH,CAAC,CAAA;QAED,aAAa,CAAC,gBAAgB,CAC5B,SAAS;QACT,mBAAmB;QACnB,aAAa,CACd,CAAA;QAED,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,mBAAmB,CAC/B,SAAS;YACT,mBAAmB;YACnB,aAAa,CACd,CAAA;QACH,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
package/dist/esm/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// via radix-ui
|
|
2
|
+
import { useCallbackRef } from '@hanzogui/use-callback-ref';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Listens for when the escape key is down
|
|
6
|
+
*/
|
|
7
|
+
export function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
8
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
const handleKeyDown = (event) => {
|
|
11
|
+
if (event.key === 'Escape') {
|
|
12
|
+
onEscapeKeyDown(event);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
ownerDocument.addEventListener('keydown',
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
handleKeyDown);
|
|
18
|
+
return () => {
|
|
19
|
+
ownerDocument.removeEventListener('keydown',
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
handleKeyDown);
|
|
22
|
+
};
|
|
23
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,mBAAgD,EAChD,aAAa,GAAa,UAAU,EAAE,QAAQ;IAE9C,MAAM,eAAe,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAA;IAE3D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAE,EAAE;YACnD,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,eAAe,CAAC,KAAK,CAAC,CAAA;YACxB,CAAC;QACH,CAAC,CAAA;QAED,aAAa,CAAC,gBAAgB,CAC5B,SAAS;QACT,mBAAmB;QACnB,aAAa,CACd,CAAA;QAED,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,mBAAmB,CAC/B,SAAS;YACT,mBAAmB;YACnB,aAAa,CACd,CAAA;QACH,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAA;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/use-escape-keydown",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -8,39 +8,39 @@
|
|
|
8
8
|
],
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
11
|
-
"main": "dist/cjs",
|
|
12
|
-
"module": "dist/esm",
|
|
11
|
+
"main": "./dist/cjs/index.js",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
13
13
|
"types": "./types/index.d.ts",
|
|
14
14
|
"exports": {
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./types/index.d.ts",
|
|
18
|
-
"react-native": "./dist/esm/index.
|
|
19
|
-
"browser": "./dist/esm/index.
|
|
20
|
-
"module": "./dist/esm/index.
|
|
21
|
-
"import": "./dist/esm/index.
|
|
22
|
-
"require": "./dist/cjs/index.
|
|
23
|
-
"default": "./dist/esm/index.
|
|
18
|
+
"react-native": "./dist/esm/index.js",
|
|
19
|
+
"browser": "./dist/esm/index.js",
|
|
20
|
+
"module": "./dist/esm/index.js",
|
|
21
|
+
"import": "./dist/esm/index.js",
|
|
22
|
+
"require": "./dist/cjs/index.js",
|
|
23
|
+
"default": "./dist/esm/index.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "hanzogui-build",
|
|
30
|
+
"build": "hanzogui-build --skip-native",
|
|
31
31
|
"watch": "hanzogui-build --watch",
|
|
32
32
|
"clean": "hanzogui-build clean",
|
|
33
33
|
"clean:build": "hanzogui-build clean:build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@hanzogui/use-callback-ref": "8.3.
|
|
36
|
+
"@hanzogui/use-callback-ref": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@hanzogui/build": "8.3.
|
|
40
|
-
"react": "
|
|
39
|
+
"@hanzogui/build": "8.3.2",
|
|
40
|
+
"react": "19.2.8"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"react": ">=19"
|
|
43
|
+
"react": ">=19.2.8"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"type": "git",
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* Listens for when the escape key is down
|
|
4
|
-
*/
|
|
3
|
+
* Listens for when the escape key is down
|
|
4
|
+
*/
|
|
5
5
|
export declare function useEscapeKeydown(onEscapeKeyDownProp?: React.KeyboardEventHandler, ownerDocument?: Document): void;
|
|
6
|
-
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mappings": "AAEA,OAAO,WAAW;;;;AAKlB,OAAO,iBAAS,iBACd,sBAAsB,MAAM,sBAC5B,gBAAe",
|
|
3
|
-
"names": [],
|
|
4
|
-
"sources": [
|
|
5
|
-
"src/index.ts"
|
|
6
|
-
],
|
|
7
|
-
"version": 3,
|
|
8
|
-
"sourcesContent": [
|
|
9
|
-
"// via radix-ui\nimport { useCallbackRef } from '@hanzogui/use-callback-ref'\nimport React from 'react'\n\n/**\n * Listens for when the escape key is down\n */\nexport function useEscapeKeydown(\n onEscapeKeyDownProp?: React.KeyboardEventHandler,\n ownerDocument: Document = globalThis?.document\n): void {\n const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp)\n\n React.useEffect(() => {\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEscapeKeyDown(event)\n }\n }\n\n ownerDocument.addEventListener(\n 'keydown',\n // @ts-expect-error\n handleKeyDown\n )\n\n return () => {\n ownerDocument.removeEventListener(\n 'keydown',\n // @ts-expect-error\n handleKeyDown\n )\n }\n }, [onEscapeKeyDown, ownerDocument])\n}\n"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,mBAAmB,CAAC,EAAE,KAAK,CAAC,oBAAoB,EAChD,aAAa,GAAE,QAA+B,GAC7C,IAAI,CAwBN"}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var index_exports = {};
|
|
35
|
-
__export(index_exports, {
|
|
36
|
-
useEscapeKeydown: () => useEscapeKeydown
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var import_use_callback_ref = require("@hanzogui/use-callback-ref");
|
|
40
|
-
var import_react = __toESM(require("react"), 1);
|
|
41
|
-
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
42
|
-
const onEscapeKeyDown = (0, import_use_callback_ref.useCallbackRef)(onEscapeKeyDownProp);
|
|
43
|
-
import_react.default.useEffect(() => {
|
|
44
|
-
const handleKeyDown = event => {
|
|
45
|
-
if (event.key === "Escape") {
|
|
46
|
-
onEscapeKeyDown(event);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
ownerDocument.addEventListener("keydown",
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
handleKeyDown);
|
|
52
|
-
return () => {
|
|
53
|
-
ownerDocument.removeEventListener("keydown",
|
|
54
|
-
// @ts-expect-error
|
|
55
|
-
handleKeyDown);
|
|
56
|
-
};
|
|
57
|
-
}, [onEscapeKeyDown, ownerDocument]);
|
|
58
|
-
}
|
package/dist/cjs/index.native.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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 __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: () => from[key],
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
32
|
-
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
36
|
-
var index_exports = {};
|
|
37
|
-
__export(index_exports, {
|
|
38
|
-
useEscapeKeydown: () => useEscapeKeydown
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(index_exports);
|
|
41
|
-
var import_use_callback_ref = require("@hanzogui/use-callback-ref");
|
|
42
|
-
var import_react = __toESM(require("react"), 1);
|
|
43
|
-
function useEscapeKeydown(onEscapeKeyDownProp) {
|
|
44
|
-
var ownerDocument = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function () {
|
|
45
|
-
var _globalThis;
|
|
46
|
-
return (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.document;
|
|
47
|
-
}();
|
|
48
|
-
var onEscapeKeyDown = (0, import_use_callback_ref.useCallbackRef)(onEscapeKeyDownProp);
|
|
49
|
-
import_react.default.useEffect(function () {
|
|
50
|
-
var handleKeyDown = function (event) {
|
|
51
|
-
if (event.key === "Escape") {
|
|
52
|
-
onEscapeKeyDown(event);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
ownerDocument.addEventListener("keydown",
|
|
56
|
-
// @ts-expect-error
|
|
57
|
-
handleKeyDown);
|
|
58
|
-
return function () {
|
|
59
|
-
ownerDocument.removeEventListener("keydown",
|
|
60
|
-
// @ts-expect-error
|
|
61
|
-
handleKeyDown);
|
|
62
|
-
};
|
|
63
|
-
}, [onEscapeKeyDown, ownerDocument]);
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","useEscapeKeydown","module","exports","import_use_callback_ref","require","import_react","__toESM","onEscapeKeyDownProp","ownerDocument","arguments","length","_globalThis","globalThis","document","onEscapeKeyDown","useCallbackRef","default","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAA+BK,aAAA;AAC/B,IAAAK,uBAAkB,GAAAC,OAAA;AAKX,IAAAC,YAAS,GAAAC,OACd,CAAAF,OAAA,aACA;AAEA,SAAMJ,iBAAAO,mBAAkB;EAExB,IAAAC,aAAA,GAAAC,SAAM,CAAAC,MAAU,GAAM,KAAAD,SAAA,iBAAAA,SAAA;IACpB,IAAAE,WAAM;IACJ,OAAI,CAAAA,WAAM,GAAQC,UAAU,cAAAD,WAAA,uBAAAA,WAAA,CAAAE,QAAA;EAC1B;EAAqB,IACvBC,eAAA,OAAAX,uBAAA,CAAAY,cAAA,EAAAR,mBAAA;EAAAF,YACF,CAAAW,OAAA,CAAAC,SAAA;IAEA,IAAAC,aAAc,YAAAA,CAAAC,KAAA;MACZ,IAAAA,KAAA,CAAAC,GAAA;QAAAN,eAAA,CAAAK,KAAA;MAEA;IACF;IAEAX,aAAa,CAAAa,gBAAA,CACX;IAAc;IACZH,aAAA;IAEA,OACF;MACFV,aAAA,CAAAc,mBAAA,CACE;MACN","ignoreList":[]}
|
package/dist/esm/index.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useCallbackRef } from "@hanzogui/use-callback-ref";
|
|
2
|
-
import React from "react";
|
|
3
|
-
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
4
|
-
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
const handleKeyDown = event => {
|
|
7
|
-
if (event.key === "Escape") {
|
|
8
|
-
onEscapeKeyDown(event);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
ownerDocument.addEventListener("keydown",
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
handleKeyDown);
|
|
14
|
-
return () => {
|
|
15
|
-
ownerDocument.removeEventListener("keydown",
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
handleKeyDown);
|
|
18
|
-
};
|
|
19
|
-
}, [onEscapeKeyDown, ownerDocument]);
|
|
20
|
-
}
|
|
21
|
-
export { useEscapeKeydown };
|
|
22
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useCallbackRef","React","useEscapeKeydown","onEscapeKeyDownProp","ownerDocument","globalThis","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,cAAA,QAAsB;AAC/B,OAAOC,KAAA,MAAW;AAKX,SAASC,iBACdC,mBAAA,EACAC,aAAA,GAA0BC,UAAA,EAAYC,QAAA,EAChC;EACN,MAAMC,eAAA,GAAkBP,cAAA,CAAeG,mBAAmB;EAE1DF,KAAA,CAAMO,SAAA,CAAU,MAAM;IACpB,MAAMC,aAAA,GAAiBC,KAAA,IAA+B;MACpD,IAAIA,KAAA,CAAMC,GAAA,KAAQ,UAAU;QAC1BJ,eAAA,CAAgBG,KAAK;MACvB;IACF;IAEAN,aAAA,CAAcQ,gBAAA,CACZ;IAAA;IAEAH,aACF;IAEA,OAAO,MAAM;MACXL,aAAA,CAAcS,mBAAA,CACZ;MAAA;MAEAJ,aACF;IACF;EACF,GAAG,CAACF,eAAA,EAAiBH,aAAa,CAAC;AACrC","ignoreList":[]}
|
package/dist/esm/index.native.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useCallbackRef } from "@hanzogui/use-callback-ref";
|
|
2
|
-
import React from "react";
|
|
3
|
-
function useEscapeKeydown(onEscapeKeyDownProp) {
|
|
4
|
-
var ownerDocument = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function () {
|
|
5
|
-
var _globalThis;
|
|
6
|
-
return (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.document;
|
|
7
|
-
}();
|
|
8
|
-
var onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
9
|
-
React.useEffect(function () {
|
|
10
|
-
var handleKeyDown = function (event) {
|
|
11
|
-
if (event.key === "Escape") {
|
|
12
|
-
onEscapeKeyDown(event);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
ownerDocument.addEventListener("keydown",
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
handleKeyDown);
|
|
18
|
-
return function () {
|
|
19
|
-
ownerDocument.removeEventListener("keydown",
|
|
20
|
-
// @ts-expect-error
|
|
21
|
-
handleKeyDown);
|
|
22
|
-
};
|
|
23
|
-
}, [onEscapeKeyDown, ownerDocument]);
|
|
24
|
-
}
|
|
25
|
-
export { useEscapeKeydown };
|
|
26
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useCallbackRef","React","useEscapeKeydown","onEscapeKeyDownProp","ownerDocument","arguments","length","_globalThis","globalThis","document","onEscapeKeyDown","useEffect","handleKeyDown","event","key","addEventListener","removeEventListener"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,cAAA,QAAsB;AAC/B,OAAOC,KAAA,MAAW;AAKX,SAASC,iBACdC,mBAAA,EACA;EAEA,IAAAC,aAAM,GAAAC,SAAkB,CAAAC,MAAA,GAAe,KAAAD,SAAA,QAAmB,SAAAA,SAAA;IAE1D,IAAME,WAAU;IACd,OAAM,CAAAA,WAAA,GAAgBC,UAAC,MAA+B,QAAAD,WAAA,uBAAAA,WAAA,CAAAE,QAAA;EACpD;EACE,IAAAC,eAAA,GAAgBV,cAAK,CAAAG,mBAAA;EAAAF,KACvB,CAAAU,SAAA;IACF,IAAAC,aAAA,YAAAA,CAAAC,KAAA;MAEA,IAAAA,KAAA,CAAAC,GAAc;QACZJ,eAAA,CAAAG,KAAA;MAAA;IAAA;IAGFT,aAAA,CAAAW,gBAAA,CAEA,SAAO;IACL;IAAcH,aACZ;IAAA,OAEA;MACFR,aAAA,CAAAY,mBAAA,CACF;MACE;MACNJ,a","ignoreList":[]}
|