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.
- package/dist/components/DatePicker/DatePicker.d.ts +8 -0
- package/dist/components/DatePicker/DatePicker.js +49 -47
- package/dist/components/DatePicker/DatePickerModal.d.ts +2 -1
- package/dist/components/DatePicker/DatePickerModal.js +24 -23
- package/dist/components/DatePicker/hooks.d.ts +1 -1
- package/dist/components/DatePicker/hooks.js +29 -15
- package/dist/components/Toasts/Toast.d.ts +12 -2
- package/dist/components/Toasts/Toast.js +63 -53
- package/dist/components/Toasts/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
4
|
-
import { months as P, EDatePickerBorderRadius as C, MAX_DAY as
|
|
5
|
-
import { DatePickerModal as
|
|
6
|
-
import { MonthPickerModal as
|
|
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
|
|
10
|
-
import { useClickOutside as
|
|
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
|
|
14
|
-
import { EInputStatus as
|
|
15
|
-
const
|
|
16
|
-
|
|
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
|
-
},
|
|
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), [
|
|
45
|
-
S.status = !!I &&
|
|
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]),
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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),
|
|
242
|
-
R(s.substring(2, 4),
|
|
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 ===
|
|
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
|
-
},
|
|
264
|
+
}, yt = H(
|
|
264
265
|
y.wrapper,
|
|
265
266
|
Y && !A && y.active
|
|
266
|
-
),
|
|
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:
|
|
274
|
-
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
|
-
|
|
284
|
+
dateFormat: h,
|
|
285
|
+
position: at
|
|
286
|
+
}, pt = {
|
|
285
287
|
...G,
|
|
286
|
-
onChangeMonth:
|
|
288
|
+
onChangeMonth: nt,
|
|
287
289
|
dateFormat: h
|
|
288
|
-
},
|
|
290
|
+
}, dt = {
|
|
289
291
|
...G,
|
|
290
|
-
onChangeYear:
|
|
291
|
-
},
|
|
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(
|
|
300
|
+
return () => /* @__PURE__ */ k(Tt, { ...G });
|
|
299
301
|
}
|
|
300
|
-
})(),
|
|
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:
|
|
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:
|
|
332
|
+
onClick: it,
|
|
331
333
|
children: /* @__PURE__ */ k(
|
|
332
|
-
|
|
334
|
+
Pt,
|
|
333
335
|
{
|
|
334
|
-
ref:
|
|
335
|
-
className:
|
|
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:
|
|
341
|
-
onChange:
|
|
342
|
+
value: ct,
|
|
343
|
+
onChange: lt,
|
|
342
344
|
rightAddon: {
|
|
343
345
|
addonType: "react-node",
|
|
344
|
-
addonContent: /* @__PURE__ */ k(
|
|
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(
|
|
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
|
-
|
|
367
|
+
Yt.displayName = "DatePicker";
|
|
366
368
|
export {
|
|
367
|
-
|
|
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
|
|
4
|
-
import { week as
|
|
5
|
-
import { useDatePickerPosition as
|
|
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
|
|
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
|
|
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] =
|
|
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 <
|
|
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
|
|
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
|
-
})(),
|
|
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
|
-
},
|
|
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
|
-
),
|
|
87
|
+
), z());
|
|
87
88
|
};
|
|
88
89
|
return /* @__PURE__ */ u(
|
|
89
90
|
"div",
|
|
90
91
|
{
|
|
91
92
|
className: n["calendar-block"],
|
|
92
|
-
ref:
|
|
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:
|
|
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(
|
|
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:
|
|
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
|
-
|
|
134
|
+
W.map((t, e) => /* @__PURE__ */ a(
|
|
134
135
|
"div",
|
|
135
136
|
{
|
|
136
137
|
className: A(n.m, {
|
|
137
|
-
[n.orange]: e >
|
|
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: () =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import { BLOCK_WIDTH as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
return
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
if (t
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
28
|
+
t.style.opacity = "1";
|
|
15
29
|
}
|
|
16
|
-
}, [a]),
|
|
30
|
+
}, [a]), l;
|
|
17
31
|
};
|
|
18
32
|
export {
|
|
19
|
-
|
|
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
|
|
2
|
-
import { c as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { ANIMATION_VARIABLES_MAP as
|
|
5
|
-
import { c as s, P as
|
|
6
|
-
import { useTimer as
|
|
7
|
-
import { Button as
|
|
8
|
-
const
|
|
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:
|
|
11
|
-
title:
|
|
12
|
-
message:
|
|
13
|
-
position:
|
|
14
|
-
variant:
|
|
15
|
-
duration:
|
|
16
|
-
autoClose:
|
|
17
|
-
needProgress:
|
|
18
|
-
needTimer:
|
|
19
|
-
needCloseButton:
|
|
20
|
-
onToastRemove:
|
|
21
|
-
|
|
22
|
-
|
|
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 =
|
|
25
|
-
expiryTimestamp: Date.now() +
|
|
26
|
-
autoStart:
|
|
27
|
-
onExpire:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
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__ */
|
|
38
|
+
return /* @__PURE__ */ t(
|
|
35
39
|
"div",
|
|
36
40
|
{
|
|
37
41
|
style: {
|
|
38
|
-
"--elm-translate":
|
|
42
|
+
"--elm-translate": U[P]
|
|
39
43
|
},
|
|
40
|
-
className:
|
|
44
|
+
className: S(
|
|
41
45
|
s["toast-in"],
|
|
42
46
|
s["toast-wrapper"],
|
|
43
|
-
s[
|
|
47
|
+
s[h]
|
|
44
48
|
),
|
|
45
49
|
ref: l,
|
|
46
50
|
role: "alert",
|
|
47
|
-
onMouseEnter:
|
|
48
|
-
onMouseLeave:
|
|
51
|
+
onMouseEnter: D,
|
|
52
|
+
onMouseLeave: E,
|
|
49
53
|
children: [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
(
|
|
53
|
-
!!
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
|
|
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
|
-
!!
|
|
61
|
-
|
|
64
|
+
!!c && N && /* @__PURE__ */ a(
|
|
65
|
+
V,
|
|
62
66
|
{
|
|
63
|
-
variant:
|
|
64
|
-
duration:
|
|
65
|
-
isPaused:
|
|
67
|
+
variant: h,
|
|
68
|
+
duration: c,
|
|
69
|
+
isPaused: n
|
|
66
70
|
}
|
|
67
71
|
)
|
|
68
72
|
] }),
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
L && /* @__PURE__ */ a(
|
|
74
|
+
G,
|
|
71
75
|
{
|
|
72
|
-
onClick: () =>
|
|
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
|
-
|
|
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
|
-
|
|
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;
|