quidproquo-web-react 0.0.237 → 0.0.239
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/lib/commonjs/auth/hooks/useIsLoggedIn.js +3 -5
- package/lib/commonjs/hooks/index.d.ts +1 -0
- package/lib/commonjs/hooks/index.js +1 -0
- package/lib/commonjs/hooks/useOnKeyDownEffect.d.ts +1 -0
- package/lib/commonjs/hooks/useOnKeyDownEffect.js +23 -0
- package/lib/esm/auth/hooks/useIsLoggedIn.js +3 -4
- package/lib/esm/hooks/index.d.ts +1 -0
- package/lib/esm/hooks/index.js +1 -0
- package/lib/esm/hooks/useOnKeyDownEffect.d.ts +1 -0
- package/lib/esm/hooks/useOnKeyDownEffect.js +19 -0
- package/package.json +5 -5
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useIsLoggedIn = void 0;
|
|
4
|
-
const
|
|
5
|
-
const authContext_1 = require("../authContext");
|
|
4
|
+
const useAuthAccessToken_1 = require("./useAuthAccessToken");
|
|
6
5
|
const useIsLoggedIn = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return !!((_a = authState.authenticationInfo) === null || _a === void 0 ? void 0 : _a.accessToken);
|
|
6
|
+
const accessToken = (0, useAuthAccessToken_1.useAuthAccessToken)();
|
|
7
|
+
return !!accessToken;
|
|
10
8
|
};
|
|
11
9
|
exports.useIsLoggedIn = useIsLoggedIn;
|
|
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useAsyncEffect"), exports);
|
|
18
18
|
__exportStar(require("./useFastCallback"), exports);
|
|
19
|
+
__exportStar(require("./useOnKeyDownEffect"), exports);
|
|
19
20
|
__exportStar(require("./useRunEvery"), exports);
|
|
20
21
|
__exportStar(require("./useThrottledMemo"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useOnKeyDownEffect(targetKey: KeyboardEvent['key'], isActive: boolean, callback?: () => void): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOnKeyDownEffect = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useOnKeyDownEffect(targetKey, isActive, callback) {
|
|
6
|
+
(0, react_1.useEffect)(() => {
|
|
7
|
+
if (!isActive || !callback) {
|
|
8
|
+
return () => {
|
|
9
|
+
// NOOP
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const handleKeyDown = (event) => {
|
|
13
|
+
if (event.key === targetKey) {
|
|
14
|
+
callback();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
18
|
+
return () => {
|
|
19
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
20
|
+
};
|
|
21
|
+
}, [targetKey, isActive, callback]);
|
|
22
|
+
}
|
|
23
|
+
exports.useOnKeyDownEffect = useOnKeyDownEffect;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { authContext } from '../authContext';
|
|
1
|
+
import { useAuthAccessToken } from './useAuthAccessToken';
|
|
3
2
|
export const useIsLoggedIn = () => {
|
|
4
|
-
const
|
|
5
|
-
return !!
|
|
3
|
+
const accessToken = useAuthAccessToken();
|
|
4
|
+
return !!accessToken;
|
|
6
5
|
};
|
package/lib/esm/hooks/index.d.ts
CHANGED
package/lib/esm/hooks/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useOnKeyDownEffect(targetKey: KeyboardEvent['key'], isActive: boolean, callback?: () => void): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export function useOnKeyDownEffect(targetKey, isActive, callback) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!isActive || !callback) {
|
|
5
|
+
return () => {
|
|
6
|
+
// NOOP
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const handleKeyDown = (event) => {
|
|
10
|
+
if (event.key === targetKey) {
|
|
11
|
+
callback();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
15
|
+
return () => {
|
|
16
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
17
|
+
};
|
|
18
|
+
}, [targetKey, isActive, callback]);
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-web-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.239",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"quidproquo-core": "0.0.
|
|
36
|
-
"quidproquo-tsconfig": "0.0.
|
|
37
|
-
"quidproquo-webserver": "0.0.
|
|
38
|
-
"quidproquo-web": "0.0.
|
|
35
|
+
"quidproquo-core": "0.0.239",
|
|
36
|
+
"quidproquo-tsconfig": "0.0.239",
|
|
37
|
+
"quidproquo-webserver": "0.0.239",
|
|
38
|
+
"quidproquo-web": "0.0.239",
|
|
39
39
|
"typescript": "^4.9.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|