mimir-ui-kit 1.58.2 → 1.59.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.
@@ -46,13 +46,23 @@ export type TProps = {
46
46
  * Функция обратного вызова, вызываемая при удалении уведомления.
47
47
  */
48
48
  onToastRemove?: (toastId: string, ref: RefObject<HTMLDivElement>) => void;
49
+ /**
50
+ * Функция обратного вызова, вызываемая при удалении тоста по причине истечения таймера.
51
+ */
52
+ onExpire?: () => void;
53
+ /**
54
+ * Функция обратного вызова, вызываемая при клике на крестик.
55
+ */
56
+ onButtonRemoveClick?: () => void;
49
57
  /**
50
58
  * Слот уведомления.
51
59
  */
52
- slot?: ReactNode;
60
+ slot?: ReactNode | ((props: {
61
+ handleToastRemove: VoidFunction;
62
+ }) => JSX.Element);
53
63
  /**
54
64
  * Флаг, указывающий на приостановку таймера при наведении курсора.
55
65
  */
56
66
  pauseOnHover?: boolean;
57
67
  };
58
- export declare const Toast: import('react').MemoExoticComponent<({ id, title, message, position, variant, duration, autoClose, needProgress, needTimer, needCloseButton, onToastRemove, slot, pauseOnHover }: TProps) => import("react/jsx-runtime").JSX.Element>;
68
+ export declare const Toast: import('react').MemoExoticComponent<({ id, title, message, position, variant, duration, autoClose, needProgress, needTimer, needCloseButton, onToastRemove, onExpire, onButtonRemoveClick, slot, pauseOnHover }: TProps) => import("react/jsx-runtime").JSX.Element>;
@@ -1,87 +1,97 @@
1
- import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
- import { c as P } from "../../index-DIxK0V-G.js";
3
- import { memo as L, useRef as _, useState as B } from "react";
4
- import { ANIMATION_VARIABLES_MAP as D, EToastPosition as S, EToastVariant as w, DEFAULT_TOAST_DURATION as O } from "./constants.js";
5
- import { c as s, P as T } from "../../ProgressBar-F970LqqJ.js";
6
- import { useTimer as U } from "../../hooks/useTimer/index.js";
7
- import { Button as j } from "../Button/Button.js";
8
- const g = L(
1
+ import { jsxs as t, jsx as a } from "react/jsx-runtime";
2
+ import { c as S } from "../../index-DIxK0V-G.js";
3
+ import { memo as w, useRef as y, useState as O } from "react";
4
+ import { ANIMATION_VARIABLES_MAP as U, EToastPosition as j, EToastVariant as x, DEFAULT_TOAST_DURATION as F } from "./constants.js";
5
+ import { c as s, P as V } from "../../ProgressBar-F970LqqJ.js";
6
+ import { useTimer as b } from "../../hooks/useTimer/index.js";
7
+ import { Button as G } from "../Button/Button.js";
8
+ const Q = w(
9
9
  ({
10
- id: c,
11
- title: i = "",
12
- message: m,
13
- position: A = S.TOP_RIGHT,
14
- variant: n = w.DEFAULT,
15
- duration: t = O,
16
- autoClose: o = !0,
17
- needProgress: u = !0,
18
- needTimer: p = !0,
19
- needCloseButton: E = !0,
20
- onToastRemove: e,
21
- slot: f,
22
- pauseOnHover: d = !1
10
+ id: i,
11
+ title: m = "",
12
+ message: u,
13
+ position: P = j.TOP_RIGHT,
14
+ variant: h = x.DEFAULT,
15
+ duration: c = F,
16
+ autoClose: p = !0,
17
+ needProgress: N = !0,
18
+ needTimer: A = !0,
19
+ needCloseButton: L = !0,
20
+ onToastRemove: r,
21
+ onExpire: f,
22
+ onButtonRemoveClick: d,
23
+ slot: e,
24
+ pauseOnHover: I = !1
23
25
  }) => {
24
- const l = _(null), [N, h] = B(!1), { seconds: I } = U({
25
- expiryTimestamp: Date.now() + t,
26
- autoStart: o,
27
- onExpire: o ? () => e == null ? void 0 : e(c, l) : void 0,
28
- isPaused: N
29
- }), x = () => {
30
- d && h(!0);
31
- }, M = () => {
32
- d && h(!1);
26
+ const l = y(null), [n, M] = O(!1), { seconds: _ } = b({
27
+ expiryTimestamp: Date.now() + c,
28
+ autoStart: p,
29
+ onExpire: p ? () => {
30
+ r == null || r(i, l), f == null || f();
31
+ } : void 0,
32
+ isPaused: n
33
+ }), D = () => {
34
+ I && M(!0);
35
+ }, E = () => {
36
+ I && M(!1);
33
37
  };
34
- return /* @__PURE__ */ a(
38
+ return /* @__PURE__ */ t(
35
39
  "div",
36
40
  {
37
41
  style: {
38
- "--elm-translate": D[A]
42
+ "--elm-translate": U[P]
39
43
  },
40
- className: P(
44
+ className: S(
41
45
  s["toast-in"],
42
46
  s["toast-wrapper"],
43
- s[n]
47
+ s[h]
44
48
  ),
45
49
  ref: l,
46
50
  role: "alert",
47
- onMouseEnter: x,
48
- onMouseLeave: M,
51
+ onMouseEnter: D,
52
+ onMouseLeave: E,
49
53
  children: [
50
- i && /* @__PURE__ */ r("h3", { className: s.title, children: i }),
51
- m && /* @__PURE__ */ r("div", { className: s.message, children: m }),
52
- (p || u) && /* @__PURE__ */ a("div", { children: [
53
- !!t && p && /* @__PURE__ */ a("div", { className: s.timer, children: [
54
- /* @__PURE__ */ r("h4", { className: s["timer-title"], children: "Осталось" }),
55
- /* @__PURE__ */ a("p", { className: s.seconds, children: [
56
- I,
54
+ m && /* @__PURE__ */ a("h3", { className: s.title, children: m }),
55
+ u && /* @__PURE__ */ a("div", { className: s.message, children: u }),
56
+ (A || N) && /* @__PURE__ */ t("div", { children: [
57
+ !!c && A && /* @__PURE__ */ t("div", { className: s.timer, children: [
58
+ /* @__PURE__ */ a("h4", { className: s["timer-title"], children: "Осталось" }),
59
+ /* @__PURE__ */ t("p", { className: s.seconds, children: [
60
+ _,
57
61
  " сек"
58
62
  ] })
59
63
  ] }),
60
- !!t && u && /* @__PURE__ */ r(
61
- T,
64
+ !!c && N && /* @__PURE__ */ a(
65
+ V,
62
66
  {
63
- variant: n,
64
- duration: t,
65
- isPaused: N
67
+ variant: h,
68
+ duration: c,
69
+ isPaused: n
66
70
  }
67
71
  )
68
72
  ] }),
69
- E && /* @__PURE__ */ r(
70
- j,
73
+ L && /* @__PURE__ */ a(
74
+ G,
71
75
  {
72
- onClick: () => e == null ? void 0 : e(c, l),
76
+ onClick: () => {
77
+ r == null || r(i, l), d == null || d();
78
+ },
73
79
  clear: !0,
74
80
  isIconButton: !0,
75
81
  className: s["close-button"],
76
82
  iconName: "Close24px"
77
83
  }
78
84
  ),
79
- f && /* @__PURE__ */ r("div", { className: s.slot, children: f })
85
+ e && /* @__PURE__ */ a("div", { className: s.slot, children: typeof e == "function" ? e({
86
+ handleToastRemove: () => {
87
+ r == null || r(i, l);
88
+ }
89
+ }) : e })
80
90
  ]
81
91
  }
82
92
  );
83
93
  }
84
94
  );
85
95
  export {
86
- g as Toast
96
+ Q as Toast
87
97
  };
@@ -1,5 +1,5 @@
1
1
  import { EToastVariant } from './constants';
2
2
  import { TProps } from './Toast';
3
3
 
4
- export type TToast = Record<EToastVariant | `${EToastVariant}`, (toast: Omit<TProps, 'id' | 'variant'>) => void>;
4
+ export type TToast = Record<EToastVariant | `${EToastVariant}`, (toast: Omit<TProps, 'id' | 'variant' | 'onToastRemove'>) => void>;
5
5
  export type ToastContextType = TToast;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.58.2",
4
+ "version": "1.59.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {