mimir-ui-kit 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +62 -54
- package/dist/{NavigationButtons-cTsXB7GS.js → NavigationButtons-B8tMfqrg.js} +18 -18
- package/dist/assets/Button.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/OtpInput.css +1 -1
- package/dist/assets/RadioGroup.css +1 -1
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/components/Button/Button.d.ts +1 -0
- package/dist/components/Button/Button.js +25 -25
- package/dist/components/Input/Input.d.ts +2 -2
- package/dist/components/Input/Input.js +15 -15
- package/dist/components/InputPassword/InputPassword.js +2 -2
- package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
- package/dist/components/MergedButton/MergedButton.d.ts +1 -1
- package/dist/components/MergedButton/MergedButton.js +2 -2
- package/dist/components/OtpInput/OtpInput.js +6 -6
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -18
- package/dist/components/RadioGroup/RadioGroup.js +1061 -127
- package/dist/components/RadioGroup/index.d.ts +1 -1
- package/dist/components/Slider/NavigationButtons/NavigationButtons.js +1 -1
- package/dist/components/Slider/NavigationButtons/index.js +1 -1
- package/dist/components/Slider/Slider.js +10 -10
- package/dist/components/Tag/Tag.d.ts +79 -0
- package/dist/components/Tag/Tag.js +99 -0
- package/dist/components/Tag/constants.d.ts +41 -0
- package/dist/components/Tag/constants.js +55 -0
- package/dist/components/Tag/index.d.ts +3 -0
- package/dist/components/Tag/index.js +8 -0
- package/dist/components/Tag/types.d.ts +6 -0
- package/dist/components/Tag/types.js +1 -0
- package/dist/components/index.d.ts +1 -10
- package/dist/components/index.js +0 -14
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/index.js +1 -7
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -23
- package/package.json +128 -127
- package/dist/DatePickerModal-DUUCHAWF.js +0 -204
- package/dist/assets/DatePickerModal.css +0 -1
- package/dist/assets/Drawer.css +0 -1
- package/dist/assets/SelectSearch.css +0 -1
- package/dist/assets/Switch.css +0 -1
- package/dist/assets/Timer.css +0 -1
- package/dist/components/DatePicker/DatePicker.d.ts +0 -44
- package/dist/components/DatePicker/DatePicker.js +0 -69
- package/dist/components/DatePicker/DatePickerModal.d.ts +0 -8
- package/dist/components/DatePicker/DatePickerModal.js +0 -9
- package/dist/components/DatePicker/constants.d.ts +0 -6
- package/dist/components/DatePicker/constants.js +0 -11
- package/dist/components/DatePicker/index.d.ts +0 -2
- package/dist/components/DatePicker/index.js +0 -4
- package/dist/components/Drawer/Drawer.d.ts +0 -38
- package/dist/components/Drawer/Drawer.js +0 -144
- package/dist/components/Drawer/constants.d.ts +0 -5
- package/dist/components/Drawer/constants.js +0 -9
- package/dist/components/Drawer/index.d.ts +0 -2
- package/dist/components/Drawer/index.js +0 -6
- package/dist/components/Portal/Portal.d.ts +0 -7
- package/dist/components/Portal/Portal.js +0 -10
- package/dist/components/Portal/index.d.ts +0 -1
- package/dist/components/Portal/index.js +0 -4
- package/dist/components/SelectSearch/SelectSearch.d.ts +0 -15
- package/dist/components/SelectSearch/SelectSearch.js +0 -3961
- package/dist/components/SelectSearch/constants.d.ts +0 -4
- package/dist/components/SelectSearch/constants.js +0 -8
- package/dist/components/SelectSearch/index.d.ts +0 -2
- package/dist/components/SelectSearch/index.js +0 -6
- package/dist/components/Switch/Switch.d.ts +0 -294
- package/dist/components/Switch/Switch.js +0 -57
- package/dist/components/Switch/index.d.ts +0 -2
- package/dist/components/Switch/index.js +0 -4
- package/dist/components/Timer/Timer.d.ts +0 -24
- package/dist/components/Timer/Timer.js +0 -29
- package/dist/components/Timer/index.d.ts +0 -1
- package/dist/components/Timer/index.js +0 -4
- package/dist/focus-management-CFDo6ZSc.js +0 -91
- package/dist/hooks/useClickOutside/index.d.ts +0 -1
- package/dist/hooks/useClickOutside/index.js +0 -4
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +0 -7
- package/dist/hooks/useClickOutside/useClickOutside.js +0 -25
- package/dist/hooks/useInterval/index.d.ts +0 -1
- package/dist/hooks/useInterval/index.js +0 -4
- package/dist/hooks/useInterval/useInterval.d.ts +0 -1
- package/dist/hooks/useInterval/useInterval.js +0 -17
- package/dist/hooks/useLockBodyScroll/index.d.ts +0 -1
- package/dist/hooks/useLockBodyScroll/index.js +0 -4
- package/dist/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +0 -6
- package/dist/hooks/useLockBodyScroll/useLockBodyScroll.js +0 -20
- package/dist/hooks/useTimer/index.d.ts +0 -18
- package/dist/hooks/useTimer/index.js +0 -83
- package/dist/hooks/useTimer/useTimer.d.ts +0 -18
- package/dist/hooks/useTimer/useTimer.js +0 -83
- package/dist/hooks/useTimer/utils.d.ts +0 -20
- package/dist/hooks/useTimer/utils.js +0 -78
- package/dist/label-BXAcSLy0.js +0 -913
- package/dist/use-active-press-9MCrfRZk.js +0 -31
- package/dist/utils/formating/Date.d.ts +0 -1
- package/dist/utils/formating/Date.js +0 -26
- package/dist/utils/formating/Month.d.ts +0 -8
- package/dist/utils/formating/Month.js +0 -80
- package/dist/utils/formating/Numbers.d.ts +0 -6
- package/dist/utils/formating/Numbers.js +0 -8
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.js +0 -11
@@ -1,20 +0,0 @@
|
|
1
|
-
import { useLayoutEffect } from "react";
|
2
|
-
function useLockBodyScroll({ on, paddingRight }) {
|
3
|
-
useLayoutEffect(() => {
|
4
|
-
const hasVerticalScrollbar = document.documentElement.scrollHeight > document.documentElement.clientHeight;
|
5
|
-
if (!on || !hasVerticalScrollbar) return;
|
6
|
-
const originalStyle = window.getComputedStyle(document.body).overflow;
|
7
|
-
const originalPaddingStyle = window.getComputedStyle(
|
8
|
-
document.body
|
9
|
-
).paddingRight;
|
10
|
-
document.body.style.overflow = "hidden";
|
11
|
-
document.body.style.paddingRight = `${paddingRight}px`;
|
12
|
-
return () => {
|
13
|
-
document.body.style.overflow = originalStyle;
|
14
|
-
document.body.style.paddingRight = originalPaddingStyle;
|
15
|
-
};
|
16
|
-
}, [on, paddingRight]);
|
17
|
-
}
|
18
|
-
export {
|
19
|
-
useLockBodyScroll
|
20
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
export type TUserTimer = ReturnType<typeof useTimer>;
|
2
|
-
export type TUseTimerProps = {
|
3
|
-
expiryTimestamp?: number;
|
4
|
-
onExpire?: VoidFunction;
|
5
|
-
autoStart?: boolean;
|
6
|
-
};
|
7
|
-
export declare function useTimer({ expiryTimestamp: expiry, onExpire, autoStart }: TUseTimerProps): {
|
8
|
-
start: () => void;
|
9
|
-
pause: () => void;
|
10
|
-
resume: () => void;
|
11
|
-
restart: (newExpiryTimestamp: number, newAutoStart?: boolean) => void;
|
12
|
-
isRunning: boolean;
|
13
|
-
totalSeconds: number;
|
14
|
-
days: number;
|
15
|
-
hours: number;
|
16
|
-
minutes: number;
|
17
|
-
seconds: number;
|
18
|
-
};
|
@@ -1,83 +0,0 @@
|
|
1
|
-
import { useState, useCallback } from "react";
|
2
|
-
import { Time, Validate } from "./utils.js";
|
3
|
-
import { useInterval } from "../useInterval/useInterval.js";
|
4
|
-
const DEFAULT_DELAY = 1e3;
|
5
|
-
function getDelayFromExpiryTimestamp(expiryTimestamp) {
|
6
|
-
if (!Validate.expiryTimestamp(expiryTimestamp)) {
|
7
|
-
return null;
|
8
|
-
}
|
9
|
-
const seconds = Time.getSecondsFromExpiry(expiryTimestamp);
|
10
|
-
const extraMilliSeconds = Math.floor((seconds - Math.floor(seconds)) * 1e3);
|
11
|
-
return extraMilliSeconds > 0 ? extraMilliSeconds : DEFAULT_DELAY;
|
12
|
-
}
|
13
|
-
function useTimer({
|
14
|
-
expiryTimestamp: expiry,
|
15
|
-
onExpire,
|
16
|
-
autoStart = false
|
17
|
-
}) {
|
18
|
-
const [expiryTimestamp, setExpiryTimestamp] = useState(expiry);
|
19
|
-
const [seconds, setSeconds] = useState(
|
20
|
-
Time.getSecondsFromExpiry(expiry ?? 0)
|
21
|
-
);
|
22
|
-
const [isRunning, setIsRunning] = useState(autoStart);
|
23
|
-
const [didStart, setDidStart] = useState(autoStart);
|
24
|
-
const [delay, setDelay] = useState(getDelayFromExpiryTimestamp(expiry ?? 0));
|
25
|
-
const handleExpire = useCallback(() => {
|
26
|
-
Validate.onExpire(onExpire) && (onExpire == null ? void 0 : onExpire());
|
27
|
-
setIsRunning(false);
|
28
|
-
setDelay(null);
|
29
|
-
}, [onExpire]);
|
30
|
-
const pause = useCallback(() => {
|
31
|
-
setIsRunning(false);
|
32
|
-
}, []);
|
33
|
-
const restart = useCallback(
|
34
|
-
(newExpiryTimestamp, newAutoStart = true) => {
|
35
|
-
setDelay(getDelayFromExpiryTimestamp(newExpiryTimestamp));
|
36
|
-
setDidStart(newAutoStart);
|
37
|
-
setIsRunning(newAutoStart);
|
38
|
-
setExpiryTimestamp(newExpiryTimestamp);
|
39
|
-
setSeconds(Time.getSecondsFromExpiry(newExpiryTimestamp));
|
40
|
-
},
|
41
|
-
[]
|
42
|
-
);
|
43
|
-
const resume = useCallback(() => {
|
44
|
-
const time = /* @__PURE__ */ new Date();
|
45
|
-
time.setMilliseconds(time.getMilliseconds() + seconds * 1e3);
|
46
|
-
restart(time.getTime(), true);
|
47
|
-
}, [seconds, restart]);
|
48
|
-
const start = useCallback(() => {
|
49
|
-
if (didStart) {
|
50
|
-
setSeconds(Time.getSecondsFromExpiry(expiryTimestamp ?? 0, false));
|
51
|
-
setIsRunning(true);
|
52
|
-
} else {
|
53
|
-
resume();
|
54
|
-
}
|
55
|
-
}, [expiryTimestamp, didStart, resume]);
|
56
|
-
useInterval(
|
57
|
-
() => {
|
58
|
-
if (delay !== DEFAULT_DELAY) {
|
59
|
-
setDelay(DEFAULT_DELAY);
|
60
|
-
}
|
61
|
-
const secondsValue = Time.getSecondsFromExpiry(
|
62
|
-
expiryTimestamp ?? 0,
|
63
|
-
false
|
64
|
-
);
|
65
|
-
setSeconds(secondsValue);
|
66
|
-
if (secondsValue <= 0) {
|
67
|
-
handleExpire();
|
68
|
-
}
|
69
|
-
},
|
70
|
-
isRunning ? delay : null
|
71
|
-
);
|
72
|
-
return {
|
73
|
-
...Time.getTimeFromSeconds(seconds),
|
74
|
-
start,
|
75
|
-
pause,
|
76
|
-
resume,
|
77
|
-
restart,
|
78
|
-
isRunning
|
79
|
-
};
|
80
|
-
}
|
81
|
-
export {
|
82
|
-
useTimer
|
83
|
-
};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
export type TUserTimer = ReturnType<typeof useTimer>;
|
2
|
-
export type TUseTimerProps = {
|
3
|
-
expiryTimestamp?: number;
|
4
|
-
onExpire?: VoidFunction;
|
5
|
-
autoStart?: boolean;
|
6
|
-
};
|
7
|
-
export declare function useTimer({ expiryTimestamp: expiry, onExpire, autoStart }: TUseTimerProps): {
|
8
|
-
start: () => void;
|
9
|
-
pause: () => void;
|
10
|
-
resume: () => void;
|
11
|
-
restart: (newExpiryTimestamp: number, newAutoStart?: boolean) => void;
|
12
|
-
isRunning: boolean;
|
13
|
-
totalSeconds: number;
|
14
|
-
days: number;
|
15
|
-
hours: number;
|
16
|
-
minutes: number;
|
17
|
-
seconds: number;
|
18
|
-
};
|
@@ -1,83 +0,0 @@
|
|
1
|
-
import { useState, useCallback } from "react";
|
2
|
-
import { Time, Validate } from "./utils.js";
|
3
|
-
import { useInterval } from "../useInterval/useInterval.js";
|
4
|
-
const DEFAULT_DELAY = 1e3;
|
5
|
-
function getDelayFromExpiryTimestamp(expiryTimestamp) {
|
6
|
-
if (!Validate.expiryTimestamp(expiryTimestamp)) {
|
7
|
-
return null;
|
8
|
-
}
|
9
|
-
const seconds = Time.getSecondsFromExpiry(expiryTimestamp);
|
10
|
-
const extraMilliSeconds = Math.floor((seconds - Math.floor(seconds)) * 1e3);
|
11
|
-
return extraMilliSeconds > 0 ? extraMilliSeconds : DEFAULT_DELAY;
|
12
|
-
}
|
13
|
-
function useTimer({
|
14
|
-
expiryTimestamp: expiry,
|
15
|
-
onExpire,
|
16
|
-
autoStart = true
|
17
|
-
}) {
|
18
|
-
const [expiryTimestamp, setExpiryTimestamp] = useState(expiry);
|
19
|
-
const [seconds, setSeconds] = useState(
|
20
|
-
Time.getSecondsFromExpiry(expiry ?? 0)
|
21
|
-
);
|
22
|
-
const [isRunning, setIsRunning] = useState(autoStart);
|
23
|
-
const [didStart, setDidStart] = useState(autoStart);
|
24
|
-
const [delay, setDelay] = useState(getDelayFromExpiryTimestamp(expiry ?? 0));
|
25
|
-
const handleExpire = useCallback(() => {
|
26
|
-
Validate.onExpire(onExpire) && (onExpire == null ? void 0 : onExpire());
|
27
|
-
setIsRunning(false);
|
28
|
-
setDelay(null);
|
29
|
-
}, [onExpire]);
|
30
|
-
const pause = useCallback(() => {
|
31
|
-
setIsRunning(false);
|
32
|
-
}, []);
|
33
|
-
const restart = useCallback(
|
34
|
-
(newExpiryTimestamp, newAutoStart = true) => {
|
35
|
-
setDelay(getDelayFromExpiryTimestamp(newExpiryTimestamp));
|
36
|
-
setDidStart(newAutoStart);
|
37
|
-
setIsRunning(newAutoStart);
|
38
|
-
setExpiryTimestamp(newExpiryTimestamp);
|
39
|
-
setSeconds(Time.getSecondsFromExpiry(newExpiryTimestamp));
|
40
|
-
},
|
41
|
-
[]
|
42
|
-
);
|
43
|
-
const resume = useCallback(() => {
|
44
|
-
const time = /* @__PURE__ */ new Date();
|
45
|
-
time.setMilliseconds(time.getMilliseconds() + seconds * 1e3);
|
46
|
-
restart(time.getTime(), true);
|
47
|
-
}, [seconds, restart]);
|
48
|
-
const start = useCallback(() => {
|
49
|
-
if (didStart) {
|
50
|
-
setSeconds(Time.getSecondsFromExpiry(expiryTimestamp ?? 0, false));
|
51
|
-
setIsRunning(true);
|
52
|
-
} else {
|
53
|
-
resume();
|
54
|
-
}
|
55
|
-
}, [expiryTimestamp, didStart, resume]);
|
56
|
-
useInterval(
|
57
|
-
() => {
|
58
|
-
if (delay !== DEFAULT_DELAY) {
|
59
|
-
setDelay(DEFAULT_DELAY);
|
60
|
-
}
|
61
|
-
const secondsValue = Time.getSecondsFromExpiry(
|
62
|
-
expiryTimestamp ?? 0,
|
63
|
-
false
|
64
|
-
);
|
65
|
-
setSeconds(secondsValue);
|
66
|
-
if (secondsValue <= 0) {
|
67
|
-
handleExpire();
|
68
|
-
}
|
69
|
-
},
|
70
|
-
isRunning ? delay : null
|
71
|
-
);
|
72
|
-
return {
|
73
|
-
...Time.getTimeFromSeconds(seconds),
|
74
|
-
start,
|
75
|
-
pause,
|
76
|
-
resume,
|
77
|
-
restart,
|
78
|
-
isRunning
|
79
|
-
};
|
80
|
-
}
|
81
|
-
export {
|
82
|
-
useTimer
|
83
|
-
};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
type TTimeObject = {
|
2
|
-
totalSeconds: number;
|
3
|
-
days: number;
|
4
|
-
hours: number;
|
5
|
-
minutes: number;
|
6
|
-
seconds: number;
|
7
|
-
};
|
8
|
-
type TFormattedTime = Omit<TTimeObject, 'totalSeconds' | 'days'>;
|
9
|
-
export declare class Time {
|
10
|
-
static getTimeFromSeconds(secs: number): TTimeObject;
|
11
|
-
static getSecondsFromExpiry(expiry: number, shouldRound?: boolean): number;
|
12
|
-
static getSecondsFromPrevTime(prevTime: number, shouldRound: boolean): number;
|
13
|
-
static getSecondsFromTimeNow(): number;
|
14
|
-
static getFormattedTimeFromSeconds(totalSeconds: number): TFormattedTime;
|
15
|
-
}
|
16
|
-
export declare class Validate {
|
17
|
-
static expiryTimestamp(expiryTimestamp: number): boolean;
|
18
|
-
static onExpire(onExpire?: VoidFunction | null): boolean | null | undefined;
|
19
|
-
}
|
20
|
-
export {};
|
@@ -1,78 +0,0 @@
|
|
1
|
-
class Time {
|
2
|
-
static getTimeFromSeconds(secs) {
|
3
|
-
const totalSeconds = Math.ceil(secs);
|
4
|
-
const days = Math.floor(totalSeconds / (60 * 60 * 24));
|
5
|
-
const hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
|
6
|
-
const minutes = Math.floor(totalSeconds % (60 * 60) / 60);
|
7
|
-
const seconds = Math.floor(totalSeconds % 60);
|
8
|
-
return {
|
9
|
-
totalSeconds,
|
10
|
-
seconds,
|
11
|
-
minutes,
|
12
|
-
hours,
|
13
|
-
days
|
14
|
-
};
|
15
|
-
}
|
16
|
-
static getSecondsFromExpiry(expiry, shouldRound) {
|
17
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
18
|
-
const milliSecondsDistance = expiry - now;
|
19
|
-
if (milliSecondsDistance > 0) {
|
20
|
-
const val = milliSecondsDistance / 1e3;
|
21
|
-
return shouldRound ? Math.round(val) : val;
|
22
|
-
}
|
23
|
-
return 0;
|
24
|
-
}
|
25
|
-
static getSecondsFromPrevTime(prevTime, shouldRound) {
|
26
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
27
|
-
const milliSecondsDistance = now - prevTime;
|
28
|
-
if (milliSecondsDistance > 0) {
|
29
|
-
const val = milliSecondsDistance / 1e3;
|
30
|
-
return shouldRound ? Math.round(val) : val;
|
31
|
-
}
|
32
|
-
return 0;
|
33
|
-
}
|
34
|
-
static getSecondsFromTimeNow() {
|
35
|
-
const now = /* @__PURE__ */ new Date();
|
36
|
-
const currentTimestamp = now.getTime();
|
37
|
-
const offset = now.getTimezoneOffset() * 60;
|
38
|
-
return currentTimestamp / 1e3 - offset;
|
39
|
-
}
|
40
|
-
static getFormattedTimeFromSeconds(totalSeconds) {
|
41
|
-
const {
|
42
|
-
seconds: secondsValue,
|
43
|
-
minutes,
|
44
|
-
hours
|
45
|
-
} = Time.getTimeFromSeconds(totalSeconds);
|
46
|
-
return {
|
47
|
-
seconds: secondsValue,
|
48
|
-
minutes,
|
49
|
-
hours
|
50
|
-
};
|
51
|
-
}
|
52
|
-
}
|
53
|
-
class Validate {
|
54
|
-
static expiryTimestamp(expiryTimestamp) {
|
55
|
-
const isValid = new Date(expiryTimestamp).getTime() > 0;
|
56
|
-
if (!isValid) {
|
57
|
-
console.warn(
|
58
|
-
"{ useTimer } Invalid expiryTimestamp settings",
|
59
|
-
expiryTimestamp
|
60
|
-
);
|
61
|
-
}
|
62
|
-
return isValid;
|
63
|
-
}
|
64
|
-
static onExpire(onExpire) {
|
65
|
-
const isValid = onExpire && typeof onExpire === "function";
|
66
|
-
if (onExpire && !isValid) {
|
67
|
-
console.warn(
|
68
|
-
" { useTimer } Invalid onExpire settings function",
|
69
|
-
onExpire
|
70
|
-
);
|
71
|
-
}
|
72
|
-
return isValid;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
export {
|
76
|
-
Time,
|
77
|
-
Validate
|
78
|
-
};
|