mimir-ui-kit 1.10.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/README.md +62 -62
  2. package/dist/DatePickerModal-DUUCHAWF.js +204 -0
  3. package/dist/{NavigationButtons-B8tMfqrg.js → NavigationButtons-DuOoqaPo.js} +20 -20
  4. package/dist/assets/Button.css +1 -1
  5. package/dist/assets/DatePickerModal.css +1 -0
  6. package/dist/assets/Drawer.css +1 -0
  7. package/dist/assets/Input.css +1 -1
  8. package/dist/assets/MergedButton.css +1 -1
  9. package/dist/assets/OtpInput.css +1 -1
  10. package/dist/assets/RadioGroup.css +1 -1
  11. package/dist/assets/SelectSearch.css +1 -0
  12. package/dist/assets/Slider.css +1 -1
  13. package/dist/assets/Switch.css +1 -0
  14. package/dist/assets/Tag.css +1 -0
  15. package/dist/assets/Timer.css +1 -0
  16. package/dist/assets/index.css +1 -1
  17. package/dist/components/Button/Button.d.ts +0 -1
  18. package/dist/components/Button/Button.js +25 -25
  19. package/dist/components/DatePicker/DatePicker.d.ts +44 -0
  20. package/dist/components/DatePicker/DatePicker.js +69 -0
  21. package/dist/components/DatePicker/DatePickerModal.d.ts +8 -0
  22. package/dist/components/DatePicker/DatePickerModal.js +9 -0
  23. package/dist/components/DatePicker/constants.d.ts +6 -0
  24. package/dist/components/DatePicker/constants.js +11 -0
  25. package/dist/components/DatePicker/index.d.ts +2 -0
  26. package/dist/components/DatePicker/index.js +4 -0
  27. package/dist/components/Drawer/Drawer.d.ts +38 -0
  28. package/dist/components/Drawer/Drawer.js +144 -0
  29. package/dist/components/Drawer/constants.d.ts +5 -0
  30. package/dist/components/Drawer/constants.js +9 -0
  31. package/dist/components/Drawer/index.d.ts +2 -0
  32. package/dist/components/Drawer/index.js +6 -0
  33. package/dist/components/Input/Input.d.ts +2 -2
  34. package/dist/components/Input/Input.js +17 -16
  35. package/dist/components/InputPassword/InputPassword.js +2 -2
  36. package/dist/components/InputPhoneNumber/InputPhoneNumber.js +1 -1
  37. package/dist/components/MergedButton/MergedButton.d.ts +1 -1
  38. package/dist/components/MergedButton/MergedButton.js +17 -19
  39. package/dist/components/OtpInput/OtpInput.js +6 -6
  40. package/dist/components/Portal/Portal.d.ts +7 -0
  41. package/dist/components/Portal/Portal.js +10 -0
  42. package/dist/components/Portal/index.d.ts +1 -0
  43. package/dist/components/Portal/index.js +4 -0
  44. package/dist/components/RadioGroup/RadioGroup.d.ts +18 -2
  45. package/dist/components/RadioGroup/RadioGroup.js +127 -1061
  46. package/dist/components/RadioGroup/index.d.ts +1 -1
  47. package/dist/components/SelectSearch/SelectSearch.d.ts +15 -0
  48. package/dist/components/SelectSearch/SelectSearch.js +3961 -0
  49. package/dist/components/SelectSearch/constants.d.ts +4 -0
  50. package/dist/components/SelectSearch/constants.js +8 -0
  51. package/dist/components/SelectSearch/index.d.ts +2 -0
  52. package/dist/components/SelectSearch/index.js +6 -0
  53. package/dist/components/Slider/NavigationButtons/NavigationButtons.js +1 -1
  54. package/dist/components/Slider/NavigationButtons/index.js +1 -1
  55. package/dist/components/Slider/Slider.js +10 -10
  56. package/dist/components/Switch/Switch.d.ts +294 -0
  57. package/dist/components/Switch/Switch.js +57 -0
  58. package/dist/components/Switch/index.d.ts +2 -0
  59. package/dist/components/Switch/index.js +4 -0
  60. package/dist/components/Tag/Tag.d.ts +19 -57
  61. package/dist/components/Tag/Tag.js +39 -84
  62. package/dist/components/Tag/constants.d.ts +5 -37
  63. package/dist/components/Tag/constants.js +13 -53
  64. package/dist/components/Tag/index.d.ts +2 -3
  65. package/dist/components/Tag/index.js +5 -6
  66. package/dist/components/Tag/types.d.ts +0 -6
  67. package/dist/components/Timer/Timer.d.ts +24 -0
  68. package/dist/components/Timer/Timer.js +29 -0
  69. package/dist/components/Timer/index.d.ts +1 -0
  70. package/dist/components/Timer/index.js +4 -0
  71. package/dist/components/index.d.ts +11 -1
  72. package/dist/components/index.js +19 -0
  73. package/dist/focus-management-CFDo6ZSc.js +91 -0
  74. package/dist/hooks/index.d.ts +3 -0
  75. package/dist/hooks/index.js +7 -1
  76. package/dist/hooks/useClickOutside/index.d.ts +1 -0
  77. package/dist/hooks/useClickOutside/index.js +4 -0
  78. package/dist/hooks/useClickOutside/useClickOutside.d.ts +7 -0
  79. package/dist/hooks/useClickOutside/useClickOutside.js +25 -0
  80. package/dist/hooks/useInterval/index.d.ts +1 -0
  81. package/dist/hooks/useInterval/index.js +4 -0
  82. package/dist/hooks/useInterval/useInterval.d.ts +1 -0
  83. package/dist/hooks/useInterval/useInterval.js +17 -0
  84. package/dist/hooks/useLockBodyScroll/index.d.ts +1 -0
  85. package/dist/hooks/useLockBodyScroll/index.js +4 -0
  86. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +6 -0
  87. package/dist/hooks/useLockBodyScroll/useLockBodyScroll.js +20 -0
  88. package/dist/hooks/useTimer/index.d.ts +18 -0
  89. package/dist/hooks/useTimer/index.js +83 -0
  90. package/dist/hooks/useTimer/useTimer.d.ts +18 -0
  91. package/dist/hooks/useTimer/useTimer.js +87 -0
  92. package/dist/hooks/useTimer/utils.d.ts +24 -0
  93. package/dist/hooks/useTimer/utils.js +88 -0
  94. package/dist/index.d.ts +1 -0
  95. package/dist/index.js +28 -1
  96. package/dist/label-BXAcSLy0.js +913 -0
  97. package/dist/use-active-press-9MCrfRZk.js +31 -0
  98. package/dist/utils/formating/Date.d.ts +1 -0
  99. package/dist/utils/formating/Date.js +26 -0
  100. package/dist/utils/formating/Month.d.ts +8 -0
  101. package/dist/utils/formating/Month.js +80 -0
  102. package/dist/utils/formating/Numbers.d.ts +6 -0
  103. package/dist/utils/formating/Numbers.js +8 -0
  104. package/dist/utils/index.d.ts +9 -0
  105. package/dist/utils/index.js +11 -0
  106. package/package.json +128 -128
@@ -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
+ };
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@
2
2
  export * from './components';
3
3
  export * from './hooks';
4
4
  export * from './icons';
5
+ export * from './utils';
package/dist/index.js CHANGED
@@ -7,31 +7,50 @@ import { InputPhoneNumber } from "./components/InputPhoneNumber/InputPhoneNumber
7
7
  import { getMaskedInputPhoneValue, getUnmaskedInputValue } from "./components/InputPhoneNumber/utils.js";
8
8
  import { OtpInput } from "./components/OtpInput/OtpInput.js";
9
9
  import { RadioGroup } from "./components/RadioGroup/RadioGroup.js";
10
+ import { DatePicker } from "./components/DatePicker/DatePicker.js";
10
11
  import { MergedButton } from "./components/MergedButton/MergedButton.js";
11
12
  import { EMergedButtonVariantRound } from "./components/MergedButton/constants.js";
12
13
  import { AppImage } from "./components/Image/Image.js";
13
14
  import { Loader } from "./components/Loader/Loader.js";
14
15
  import { Slider } from "./components/Slider/Slider.js";
16
+ import { Drawer } from "./components/Drawer/Drawer.js";
17
+ import { EDrawerPosition } from "./components/Drawer/constants.js";
15
18
  import { Steps } from "./components/Steps/Steps.js";
16
19
  import { EStepsPrimaryColor, EStepsSecondaryColor, EStepsSize } from "./components/Steps/constants.js";
17
20
  import { Vote } from "./components/Vote/Vote.js";
18
21
  import { EVoteSize } from "./components/Vote/constants.js";
22
+ import { SelectSearch } from "./components/SelectSearch/SelectSearch.js";
23
+ import { ESelectSearchSize } from "./components/SelectSearch/constants.js";
24
+ import { Switch } from "./components/Switch/Switch.js";
25
+ import { Tag } from "./components/Tag/Tag.js";
26
+ import { ETagSize, ETagType } from "./components/Tag/constants.js";
27
+ import { Timer } from "./components/Timer/Timer.js";
19
28
  import { useMediaQuery } from "./hooks/useMediaQuery/useMediaQuery.js";
20
29
  import { EMediaQuery } from "./hooks/useMediaQuery/constants.js";
30
+ import { useLockBodyScroll } from "./hooks/useLockBodyScroll/useLockBodyScroll.js";
31
+ import { useInterval } from "./hooks/useInterval/useInterval.js";
32
+ import { useTimer } from "./hooks/useTimer/index.js";
21
33
  import { Icon } from "./icons/Icon.js";
34
+ import { formating } from "./utils/index.js";
22
35
  import './assets/index.css';export {
23
36
  Button,
37
+ DatePicker,
38
+ Drawer,
24
39
  EButtonForm,
25
40
  EButtonSize,
26
41
  EButtonVariantDefault,
27
42
  EButtonVariantRound,
43
+ EDrawerPosition,
28
44
  EInputSize,
29
45
  EInputVariant,
30
46
  EMediaQuery,
31
47
  EMergedButtonVariantRound,
48
+ ESelectSearchSize,
32
49
  EStepsPrimaryColor,
33
50
  EStepsSecondaryColor,
34
51
  EStepsSize,
52
+ ETagSize,
53
+ ETagType,
35
54
  EVoteSize,
36
55
  Icon,
37
56
  AppImage as Image,
@@ -42,10 +61,18 @@ import './assets/index.css';export {
42
61
  MergedButton,
43
62
  OtpInput,
44
63
  RadioGroup,
64
+ SelectSearch,
45
65
  Slider,
46
66
  Steps,
67
+ Switch,
68
+ Tag,
69
+ Timer,
47
70
  Vote,
71
+ formating,
48
72
  getMaskedInputPhoneValue,
49
73
  getUnmaskedInputValue,
50
- useMediaQuery
74
+ useInterval,
75
+ useLockBodyScroll,
76
+ useMediaQuery,
77
+ useTimer
51
78
  };