ui-soxo-bootstrap-core 2.4.25 → 2.5.0
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/core/components/external-window/DEVELOPER_GUIDE.md +705 -0
- package/core/components/external-window/external-window.js +225 -0
- package/core/components/external-window/external-window.test.js +80 -0
- package/core/components/index.js +4 -1
- package/core/components/landing-api/landing-api.js +18 -18
- package/core/lib/Store.js +20 -18
- package/core/lib/components/index.js +4 -1
- package/core/lib/elements/basic/rangepicker/rangepicker.js +118 -29
- package/core/lib/elements/basic/switch/switch.js +34 -24
- package/core/lib/hooks/index.js +2 -12
- package/core/lib/hooks/use-otp-timer.js +80 -0
- package/core/lib/pages/login/login.js +255 -139
- package/core/lib/pages/login/login.scss +144 -32
- package/core/models/dashboard/dashboard.js +14 -0
- package/core/models/menus/components/menu-add/menu-add.js +230 -268
- package/core/models/menus/menus.js +1 -1
- package/core/modules/index.js +2 -0
- package/core/modules/steps/action-buttons.js +88 -0
- package/core/modules/steps/steps.js +332 -0
- package/core/modules/steps/steps.scss +158 -0
- package/core/modules/steps/timeline.js +54 -0
- package/jest.config.js +8 -0
- package/jest.setup.js +1 -0
- package/package.json +9 -4
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component for antd switch
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
import React, { useState, useContext, useEffect } from 'react';
|
|
6
|
-
import { GlobalContext } from '../../../Store';
|
|
7
|
-
|
|
4
|
+
import React, { useContext } from 'react';
|
|
8
5
|
import { Switch as AntdSwitch } from 'antd';
|
|
9
|
-
|
|
6
|
+
import { GlobalContext } from '../../../Store';
|
|
10
7
|
import PropTypes from 'prop-types';
|
|
11
8
|
|
|
12
|
-
export default function Switch({
|
|
9
|
+
export default function Switch({
|
|
10
|
+
checked,
|
|
11
|
+
defaultChecked,
|
|
12
|
+
onChange,
|
|
13
|
+
disabled,
|
|
14
|
+
id,
|
|
15
|
+
size,
|
|
16
|
+
checkedChildren,
|
|
17
|
+
unCheckedChildren,
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
}) {
|
|
13
21
|
const { state } = useContext(GlobalContext);
|
|
14
22
|
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
// Reacting to theme changes
|
|
17
|
-
}, [state.theme.colors]);
|
|
18
|
-
|
|
19
23
|
return (
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
<AntdSwitch
|
|
25
|
+
id={id}
|
|
26
|
+
checked={checked}
|
|
27
|
+
defaultChecked={defaultChecked}
|
|
28
|
+
onChange={onChange}
|
|
29
|
+
disabled={disabled}
|
|
30
|
+
size={size}
|
|
31
|
+
checkedChildren={checkedChildren}
|
|
32
|
+
unCheckedChildren={unCheckedChildren}
|
|
33
|
+
className={className}
|
|
34
|
+
style={{
|
|
35
|
+
backgroundColor: checked
|
|
36
|
+
? state.theme.colors.primaryButtonBg
|
|
37
|
+
: state.theme.colors.primaryButtonDisabledBg,
|
|
38
|
+
borderColor: checked
|
|
39
|
+
? state.theme.colors.primaryButtonBg
|
|
40
|
+
: state.theme.colors.primaryButtonDisabledBg,
|
|
41
|
+
...style,
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
34
44
|
);
|
|
35
45
|
}
|
|
36
46
|
|
package/core/lib/hooks/index.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
import useDeviceDetect from './device-detect';
|
|
5
2
|
|
|
6
3
|
import useWindowSize from './use-window-size';
|
|
7
4
|
|
|
8
5
|
import useFormUtils from './../utils/form/form.utils';
|
|
9
6
|
import useLocation from './use-location';
|
|
7
|
+
import { useOtpTimer } from './use-otp-timer';
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
useDeviceDetect,
|
|
14
|
-
useWindowSize,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
useFormUtils,
|
|
18
|
-
useLocation
|
|
19
|
-
}
|
|
9
|
+
export { useDeviceDetect, useWindowSize, useOtpTimer, useFormUtils, useLocation };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useState, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook to manage an OTP (One-Time Password) countdown timer.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Can start a timer directly with seconds.
|
|
8
|
+
* - Can start a timer using an expiry timestamp (from backend).
|
|
9
|
+
* - Provides formatted remaining time (MM:SS).
|
|
10
|
+
* - Tracks whether the timer has expired.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Object} API
|
|
13
|
+
* @returns {number} API.remaining - Remaining seconds.
|
|
14
|
+
* @returns {boolean} API.expired - Whether the timer has expired.
|
|
15
|
+
* @returns {string} API.formatted - Formatted remaining time (MM:SS).
|
|
16
|
+
* @returns {(seconds: number) => void} API.start - Start timer with seconds.
|
|
17
|
+
* @returns {(expirytime: string) => void} API.startFromExpiry - Start timer using expiry string (e.g. "2025-09-04T12:13:09.000Z").
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// helper to format time
|
|
22
|
+
const formatTime = (seconds) => {
|
|
23
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
24
|
+
const secs = seconds % 60;
|
|
25
|
+
return `${String(minutes).padStart(2, '0')}:${String(secs).padStart(2, '0')}`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const useOtpTimer = () => {
|
|
29
|
+
const [remaining, setRemaining] = useState(0);
|
|
30
|
+
const [expired, setExpired] = useState(false);
|
|
31
|
+
const intervalRef = useRef(null);
|
|
32
|
+
|
|
33
|
+
// Start timer by passing expiry string from backend
|
|
34
|
+
const startFromExpiry = (expirytime) => {
|
|
35
|
+
if (!expirytime) {
|
|
36
|
+
setRemaining(0);
|
|
37
|
+
setExpired(true);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Handle backend expiry string
|
|
42
|
+
const expiryTime = new Date(expirytime).getTime();
|
|
43
|
+
const now = Date.now();
|
|
44
|
+
const seconds = Math.max(0, Math.floor((expiryTime - now) / 1000));
|
|
45
|
+
|
|
46
|
+
start(seconds);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Generic start (seconds)
|
|
50
|
+
const start = (seconds) => {
|
|
51
|
+
clearInterval(intervalRef.current);
|
|
52
|
+
|
|
53
|
+
if (!seconds || seconds <= 0) {
|
|
54
|
+
setRemaining(0);
|
|
55
|
+
setExpired(true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setRemaining(seconds);
|
|
60
|
+
setExpired(false);
|
|
61
|
+
|
|
62
|
+
intervalRef.current = setInterval(() => {
|
|
63
|
+
setRemaining((prev) => {
|
|
64
|
+
if (prev <= 1) {
|
|
65
|
+
clearInterval(intervalRef.current);
|
|
66
|
+
setExpired(true);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
return prev - 1;
|
|
70
|
+
});
|
|
71
|
+
}, 1000);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Cleanup on unmount
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
return () => clearInterval(intervalRef.current);
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
return { remaining, expired, formatted: formatTime(remaining), start, startFromExpiry };
|
|
80
|
+
};
|