mimir-ui-kit 1.14.5 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/README.md +62 -62
  2. package/dist/ProgressBar-BekX41HR.js +77 -0
  3. package/dist/SelectSearchOption-snHM9uZX.js +3796 -0
  4. package/dist/assets/Button.css +1 -1
  5. package/dist/assets/ProgressBar2.css +1 -0
  6. package/dist/assets/SelectSearch.css +1 -1
  7. package/dist/assets/SelectSearchOption.css +1 -0
  8. package/dist/assets/Tag.css +1 -1
  9. package/dist/components/Button/Button.js +29 -29
  10. package/dist/components/Input/Input.js +1 -1
  11. package/dist/components/SelectSearch/SelectSearch.d.ts +7 -12
  12. package/dist/components/SelectSearch/SelectSearch.js +681 -3792
  13. package/dist/components/SelectSearch/constants.d.ts +2 -2
  14. package/dist/components/SelectSearch/constants.js +1 -1
  15. package/dist/components/SelectSearch/index.d.ts +2 -1
  16. package/dist/components/SelectSearch/types.d.ts +40 -0
  17. package/dist/components/SelectSearch/types.js +1 -0
  18. package/dist/components/SelectSearchOption/SelectSearchOption.d.ts +10 -0
  19. package/dist/components/SelectSearchOption/SelectSearchOption.js +8 -0
  20. package/dist/components/SelectSearchOption/index.d.ts +2 -0
  21. package/dist/components/SelectSearchOption/index.js +4 -0
  22. package/dist/components/Tag/Tag.js +6 -6
  23. package/dist/components/Timer/Timer.d.ts +1 -1
  24. package/dist/components/Timer/Timer.js +17 -19
  25. package/dist/components/Toasts/ProgressBar.d.ts +5 -0
  26. package/dist/components/Toasts/ProgressBar.js +8 -0
  27. package/dist/components/Toasts/Toast.d.ts +54 -0
  28. package/dist/components/Toasts/Toast.js +73 -0
  29. package/dist/components/Toasts/ToastList.d.ts +10 -0
  30. package/dist/components/Toasts/ToastList.js +50 -0
  31. package/dist/components/Toasts/ToastsProvider.d.ts +3 -0
  32. package/dist/components/Toasts/ToastsProvider.js +46 -0
  33. package/dist/components/Toasts/constants.d.ts +23 -0
  34. package/dist/components/Toasts/constants.js +49 -0
  35. package/dist/components/Toasts/hooks.d.ts +2 -0
  36. package/dist/components/Toasts/hooks.js +16 -0
  37. package/dist/components/Toasts/index.d.ts +3 -0
  38. package/dist/components/Toasts/index.js +9 -0
  39. package/dist/components/Toasts/store.d.ts +29 -0
  40. package/dist/components/Toasts/store.js +50 -0
  41. package/dist/components/Toasts/types.d.ts +5 -0
  42. package/dist/components/Toasts/types.js +1 -0
  43. package/dist/components/Uploader/Uploader.d.ts +4 -4
  44. package/dist/components/Uploader/Uploader.js +5 -4
  45. package/dist/components/Uploader/constants.d.ts +1 -1
  46. package/dist/components/Uploader/constants.js +1 -1
  47. package/dist/components/Uploader/index.d.ts +1 -1
  48. package/dist/components/UploaderPhotos/UploaderPhotos.d.ts +3 -3
  49. package/dist/components/UploaderPhotos/UploaderPhotos.js +2 -2
  50. package/dist/components/UploaderPhotos/index.d.ts +1 -1
  51. package/dist/components/index.d.ts +8 -1
  52. package/dist/components/index.js +14 -1
  53. package/dist/hooks/index.d.ts +1 -0
  54. package/dist/hooks/index.js +2 -0
  55. package/dist/hooks/useCopyToClipboard/index.d.ts +1 -0
  56. package/dist/hooks/useCopyToClipboard/index.js +4 -0
  57. package/dist/hooks/useCopyToClipboard/useCopyToClipboard.d.ts +4 -0
  58. package/dist/hooks/useCopyToClipboard/useCopyToClipboard.js +23 -0
  59. package/dist/hooks/useTimer/index.d.ts +2 -2
  60. package/dist/hooks/useTimer/index.js +14 -7
  61. package/dist/index.js +16 -1
  62. package/package.json +127 -128
@@ -1,4 +1,4 @@
1
1
  export declare enum ESelectSearchSize {
2
- L = "l",
3
- XXL = "xxl"
2
+ M = "m",
3
+ L = "l"
4
4
  }
@@ -1,6 +1,6 @@
1
1
  var ESelectSearchSize = /* @__PURE__ */ ((ESelectSearchSize2) => {
2
+ ESelectSearchSize2["M"] = "m";
2
3
  ESelectSearchSize2["L"] = "l";
3
- ESelectSearchSize2["XXL"] = "xxl";
4
4
  return ESelectSearchSize2;
5
5
  })(ESelectSearchSize || {});
6
6
  export {
@@ -1,2 +1,3 @@
1
- export { SelectSearch, type TSelectSearchProps, type TSelectSearchItem } from './SelectSearch';
1
+ export { SelectSearch } from './SelectSearch';
2
+ export type { TSelectSearchProps } from './types';
2
3
  export { ESelectSearchSize } from './constants';
@@ -0,0 +1,40 @@
1
+ import { ESelectSearchSize } from './constants';
2
+ import { VirtualizedFixedSizeListProps } from './SelectSearch';
3
+
4
+ export type TSelectSearchProps = {
5
+ /**
6
+ * Текущее выбранное значение.
7
+ */
8
+ value?: Record<string, unknown> | null;
9
+ /**
10
+ * Функция обратного вызова при изменении выбранного значения.
11
+ */
12
+ onChange?: (value: Record<string, unknown>) => void;
13
+ /**
14
+ * Текст-подсказка для поля ввода.
15
+ */
16
+ placeholder?: string;
17
+ /**
18
+ * Размер компонента выбора.
19
+ */
20
+ size?: ESelectSearchSize;
21
+ /**
22
+ * Флаг для растягивания компонента на всю ширину контейнера.
23
+ */
24
+ full?: boolean;
25
+ /**
26
+ * Дочерние элементы компонента.
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Свойства для виртуализированного списка фиксированного размера.
31
+ */
32
+ virtualizedFixedSizeList?: VirtualizedFixedSizeListProps;
33
+ /**
34
+ * Значение, отображаемое в поле выбора.
35
+ */
36
+ displayValue?: string;
37
+ showArrow?: boolean;
38
+ onSearch?: (value: string) => void;
39
+ filterOnSearch?: boolean;
40
+ };
@@ -0,0 +1,10 @@
1
+ import { ESelectSearchSize } from '../SelectSearch/constants';
2
+
3
+ export interface SelectSearchOptionProps {
4
+ record: Record<string, unknown>;
5
+ children?: React.ReactNode;
6
+ size?: ESelectSearchSize;
7
+ className?: string;
8
+ title?: string;
9
+ }
10
+ export declare function SelectSearchOption({ record, size, children, className }: SelectSearchOptionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import "react/jsx-runtime";
2
+ import "../../index-CweZ_OcN.js";
3
+ import { S } from "../../SelectSearchOption-snHM9uZX.js";
4
+ import "../../icons/Icon.js";
5
+ import "../SelectSearch/constants.js";
6
+ export {
7
+ S as SelectSearchOption
8
+ };
@@ -0,0 +1,2 @@
1
+ export { SelectSearchOption } from './SelectSearchOption';
2
+ export type { SelectSearchOptionProps } from './SelectSearchOption';
@@ -0,0 +1,4 @@
1
+ import { S } from "../../SelectSearchOption-snHM9uZX.js";
2
+ export {
3
+ S as SelectSearchOption
4
+ };
@@ -2,12 +2,12 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
3
  import { forwardRef } from "react";
4
4
  import { ETagSize, ETagType } from "./constants.js";
5
- import '../../assets/Tag.css';const container = "_container_1f2sk_2";
6
- const disabled = "_disabled_1f2sk_24";
7
- const inner = "_inner_1f2sk_29";
8
- const M = "_M_1f2sk_37";
9
- const S = "_S_1f2sk_41";
10
- const XS = "_XS_1f2sk_49";
5
+ import '../../assets/Tag.css';const container = "_container_ok6fq_2";
6
+ const disabled = "_disabled_ok6fq_25";
7
+ const inner = "_inner_ok6fq_30";
8
+ const M = "_M_ok6fq_38";
9
+ const S = "_S_ok6fq_42";
10
+ const XS = "_XS_ok6fq_50";
11
11
  const cls = {
12
12
  container,
13
13
  disabled,
@@ -20,5 +20,5 @@ type TProps = {
20
20
  /**
21
21
  * Компонент Timer отображает таймер с отсчетом времени в минутах и секундах.
22
22
  */
23
- export declare const Timer: ({ expiryTimestamp, autoStart, onTimerEnd, className }: TProps) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const Timer: import('react').MemoExoticComponent<({ expiryTimestamp, autoStart, onTimerEnd, className }: TProps) => import("react/jsx-runtime").JSX.Element>;
24
24
  export {};
@@ -1,29 +1,27 @@
1
1
  import { jsxs } from "react/jsx-runtime";
2
2
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { memo } from "react";
3
4
  import { useTimer } from "../../hooks/useTimer/index.js";
4
5
  import '../../assets/Timer.css';const timer = "_timer_llwad_3";
5
6
  const cls = {
6
7
  timer
7
8
  };
8
- const Timer = ({
9
- expiryTimestamp,
10
- autoStart = false,
11
- onTimerEnd,
12
- className
13
- }) => {
14
- const { minutes, seconds } = useTimer({
15
- expiryTimestamp,
16
- onExpire: onTimerEnd,
17
- autoStart
18
- });
19
- const formattedMinutes = String(minutes).padStart(2, "0");
20
- const formattedSeconds = String(seconds).padStart(2, "0");
21
- return /* @__PURE__ */ jsxs("div", { className: classNames(cls.timer, className), children: [
22
- formattedMinutes,
23
- ":",
24
- formattedSeconds
25
- ] });
26
- };
9
+ const Timer = memo(
10
+ ({ expiryTimestamp, autoStart = false, onTimerEnd, className }) => {
11
+ const { minutes, seconds } = useTimer({
12
+ expiryTimestamp,
13
+ onExpire: onTimerEnd,
14
+ autoStart
15
+ });
16
+ const formattedMinutes = String(minutes).padStart(2, "0");
17
+ const formattedSeconds = String(seconds).padStart(2, "0");
18
+ return /* @__PURE__ */ jsxs("div", { className: classNames(cls.timer, className), children: [
19
+ formattedMinutes,
20
+ ":",
21
+ formattedSeconds
22
+ ] });
23
+ }
24
+ );
27
25
  export {
28
26
  Timer
29
27
  };
@@ -0,0 +1,5 @@
1
+ import { TProps as TToastProps } from './Toast';
2
+
3
+ type TProps = Pick<TToastProps, 'duration' | 'variant'>;
4
+ export declare const ProgressBar: import('react').MemoExoticComponent<({ duration, variant }: TProps) => import("react/jsx-runtime").JSX.Element>;
5
+ export {};
@@ -0,0 +1,8 @@
1
+ import "react/jsx-runtime";
2
+ import "../../index-CweZ_OcN.js";
3
+ import "react";
4
+ import "./constants.js";
5
+ import { P } from "../../ProgressBar-BekX41HR.js";
6
+ export {
7
+ P as ProgressBar
8
+ };
@@ -0,0 +1,54 @@
1
+ import { ReactNode, RefObject } from 'react';
2
+ import { EToastVariant, EToastPosition } from './constants';
3
+
4
+ export type TProps = {
5
+ /**
6
+ * Идентификатор уведомления.
7
+ */
8
+ id: string;
9
+ /**
10
+ * Вариант уведомления.
11
+ */
12
+ variant?: EToastVariant | `${EToastVariant}`;
13
+ /**
14
+ * Сообщение уведомления.
15
+ */
16
+ message: ReactNode;
17
+ /**
18
+ * Заголовок уведомления.
19
+ */
20
+ title: string;
21
+ /**
22
+ * Длительность уведомления.
23
+ */
24
+ duration?: number;
25
+ /**
26
+ * Позиция уведомления.
27
+ */
28
+ position?: EToastPosition | `${EToastPosition}`;
29
+ /**
30
+ * Флаг, указывающий на автоматическое закрытие уведомления.
31
+ */
32
+ autoClose?: boolean;
33
+ /**
34
+ * Флаг, указывающий на необходимость таймера.
35
+ */
36
+ needTimer?: boolean;
37
+ /**
38
+ * Флаг, указывающий на необходимость индикатора прогресса.
39
+ */
40
+ needProgress?: boolean;
41
+ /**
42
+ * Флаг, указывающий на необходимость кнопки закрытия.
43
+ */
44
+ needCloseButton?: boolean;
45
+ /**
46
+ * Функция обратного вызова, вызываемая при удалении уведомления.
47
+ */
48
+ onToastRemove?: (toastId: string, ref: RefObject<HTMLDivElement>) => void;
49
+ /**
50
+ * Слот уведомления.
51
+ */
52
+ slot?: ReactNode;
53
+ };
54
+ export declare const Toast: import('react').MemoExoticComponent<({ id, title, message, position, variant, duration, autoClose, needProgress, needTimer, needCloseButton, onToastRemove, slot }: TProps) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,73 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { memo, useRef } from "react";
4
+ import { ANIMATION_VARIABLES_MAP, EToastPosition, EToastVariant, DEFAULT_TOAST_DURATION } from "./constants.js";
5
+ import { c as cls, P as ProgressBar } from "../../ProgressBar-BekX41HR.js";
6
+ import { useTimer } from "../../hooks/useTimer/index.js";
7
+ import { Button } from "../Button/Button.js";
8
+ const Toast = memo(
9
+ ({
10
+ id,
11
+ title = "",
12
+ message,
13
+ position = EToastPosition.TOP_RIGHT,
14
+ variant = EToastVariant.DEFAULT,
15
+ duration = DEFAULT_TOAST_DURATION,
16
+ autoClose = true,
17
+ needProgress = true,
18
+ needTimer = true,
19
+ needCloseButton = true,
20
+ onToastRemove,
21
+ slot
22
+ }) => {
23
+ const wrapperRef = useRef(null);
24
+ const { seconds } = useTimer({
25
+ expiryTimestamp: Date.now() + duration,
26
+ autoStart: needTimer,
27
+ onExpire: autoClose ? () => onToastRemove == null ? void 0 : onToastRemove(id, wrapperRef) : void 0
28
+ });
29
+ return /* @__PURE__ */ jsxs(
30
+ "div",
31
+ {
32
+ style: {
33
+ ["--elm-translate"]: ANIMATION_VARIABLES_MAP[position]
34
+ },
35
+ className: classNames(
36
+ cls["toast-in"],
37
+ cls["toast-wrapper"],
38
+ cls[variant]
39
+ ),
40
+ ref: wrapperRef,
41
+ role: "alert",
42
+ children: [
43
+ title && /* @__PURE__ */ jsx("h3", { className: cls.title, children: title }),
44
+ message && /* @__PURE__ */ jsx("div", { className: cls.message, children: message }),
45
+ (needTimer || needProgress) && /* @__PURE__ */ jsxs("div", { children: [
46
+ !!duration && needTimer && /* @__PURE__ */ jsxs("div", { className: cls.timer, children: [
47
+ /* @__PURE__ */ jsx("h4", { className: cls["timer-title"], children: "Осталось" }),
48
+ /* @__PURE__ */ jsxs("p", { className: cls.seconds, children: [
49
+ seconds,
50
+ " сек"
51
+ ] })
52
+ ] }),
53
+ !!duration && needProgress && /* @__PURE__ */ jsx(ProgressBar, { variant, duration })
54
+ ] }),
55
+ needCloseButton && /* @__PURE__ */ jsx(
56
+ Button,
57
+ {
58
+ onClick: () => onToastRemove == null ? void 0 : onToastRemove(id, wrapperRef),
59
+ clear: true,
60
+ isIconButton: true,
61
+ className: cls["close-button"],
62
+ iconName: "Close24px"
63
+ }
64
+ ),
65
+ slot && /* @__PURE__ */ jsx("div", { className: cls.slot, children: slot })
66
+ ]
67
+ }
68
+ );
69
+ }
70
+ );
71
+ export {
72
+ Toast
73
+ };
@@ -0,0 +1,10 @@
1
+ import { EToastPosition } from './constants';
2
+ import { TProps as TToastProps } from './Toast';
3
+
4
+ type TProps = {
5
+ position?: EToastPosition | `${EToastPosition}`;
6
+ toasts: TToastProps[];
7
+ onToastRemove?: (toastId: string, ref: React.RefObject<HTMLDivElement>) => void;
8
+ };
9
+ export declare const ToastList: import('react').MemoExoticComponent<({ toasts, position, onToastRemove }: TProps) => import("react/jsx-runtime").JSX.Element | null>;
10
+ export {};
@@ -0,0 +1,50 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { memo, useRef, useCallback, useEffect } from "react";
4
+ import { EToastPosition } from "./constants.js";
5
+ import { c as cls } from "../../ProgressBar-BekX41HR.js";
6
+ import { Toast } from "./Toast.js";
7
+ const ToastList = memo(
8
+ ({ toasts, position = EToastPosition.TOP_RIGHT, onToastRemove }) => {
9
+ const listRef = useRef(null);
10
+ const handleScrolling = useCallback(
11
+ (el) => {
12
+ const isTopPosition = [
13
+ EToastPosition.TOP_LEFT,
14
+ EToastPosition.TOP_RIGHT
15
+ ].includes(position);
16
+ if (isTopPosition) {
17
+ el == null ? void 0 : el.scrollTo(0, el.scrollHeight);
18
+ } else {
19
+ el == null ? void 0 : el.scrollTo(0, 0);
20
+ }
21
+ },
22
+ [position]
23
+ );
24
+ useEffect(() => {
25
+ listRef.current && handleScrolling(listRef.current);
26
+ }, [handleScrolling, toasts]);
27
+ if (!toasts.length) {
28
+ return null;
29
+ }
30
+ return /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ ref: listRef,
34
+ className: classNames(cls["toast-list"], cls[position]),
35
+ children: toasts.map((toast) => /* @__PURE__ */ jsx(
36
+ Toast,
37
+ {
38
+ position,
39
+ onToastRemove,
40
+ ...toast
41
+ },
42
+ toast.id
43
+ ))
44
+ }
45
+ );
46
+ }
47
+ );
48
+ export {
49
+ ToastList
50
+ };
@@ -0,0 +1,3 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ export declare const ToastProvider: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useReducer, useCallback, useMemo } from "react";
3
+ import { EToastVariant } from "./constants.js";
4
+ import { ToastContext } from "./hooks.js";
5
+ import { reducer, initialState, actionCreators } from "./store.js";
6
+ import { c as cls } from "../../ProgressBar-BekX41HR.js";
7
+ import { ToastList } from "./ToastList.js";
8
+ const ToastProvider = ({ children }) => {
9
+ const [toasts, dispatch] = useReducer(reducer, initialState);
10
+ const handleToastAdd = useCallback((toast2) => {
11
+ dispatch(actionCreators.setToasts(toast2));
12
+ }, []);
13
+ const toast = useMemo(
14
+ () => ({
15
+ [EToastVariant.DEFAULT]: (toast2) => handleToastAdd({ variant: EToastVariant.DEFAULT, ...toast2 }),
16
+ [EToastVariant.SUCCESS]: (toast2) => handleToastAdd({ variant: EToastVariant.SUCCESS, ...toast2 }),
17
+ [EToastVariant.ALARM]: (toast2) => handleToastAdd({ variant: EToastVariant.ALARM, ...toast2 }),
18
+ [EToastVariant.ERROR]: (toast2) => handleToastAdd({ variant: EToastVariant.ERROR, ...toast2 })
19
+ }),
20
+ [handleToastAdd]
21
+ );
22
+ const handleToastRemove = useCallback(
23
+ (toastId, ref) => {
24
+ var _a, _b;
25
+ (_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.classList.add(cls["toast-out"]);
26
+ (_b = ref == null ? void 0 : ref.current) == null ? void 0 : _b.addEventListener("animationend", () => {
27
+ dispatch(actionCreators.removeToast(toastId));
28
+ });
29
+ },
30
+ []
31
+ );
32
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: toast, children: [
33
+ children,
34
+ /* @__PURE__ */ jsx(
35
+ ToastList,
36
+ {
37
+ toasts: toasts.toasts,
38
+ onToastRemove: handleToastRemove,
39
+ position: toasts.position
40
+ }
41
+ )
42
+ ] });
43
+ };
44
+ export {
45
+ ToastProvider
46
+ };
@@ -0,0 +1,23 @@
1
+ export declare enum EToastVariant {
2
+ DEFAULT = "default",
3
+ ALARM = "alarm",
4
+ SUCCESS = "success",
5
+ ERROR = "error"
6
+ }
7
+ export declare enum EToastPosition {
8
+ TOP_LEFT = "top-left",
9
+ TOP_CENTER = "top-center",
10
+ TOP_RIGHT = "top-right",
11
+ BOTTOM_RIGHT = "bottom-right",
12
+ BOTTOM_CENTER = "bottom-center",
13
+ BOTTOM_LEFT = "bottom-left"
14
+ }
15
+ export declare const ANIMATION_VARIABLES_MAP: {
16
+ "top-right": string;
17
+ "top-center": string;
18
+ "top-left": string;
19
+ "bottom-left": string;
20
+ "bottom-center": string;
21
+ "bottom-right": string;
22
+ };
23
+ export declare const DEFAULT_TOAST_DURATION = 3000;
@@ -0,0 +1,49 @@
1
+ var EToastVariant = /* @__PURE__ */ ((EToastVariant2) => {
2
+ EToastVariant2["DEFAULT"] = "default";
3
+ EToastVariant2["ALARM"] = "alarm";
4
+ EToastVariant2["SUCCESS"] = "success";
5
+ EToastVariant2["ERROR"] = "error";
6
+ return EToastVariant2;
7
+ })(EToastVariant || {});
8
+ var EToastPosition = /* @__PURE__ */ ((EToastPosition2) => {
9
+ EToastPosition2["TOP_LEFT"] = "top-left";
10
+ EToastPosition2["TOP_CENTER"] = "top-center";
11
+ EToastPosition2["TOP_RIGHT"] = "top-right";
12
+ EToastPosition2["BOTTOM_RIGHT"] = "bottom-right";
13
+ EToastPosition2["BOTTOM_CENTER"] = "bottom-center";
14
+ EToastPosition2["BOTTOM_LEFT"] = "bottom-left";
15
+ return EToastPosition2;
16
+ })(EToastPosition || {});
17
+ const ANIMATION_VARIABLES_MAP = {
18
+ [
19
+ "top-right"
20
+ /* TOP_RIGHT */
21
+ ]: "translateX(1000px)",
22
+ [
23
+ "top-center"
24
+ /* TOP_CENTER */
25
+ ]: "translateY(-1300px)",
26
+ [
27
+ "top-left"
28
+ /* TOP_LEFT */
29
+ ]: "translateX(-1000px)",
30
+ [
31
+ "bottom-left"
32
+ /* BOTTOM_LEFT */
33
+ ]: "translateX(-1000px)",
34
+ [
35
+ "bottom-center"
36
+ /* BOTTOM_CENTER */
37
+ ]: "translateY(1300px)",
38
+ [
39
+ "bottom-right"
40
+ /* BOTTOM_RIGHT */
41
+ ]: "translateX(1000px)"
42
+ };
43
+ const DEFAULT_TOAST_DURATION = 3e3;
44
+ export {
45
+ ANIMATION_VARIABLES_MAP,
46
+ DEFAULT_TOAST_DURATION,
47
+ EToastPosition,
48
+ EToastVariant
49
+ };
@@ -0,0 +1,2 @@
1
+ export declare const ToastContext: import('react').Context<import('./types').TToast>;
2
+ export declare const useToast: () => import('./types').TToast;
@@ -0,0 +1,16 @@
1
+ import { createContext, useContext } from "react";
2
+ const ToastContext = createContext({
3
+ alarm: () => {
4
+ },
5
+ default: () => {
6
+ },
7
+ error: () => {
8
+ },
9
+ success: () => {
10
+ }
11
+ });
12
+ const useToast = () => useContext(ToastContext);
13
+ export {
14
+ ToastContext,
15
+ useToast
16
+ };
@@ -0,0 +1,3 @@
1
+ export { ToastProvider } from './ToastsProvider';
2
+ export { useToast } from './hooks';
3
+ export { EToastPosition, EToastVariant } from './constants';
@@ -0,0 +1,9 @@
1
+ import { ToastProvider } from "./ToastsProvider.js";
2
+ import { useToast } from "./hooks.js";
3
+ import { EToastPosition, EToastVariant } from "./constants.js";
4
+ export {
5
+ EToastPosition,
6
+ EToastVariant,
7
+ ToastProvider,
8
+ useToast
9
+ };
@@ -0,0 +1,29 @@
1
+ import { EToastPosition } from './constants';
2
+ import { TProps } from './Toast';
3
+
4
+ export type State = {
5
+ toasts: TProps[];
6
+ position: EToastPosition | `${EToastPosition}`;
7
+ };
8
+ export declare enum EToastsActions {
9
+ SET_TOASTS = "setToasts",
10
+ REMOVE_TOAST = "removeToast",
11
+ RESET = "reset"
12
+ }
13
+ export declare const actionCreators: {
14
+ setToasts: (payload: Omit<TProps, "id">) => {
15
+ readonly type: EToastsActions.SET_TOASTS;
16
+ readonly payload: Omit<TProps, "id">;
17
+ };
18
+ removeToast: (payload: string) => {
19
+ readonly type: EToastsActions.REMOVE_TOAST;
20
+ readonly payload: string;
21
+ };
22
+ reset: () => {
23
+ readonly type: EToastsActions.RESET;
24
+ };
25
+ };
26
+ type ActionTypes = ReturnType<typeof actionCreators.setToasts> | ReturnType<typeof actionCreators.removeToast> | ReturnType<typeof actionCreators.reset>;
27
+ export declare const initialState: State;
28
+ export declare const reducer: (state: State | undefined, action: ActionTypes) => State;
29
+ export {};
@@ -0,0 +1,50 @@
1
+ import { EToastPosition } from "./constants.js";
2
+ var EToastsActions = /* @__PURE__ */ ((EToastsActions2) => {
3
+ EToastsActions2["SET_TOASTS"] = "setToasts";
4
+ EToastsActions2["REMOVE_TOAST"] = "removeToast";
5
+ EToastsActions2["RESET"] = "reset";
6
+ return EToastsActions2;
7
+ })(EToastsActions || {});
8
+ const actionCreators = {
9
+ setToasts: (payload) => ({ type: "setToasts", payload }),
10
+ removeToast: (payload) => ({ type: "removeToast", payload }),
11
+ reset: () => ({
12
+ type: "reset"
13
+ /* RESET */
14
+ })
15
+ };
16
+ const initialState = {
17
+ toasts: [],
18
+ position: EToastPosition.TOP_RIGHT
19
+ };
20
+ const reducer = (state = initialState, action) => {
21
+ switch (action.type) {
22
+ case "setToasts":
23
+ return {
24
+ ...state,
25
+ toasts: [
26
+ ...state.toasts,
27
+ { ...action.payload, id: `${Math.random() * 1e4}` }
28
+ ],
29
+ position: action.payload.position && action.payload.position !== state.position ? action.payload.position : state.position
30
+ };
31
+ case "removeToast": {
32
+ return {
33
+ ...state,
34
+ toasts: state.toasts.filter((t) => t.id !== action.payload)
35
+ };
36
+ }
37
+ case "reset": {
38
+ return initialState;
39
+ }
40
+ default: {
41
+ return state;
42
+ }
43
+ }
44
+ };
45
+ export {
46
+ EToastsActions,
47
+ actionCreators,
48
+ initialState,
49
+ reducer
50
+ };
@@ -0,0 +1,5 @@
1
+ import { EToastVariant } from './constants';
2
+ import { TProps } from './Toast';
3
+
4
+ export type TToast = Record<EToastVariant | `${EToastVariant}`, (toast: Omit<TProps, 'id' | 'variant'>) => void>;
5
+ export type ToastContextType = TToast;
@@ -0,0 +1 @@
1
+