skillgrid 0.0.85 → 0.0.87
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/assets/components/Dialog/Dialog.module-BvSBnHQm.css +1 -0
- package/dist/assets/components/Snackbar/Provider/SnackbarProvider.module-CXp57W1g.css +1 -0
- package/dist/assets/components/Snackbar/Snackbar.module-gnMPmaUr.css +1 -0
- package/dist/components/Dialog/Dialog.js +23 -22
- package/dist/components/Dialog/Dialog.module.css.js +12 -12
- package/dist/components/Dialog/lib/use-dialog-draggable.d.ts +6 -2
- package/dist/components/Dialog/lib/use-dialog-draggable.js +91 -80
- package/dist/components/Snackbar/Provider/SnackbarProvider.js +153 -64
- package/dist/components/Snackbar/Provider/SnackbarProvider.module.css.js +14 -6
- package/dist/components/Snackbar/Provider/SnackbarProvider.type.d.ts +9 -4
- package/dist/components/Snackbar/Snackbar.js +172 -134
- package/dist/components/Snackbar/Snackbar.module.css.js +42 -40
- package/dist/components/Snackbar/Snackbar.type.d.ts +8 -1
- package/dist/components/Tabs/ScrollWrapper.js +10 -8
- package/dist/components/Tabs/Tabs.js +77 -76
- package/dist/components/Tabs/Tabs.type.d.ts +7 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.css +1 -1
- package/package.json +1 -1
- package/dist/assets/components/Dialog/Dialog.module-OXi8ThCq.css +0 -1
- package/dist/assets/components/Snackbar/Provider/SnackbarProvider.module-F1FVM9qU.css +0 -1
- package/dist/assets/components/Snackbar/Snackbar.module-KVPJ2b4w.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--dialog-margin: 12px;--dialog-border-radius: 24px}._overlay_12slx_6{position:fixed;top:0;right:0;bottom:0;left:0;overflow:hidden;display:flex;flex-direction:column;background:#00000080;transition:opacity .2s ease-in-out}._container_12slx_19{position:absolute;overflow:hidden;overflow-y:auto;min-width:300px;background:var(--bg-primary);border-radius:var(--dialog-border-radius);box-shadow:0 4px 24px #0000001a}._placement-default_12slx_32{top:0;left:50%;translate:-50% 0;max-width:90dvw;max-height:90dvh;margin-right:auto;margin-left:auto;margin-block:80px}._placement-bottom-left_12slx_45{bottom:0;left:0;max-width:90dvw;max-height:90dvh;margin:12px}._placement-bottom-right_12slx_54{right:0;bottom:0;max-width:90dvw;max-height:90dvh;margin:12px}._placement-center_12slx_64{position:fixed;top:50%;left:50%;translate:-50% -50%;max-width:90dvw;max-height:90dvh;margin-right:auto;margin-left:auto}._placement-left-drawer_12slx_77{inset:0 auto 0 0;margin:12px;border-radius:16px}._placement-right-drawer_12slx_83{inset:0 0 0 auto;margin:12px;border-radius:16px}._placement-bottom-sheet_12slx_89{inset:auto 0 0;max-width:100dvw;max-height:90dvh;margin:0;border-radius:var(--dialog-border-radius) var(--dialog-border-radius) 0 0}._grabber_12slx_100{touch-action:none;position:absolute;z-index:1000;width:40px;height:4px;opacity:.7;background:var(--stroke-neutral);border-radius:4px}._grabber_12slx_100:before{content:"";position:absolute;top:-10px;right:-10px;bottom:-10px;left:-10px}._container_12slx_19:hover ._grabber_12slx_100{opacity:1}._grabber-top_12slx_127,._grabber-bottom_12slx_128{top:10px;left:50%;transform:translate(-50%)}._grabber-right_12slx_134{top:50%;left:10px;transform:translateY(-50%);width:4px;height:40px}._grabber-left_12slx_143{top:50%;right:10px;transform:translateY(-50%);width:4px;height:40px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._stack_184s0_1{pointer-events:none;position:fixed;z-index:var(--z-toast);bottom:48px;left:50%;transform:translate(-50%);overflow-x:clip;display:flex;flex-direction:column;align-items:center;box-sizing:border-box;width:100%;padding:24px 24px 0}._stack_184s0_1._local_184s0_20{position:absolute;right:0;left:0;transform:none}._snackGroup_184s0_27{display:inline-flex;flex-direction:column;align-items:stretch;box-sizing:border-box;max-width:100%}._snackGroupHug_184s0_43{width:fit-content;max-width:100%}._snackGroupFix_184s0_54{width:600px;max-width:100%}._snackGroupFill_184s0_64{width:100%}._snackWrapper_184s0_68{pointer-events:none;display:flex;justify-content:center;width:100%;transition:transform var(--duration-400) var(--ease-in-out)}@media (width <= 600px){._stack_184s0_1{bottom:16px;padding:16px 16px 0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--snackbar-content-gap: 8px;--snackbar-content-big-gap: 11px;--snackbar-vertical-padding: 24px;--snackbar-horizontal-padding: 16px 24px;--snackbar-vertical-radius: 24px;--snackbar-horizontal-radius: 64px;--snackbar-bg: #000000;--snackbar-color: var(--text-text-invert, #ffffff)}._snackbar_92a88_13{pointer-events:all;will-change:transform,opacity;z-index:var(--z-toast);overflow:hidden;display:flex;gap:var(--snackbar-content-big-gap);align-items:center;justify-content:space-between;padding:var(--snackbar-horizontal-padding);font-family:var(--font-family);font-weight:400;color:var(--snackbar-color);background-color:var(--snackbar-bg);border-radius:var(--snackbar-horizontal-radius);transition:transform var(--duration-300) var(--ease-in-out),opacity var(--duration-300) var(--ease-in-out);animation-name:_slideIn_92a88_1;animation-duration:var(--duration-300);animation-timing-function:var(--ease-in-out);animation-fill-mode:both}._snackbarStack_92a88_44{animation-duration:var(--duration-400);animation-timing-function:var(--ease-in-out)}._snackbarVertical_92a88_49{align-items:start;padding:var(--snackbar-vertical-padding);border-radius:var(--snackbar-vertical-radius)}._fix_92a88_56{box-sizing:border-box;width:100%;max-width:600px}._fill_92a88_62{box-sizing:border-box;width:100%;max-width:none}._hug_92a88_68{display:inline-flex;width:auto;max-width:100%}._snackbar_92a88_13._stackWidth_92a88_80{box-sizing:border-box;width:100%;max-width:100%}._content_92a88_86{touch-action:auto;display:flex;gap:var(--snackbar-content-gap);align-items:center;width:100%}._textActionsContainer_92a88_96{display:flex;gap:var(--snackbar-content-big-gap);align-items:center;width:100%}._textActionsContainerVertical_92a88_103{flex-direction:column;align-items:start}._contentVertical_92a88_108{align-items:start}._contentText_92a88_112{width:100%;overflow-wrap:anywhere}._icon_92a88_117{width:24px;height:24px}._buttonLink_92a88_122{min-width:fit-content;font-weight:600}._exiting_92a88_128{animation-name:_slideOut_92a88_1;animation-fill-mode:both}._exitingTimeout_92a88_134{animation-duration:var(--duration-500);animation-timing-function:var(--ease-in-out)}._exitingClose_92a88_139{animation-duration:var(--duration-100);animation-timing-function:var(--ease-in-out)}._exitingStack_92a88_145{animation-duration:var(--duration-400);animation-timing-function:var(--ease-in-out);animation-fill-mode:both}._swipeTransition_92a88_151{transition:transform var(--duration-300) var(--ease-in-out),opacity var(--duration-300) var(--ease-in-out)}._exitingEscape_92a88_157{animation-duration:var(--duration-100);animation-timing-function:var(--ease-in-out)}@keyframes _slideOut_92a88_1{0%{transform:translateY(0) scale(1);opacity:1}to{transform:translateY(100%) scale(.75);opacity:0}}@keyframes _slideIn_92a88_1{0%{transform:translateY(100%) scale(.75);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { useMergeRefs as w, FloatingPortal as V, FloatingOverlay as E, FloatingFocusManager as $ } from "@floating-ui/react";
|
|
3
|
-
import
|
|
3
|
+
import a from "./Dialog.module.css.js";
|
|
4
4
|
import { forwardRef as j } from "react";
|
|
5
5
|
import { clsx as c } from "clsx";
|
|
6
6
|
import { useDialogDraggable as I } from "./lib/use-dialog-draggable.js";
|
|
7
7
|
import { useVisualViewportCenter as M } from "./lib/use-visual-viewport-center.js";
|
|
8
|
-
const
|
|
8
|
+
const B = j((f, u) => {
|
|
9
9
|
const {
|
|
10
10
|
placement: i = "default",
|
|
11
11
|
open: d,
|
|
12
|
-
onOpenChange:
|
|
12
|
+
onOpenChange: g,
|
|
13
13
|
overlayProps: e,
|
|
14
14
|
portalProps: b,
|
|
15
|
-
focusManagement:
|
|
15
|
+
focusManagement: r,
|
|
16
16
|
children: h,
|
|
17
17
|
disableOutsideClick: N = !1,
|
|
18
18
|
disableEscapeKey: O = !1,
|
|
@@ -22,29 +22,29 @@ const G = j((p, u) => {
|
|
|
22
22
|
style: D,
|
|
23
23
|
"data-testid": s,
|
|
24
24
|
...F
|
|
25
|
-
} =
|
|
25
|
+
} = f;
|
|
26
26
|
d === void 0 && process.env.NODE_ENV !== "production" && console.error(
|
|
27
27
|
"Dialog: компонент должен быть контролируемым. Используйте пропсы open и onOpenChange."
|
|
28
28
|
);
|
|
29
|
-
const
|
|
29
|
+
const o = I({
|
|
30
30
|
open: d,
|
|
31
|
-
onOpenChange:
|
|
31
|
+
onOpenChange: g,
|
|
32
32
|
placement: i,
|
|
33
33
|
disableEscapeKey: O,
|
|
34
34
|
closeOnDrag: l
|
|
35
|
-
}), { isMounted:
|
|
36
|
-
N ||
|
|
35
|
+
}), { isMounted: m, transitionStyles: t } = o, y = M(i === "center" && m), v = w([u, o.refs.setFloating]), k = () => {
|
|
36
|
+
N || g(!1);
|
|
37
37
|
};
|
|
38
|
-
return
|
|
38
|
+
return m ? (
|
|
39
39
|
// `FloatingPortal` рендерит диалог в корне `document.body`,
|
|
40
40
|
// чтобы избежать проблем с z-index и overflow.
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ p(V, { ...b, children: [
|
|
42
42
|
!x && /* @__PURE__ */ n(
|
|
43
43
|
E,
|
|
44
44
|
{
|
|
45
45
|
onPointerDown: k,
|
|
46
46
|
"data-testid": "dialog-overlay",
|
|
47
|
-
className: c(
|
|
47
|
+
className: c(a.overlay, e == null ? void 0 : e.className),
|
|
48
48
|
lockScroll: (e == null ? void 0 : e.lockScroll) ?? !0,
|
|
49
49
|
style: {
|
|
50
50
|
// Стили для анимации прозрачности оверлея
|
|
@@ -58,35 +58,36 @@ const G = j((p, u) => {
|
|
|
58
58
|
$,
|
|
59
59
|
{
|
|
60
60
|
initialFocus: 1 / 0,
|
|
61
|
-
...
|
|
62
|
-
context: { ...
|
|
63
|
-
children: /* @__PURE__ */
|
|
61
|
+
...r,
|
|
62
|
+
context: { ...o.context, ...r == null ? void 0 : r.context },
|
|
63
|
+
children: /* @__PURE__ */ p(
|
|
64
64
|
"section",
|
|
65
65
|
{
|
|
66
66
|
ref: v,
|
|
67
67
|
"aria-modal": "true",
|
|
68
68
|
role: "dialog",
|
|
69
|
-
className: c(C,
|
|
69
|
+
className: c(C, a.container, a[`placement-${i}`]),
|
|
70
70
|
style: {
|
|
71
71
|
...y ?? {},
|
|
72
72
|
...D,
|
|
73
73
|
...t
|
|
74
74
|
},
|
|
75
75
|
"data-testid": s,
|
|
76
|
-
...
|
|
76
|
+
...o.getFloatingProps(F),
|
|
77
77
|
children: [
|
|
78
78
|
h,
|
|
79
79
|
l && /* @__PURE__ */ n(
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
82
82
|
className: c(
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
a.grabber,
|
|
84
|
+
a[`grabber-${l.direction}`]
|
|
85
85
|
// classNames?.grabber,
|
|
86
86
|
),
|
|
87
87
|
role: "presentation",
|
|
88
88
|
"aria-hidden": "true",
|
|
89
|
-
"data-testid": s ? `${s}-grabber` : void 0
|
|
89
|
+
"data-testid": s ? `${s}-grabber` : void 0,
|
|
90
|
+
...o.getGrabberProps()
|
|
90
91
|
}
|
|
91
92
|
)
|
|
92
93
|
]
|
|
@@ -98,5 +99,5 @@ const G = j((p, u) => {
|
|
|
98
99
|
) : null;
|
|
99
100
|
});
|
|
100
101
|
export {
|
|
101
|
-
|
|
102
|
+
B as Dialog
|
|
102
103
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import '../../assets/components/Dialog/Dialog.module-
|
|
1
|
+
import '../../assets/components/Dialog/Dialog.module-BvSBnHQm.css';const e = "_overlay_12slx_6", t = "_container_12slx_19", r = "_grabber_12slx_100", _ = {
|
|
2
2
|
overlay: e,
|
|
3
3
|
container: t,
|
|
4
|
-
"placement-default": "_placement-
|
|
5
|
-
"placement-bottom-left": "_placement-bottom-
|
|
6
|
-
"placement-bottom-right": "_placement-bottom-
|
|
7
|
-
"placement-center": "_placement-
|
|
8
|
-
"placement-left-drawer": "_placement-left-
|
|
9
|
-
"placement-right-drawer": "_placement-right-
|
|
10
|
-
"placement-bottom-sheet": "_placement-bottom-
|
|
4
|
+
"placement-default": "_placement-default_12slx_32",
|
|
5
|
+
"placement-bottom-left": "_placement-bottom-left_12slx_45",
|
|
6
|
+
"placement-bottom-right": "_placement-bottom-right_12slx_54",
|
|
7
|
+
"placement-center": "_placement-center_12slx_64",
|
|
8
|
+
"placement-left-drawer": "_placement-left-drawer_12slx_77",
|
|
9
|
+
"placement-right-drawer": "_placement-right-drawer_12slx_83",
|
|
10
|
+
"placement-bottom-sheet": "_placement-bottom-sheet_12slx_89",
|
|
11
11
|
grabber: r,
|
|
12
|
-
"grabber-top": "_grabber-
|
|
13
|
-
"grabber-bottom": "_grabber-
|
|
14
|
-
"grabber-right": "_grabber-
|
|
15
|
-
"grabber-left": "_grabber-
|
|
12
|
+
"grabber-top": "_grabber-top_12slx_127",
|
|
13
|
+
"grabber-bottom": "_grabber-bottom_12slx_128",
|
|
14
|
+
"grabber-right": "_grabber-right_12slx_134",
|
|
15
|
+
"grabber-left": "_grabber-left_12slx_143"
|
|
16
16
|
};
|
|
17
17
|
export {
|
|
18
18
|
t as container,
|
|
@@ -6,9 +6,12 @@ type UseDialogDraggableOptions = Pick<DialogProps, 'placement' | 'open' | 'disab
|
|
|
6
6
|
* Оборачивает `useDialog` и добавляет обработчики событий указателя (`PointerEvents`)
|
|
7
7
|
* для отслеживания перетаскивания и закрытия диалога при превышении порога.
|
|
8
8
|
*
|
|
9
|
+
* Обработчики вешаются на граббер (`getGrabberProps`), а не на корень диалога: у контейнера
|
|
10
|
+
* есть `overflow-y: auto`, и на touch вертикальный жест иначе уходит в скролл.
|
|
11
|
+
*
|
|
9
12
|
* @param {UseDialogDraggableOptions} options - Опции для конфигурации хука.
|
|
10
13
|
* @returns Возвращает объект с данными и пропсами, аналогичный `useDialog`,
|
|
11
|
-
* но с модифицированными `transitionStyles` и `
|
|
14
|
+
* но с модифицированными `transitionStyles` и `getGrabberProps` для поддержки перетаскивания.
|
|
12
15
|
*/
|
|
13
16
|
export declare function useDialogDraggable({ open, onOpenChange, placement, disableEscapeKey, closeOnDrag, }: UseDialogDraggableOptions): {
|
|
14
17
|
isMounted: boolean;
|
|
@@ -37,6 +40,7 @@ export declare function useDialogDraggable({ open, onOpenChange, placement, disa
|
|
|
37
40
|
setFloating: (node: HTMLElement | null) => void;
|
|
38
41
|
} & import('@floating-ui/react').ExtendedRefs<import('@floating-ui/react').ReferenceType>;
|
|
39
42
|
transitionStyles: CSSProperties;
|
|
40
|
-
getFloatingProps: (userProps
|
|
43
|
+
getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
|
|
44
|
+
getGrabberProps: () => HTMLProps<HTMLDivElement> | undefined;
|
|
41
45
|
};
|
|
42
46
|
export {};
|
|
@@ -1,97 +1,108 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useDialog as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useRef as w, useState as A, useEffect as _, useCallback as p, useMemo as L } from "react";
|
|
2
|
+
import { useDialog as F } from "./use-dialog.js";
|
|
3
|
+
const G = 80;
|
|
4
|
+
function U(s, a, u, h) {
|
|
5
|
+
switch (s) {
|
|
6
|
+
case "bottom":
|
|
7
|
+
return Math.max(0, u);
|
|
8
|
+
// Разрешаем движение только вниз
|
|
9
|
+
case "top":
|
|
10
|
+
return Math.max(0, -u);
|
|
11
|
+
// Движение вверх (отрицательный dy)
|
|
12
|
+
case "right":
|
|
13
|
+
return Math.max(0, a);
|
|
14
|
+
// Только вправо
|
|
15
|
+
case "left":
|
|
16
|
+
return Math.max(0, -a);
|
|
17
|
+
// Только влево (отрицательный dx)
|
|
18
|
+
default:
|
|
19
|
+
return h ? u : a;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function $({
|
|
23
|
+
open: s,
|
|
24
|
+
onOpenChange: a,
|
|
25
|
+
placement: u = "center",
|
|
26
|
+
disableEscapeKey: h = !1,
|
|
27
|
+
closeOnDrag: o
|
|
10
28
|
}) {
|
|
11
|
-
const { getFloatingProps:
|
|
12
|
-
open:
|
|
13
|
-
onOpenChange:
|
|
14
|
-
placement:
|
|
15
|
-
disableEscapeKey:
|
|
16
|
-
}), r =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
const
|
|
29
|
+
const { getFloatingProps: M, transitionStyles: l, isMounted: X, context: Y, refs: y } = F({
|
|
30
|
+
open: s,
|
|
31
|
+
onOpenChange: a,
|
|
32
|
+
placement: u,
|
|
33
|
+
disableEscapeKey: h
|
|
34
|
+
}), r = w({ startX: 0, startY: 0, dragging: !1 }), f = w(0), [S, P] = A(!1), [g, d] = A(0), e = o == null ? void 0 : o.direction, D = (o == null ? void 0 : o.threshold) ?? G, i = e === "top" || e === "bottom", n = s && !!e;
|
|
35
|
+
_(() => {
|
|
36
|
+
s || (r.current.dragging = !1, P(!1), f.current = 0, d(0));
|
|
37
|
+
}, [s]);
|
|
38
|
+
const T = p(
|
|
21
39
|
(t) => {
|
|
22
|
-
|
|
40
|
+
if (n) {
|
|
41
|
+
t.preventDefault(), t.stopPropagation(), r.current.startX = t.clientX, r.current.startY = t.clientY, r.current.dragging = !0, f.current = 0, P(!0), d(0);
|
|
42
|
+
try {
|
|
43
|
+
t.currentTarget.setPointerCapture(t.pointerId);
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
}
|
|
23
47
|
},
|
|
24
|
-
[
|
|
25
|
-
),
|
|
48
|
+
[n]
|
|
49
|
+
), v = p(
|
|
26
50
|
(t) => {
|
|
27
|
-
if (!r.current.dragging || !
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
switch (a) {
|
|
31
|
-
case "bottom":
|
|
32
|
-
c = Math.max(0, s);
|
|
33
|
-
break;
|
|
34
|
-
case "top":
|
|
35
|
-
c = Math.max(0, -s);
|
|
36
|
-
break;
|
|
37
|
-
case "right":
|
|
38
|
-
c = Math.max(0, n);
|
|
39
|
-
break;
|
|
40
|
-
case "left":
|
|
41
|
-
c = Math.max(0, -n);
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
c = l ? s : n;
|
|
45
|
-
}
|
|
46
|
-
g(c);
|
|
51
|
+
if (!r.current.dragging || !n) return;
|
|
52
|
+
const c = t.clientX - r.current.startX, b = t.clientY - r.current.startY, x = U(e, c, b, i);
|
|
53
|
+
f.current = x, d(x);
|
|
47
54
|
},
|
|
48
|
-
[
|
|
49
|
-
), m =
|
|
55
|
+
[n, e, i]
|
|
56
|
+
), m = p(
|
|
50
57
|
(t) => {
|
|
51
|
-
var
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
o >= M ? h(!1) : g(0);
|
|
58
|
+
var I, R;
|
|
59
|
+
if (!r.current.dragging || !n) return;
|
|
60
|
+
r.current.dragging = !1, P(!1);
|
|
61
|
+
try {
|
|
62
|
+
(R = (I = t.currentTarget).hasPointerCapture) != null && R.call(I, t.pointerId) && t.currentTarget.releasePointerCapture(t.pointerId);
|
|
63
|
+
} catch {
|
|
59
64
|
}
|
|
65
|
+
const c = t.clientX - r.current.startX, b = t.clientY - r.current.startY;
|
|
66
|
+
Math.max(
|
|
67
|
+
f.current,
|
|
68
|
+
U(e, c, b, i)
|
|
69
|
+
) >= D ? a(!1) : (f.current = 0, d(0));
|
|
60
70
|
},
|
|
61
|
-
[
|
|
62
|
-
),
|
|
63
|
-
if (!
|
|
64
|
-
if (
|
|
65
|
-
const t = { ...
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
t.transform =
|
|
71
|
+
[D, a, n, e, i]
|
|
72
|
+
), C = L(() => {
|
|
73
|
+
if (!n) return l;
|
|
74
|
+
if (S) {
|
|
75
|
+
const t = { ...l, transitionProperty: "none" };
|
|
76
|
+
if (g > 0) {
|
|
77
|
+
const c = e === "left" || e === "top" ? -g : g;
|
|
78
|
+
t.transform = i ? `translateY(${c}px)` : `translateX(${c}px)`;
|
|
69
79
|
}
|
|
70
80
|
return t;
|
|
71
81
|
}
|
|
72
|
-
return
|
|
73
|
-
}, [
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
return
|
|
82
|
+
return l;
|
|
83
|
+
}, [l, g, n, i, e, S]), E = p(() => {
|
|
84
|
+
if (n)
|
|
85
|
+
return {
|
|
86
|
+
onPointerDown: T,
|
|
87
|
+
onPointerUp: m,
|
|
88
|
+
onPointerMove: v,
|
|
89
|
+
onPointerCancel: m,
|
|
90
|
+
// Отмена (например, уход фокуса) также завершает перетаскивание
|
|
91
|
+
style: { touchAction: "none" }
|
|
92
|
+
};
|
|
93
|
+
}, [T, v, m, n]);
|
|
94
|
+
return L(
|
|
85
95
|
() => ({
|
|
86
|
-
isMounted:
|
|
87
|
-
context:
|
|
88
|
-
refs:
|
|
89
|
-
transitionStyles:
|
|
90
|
-
getFloatingProps:
|
|
96
|
+
isMounted: X,
|
|
97
|
+
context: Y,
|
|
98
|
+
refs: y,
|
|
99
|
+
transitionStyles: C,
|
|
100
|
+
getFloatingProps: M,
|
|
101
|
+
getGrabberProps: E
|
|
91
102
|
}),
|
|
92
|
-
[
|
|
103
|
+
[X, C, M, E, Y, y]
|
|
93
104
|
);
|
|
94
105
|
}
|
|
95
106
|
export {
|
|
96
|
-
|
|
107
|
+
$ as useDialogDraggable
|
|
97
108
|
};
|
|
@@ -1,76 +1,165 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useReducer as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { nanoid as
|
|
6
|
-
import
|
|
7
|
-
import { Snackbar as
|
|
8
|
-
import { snackbarReducer as
|
|
9
|
-
import { MAX_VISIBLE as
|
|
10
|
-
import { SnackbarContext as
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { jsx as u, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import { useReducer as O, useEffect as v, useRef as T, useState as S, useLayoutEffect as x } from "react";
|
|
3
|
+
import E from "react-dom";
|
|
4
|
+
import N from "classnames";
|
|
5
|
+
import { nanoid as W } from "nanoid";
|
|
6
|
+
import l from "./SnackbarProvider.module.css.js";
|
|
7
|
+
import { Snackbar as C } from "../Snackbar.js";
|
|
8
|
+
import { snackbarReducer as I } from "../lib/snackbarReducer/snackbarReducer.js";
|
|
9
|
+
import { MAX_VISIBLE as k } from "../lib/constants.js";
|
|
10
|
+
import { SnackbarContext as G } from "../lib/useSnackbar.js";
|
|
11
|
+
const f = {
|
|
12
|
+
hug: 0,
|
|
13
|
+
fix: 1,
|
|
14
|
+
fill: 2
|
|
15
|
+
}, H = (n) => n.reduce((d, p) => {
|
|
16
|
+
const t = p.mode ?? "fix";
|
|
17
|
+
return f[t] > f[d] ? t : d;
|
|
18
|
+
}, "hug"), R = ({
|
|
19
|
+
snacks: n,
|
|
20
|
+
dataTestId: d,
|
|
21
|
+
onClose: p
|
|
22
|
+
}) => {
|
|
23
|
+
const t = T(null), [s, h] = S("hug"), [m, g] = S(0), a = H(n), c = n.length > 0 && f[a] > f[s] ? a : s;
|
|
24
|
+
x(() => {
|
|
25
|
+
if (n.length === 0) {
|
|
26
|
+
h("hug"), g(0);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
h((r) => f[a] > f[r] ? a : r);
|
|
30
|
+
}, [n.length, a]), x(() => {
|
|
31
|
+
if (n.length === 0 || c !== "hug")
|
|
32
|
+
return;
|
|
33
|
+
const r = t.current;
|
|
34
|
+
if (!r) return;
|
|
35
|
+
const e = () => {
|
|
36
|
+
const i = r.getBoundingClientRect().width;
|
|
37
|
+
g(
|
|
38
|
+
(y) => Math.max(y, i)
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
e();
|
|
42
|
+
const o = new ResizeObserver(e);
|
|
43
|
+
return o.observe(r), () => o.disconnect();
|
|
44
|
+
}, [c, n.length]);
|
|
45
|
+
const b = n.length > 1;
|
|
46
|
+
return /* @__PURE__ */ u(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
ref: t,
|
|
50
|
+
className: N(l.snackGroup, {
|
|
51
|
+
[l.snackGroupHug]: c === "hug",
|
|
52
|
+
[l.snackGroupFix]: c === "fix",
|
|
53
|
+
[l.snackGroupFill]: c === "fill"
|
|
54
|
+
}),
|
|
55
|
+
style: m > 0 ? {
|
|
56
|
+
/**
|
|
57
|
+
* Сохранённая hug-ширина продолжает действовать
|
|
58
|
+
* и после перехода в fix/fill.
|
|
59
|
+
*
|
|
60
|
+
* Например:
|
|
61
|
+
* hug 820px -> fix не должен уменьшить стек до 600px.
|
|
62
|
+
*/
|
|
63
|
+
minWidth: `min(${m}px, 100%)`
|
|
64
|
+
} : void 0,
|
|
65
|
+
children: n.map((r, e) => {
|
|
66
|
+
const o = (n.length - 1 - e) * -8;
|
|
67
|
+
return /* @__PURE__ */ u(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
"data-testid": d,
|
|
71
|
+
className: l.snackWrapper,
|
|
72
|
+
style: {
|
|
73
|
+
transform: `translateY(${o}px)`
|
|
74
|
+
},
|
|
75
|
+
children: /* @__PURE__ */ u(
|
|
76
|
+
C,
|
|
77
|
+
{
|
|
78
|
+
...r,
|
|
79
|
+
open: !r.exiting,
|
|
80
|
+
isStack: b,
|
|
81
|
+
stretchToStack: !0,
|
|
82
|
+
forceClose: r.exiting,
|
|
83
|
+
onClose: () => p(r.id)
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
},
|
|
87
|
+
r.id
|
|
88
|
+
);
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}, B = (n) => {
|
|
93
|
+
const { children: d, dataTestId: p = "snackbar-wrapper" } = n, [t, s] = O(I, {
|
|
94
|
+
visible: [],
|
|
95
|
+
queue: []
|
|
96
|
+
}), h = (e) => {
|
|
97
|
+
const o = W(), i = {
|
|
98
|
+
...e,
|
|
99
|
+
id: o,
|
|
100
|
+
open: !0
|
|
101
|
+
};
|
|
102
|
+
s({
|
|
103
|
+
type: "ENQUEUE",
|
|
104
|
+
snack: i
|
|
105
|
+
});
|
|
106
|
+
}, m = (e) => {
|
|
107
|
+
s({
|
|
108
|
+
type: "REMOVE",
|
|
109
|
+
id: e
|
|
110
|
+
});
|
|
17
111
|
};
|
|
18
|
-
|
|
112
|
+
v(() => {
|
|
19
113
|
s({ type: "SHOW_NEXT" });
|
|
20
|
-
}, [
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
const e =
|
|
24
|
-
s({
|
|
114
|
+
}, [t.queue, t.visible]), v(() => {
|
|
115
|
+
if (t.queue.length !== 0)
|
|
116
|
+
if (t.visible.length >= k) {
|
|
117
|
+
const e = t.visible[0];
|
|
118
|
+
s({
|
|
119
|
+
type: "START_EXIT",
|
|
120
|
+
id: e.id
|
|
121
|
+
});
|
|
25
122
|
} else
|
|
26
123
|
s({ type: "SHOW_NEXT" });
|
|
27
|
-
}, [
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const x = t.wasInStack || a ? "fix" : t.mode;
|
|
32
|
-
return /* @__PURE__ */ n(
|
|
33
|
-
"div",
|
|
124
|
+
}, [t.queue]);
|
|
125
|
+
const g = t.visible.filter((e) => !e.parent), a = t.visible.filter((e) => e.parent), c = E.createPortal(
|
|
126
|
+
/* @__PURE__ */ u("div", { className: l.stack, children: /* @__PURE__ */ u(
|
|
127
|
+
R,
|
|
34
128
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
children: /* @__PURE__ */ n(
|
|
41
|
-
w,
|
|
42
|
-
{
|
|
43
|
-
...t,
|
|
44
|
-
open: !t.exiting,
|
|
45
|
-
isStack: a,
|
|
46
|
-
mode: x,
|
|
47
|
-
forceClose: t.exiting,
|
|
48
|
-
onClose: () => S(t.id)
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
},
|
|
52
|
-
t.id
|
|
53
|
-
);
|
|
54
|
-
}), b = o.visible.filter((e) => !e.parent), h = o.visible.filter((e) => e.parent), v = d.createPortal(
|
|
55
|
-
/* @__PURE__ */ n("div", { className: i.stack, children: l(b) }),
|
|
129
|
+
snacks: g,
|
|
130
|
+
dataTestId: p,
|
|
131
|
+
onClose: m
|
|
132
|
+
}
|
|
133
|
+
) }),
|
|
56
134
|
document.body
|
|
57
|
-
),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
135
|
+
), b = a.reduce(
|
|
136
|
+
(e, o) => {
|
|
137
|
+
if (!o.parent) return e;
|
|
138
|
+
const i = o.parent.id || `parent-${o.parent.className}`;
|
|
139
|
+
return (e[i] || (e[i] = [])).push(o), e;
|
|
140
|
+
},
|
|
141
|
+
{}
|
|
142
|
+
), r = Object.entries(b).map(([e, o]) => {
|
|
143
|
+
const i = o[0];
|
|
144
|
+
return i.parent ? E.createPortal(
|
|
145
|
+
/* @__PURE__ */ u("div", { className: N(l.stack, l.local), children: /* @__PURE__ */ u(
|
|
146
|
+
R,
|
|
147
|
+
{
|
|
148
|
+
snacks: o,
|
|
149
|
+
dataTestId: p,
|
|
150
|
+
onClose: m
|
|
151
|
+
}
|
|
152
|
+
) }),
|
|
153
|
+
i.parent,
|
|
154
|
+
e
|
|
66
155
|
) : null;
|
|
67
156
|
});
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
157
|
+
return /* @__PURE__ */ M(G.Provider, { value: { show: h }, children: [
|
|
158
|
+
d,
|
|
159
|
+
c,
|
|
160
|
+
r
|
|
72
161
|
] });
|
|
73
162
|
};
|
|
74
163
|
export {
|
|
75
|
-
|
|
164
|
+
B as SnackbarProvider
|
|
76
165
|
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import '../../../assets/components/Snackbar/Provider/SnackbarProvider.module-
|
|
2
|
-
stack:
|
|
1
|
+
import '../../../assets/components/Snackbar/Provider/SnackbarProvider.module-CXp57W1g.css';const s = "_stack_184s0_1", c = "_local_184s0_20", a = "_snackGroup_184s0_27", o = "_snackGroupHug_184s0_43", n = "_snackGroupFix_184s0_54", _ = "_snackGroupFill_184s0_64", p = "_snackWrapper_184s0_68", r = {
|
|
2
|
+
stack: s,
|
|
3
3
|
local: c,
|
|
4
|
-
|
|
4
|
+
snackGroup: a,
|
|
5
|
+
snackGroupHug: o,
|
|
6
|
+
snackGroupFix: n,
|
|
7
|
+
snackGroupFill: _,
|
|
8
|
+
snackWrapper: p
|
|
5
9
|
};
|
|
6
10
|
export {
|
|
7
|
-
|
|
11
|
+
r as default,
|
|
8
12
|
c as local,
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
a as snackGroup,
|
|
14
|
+
_ as snackGroupFill,
|
|
15
|
+
n as snackGroupFix,
|
|
16
|
+
o as snackGroupHug,
|
|
17
|
+
p as snackWrapper,
|
|
18
|
+
s as stack
|
|
11
19
|
};
|