mimir-ui-kit 1.58.2 → 1.59.1

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.
@@ -79,6 +79,10 @@ export type TProps = {
79
79
  * Флаг для растяжки компонента на всю ширину экрана
80
80
  */
81
81
  full?: boolean;
82
+ /**
83
+ * позиция компонента относительно инпута
84
+ */
85
+ position?: 'center' | 'bottom' | 'top';
82
86
  } & TInputProps;
83
87
  export type TDatePickerValue = {
84
88
  value?: string;
@@ -166,4 +170,8 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
166
170
  * Флаг для растяжки компонента на всю ширину экрана
167
171
  */
168
172
  full?: boolean;
173
+ /**
174
+ * позиция компонента относительно инпута
175
+ */
176
+ position?: "center" | "bottom" | "top";
169
177
  } & import('../Input/types').TInputProps & import('../Input').TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -1,19 +1,19 @@
1
1
  import { jsxs as z, jsx as k } from "react/jsx-runtime";
2
2
  import { c as H } from "../../index-DIxK0V-G.js";
3
- import { memo as kt, forwardRef as Nt, useState as b, useEffect as v } from "react";
4
- import { months as P, EDatePickerBorderRadius as C, MAX_DAY as ut, MAX_MONTH as ht, DATE_LENGTH as Mt } from "./constants.js";
5
- import { DatePickerModal as gt } from "./DatePickerModal.js";
6
- import { MonthPickerModal as Tt } from "./MonthPickerModal.js";
3
+ import { memo as Nt, forwardRef as ut, useState as b, useEffect as v } from "react";
4
+ import { months as P, EDatePickerBorderRadius as C, MAX_DAY as ht, MAX_MONTH as Mt, DATE_LENGTH as gt } from "./constants.js";
5
+ import { DatePickerModal as Tt } from "./DatePickerModal.js";
6
+ import { MonthPickerModal as $t } from "./MonthPickerModal.js";
7
7
  import { c as y } from "../../styles.module-DeBRSK_x.js";
8
8
  import { formatDatePart as R } from "./utils.js";
9
- import { YearPickerModal as $t } from "./YearPickerModal.js";
10
- import { useClickOutside as bt } from "../../hooks/useClickOutside/useClickOutside.js";
9
+ import { YearPickerModal as bt } from "./YearPickerModal.js";
10
+ import { useClickOutside as At } from "../../hooks/useClickOutside/useClickOutside.js";
11
11
  import { Icon as B } from "../../icons/Icon.js";
12
12
  import { formating as d } from "../../utils/index.js";
13
- import { I as At } from "../../Input-DPnH8pKc.js";
14
- import { EInputStatus as Pt, EInputSize as V } from "../Input/constants.js";
15
- const St = kt(
16
- Nt(
13
+ import { I as Pt } from "../../Input-DPnH8pKc.js";
14
+ import { EInputStatus as St, EInputSize as V } from "../Input/constants.js";
15
+ const Yt = Nt(
16
+ ut(
17
17
  ({
18
18
  size: j,
19
19
  value: u,
@@ -37,12 +37,13 @@ const St = kt(
37
37
  validRange: c,
38
38
  borderRadius: X = C.All,
39
39
  full: st,
40
+ position: at,
40
41
  ...S
41
- }, at) => {
42
+ }, rt) => {
42
43
  const [Y, D] = b(!1), [E, p] = b(l), [f, g] = b(
43
44
  () => u && !isNaN(new Date(u).getTime()) ? new Date(u) : void 0
44
- ), [I, F] = b(O), [rt, x] = b(""), [ct, $] = b();
45
- S.status = !!I && Pt.Error || S.status, v(() => {
45
+ ), [I, F] = b(O), [ct, x] = b(""), [ot, $] = b();
46
+ S.status = !!I && St.Error || S.status, v(() => {
46
47
  F(O);
47
48
  }, [O]), v(() => {
48
49
  g(
@@ -77,14 +78,14 @@ const St = kt(
77
78
  const K = u && new Date(u).getTime;
78
79
  v(() => {
79
80
  L && (K ? (F(!1), T == null || T({ name: N, active: !1 })) : (F(!0), T == null || T({ name: N, active: !0 })));
80
- }, [L, N, K]), bt({
81
+ }, [L, N, K]), At({
81
82
  isActive: Y,
82
83
  setActive: (t) => {
83
84
  D(t), p(l), t || $(void 0);
84
85
  },
85
86
  className: y["calendar-block"]
86
87
  });
87
- const ot = () => {
88
+ const it = () => {
88
89
  !_ && (W || !A) && D(!0);
89
90
  }, Q = (t) => {
90
91
  const s = t.getTime();
@@ -112,7 +113,7 @@ const St = kt(
112
113
  if (m.setHours(0, 0, 0, 0), n.setHours(23, 59, 59, 999), t < m || t > n) return !1;
113
114
  }
114
115
  return !0;
115
- }, it = (t) => {
116
+ }, ft = (t) => {
116
117
  if (!isNaN(t.getTime())) {
117
118
  g(t), $(void 0);
118
119
  let e = "";
@@ -165,7 +166,7 @@ const St = kt(
165
166
  value: s,
166
167
  name: N
167
168
  }), i == null || i(s);
168
- }, ft = (t) => {
169
+ }, mt = (t) => {
169
170
  const s = f || /* @__PURE__ */ new Date(), e = s.getDate(), o = s.getMonth() + 1, r = new Date(t, o - 1, e);
170
171
  if (r.getFullYear() === t && r.getMonth() === o - 1 && r.getDate() === e && Q(r)) {
171
172
  g(r), $(void 0);
@@ -198,7 +199,7 @@ const St = kt(
198
199
  } else
199
200
  $(new Date(t, o - 1, 1));
200
201
  l === "years" ? (D(!1), p(l)) : p("months");
201
- }, mt = (t, s) => {
202
+ }, nt = (t, s) => {
202
203
  const o = (f || /* @__PURE__ */ new Date()).getDate(), r = new Date(t, s, 0).getDate(), m = Math.min(o, r), n = new Date(t, s - 1, m);
203
204
  if (n.getFullYear() === t && n.getMonth() === s - 1 && n.getDate() === m && Q(n)) {
204
205
  g(n), $(void 0);
@@ -231,15 +232,15 @@ const St = kt(
231
232
  } else
232
233
  $(new Date(t, s - 1, 1));
233
234
  l === "months" ? (D(!1), p(l)) : p("days");
234
- }, nt = (t) => {
235
+ }, lt = (t) => {
235
236
  if (A || t.target.value === "") {
236
237
  const s = t.target.value.replace(/[^\d]/g, "");
237
238
  if (s.length === 0)
238
239
  x(""), g(void 0), D(!1), a == null || a({ value: "", name: N }), i == null || i("");
239
240
  else {
240
241
  const [e, o, r] = [
241
- R(s.substring(0, 2), ut),
242
- R(s.substring(2, 4), ht),
242
+ R(s.substring(0, 2), ht),
243
+ R(s.substring(2, 4), Mt),
243
244
  s.substring(4, 8)
244
245
  ], m = [e, o, r].filter(Boolean).join("/");
245
246
  if (x(m), et) {
@@ -249,7 +250,7 @@ const St = kt(
249
250
  name: N
250
251
  });
251
252
  }
252
- if (m.length === Mt) {
253
+ if (m.length === gt) {
253
254
  const n = parseInt(r), w = /* @__PURE__ */ new Date(
254
255
  `${n}-${o.padStart(2, "0")}-${e.padStart(2, "0")}`
255
256
  );
@@ -260,18 +261,18 @@ const St = kt(
260
261
  }
261
262
  }
262
263
  }
263
- }, lt = H(
264
+ }, yt = H(
264
265
  y.wrapper,
265
266
  Y && !A && y.active
266
- ), yt = H(y.input, y.inputBorderControl);
267
+ ), Dt = H(y.input, y.inputBorderControl);
267
268
  let Z;
268
269
  if (c) {
269
270
  let t, s;
270
271
  typeof c[0] == "string" ? t = new Date(c[0]) : t = c[0], typeof c[1] == "string" ? s = new Date(c[1]) : s = c[1], Z = [t, s];
271
272
  }
272
273
  const G = {
273
- onChangeValue: it,
274
- date: ct || f || /* @__PURE__ */ new Date(),
274
+ onChangeValue: ft,
275
+ date: ot || f || /* @__PURE__ */ new Date(),
275
276
  selectedDate: f,
276
277
  before: typeof M == "string" ? new Date(M) : M,
277
278
  onChangeType: p,
@@ -280,24 +281,25 @@ const St = kt(
280
281
  disablePast: J,
281
282
  disabledDate: U,
282
283
  validRange: Z,
283
- dateFormat: h
284
- }, Dt = {
284
+ dateFormat: h,
285
+ position: at
286
+ }, pt = {
285
287
  ...G,
286
- onChangeMonth: mt,
288
+ onChangeMonth: nt,
287
289
  dateFormat: h
288
- }, pt = {
290
+ }, dt = {
289
291
  ...G,
290
- onChangeYear: ft
291
- }, dt = (() => {
292
+ onChangeYear: mt
293
+ }, wt = (() => {
292
294
  switch (E) {
293
295
  case "months":
294
- return () => /* @__PURE__ */ k(Tt, { ...Dt });
295
- case "years":
296
296
  return () => /* @__PURE__ */ k($t, { ...pt });
297
+ case "years":
298
+ return () => /* @__PURE__ */ k(bt, { ...dt });
297
299
  default:
298
- return () => /* @__PURE__ */ k(gt, { ...G });
300
+ return () => /* @__PURE__ */ k(Tt, { ...G });
299
301
  }
300
- })(), wt = ({ isActive: t }) => /* @__PURE__ */ k("button", { onClick: (e) => {
302
+ })(), kt = ({ isActive: t }) => /* @__PURE__ */ k("button", { onClick: (e) => {
301
303
  e.stopPropagation(), _ || D(!t);
302
304
  }, className: y["icon-button"], children: t ? /* @__PURE__ */ k(
303
305
  B,
@@ -317,7 +319,7 @@ const St = kt(
317
319
  [y.full]: st
318
320
  }),
319
321
  children: [
320
- /* @__PURE__ */ z("div", { className: lt, "data-disabled": _, children: [
322
+ /* @__PURE__ */ z("div", { className: yt, "data-disabled": _, children: [
321
323
  /* @__PURE__ */ k(
322
324
  "div",
323
325
  {
@@ -327,21 +329,21 @@ const St = kt(
327
329
  [y.editable]: A,
328
330
  [y[`border-radius-${X}`]]: X !== C.All
329
331
  }),
330
- onClick: ot,
332
+ onClick: it,
331
333
  children: /* @__PURE__ */ k(
332
- At,
334
+ Pt,
333
335
  {
334
- ref: at,
335
- className: yt,
336
+ ref: rt,
337
+ className: Dt,
336
338
  wrapperClassName: y["input-wrapper"],
337
339
  size: j,
338
340
  type: "text",
339
341
  variant: tt,
340
- value: rt,
341
- onChange: nt,
342
+ value: ct,
343
+ onChange: lt,
342
344
  rightAddon: {
343
345
  addonType: "react-node",
344
- addonContent: /* @__PURE__ */ k(wt, { isActive: Y })
346
+ addonContent: /* @__PURE__ */ k(kt, { isActive: Y })
345
347
  },
346
348
  rightSlotClassName: y["right-slot"],
347
349
  onFocus: () => {
@@ -353,7 +355,7 @@ const St = kt(
353
355
  )
354
356
  }
355
357
  ),
356
- Y && /* @__PURE__ */ k(dt, {})
358
+ Y && /* @__PURE__ */ k(wt, {})
357
359
  ] }),
358
360
  I && typeof I == "string" && /* @__PURE__ */ k("div", { className: y.textError, children: I })
359
361
  ]
@@ -362,7 +364,7 @@ const St = kt(
362
364
  }
363
365
  )
364
366
  );
365
- St.displayName = "DatePicker";
367
+ Yt.displayName = "DatePicker";
366
368
  export {
367
- St as DatePicker
369
+ Yt as DatePicker
368
370
  };
@@ -10,6 +10,7 @@ type TProps = {
10
10
  disabledDate?: (date: Date) => boolean;
11
11
  validRange?: [Date, Date];
12
12
  dateFormat?: 'full' | 'month' | 'year';
13
+ position?: 'center' | 'bottom' | 'top';
13
14
  };
14
- export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange, dateFormat }: TProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const DatePickerModal: ({ date, selectedDate, onChangeValue, setIsActive, before, onChangeType, disableFuture, disablePast, disabledDate, validRange, dateFormat, position }: TProps) => import("react/jsx-runtime").JSX.Element;
15
16
  export {};
@@ -1,15 +1,15 @@
1
1
  import { jsxs as u, jsx as a } from "react/jsx-runtime";
2
2
  import { c as A } from "../../index-DIxK0V-G.js";
3
- import { useState as U } from "react";
4
- import { week as V, COUNT_WORK_DAYS as W } from "./constants.js";
5
- import { useDatePickerPosition as E } from "./hooks.js";
3
+ import { useState as V } from "react";
4
+ import { week as W, COUNT_WORK_DAYS as E } from "./constants.js";
5
+ import { useDatePickerPosition as K } from "./hooks.js";
6
6
  import { c as n } from "../../styles.module-DeBRSK_x.js";
7
7
  import { getUpdateDate as B } from "./utils.js";
8
- import { Icon as K } from "../../icons/Icon.js";
8
+ import { Icon as R } from "../../icons/Icon.js";
9
9
  import { formating as m } from "../../utils/index.js";
10
10
  import { Button as H } from "../Button/Button.js";
11
11
  import { parseDate as I } from "../../utils/formating/Date.js";
12
- const mt = ({
12
+ const ct = ({
13
13
  date: i,
14
14
  selectedDate: d,
15
15
  onChangeValue: O,
@@ -20,7 +20,8 @@ const mt = ({
20
20
  disablePast: _ = !1,
21
21
  disabledDate: p,
22
22
  validRange: N,
23
- dateFormat: w
23
+ dateFormat: w,
24
+ position: j
24
25
  }) => {
25
26
  var k;
26
27
  i = isNaN(new Date(i).getTime()) ? /* @__PURE__ */ new Date() : i;
@@ -32,29 +33,29 @@ const mt = ({
32
33
  y: l.getFullYear(),
33
34
  d: l.getDate(),
34
35
  m: l.getMonth() + 1
35
- }, [r, b] = U({ y: v.y, m: v.m }), j = E([r]), C = (t) => {
36
+ }, [r, b] = V({ y: v.y, m: v.m }), C = K([r], j), L = (t) => {
36
37
  let e = t.getDay();
37
38
  return e === 0 && (e = 7), e - 1;
38
39
  }, x = r.m - 1, c = new Date(r.y, x), h = [], M = (() => {
39
40
  const t = new Date(c);
40
41
  t.setDate(t.getDate() - 1);
41
42
  const e = t.getDate(), o = [];
42
- for (let s = 0; s < C(c); s++)
43
+ for (let s = 0; s < L(c); s++)
43
44
  o.push(e - s);
44
45
  return o.reverse(), o;
45
46
  })();
46
47
  for (; c.getMonth() === x; )
47
48
  h.push(c.getDate()), c.setDate(c.getDate() + 1);
48
- const L = (() => {
49
+ const Y = (() => {
49
50
  const e = 42 - (M.length + h.length), o = [];
50
51
  for (let s = 1; s <= e; s++)
51
52
  o.push(s);
52
53
  return o;
53
- })(), Y = () => {
54
+ })(), z = () => {
54
55
  S(!1);
55
- }, z = () => {
56
- b(B(r.m + 1, r.y));
57
56
  }, F = () => {
57
+ b(B(r.m + 1, r.y));
58
+ }, G = () => {
58
59
  b(B(r.m - 1, r.y));
59
60
  }, $ = (t) => {
60
61
  const e = new Date(t);
@@ -74,7 +75,7 @@ const mt = ({
74
75
  if (o.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), P < o || P > s) return !0;
75
76
  }
76
77
  return !1;
77
- }, G = (t) => {
78
+ }, U = (t) => {
78
79
  $(
79
80
  (/* @__PURE__ */ new Date(
80
81
  `${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
@@ -83,13 +84,13 @@ const mt = ({
83
84
  /* @__PURE__ */ new Date(
84
85
  `${r.y}-${m.Number(2, r.m)}-${m.Number(2, t)}`
85
86
  )
86
- ), Y());
87
+ ), z());
87
88
  };
88
89
  return /* @__PURE__ */ u(
89
90
  "div",
90
91
  {
91
92
  className: n["calendar-block"],
92
- ref: j,
93
+ ref: C,
93
94
  "data-testid": "calendar-modal",
94
95
  children: [
95
96
  /* @__PURE__ */ u("div", { className: n.h, children: [
@@ -98,7 +99,7 @@ const mt = ({
98
99
  {
99
100
  isIconButton: !0,
100
101
  iconName: "DropdownArrowLeft16px",
101
- onClick: F,
102
+ onClick: G,
102
103
  variant: "secondary-gray",
103
104
  size: "l"
104
105
  }
@@ -114,7 +115,7 @@ const mt = ({
114
115
  (k = m.Month(r.m)) == null ? void 0 : k.name,
115
116
  "’",
116
117
  r.y.toString().slice(-2),
117
- w !== "month" && /* @__PURE__ */ a(K, { iconName: "DropdownArrowBottom16px" })
118
+ w !== "month" && /* @__PURE__ */ a(R, { iconName: "DropdownArrowBottom16px" })
118
119
  ]
119
120
  }
120
121
  ),
@@ -123,18 +124,18 @@ const mt = ({
123
124
  {
124
125
  isIconButton: !0,
125
126
  iconName: "DropdownArrowRight16px",
126
- onClick: z,
127
+ onClick: F,
127
128
  variant: "secondary-gray",
128
129
  size: "l"
129
130
  }
130
131
  )
131
132
  ] }),
132
133
  /* @__PURE__ */ u("div", { className: n.b, children: [
133
- V.map((t, e) => /* @__PURE__ */ a(
134
+ W.map((t, e) => /* @__PURE__ */ a(
134
135
  "div",
135
136
  {
136
137
  className: A(n.m, {
137
- [n.orange]: e > W
138
+ [n.orange]: e > E
138
139
  }),
139
140
  children: t
140
141
  },
@@ -145,7 +146,7 @@ const mt = ({
145
146
  "button",
146
147
  {
147
148
  type: "button",
148
- onClick: () => G(t),
149
+ onClick: () => U(t),
149
150
  className: A(
150
151
  $(
151
152
  (/* @__PURE__ */ new Date(
@@ -160,12 +161,12 @@ const mt = ({
160
161
  },
161
162
  e
162
163
  )),
163
- L.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e))
164
+ Y.map((t, e) => /* @__PURE__ */ a("div", { className: n.m, children: t }, e))
164
165
  ] })
165
166
  ]
166
167
  }
167
168
  );
168
169
  };
169
170
  export {
170
- mt as DatePickerModal
171
+ ct as DatePickerModal
171
172
  };
@@ -1,3 +1,3 @@
1
1
  import { DependencyList } from 'react';
2
2
 
3
- export declare const useDatePickerPosition: (deps?: DependencyList) => import('react').RefObject<HTMLDivElement>;
3
+ export declare const useDatePickerPosition: (deps?: DependencyList, position?: "center" | "bottom" | "top") => import('react').RefObject<HTMLDivElement>;
@@ -1,20 +1,34 @@
1
- import { useRef as x, useEffect as w } from "react";
2
- import { BLOCK_WIDTH as o, MAX_MOBILE_WIDTH as g } from "./constants.js";
3
- const W = (a) => {
4
- const t = x(null);
5
- return w(() => {
6
- var s, l, u, p, f, y;
7
- const d = window.innerHeight, c = window.innerWidth;
8
- if (t.current !== null) {
9
- const h = ((l = (s = t == null ? void 0 : t.current) == null ? void 0 : s.parentElement) == null ? void 0 : l.offsetWidth) ?? 0, r = ((p = (u = t == null ? void 0 : t.current) == null ? void 0 : u.parentElement) == null ? void 0 : p.offsetHeight) ?? 0, n = (y = (f = t == null ? void 0 : t.current) == null ? void 0 : f.parentElement) == null ? void 0 : y.getBoundingClientRect(), i = t.current.offsetHeight;
10
- if (c < n.x + o) {
11
- const e = h - o;
12
- n.x - Math.abs(e) < 0 ? t.current.style.left = (e < 0 ? e / 2 : e) + "px" : t.current.style.left = e + "px";
1
+ import { useRef as h, useEffect as u } from "react";
2
+ import { BLOCK_WIDTH as n, MAX_MOBILE_WIDTH as w } from "./constants.js";
3
+ const H = (a, y) => {
4
+ const l = h(null);
5
+ return u(() => {
6
+ var c, f, r;
7
+ const x = window.innerHeight, p = window.innerWidth, t = l.current;
8
+ if (t && t !== null) {
9
+ const d = ((c = t == null ? void 0 : t.parentElement) == null ? void 0 : c.offsetWidth) ?? 0, s = ((f = t == null ? void 0 : t.parentElement) == null ? void 0 : f.offsetHeight) ?? 0, o = (r = t == null ? void 0 : t.parentElement) == null ? void 0 : r.getBoundingClientRect(), e = t.offsetHeight;
10
+ switch (y) {
11
+ case "center":
12
+ t.style.position = "fixed", t.style.top = `calc(50vh - ${e / 2}px)`, t.style.left = `calc(50vw - ${n / 2}px)`;
13
+ break;
14
+ case "bottom":
15
+ t.style.top = s + "px";
16
+ break;
17
+ case "top":
18
+ t.style.top = -e + "px";
19
+ break;
20
+ default:
21
+ if (p < o.x + n) {
22
+ const i = d - n;
23
+ o.x - Math.abs(i) < 0 ? t.style.left = (i < 0 ? i / 2 : i) + "px" : t.style.left = i + "px";
24
+ }
25
+ x < o.y + e + s ? o.y - e > 0 ? t.style.top = -e + "px" : p > w ? t.style.top = s + "px" : (t.style.position = "fixed", t.style.top = `calc(50vh - ${e / 2}px)`, t.style.left = `calc(50vw - ${n / 2}px)`) : t.style.top = s + "px";
26
+ break;
13
27
  }
14
- d < n.y + i + r ? n.y - i > 0 ? t.current.style.top = -i + "px" : c > g ? t.current.style.top = r + "px" : (t.current.style.position = "fixed", t.current.style.top = `calc(50vh - ${i / 2}px)`, t.current.style.left = `calc(50vw - ${o / 2}px)`) : t.current.style.top = r + "px", t.current.style.opacity = "1";
28
+ t.style.opacity = "1";
15
29
  }
16
- }, [a]), t;
30
+ }, [a]), l;
17
31
  };
18
32
  export {
19
- W as useDatePickerPosition
33
+ H as useDatePickerPosition
20
34
  };
@@ -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.1",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {