@nethru/ui 2.1.51 → 2.1.53
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/base/Snackbar.js +2 -0
- package/base/context/AutoLogoutContext.js +22 -0
- package/base/editor/Editor.js +3 -1
- package/base/frame/AppBar.js +7 -1
- package/base/frame/AutoLogoutWarning.js +115 -0
- package/base/hook/Timer.js +18 -0
- package/base/index.js +2 -0
- package/package.json +1 -1
package/base/Snackbar.js
CHANGED
|
@@ -9,6 +9,7 @@ const Snackbar = /*#__PURE__*/forwardRef(({
|
|
|
9
9
|
subcontent,
|
|
10
10
|
slideDirection = 'down',
|
|
11
11
|
children,
|
|
12
|
+
alertProps,
|
|
12
13
|
...props
|
|
13
14
|
}, ref) => {
|
|
14
15
|
const Transition = useCallback(props => {
|
|
@@ -26,6 +27,7 @@ const Snackbar = /*#__PURE__*/forwardRef(({
|
|
|
26
27
|
severity: severity,
|
|
27
28
|
icon: icon,
|
|
28
29
|
subcontent: subcontent,
|
|
30
|
+
...alertProps,
|
|
29
31
|
children: children
|
|
30
32
|
})
|
|
31
33
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from "react";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const AutoLogoutContext = /*#__PURE__*/createContext();
|
|
4
|
+
export function AutoLogoutContextProvider({
|
|
5
|
+
sessionTimeout,
|
|
6
|
+
sessionTimeoutWarningTime,
|
|
7
|
+
children
|
|
8
|
+
}) {
|
|
9
|
+
const [refresh, setRefresh] = useState(false);
|
|
10
|
+
return /*#__PURE__*/_jsx(AutoLogoutContext.Provider, {
|
|
11
|
+
value: {
|
|
12
|
+
sessionTimeout,
|
|
13
|
+
sessionTimeoutWarningTime,
|
|
14
|
+
refresh,
|
|
15
|
+
setRefresh
|
|
16
|
+
},
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function useAutoLogoutContext() {
|
|
21
|
+
return useContext(AutoLogoutContext);
|
|
22
|
+
}
|
package/base/editor/Editor.js
CHANGED
|
@@ -222,7 +222,8 @@ function makeEslinter(format, eslintRules, onEslintUpdate, customVariables, read
|
|
|
222
222
|
let hints = [];
|
|
223
223
|
const config = {
|
|
224
224
|
env: {
|
|
225
|
-
es6: true
|
|
225
|
+
es6: true,
|
|
226
|
+
browser: true
|
|
226
227
|
},
|
|
227
228
|
parserOptions: {
|
|
228
229
|
ecmaVersion: 6
|
|
@@ -231,6 +232,7 @@ function makeEslinter(format, eslintRules, onEslintUpdate, customVariables, read
|
|
|
231
232
|
"semi": ["error", "always"],
|
|
232
233
|
"func-names": "off",
|
|
233
234
|
"no-unused-expressions": "off",
|
|
235
|
+
"no-undef": "error",
|
|
234
236
|
...eslintRules
|
|
235
237
|
}
|
|
236
238
|
};
|
package/base/frame/AppBar.js
CHANGED
|
@@ -8,6 +8,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
const AppBar = /*#__PURE__*/forwardRef(({
|
|
9
9
|
appsSlot,
|
|
10
10
|
brandSlot,
|
|
11
|
+
sessionSlot,
|
|
11
12
|
avatarSlot,
|
|
12
13
|
children,
|
|
13
14
|
...props
|
|
@@ -42,7 +43,12 @@ const AppBar = /*#__PURE__*/forwardRef(({
|
|
|
42
43
|
alignItems: "center",
|
|
43
44
|
flexGrow: 1,
|
|
44
45
|
gap: 6,
|
|
45
|
-
children: [children, !children && /*#__PURE__*/_jsx(Box, {}),
|
|
46
|
+
children: [children, !children && /*#__PURE__*/_jsx(Box, {}), /*#__PURE__*/_jsxs(Stack, {
|
|
47
|
+
direction: "row",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
gap: 2,
|
|
50
|
+
children: [sessionSlot, avatarSlot]
|
|
51
|
+
})]
|
|
46
52
|
})]
|
|
47
53
|
})
|
|
48
54
|
}), !isEmpty(sections) && /*#__PURE__*/_jsx(Box, {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { Box, Button, Popover, Stack, Typography } from "@mui/material";
|
|
3
|
+
import useInterval from "../hook/Timer";
|
|
4
|
+
import { useAutoLogoutContext } from "../context/AutoLogoutContext";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
const AutoLogoutWarning = /*#__PURE__*/forwardRef(({
|
|
9
|
+
onExtendSession,
|
|
10
|
+
onTimeout,
|
|
11
|
+
...props
|
|
12
|
+
}, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
sessionTimeout,
|
|
15
|
+
sessionTimeoutWarningTime,
|
|
16
|
+
refresh
|
|
17
|
+
} = useAutoLogoutContext();
|
|
18
|
+
const [remaingTime, setRemainingTime] = useState(sessionTimeout);
|
|
19
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
20
|
+
const isVisible = useMemo(() => remaingTime >= 0 && remaingTime <= sessionTimeoutWarningTime, [remaingTime, sessionTimeoutWarningTime]);
|
|
21
|
+
const open = useMemo(() => Boolean(anchorEl), [anchorEl]);
|
|
22
|
+
const handleOpen = useCallback(event => {
|
|
23
|
+
setAnchorEl(event.currentTarget);
|
|
24
|
+
}, []);
|
|
25
|
+
const handleClose = useCallback(() => {
|
|
26
|
+
setAnchorEl(null);
|
|
27
|
+
}, []);
|
|
28
|
+
const handleExtend = useCallback(() => {
|
|
29
|
+
setAnchorEl(null);
|
|
30
|
+
onExtendSession?.();
|
|
31
|
+
}, [onExtendSession]);
|
|
32
|
+
useInterval(() => {
|
|
33
|
+
if (remaingTime === 0) onTimeout?.();
|
|
34
|
+
setRemainingTime(prev => prev - 1);
|
|
35
|
+
}, remaingTime >= 0 ? 1000 : null);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setRemainingTime(sessionTimeout);
|
|
38
|
+
// eslint-disable-next-line
|
|
39
|
+
}, [refresh]);
|
|
40
|
+
console.log(remaingTime);
|
|
41
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
42
|
+
children: [isVisible && /*#__PURE__*/_jsx(Button, {
|
|
43
|
+
color: "curd",
|
|
44
|
+
onClick: handleOpen,
|
|
45
|
+
children: /*#__PURE__*/_jsxs(Stack, {
|
|
46
|
+
sx: styles.container,
|
|
47
|
+
...props,
|
|
48
|
+
children: [/*#__PURE__*/_jsxs(Typography, {
|
|
49
|
+
variant: "bodySmBold",
|
|
50
|
+
children: [remaingTime, "\uCD08"]
|
|
51
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
52
|
+
variant: "bodyXsMedium",
|
|
53
|
+
sx: styles.description,
|
|
54
|
+
children: "\uB85C\uADF8\uC544\uC6C3\uAE4C\uC9C0 \uB0A8\uC740 \uC2DC\uAC04"
|
|
55
|
+
})]
|
|
56
|
+
})
|
|
57
|
+
}), remaingTime > 0 && /*#__PURE__*/_jsx(Popover, {
|
|
58
|
+
open: open,
|
|
59
|
+
anchorEl: anchorEl,
|
|
60
|
+
anchorOrigin: {
|
|
61
|
+
vertical: 'bottom',
|
|
62
|
+
horizontal: 'left'
|
|
63
|
+
},
|
|
64
|
+
transformOrigin: {
|
|
65
|
+
vertical: 'top',
|
|
66
|
+
horizontal: 'left'
|
|
67
|
+
},
|
|
68
|
+
onClose: handleClose,
|
|
69
|
+
disableRestoreFocus: true,
|
|
70
|
+
sx: styles.popover,
|
|
71
|
+
children: /*#__PURE__*/_jsxs(Stack, {
|
|
72
|
+
gap: 2,
|
|
73
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
74
|
+
variant: "bodySmBold",
|
|
75
|
+
children: "\uC790\uB3D9 \uB85C\uADF8\uC544\uC6C3 \uC548\uB0B4"
|
|
76
|
+
}), /*#__PURE__*/_jsxs(Typography, {
|
|
77
|
+
variant: "bodySmRegular",
|
|
78
|
+
children: [Math.round(sessionTimeout / 60), "\uBD84 \uB3D9\uC548 \uC11C\uBE44\uC2A4\uB97C \uC774\uC6A9\uD558\uC9C0 \uC54A\uC544", /*#__PURE__*/_jsx("br", {}), "\uC7A0\uC2DC \uD6C4 \uC790\uB3D9\uC73C\uB85C \uB85C\uADF8\uC544\uC6C3\uB420 \uC608\uC815\uC785\uB2C8\uB2E4.", /*#__PURE__*/_jsx("br", {}), "\uB85C\uADF8\uC778 \uC2DC\uAC04\uC744 \uC5F0\uC7A5\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?"]
|
|
79
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
80
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
81
|
+
size: "small",
|
|
82
|
+
onClick: handleExtend,
|
|
83
|
+
children: "\uB85C\uADF8\uC778 \uC5F0\uC7A5"
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
const styles = {
|
|
91
|
+
container: {
|
|
92
|
+
height: '36px',
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
alignItems: 'center'
|
|
95
|
+
},
|
|
96
|
+
timeRemaining: {},
|
|
97
|
+
description: {
|
|
98
|
+
lineHeight: 1
|
|
99
|
+
},
|
|
100
|
+
popover: {
|
|
101
|
+
'& .MuiPaper-root': {
|
|
102
|
+
padding: 3
|
|
103
|
+
},
|
|
104
|
+
'& .MuiBox-root': {
|
|
105
|
+
width: '100%',
|
|
106
|
+
textAlign: 'center'
|
|
107
|
+
},
|
|
108
|
+
'& .MuiTypography-root': {
|
|
109
|
+
lineHeight: 1.2,
|
|
110
|
+
whiteSpace: 'pre',
|
|
111
|
+
cursor: 'default'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export default AutoLogoutWarning;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
const useInterval = (callback, delay, onMount) => {
|
|
3
|
+
const callbackRef = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
callbackRef.current = callback;
|
|
6
|
+
}, [callback]);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
let timerId;
|
|
9
|
+
if (delay) {
|
|
10
|
+
timerId = setInterval(() => {
|
|
11
|
+
callbackRef.current();
|
|
12
|
+
}, delay);
|
|
13
|
+
}
|
|
14
|
+
if (onMount) onMount(timerId);
|
|
15
|
+
return () => clearInterval(timerId);
|
|
16
|
+
}, [delay, onMount]);
|
|
17
|
+
};
|
|
18
|
+
export default useInterval;
|
package/base/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as AddableFormList } from "./AddableFormList";
|
|
|
10
10
|
export { default as Alert } from "./Alert";
|
|
11
11
|
export { default as AlertDialog } from "./dialog/AlertDialog";
|
|
12
12
|
export { default as AppBar } from "./frame/AppBar";
|
|
13
|
+
export { default as AutoLogoutWarning } from "./frame/AutoLogoutWarning";
|
|
13
14
|
export { default as Brand } from "./frame/Brand";
|
|
14
15
|
export { default as CircularProgressButton } from "./CircularProgressButton";
|
|
15
16
|
export { default as Checkbox } from "./Checkbox";
|
|
@@ -39,6 +40,7 @@ export { default as Snackbar } from "./Snackbar";
|
|
|
39
40
|
export { default as SplitLayout } from "./frame/SplitLayout";
|
|
40
41
|
export { default as Switch } from "./Switch";
|
|
41
42
|
export { default as TextField } from "./TextField";
|
|
43
|
+
export * from "./context/AutoLogoutContext";
|
|
42
44
|
export * from './frame/sidebar/SidebarContext';
|
|
43
45
|
export { default as Error } from "./error/Error";
|
|
44
46
|
export { default as HttpError } from "./error/HttpError";
|