mimir-ui-kit 1.14.0 → 1.14.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/DatePickerModal-BM0BgzTb.js +204 -0
- package/dist/{NavigationButtons-B8tMfqrg.js → NavigationButtons-DuOoqaPo.js} +20 -20
- package/dist/assets/Accordion.css +1 -0
- package/dist/assets/AccordionItem.css +1 -0
- package/dist/assets/Button.css +1 -1
- package/dist/assets/DatePickerModal.css +1 -0
- package/dist/assets/Drawer.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/ListPhotos.css +1 -0
- package/dist/assets/MergedButton.css +1 -1
- package/dist/assets/OtpInput.css +1 -1
- package/dist/assets/Pagination.css +1 -0
- package/dist/assets/RadioGroup.css +1 -1
- package/dist/assets/SelectSearch.css +1 -0
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/Switch.css +1 -0
- package/dist/assets/TabTrail.css +1 -0
- package/dist/assets/Tag.css +1 -0
- package/dist/assets/Timer.css +1 -0
- package/dist/assets/Uploader.css +1 -0
- package/dist/assets/UploaderPhotos.css +1 -0
- package/dist/assets/index.css +1 -1
- package/dist/bugs-CSBdWk0R.js +18 -0
- package/dist/components/Accordion/Accordion.d.ts +10 -0
- package/dist/components/Accordion/Accordion.js +176 -0
- package/dist/components/Accordion/AccordionItem/AccordionItem.d.ts +8 -0
- package/dist/components/Accordion/AccordionItem/AccordionItem.js +16 -0
- package/dist/components/Accordion/AccordionItem/index.d.ts +1 -0
- package/dist/components/Accordion/AccordionItem/index.js +4 -0
- package/dist/components/Accordion/constants.d.ts +8 -0
- package/dist/components/Accordion/constants.js +14 -0
- package/dist/components/Accordion/index.d.ts +3 -0
- package/dist/components/Accordion/index.js +8 -0
- package/dist/components/Button/Button.d.ts +0 -1
- package/dist/components/Button/Button.js +26 -25
- package/dist/components/Button/constants.d.ts +2 -1
- package/dist/components/Button/constants.js +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +44 -0
- package/dist/components/DatePicker/DatePicker.js +69 -0
- package/dist/components/DatePicker/DatePickerModal.d.ts +8 -0
- package/dist/components/DatePicker/DatePickerModal.js +9 -0
- package/dist/components/DatePicker/constants.d.ts +6 -0
- package/dist/components/DatePicker/constants.js +11 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/index.js +4 -0
- package/dist/components/Drawer/Drawer.d.ts +38 -0
- package/dist/components/Drawer/Drawer.js +144 -0
- package/dist/components/Drawer/constants.d.ts +5 -0
- package/dist/components/Drawer/constants.js +9 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Drawer/index.js +6 -0
- package/dist/components/Input/Input.d.ts +2 -2
- package/dist/components/Input/Input.js +17 -16
- package/dist/components/InputPassword/InputPassword.js +2 -2
- package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
- package/dist/components/ListPhotos/ListPhotos.d.ts +23 -0
- package/dist/components/ListPhotos/ListPhotos.js +33 -0
- package/dist/components/ListPhotos/constants.d.ts +3 -0
- package/dist/components/ListPhotos/constants.js +21 -0
- package/dist/components/ListPhotos/index.d.ts +2 -0
- package/dist/components/ListPhotos/index.js +4 -0
- package/dist/components/MergedButton/MergedButton.d.ts +1 -1
- package/dist/components/MergedButton/MergedButton.js +17 -19
- package/dist/components/OtpInput/OtpInput.js +6 -6
- package/dist/components/Pagination/Pagination.d.ts +42 -0
- package/dist/components/Pagination/Pagination.js +220 -0
- package/dist/components/Pagination/constants.d.ts +2 -0
- package/dist/components/Pagination/constants.js +6 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Pagination/index.js +4 -0
- package/dist/components/Pagination/types.d.ts +0 -0
- package/dist/components/Pagination/types.js +1 -0
- package/dist/components/Portal/Portal.d.ts +7 -0
- package/dist/components/Portal/Portal.js +10 -0
- package/dist/components/Portal/index.d.ts +1 -0
- package/dist/components/Portal/index.js +4 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +18 -2
- package/dist/components/RadioGroup/RadioGroup.js +130 -1061
- package/dist/components/RadioGroup/index.d.ts +1 -1
- package/dist/components/SelectSearch/SelectSearch.d.ts +15 -0
- package/dist/components/SelectSearch/SelectSearch.js +3876 -0
- package/dist/components/SelectSearch/constants.d.ts +4 -0
- package/dist/components/SelectSearch/constants.js +8 -0
- package/dist/components/SelectSearch/index.d.ts +2 -0
- package/dist/components/SelectSearch/index.js +6 -0
- 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/Switch/Switch.d.ts +294 -0
- package/dist/components/Switch/Switch.js +59 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +4 -0
- package/dist/components/TabTrail/TabButtons/TabButtons.d.ts +8 -0
- package/dist/components/TabTrail/TabButtons/TabButtons.js +29 -0
- package/dist/components/TabTrail/TabButtons/constants.d.ts +8 -0
- package/dist/components/TabTrail/TabButtons/constants.js +14 -0
- package/dist/components/TabTrail/TabButtons/index.d.ts +1 -0
- package/dist/components/TabTrail/TabButtons/index.js +4 -0
- package/dist/components/TabTrail/TabTrail.d.ts +11 -0
- package/dist/components/TabTrail/TabTrail.js +282 -0
- package/dist/components/TabTrail/constants.d.ts +4 -0
- package/dist/components/TabTrail/constants.js +8 -0
- package/dist/components/TabTrail/index.d.ts +2 -0
- package/dist/components/TabTrail/index.js +6 -0
- package/dist/components/Tag/Tag.d.ts +20 -57
- package/dist/components/Tag/Tag.js +39 -84
- package/dist/components/Tag/constants.d.ts +5 -37
- package/dist/components/Tag/constants.js +13 -53
- package/dist/components/Tag/index.d.ts +2 -3
- package/dist/components/Tag/index.js +5 -6
- package/dist/components/Tag/types.d.ts +0 -6
- package/dist/components/Timer/Timer.d.ts +24 -0
- package/dist/components/Timer/Timer.js +29 -0
- package/dist/components/Timer/index.d.ts +1 -0
- package/dist/components/Timer/index.js +4 -0
- package/dist/components/Uploader/Uploader.d.ts +30 -0
- package/dist/components/Uploader/Uploader.js +90 -0
- package/dist/components/Uploader/constants.d.ts +5 -0
- package/dist/components/Uploader/constants.js +16 -0
- package/dist/components/Uploader/index.d.ts +2 -0
- package/dist/components/Uploader/index.js +4 -0
- package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +29 -0
- package/dist/components/UploaderPhotos/UploaderPhotos.js +46 -0
- package/dist/components/UploaderPhotos/index.d.ts +2 -0
- package/dist/components/UploaderPhotos/index.js +4 -0
- package/dist/components/index.d.ts +16 -1
- package/dist/components/index.js +31 -0
- package/dist/focus-management-1rQPII7Z.js +77 -0
- package/dist/hidden-BuVoeHNy.js +13 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +7 -1
- package/dist/hooks/useClickOutside/index.d.ts +1 -0
- package/dist/hooks/useClickOutside/index.js +4 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +7 -0
- package/dist/hooks/useClickOutside/useClickOutside.js +25 -0
- package/dist/hooks/useInterval/index.d.ts +1 -0
- package/dist/hooks/useInterval/index.js +4 -0
- package/dist/hooks/useInterval/useInterval.d.ts +1 -0
- package/dist/hooks/useInterval/useInterval.js +17 -0
- package/dist/hooks/useLockBodyScroll/index.d.ts +1 -0
- package/dist/hooks/useLockBodyScroll/index.js +4 -0
- package/dist/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +6 -0
- package/dist/hooks/useLockBodyScroll/useLockBodyScroll.js +20 -0
- package/dist/hooks/useTimer/index.d.ts +18 -0
- package/dist/hooks/useTimer/index.js +83 -0
- package/dist/hooks/useTimer/useTimer.d.ts +18 -0
- package/dist/hooks/useTimer/useTimer.js +87 -0
- package/dist/hooks/useTimer/utils.d.ts +24 -0
- package/dist/hooks/useTimer/utils.js +88 -0
- package/dist/hooks/useWindowSize/index.d.ts +4 -0
- package/dist/hooks/useWindowSize/index.js +26 -0
- package/dist/icons/Icon.js +1 -1
- package/dist/icons/components/12px/Close12px.d.ts +4 -0
- package/dist/icons/components/12px/Close12px.js +18 -0
- package/dist/icons/components/index.d.ts +1 -0
- package/dist/icons/components/index.js +560 -559
- package/dist/{index-_ACzPKPw.js → index-Cxiikb7g.js} +561 -558
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -1
- package/dist/keyboard-B256ZoM-.js +745 -0
- package/dist/label-C_5Syaoj.js +159 -0
- package/dist/open-closed-CbXq00et.js +93 -0
- package/dist/use-active-press-B6yeSopF.js +31 -0
- package/dist/use-by-comparator-BUO78DGe.js +16 -0
- package/dist/use-resolve-button-type-B6LE6gU3.js +19 -0
- package/dist/utils/UUID4.d.ts +1 -0
- package/dist/utils/UUID4.js +9 -0
- package/dist/utils/formating/Date.d.ts +1 -0
- package/dist/utils/formating/Date.js +26 -0
- package/dist/utils/formating/Month.d.ts +8 -0
- package/dist/utils/formating/Month.js +80 -0
- package/dist/utils/formating/Numbers.d.ts +6 -0
- package/dist/utils/formating/Numbers.js +8 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +13 -0
- package/package.json +1 -1
@@ -0,0 +1,18 @@
|
|
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
|
+
};
|
@@ -0,0 +1,83 @@
|
|
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
|
+
};
|
@@ -0,0 +1,18 @@
|
|
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
|
+
};
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { useState, useCallback } from "react";
|
2
|
+
import { Time, Validate, SECONDS_IN_MILLISECONDS } 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(
|
11
|
+
(seconds - Math.floor(seconds)) * SECONDS_IN_MILLISECONDS
|
12
|
+
);
|
13
|
+
return extraMilliSeconds > 0 ? extraMilliSeconds : DEFAULT_DELAY;
|
14
|
+
}
|
15
|
+
function useTimer({
|
16
|
+
expiryTimestamp: expiry,
|
17
|
+
onExpire,
|
18
|
+
autoStart = true
|
19
|
+
}) {
|
20
|
+
const [expiryTimestamp, setExpiryTimestamp] = useState(expiry);
|
21
|
+
const [seconds, setSeconds] = useState(
|
22
|
+
Time.getSecondsFromExpiry(expiry ?? 0)
|
23
|
+
);
|
24
|
+
const [isRunning, setIsRunning] = useState(autoStart);
|
25
|
+
const [didStart, setDidStart] = useState(autoStart);
|
26
|
+
const [delay, setDelay] = useState(getDelayFromExpiryTimestamp(expiry ?? 0));
|
27
|
+
const handleExpire = useCallback(() => {
|
28
|
+
Validate.onExpire(onExpire) && (onExpire == null ? void 0 : onExpire());
|
29
|
+
setIsRunning(false);
|
30
|
+
setDelay(null);
|
31
|
+
}, [onExpire]);
|
32
|
+
const pause = useCallback(() => {
|
33
|
+
setIsRunning(false);
|
34
|
+
}, []);
|
35
|
+
const restart = useCallback(
|
36
|
+
(newExpiryTimestamp, newAutoStart = true) => {
|
37
|
+
setDelay(getDelayFromExpiryTimestamp(newExpiryTimestamp));
|
38
|
+
setDidStart(newAutoStart);
|
39
|
+
setIsRunning(newAutoStart);
|
40
|
+
setExpiryTimestamp(newExpiryTimestamp);
|
41
|
+
setSeconds(Time.getSecondsFromExpiry(newExpiryTimestamp));
|
42
|
+
},
|
43
|
+
[]
|
44
|
+
);
|
45
|
+
const resume = useCallback(() => {
|
46
|
+
const time = /* @__PURE__ */ new Date();
|
47
|
+
time.setMilliseconds(
|
48
|
+
time.getMilliseconds() + seconds * SECONDS_IN_MILLISECONDS
|
49
|
+
);
|
50
|
+
restart(time.getTime(), true);
|
51
|
+
}, [seconds, restart]);
|
52
|
+
const start = useCallback(() => {
|
53
|
+
if (didStart) {
|
54
|
+
setSeconds(Time.getSecondsFromExpiry(expiryTimestamp ?? 0, false));
|
55
|
+
setIsRunning(true);
|
56
|
+
} else {
|
57
|
+
resume();
|
58
|
+
}
|
59
|
+
}, [expiryTimestamp, didStart, resume]);
|
60
|
+
useInterval(
|
61
|
+
() => {
|
62
|
+
if (delay !== DEFAULT_DELAY) {
|
63
|
+
setDelay(DEFAULT_DELAY);
|
64
|
+
}
|
65
|
+
const secondsValue = Time.getSecondsFromExpiry(
|
66
|
+
expiryTimestamp ?? 0,
|
67
|
+
false
|
68
|
+
);
|
69
|
+
setSeconds(secondsValue);
|
70
|
+
if (secondsValue <= 0) {
|
71
|
+
handleExpire();
|
72
|
+
}
|
73
|
+
},
|
74
|
+
isRunning ? delay : null
|
75
|
+
);
|
76
|
+
return {
|
77
|
+
...Time.getTimeFromSeconds(seconds),
|
78
|
+
start,
|
79
|
+
pause,
|
80
|
+
resume,
|
81
|
+
restart,
|
82
|
+
isRunning
|
83
|
+
};
|
84
|
+
}
|
85
|
+
export {
|
86
|
+
useTimer
|
87
|
+
};
|
@@ -0,0 +1,24 @@
|
|
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 const SECONDS_IN_MINUTE = 60;
|
10
|
+
export declare const SECONDS_IN_HOUR: number;
|
11
|
+
export declare const SECONDS_IN_DAY: number;
|
12
|
+
export declare const SECONDS_IN_MILLISECONDS = 1000;
|
13
|
+
export declare class Time {
|
14
|
+
static getTimeFromSeconds(secs: number): TTimeObject;
|
15
|
+
static getSecondsFromExpiry(expiry: number, shouldRound?: boolean): number;
|
16
|
+
static getSecondsFromPrevTime(prevTime: number, shouldRound: boolean): number;
|
17
|
+
static getSecondsFromTimeNow(): number;
|
18
|
+
static getFormattedTimeFromSeconds(totalSeconds: number): TFormattedTime;
|
19
|
+
}
|
20
|
+
export declare class Validate {
|
21
|
+
static expiryTimestamp(expiryTimestamp: number): boolean;
|
22
|
+
static onExpire(onExpire?: VoidFunction | null): boolean | null | undefined;
|
23
|
+
}
|
24
|
+
export {};
|
@@ -0,0 +1,88 @@
|
|
1
|
+
const SECONDS_IN_MINUTE = 60;
|
2
|
+
const SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE;
|
3
|
+
const SECONDS_IN_DAY = SECONDS_IN_HOUR * 24;
|
4
|
+
const SECONDS_IN_MILLISECONDS = 1e3;
|
5
|
+
class Time {
|
6
|
+
static getTimeFromSeconds(secs) {
|
7
|
+
const totalSeconds = Math.ceil(secs);
|
8
|
+
const days = Math.floor(totalSeconds / SECONDS_IN_DAY);
|
9
|
+
const hours = Math.floor(totalSeconds % SECONDS_IN_DAY / SECONDS_IN_HOUR);
|
10
|
+
const minutes = Math.floor(
|
11
|
+
totalSeconds % SECONDS_IN_HOUR / SECONDS_IN_MINUTE
|
12
|
+
);
|
13
|
+
const seconds = Math.floor(totalSeconds % SECONDS_IN_MINUTE);
|
14
|
+
return {
|
15
|
+
totalSeconds,
|
16
|
+
seconds,
|
17
|
+
minutes,
|
18
|
+
hours,
|
19
|
+
days
|
20
|
+
};
|
21
|
+
}
|
22
|
+
static getSecondsFromExpiry(expiry, shouldRound) {
|
23
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
24
|
+
const milliSecondsDistance = expiry - now;
|
25
|
+
if (milliSecondsDistance > 0) {
|
26
|
+
const val = milliSecondsDistance / SECONDS_IN_MILLISECONDS;
|
27
|
+
return shouldRound ? Math.round(val) : val;
|
28
|
+
}
|
29
|
+
return 0;
|
30
|
+
}
|
31
|
+
static getSecondsFromPrevTime(prevTime, shouldRound) {
|
32
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
33
|
+
const milliSecondsDistance = now - prevTime;
|
34
|
+
if (milliSecondsDistance > 0) {
|
35
|
+
const val = milliSecondsDistance / SECONDS_IN_MILLISECONDS;
|
36
|
+
return shouldRound ? Math.round(val) : val;
|
37
|
+
}
|
38
|
+
return 0;
|
39
|
+
}
|
40
|
+
static getSecondsFromTimeNow() {
|
41
|
+
const now = /* @__PURE__ */ new Date();
|
42
|
+
const currentTimestamp = now.getTime();
|
43
|
+
const offset = now.getTimezoneOffset() * SECONDS_IN_MINUTE;
|
44
|
+
return currentTimestamp / SECONDS_IN_MILLISECONDS - offset;
|
45
|
+
}
|
46
|
+
static getFormattedTimeFromSeconds(totalSeconds) {
|
47
|
+
const {
|
48
|
+
seconds: secondsValue,
|
49
|
+
minutes,
|
50
|
+
hours
|
51
|
+
} = Time.getTimeFromSeconds(totalSeconds);
|
52
|
+
return {
|
53
|
+
seconds: secondsValue,
|
54
|
+
minutes,
|
55
|
+
hours
|
56
|
+
};
|
57
|
+
}
|
58
|
+
}
|
59
|
+
class Validate {
|
60
|
+
static expiryTimestamp(expiryTimestamp) {
|
61
|
+
const isValid = new Date(expiryTimestamp).getTime() > 0;
|
62
|
+
if (!isValid) {
|
63
|
+
console.warn(
|
64
|
+
"{ useTimer } Invalid expiryTimestamp settings",
|
65
|
+
expiryTimestamp
|
66
|
+
);
|
67
|
+
}
|
68
|
+
return isValid;
|
69
|
+
}
|
70
|
+
static onExpire(onExpire) {
|
71
|
+
const isValid = onExpire && typeof onExpire === "function";
|
72
|
+
if (onExpire && !isValid) {
|
73
|
+
console.warn(
|
74
|
+
" { useTimer } Invalid onExpire settings function",
|
75
|
+
onExpire
|
76
|
+
);
|
77
|
+
}
|
78
|
+
return isValid;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
export {
|
82
|
+
SECONDS_IN_DAY,
|
83
|
+
SECONDS_IN_HOUR,
|
84
|
+
SECONDS_IN_MILLISECONDS,
|
85
|
+
SECONDS_IN_MINUTE,
|
86
|
+
Time,
|
87
|
+
Validate
|
88
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { useState, useRef, useEffect } from "react";
|
2
|
+
function getWindowSize() {
|
3
|
+
const { innerWidth: width, innerHeight: height } = window;
|
4
|
+
return {
|
5
|
+
width,
|
6
|
+
height
|
7
|
+
};
|
8
|
+
}
|
9
|
+
function useWindowSize() {
|
10
|
+
const [windowSize, setWindowSize] = useState(getWindowSize());
|
11
|
+
const timeoutRef = useRef(null);
|
12
|
+
function handleResize() {
|
13
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
14
|
+
timeoutRef.current = setTimeout(() => setWindowSize(getWindowSize()), 500);
|
15
|
+
}
|
16
|
+
useEffect(() => {
|
17
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
18
|
+
window.addEventListener("resize", handleResize);
|
19
|
+
return () => window.removeEventListener("resize", handleResize);
|
20
|
+
}, []);
|
21
|
+
const { width, height } = windowSize;
|
22
|
+
return { width, height };
|
23
|
+
}
|
24
|
+
export {
|
25
|
+
useWindowSize
|
26
|
+
};
|
package/dist/icons/Icon.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
2
2
|
import { Suspense } from "react";
|
3
|
-
import { i as icons } from "../index-
|
3
|
+
import { i as icons } from "../index-Cxiikb7g.js";
|
4
4
|
const Icon = ({ iconName, ...props }) => {
|
5
5
|
const Component = icons[iconName];
|
6
6
|
if (!Component) {
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
2
|
+
const Close12px = (props) => {
|
3
|
+
return /* @__PURE__ */ jsx(
|
4
|
+
"svg",
|
5
|
+
{
|
6
|
+
width: "12",
|
7
|
+
height: "12",
|
8
|
+
viewBox: "0 0 12 12",
|
9
|
+
fill: "none",
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
11
|
+
...props,
|
12
|
+
children: /* @__PURE__ */ jsx("path", { d: "M3 9L8.99991 3M9 9L3 3", stroke: "#333333", "stroke-width": "1.5" })
|
13
|
+
}
|
14
|
+
);
|
15
|
+
};
|
16
|
+
export {
|
17
|
+
Close12px as default
|
18
|
+
};
|
@@ -1,3 +1,4 @@
|
|
1
|
+
export declare const Close12px: import('react').LazyExoticComponent<(props: import('react').SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
1
2
|
export declare const Accept16px: import('react').LazyExoticComponent<(props: import('react').SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
2
3
|
export declare const Acts16px: import('react').LazyExoticComponent<(props: import('react').SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|
3
4
|
export declare const Acts16pxF: import('react').LazyExoticComponent<(props: import('react').SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element>;
|