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.
@@ -3,9 +3,10 @@ import { SnackbarProps } from '../Snackbar.type';
3
3
  * Параметры, которые можно передать в метод `show()` для отображения Snackbar.
4
4
  * Наследует все пропсы Snackbar, кроме управляемых провайдером (`open`, `onClose`).
5
5
  */
6
- export type ShowSnackbarProps = Omit<SnackbarProps, 'open' | 'onClose' | 'isStack' | 'forceClose'> & {
6
+ export type ShowSnackbarProps = Omit<SnackbarProps, 'open' | 'onClose' | 'isStack' | 'forceClose' | 'stretchToStack'> & {
7
7
  /**
8
- * Контейнер, в котором Snackbar будет показан (по умолчанию — `document.body`).
8
+ * Контейнер, в котором Snackbar будет показан
9
+ * (по умолчанию — document.body).
9
10
  */
10
11
  parent?: HTMLElement;
11
12
  };
@@ -20,8 +21,12 @@ export interface InternalSnackbar extends ShowSnackbarProps {
20
21
  open: boolean;
21
22
  /** Флаг завершения анимации (используется при скрытии). */
22
23
  exiting?: boolean;
23
- /** Флаг, указывающий, что Snackbar когда-либо находился в стеке */
24
- wasInStack?: boolean;
24
+ }
25
+ export type StackWidthMode = NonNullable<InternalSnackbar['mode']>;
26
+ export interface SnackbarGroupProps {
27
+ snacks: InternalSnackbar[];
28
+ dataTestId: string;
29
+ onClose: (id: string) => void;
25
30
  }
26
31
  /**
27
32
  * Интерфейс контекста Snackbar-провайдера.
@@ -1,157 +1,195 @@
1
1
  import { jsxs as w, jsx as n } from "react/jsx-runtime";
2
- import { forwardRef as W, useRef as i, useState as x, useEffect as a } from "react";
2
+ import { forwardRef as Z, useRef as s, useState as x, useEffect as a } from "react";
3
+ import S from "classnames";
3
4
  import e from "./Snackbar.module.css.js";
4
- import b from "classnames";
5
- import { useSwipe as Z } from "./lib/useSwipe.js";
6
- import { Typography as _ } from "../Typography/Typography.js";
5
+ import { useSwipe as _ } from "./lib/useSwipe.js";
6
+ import { Typography as $ } from "../Typography/Typography.js";
7
7
  import { Button as E } from "../Button/Button.js";
8
- import { CloseIcon as $ } from "./assets/close.js";
9
- import { stackDurationMap as tt, durationMap as et, animationMap as nt } from "./lib/constants.js";
10
- import { Loader as ot } from "../Loader/Loader.js";
8
+ import { CloseIcon as tt } from "./assets/close.js";
9
+ import { stackDurationMap as et, durationMap as nt, animationMap as ot } from "./lib/constants.js";
10
+ import { Loader as st } from "../Loader/Loader.js";
11
11
  import { InfoIcon as it } from "./assets/info.js";
12
- import { ErrorIcon as st } from "./assets/error.js";
13
- import { SuccessIcon as rt } from "./assets/success.js";
14
- const xt = W((M, u) => {
15
- const {
16
- open: o,
17
- variant: d = "info",
18
- mode: H = "fix",
19
- onClose: p,
20
- autoHideDuration: S = 6e3,
21
- disableAutoHide: h = !1,
22
- showButtonClose: A = !0,
23
- showIcon: B = !0,
24
- content: v,
25
- classNameSnackbarRoot: D,
26
- icon: N,
27
- isStack: k = !1,
28
- forceClose: R,
29
- linkButtonProps: y,
30
- closeOnLinkClick: V = !0,
31
- "data-testid": j = "snackbar"
32
- } = M, L = i(null), T = i(null), [g, z] = x(!1), [l, m] = x(!1), [C, f] = x(), F = i(0), O = i(0), X = i(0), Y = i(0), q = i(!1), s = i(null), c = (t) => {
33
- clearTimeout(s.current || 0), s.current = null;
34
- const r = k ? tt[t] : et[t];
35
- t === "swipe" || (m(!0), f(t)), s.current = setTimeout(() => {
36
- p == null || p(), m(!1), f(void 0), s.current = null;
37
- }, r);
38
- };
39
- Z({
40
- ref: T,
41
- open: o,
42
- onClose: c,
43
- setExiting: m,
44
- setExitReason: f,
45
- swiping: q,
46
- startX: F,
47
- startY: O,
48
- currentX: X,
49
- currentY: Y
50
- }), a(() => {
51
- R && c("close");
52
- }, [R]), a(() => {
53
- if (o && !h && d !== "loading") {
54
- const t = setTimeout(() => c("timeout"), S);
55
- return () => clearTimeout(t);
56
- }
57
- }, [o, h, d, S]), a(() => {
58
- o && (m(!1), f(void 0));
59
- }, [o]), a(() => {
60
- const t = L.current;
61
- t && requestAnimationFrame(() => {
62
- const r = parseFloat(getComputedStyle(t).lineHeight), I = t.offsetHeight, U = Math.round(I / r);
63
- z(U > 1);
64
- });
65
- }, [v]), a(() => {
66
- if (!o) return;
67
- const t = (r) => {
68
- r.key === "Escape" && c("escape");
12
+ import { ErrorIcon as rt } from "./assets/error.js";
13
+ import { SuccessIcon as ct } from "./assets/success.js";
14
+ const St = Z(
15
+ (M, u) => {
16
+ const {
17
+ open: o,
18
+ variant: d = "info",
19
+ mode: H = "fix",
20
+ onClose: p,
21
+ autoHideDuration: b = 6e3,
22
+ disableAutoHide: h = !1,
23
+ showButtonClose: A = !0,
24
+ showIcon: B = !0,
25
+ content: v,
26
+ classNameSnackbarRoot: D,
27
+ icon: N,
28
+ isStack: k = !1,
29
+ stretchToStack: V = !1,
30
+ forceClose: R,
31
+ linkButtonProps: y,
32
+ closeOnLinkClick: j = !0,
33
+ "data-testid": z = "snackbar"
34
+ } = M, T = s(null), L = s(null), [g, F] = x(!1), [l, m] = x(!1), [C, f] = x(), O = s(0), X = s(0), Y = s(0), q = s(0), K = s(!1), i = s(null), c = (t) => {
35
+ clearTimeout(i.current || 0), i.current = null;
36
+ const r = k ? et[t] : nt[t];
37
+ t === "swipe" || (m(!0), f(t)), i.current = setTimeout(() => {
38
+ p == null || p(), m(!1), f(void 0), i.current = null;
39
+ }, r);
69
40
  };
70
- return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
71
- }, [o]), a(() => () => {
72
- s.current && (clearTimeout(s.current), s.current = null);
73
- }, []);
74
- const K = l && C && e[nt[C]];
75
- if (!o && !l) return null;
76
- const P = {
77
- success: /* @__PURE__ */ n(rt, { className: e.icon }),
78
- error: /* @__PURE__ */ n(st, { className: e.icon }),
79
- info: /* @__PURE__ */ n(it, { className: e.icon }),
80
- loading: /* @__PURE__ */ n(ot, { "data-testid": "snackbar-icon-loading", variant: "contrast" })
81
- }, G = b(
82
- e.snackbar,
83
- e[H],
84
- { [e.exiting]: l && C },
85
- { [e.snackbarVertical]: g },
86
- D,
87
- K,
88
- {
89
- [e.snackbarStack]: k && !l,
90
- // при появлении стека
91
- [e.exitingStack]: k && l
92
- // при уходе стека
93
- }
94
- ), J = (t) => {
95
- T.current = t, u && (typeof u == "function" ? u(t) : u.current = t);
96
- }, Q = (t, r) => {
97
- t == null || t(r);
98
- };
99
- return /* @__PURE__ */ w("div", { ref: J, "data-testid": j, className: G, children: [
100
- /* @__PURE__ */ w(
41
+ _({
42
+ ref: L,
43
+ open: o,
44
+ onClose: c,
45
+ setExiting: m,
46
+ setExitReason: f,
47
+ swiping: K,
48
+ startX: O,
49
+ startY: X,
50
+ currentX: Y,
51
+ currentY: q
52
+ }), a(() => {
53
+ R && c("close");
54
+ }, [R]), a(() => {
55
+ if (o && !h && d !== "loading") {
56
+ const t = setTimeout(
57
+ () => c("timeout"),
58
+ b
59
+ );
60
+ return () => clearTimeout(t);
61
+ }
62
+ }, [
63
+ o,
64
+ h,
65
+ d,
66
+ b
67
+ ]), a(() => {
68
+ o && (m(!1), f(void 0));
69
+ }, [o]), a(() => {
70
+ const t = T.current;
71
+ t && requestAnimationFrame(() => {
72
+ const r = parseFloat(getComputedStyle(t).lineHeight), I = t.offsetHeight, U = Math.round(I / r);
73
+ F(U > 1);
74
+ });
75
+ }, [v]), a(() => {
76
+ if (!o) return;
77
+ const t = (r) => {
78
+ r.key === "Escape" && c("escape");
79
+ };
80
+ return window.addEventListener("keydown", t), () => {
81
+ window.removeEventListener("keydown", t);
82
+ };
83
+ }, [o]), a(() => () => {
84
+ i.current && (clearTimeout(i.current), i.current = null);
85
+ }, []);
86
+ const P = l && C && e[ot[C]];
87
+ if (!o && !l)
88
+ return null;
89
+ const W = {
90
+ success: /* @__PURE__ */ n(ct, { className: e.icon }),
91
+ error: /* @__PURE__ */ n(rt, { className: e.icon }),
92
+ info: /* @__PURE__ */ n(it, { className: e.icon }),
93
+ loading: /* @__PURE__ */ n(
94
+ st,
95
+ {
96
+ "data-testid": "snackbar-icon-loading",
97
+ variant: "contrast"
98
+ }
99
+ )
100
+ }, G = S(
101
+ e.snackbar,
102
+ e[H],
103
+ {
104
+ [e.exiting]: l && C
105
+ },
106
+ {
107
+ [e.snackbarVertical]: g
108
+ },
109
+ D,
110
+ P,
111
+ {
112
+ /*
113
+ * Ширина элемента в provider-стеке теперь не зависит
114
+ * от количества элементов.
115
+ *
116
+ * Даже когда после удаления остаётся один snackbar,
117
+ * он продолжает занимать сохранённую ширину группы.
118
+ */
119
+ [e.stackWidth]: V,
120
+ [e.snackbarStack]: k && !l,
121
+ [e.exitingStack]: k && l
122
+ }
123
+ ), J = (t) => {
124
+ L.current = t, u && (typeof u == "function" ? u(t) : u.current = t);
125
+ }, Q = (t, r) => {
126
+ t == null || t(r);
127
+ };
128
+ return /* @__PURE__ */ w(
101
129
  "div",
102
130
  {
103
- className: b(e.content, {
104
- [e.contentVertical]: g
105
- }),
131
+ ref: J,
132
+ "data-testid": z,
133
+ className: G,
106
134
  children: [
107
- B && /* @__PURE__ */ n("div", { className: e.icon, children: N || P[d] }),
108
135
  /* @__PURE__ */ w(
109
136
  "div",
110
137
  {
111
- className: b(e.textActionsContainer, {
112
- [e.textActionsContainerVertical]: g
138
+ className: S(e.content, {
139
+ [e.contentVertical]: g
113
140
  }),
114
141
  children: [
115
- /* @__PURE__ */ n(
116
- _.Label,
142
+ B && /* @__PURE__ */ n("div", { className: e.icon, children: N || W[d] }),
143
+ /* @__PURE__ */ w(
144
+ "div",
117
145
  {
118
- className: e.contentText,
119
- ref: L,
120
- typographyStyle: "contrast",
121
- children: v
122
- }
123
- ),
124
- y && /* @__PURE__ */ n(
125
- E.Link,
126
- {
127
- size: "s",
128
- className: e.buttonLink,
129
- buttonStyle: "contrast",
130
- ...y,
131
- onClick: (t) => {
132
- Q(y.onClick, t), V && c("timeout");
133
- }
146
+ className: S(e.textActionsContainer, {
147
+ [e.textActionsContainerVertical]: g
148
+ }),
149
+ children: [
150
+ /* @__PURE__ */ n(
151
+ $.Label,
152
+ {
153
+ className: e.contentText,
154
+ ref: T,
155
+ typographyStyle: "contrast",
156
+ children: v
157
+ }
158
+ ),
159
+ y && /* @__PURE__ */ n(
160
+ E.Link,
161
+ {
162
+ size: "s",
163
+ className: e.buttonLink,
164
+ buttonStyle: "contrast",
165
+ ...y,
166
+ onClick: (t) => {
167
+ Q(y.onClick, t), j && c("timeout");
168
+ }
169
+ }
170
+ )
171
+ ]
134
172
  }
135
173
  )
136
174
  ]
137
175
  }
176
+ ),
177
+ A && /* @__PURE__ */ n(
178
+ E,
179
+ {
180
+ iconLeft: /* @__PURE__ */ n(tt, {}),
181
+ onClick: () => c("close"),
182
+ mode: "tertiary",
183
+ size: "l",
184
+ buttonStyle: "contrast",
185
+ style: { padding: "0px" }
186
+ }
138
187
  )
139
188
  ]
140
189
  }
141
- ),
142
- A && /* @__PURE__ */ n(
143
- E,
144
- {
145
- iconLeft: /* @__PURE__ */ n($, {}),
146
- onClick: () => c("close"),
147
- mode: "tertiary",
148
- size: "l",
149
- buttonStyle: "contrast",
150
- style: { padding: "0px" }
151
- }
152
- )
153
- ] });
154
- });
190
+ );
191
+ }
192
+ );
155
193
  export {
156
- xt as Snackbar
194
+ St as Snackbar
157
195
  };
@@ -1,47 +1,49 @@
1
- import '../../assets/components/Snackbar/Snackbar.module-KVPJ2b4w.css';const t = "_snackbar_1j7iw_15", i = "_slideIn_1j7iw_1", n = "_snackbarStack_1j7iw_44", e = "_snackbarVertical_1j7iw_49", c = "_fix_1j7iw_57", _ = "_fill_1j7iw_63", o = "_hug_1j7iw_69", s = "_content_1j7iw_75", a = "_textActionsContainer_1j7iw_85", r = "_textActionsContainerVertical_1j7iw_92", x = "_contentVertical_1j7iw_97", l = "_contentText_1j7iw_101", w = "_icon_1j7iw_106", j = "_buttonLink_1j7iw_111", g = "_exiting_1j7iw_117", k = "_slideOut_1j7iw_1", u = "_exitingTimeout_1j7iw_123", b = "_exitingClose_1j7iw_128", C = "_exitingStack_1j7iw_135", T = "_swipeTransition_1j7iw_142", V = "_exitingEscape_1j7iw_148", d = {
1
+ import '../../assets/components/Snackbar/Snackbar.module-gnMPmaUr.css';const t = "_snackbar_92a88_13", n = "_slideIn_92a88_1", i = "_snackbarStack_92a88_44", a = "_snackbarVertical_92a88_49", c = "_fix_92a88_56", e = "_fill_92a88_62", _ = "_hug_92a88_68", s = "_stackWidth_92a88_80", o = "_content_92a88_86", r = "_textActionsContainer_92a88_96", x = "_textActionsContainerVertical_92a88_103", l = "_contentVertical_92a88_108", k = "_contentText_92a88_112", g = "_icon_92a88_117", u = "_buttonLink_92a88_122", b = "_exiting_92a88_128", d = "_slideOut_92a88_1", C = "_exitingTimeout_92a88_134", T = "_exitingClose_92a88_139", V = "_exitingStack_92a88_145", f = "_swipeTransition_92a88_151", p = "_exitingEscape_92a88_157", h = {
2
2
  snackbar: t,
3
- slideIn: i,
4
- snackbarStack: n,
5
- snackbarVertical: e,
3
+ slideIn: n,
4
+ snackbarStack: i,
5
+ snackbarVertical: a,
6
6
  fix: c,
7
- fill: _,
8
- hug: o,
9
- content: s,
10
- textActionsContainer: a,
11
- textActionsContainerVertical: r,
12
- contentVertical: x,
13
- contentText: l,
14
- icon: w,
15
- buttonLink: j,
16
- exiting: g,
17
- slideOut: k,
18
- exitingTimeout: u,
19
- exitingClose: b,
20
- exitingStack: C,
21
- swipeTransition: T,
22
- exitingEscape: V
7
+ fill: e,
8
+ hug: _,
9
+ stackWidth: s,
10
+ content: o,
11
+ textActionsContainer: r,
12
+ textActionsContainerVertical: x,
13
+ contentVertical: l,
14
+ contentText: k,
15
+ icon: g,
16
+ buttonLink: u,
17
+ exiting: b,
18
+ slideOut: d,
19
+ exitingTimeout: C,
20
+ exitingClose: T,
21
+ exitingStack: V,
22
+ swipeTransition: f,
23
+ exitingEscape: p
23
24
  };
24
25
  export {
25
- j as buttonLink,
26
- s as content,
27
- l as contentText,
28
- x as contentVertical,
29
- d as default,
30
- g as exiting,
31
- b as exitingClose,
32
- V as exitingEscape,
33
- C as exitingStack,
34
- u as exitingTimeout,
35
- _ as fill,
26
+ u as buttonLink,
27
+ o as content,
28
+ k as contentText,
29
+ l as contentVertical,
30
+ h as default,
31
+ b as exiting,
32
+ T as exitingClose,
33
+ p as exitingEscape,
34
+ V as exitingStack,
35
+ C as exitingTimeout,
36
+ e as fill,
36
37
  c as fix,
37
- o as hug,
38
- w as icon,
39
- i as slideIn,
40
- k as slideOut,
38
+ _ as hug,
39
+ g as icon,
40
+ n as slideIn,
41
+ d as slideOut,
41
42
  t as snackbar,
42
- n as snackbarStack,
43
- e as snackbarVertical,
44
- T as swipeTransition,
45
- a as textActionsContainer,
46
- r as textActionsContainerVertical
43
+ i as snackbarStack,
44
+ a as snackbarVertical,
45
+ s as stackWidth,
46
+ f as swipeTransition,
47
+ r as textActionsContainer,
48
+ x as textActionsContainerVertical
47
49
  };
@@ -77,8 +77,15 @@ export type SnackbarProps = {
77
77
  */
78
78
  linkButtonProps?: LinkButtonProps;
79
79
  /**
80
- * Если true — по клику на кнопку "Link" закроется снекбар
80
+ * Если true — по клику на кнопку "Link" закроется снекбар
81
81
  * По дефолту true
82
82
  */
83
83
  closeOnLinkClick?: boolean;
84
+ /**
85
+ * Растягивает Snackbar до ширины контейнера стека.
86
+ * Служебный prop SnackbarProvider.
87
+ *
88
+ * @internal
89
+ */
90
+ stretchToStack?: boolean;
84
91
  };
@@ -1,15 +1,15 @@
1
1
  import { jsxs as N, jsx as r } from "react/jsx-runtime";
2
2
  import { useRef as W, useState as g, useEffect as w } from "react";
3
- import { clsx as i } from "clsx";
3
+ import { clsx as a } from "clsx";
4
4
  import e from "./ScrollWrapper.module.css.js";
5
5
  import { useBackgroundColor as M } from "../../hooks/useBackgroundColor.js";
6
6
  const B = "white", G = ({
7
7
  children: b,
8
- withControls: a = !0,
8
+ withControls: i = !0,
9
9
  className: L,
10
10
  size: c
11
11
  }) => {
12
- const s = W(null), [d, C] = g(!1), [h, k] = g(!1), { ref: x, bgColor: R } = M(), E = x ?? { current: null }, f = R ?? B, u = a && d, m = a && h, v = ({ direction: t }) => /* @__PURE__ */ r(
12
+ const s = W(null), [d, C] = g(!1), [h, k] = g(!1), { ref: x, bgColor: R } = M(), E = x ?? { current: null }, f = R ?? B, u = i && d, m = i && h, v = ({ direction: t }) => /* @__PURE__ */ r(
13
13
  "svg",
14
14
  {
15
15
  height: "12px",
@@ -49,11 +49,11 @@ const B = "white", G = ({
49
49
  return t.addEventListener("scroll", l, { passive: !0 }), window.addEventListener("resize", l), () => {
50
50
  t.removeEventListener("scroll", l), window.removeEventListener("resize", l);
51
51
  };
52
- }, []), /* @__PURE__ */ N("div", { ref: E, className: i(e.wrapper, L), children: [
52
+ }, []), /* @__PURE__ */ N("div", { ref: E, className: a(e.wrapper, L), children: [
53
53
  u && /* @__PURE__ */ r(
54
54
  "div",
55
55
  {
56
- className: i(e.mask, e.maskLeft, d && e.visible),
56
+ className: a(e.mask, e.maskLeft, d && e.visible),
57
57
  style: {
58
58
  background: `linear-gradient(to right, ${f} 17%, transparent 80%)`
59
59
  }
@@ -62,7 +62,7 @@ const B = "white", G = ({
62
62
  m && /* @__PURE__ */ r(
63
63
  "div",
64
64
  {
65
- className: i(e.mask, e.maskRight, h && e.visible),
65
+ className: a(e.mask, e.maskRight, h && e.visible),
66
66
  style: {
67
67
  background: `linear-gradient(to left, ${f} 17%, transparent 80%)`
68
68
  }
@@ -75,7 +75,8 @@ const B = "white", G = ({
75
75
  type: "button",
76
76
  tabIndex: -1,
77
77
  "aria-hidden": "true",
78
- className: i(e.control, e.left, e[c]),
78
+ "data-testid": "tabs-scroll-control-left",
79
+ className: a(e.control, e.left, e[c]),
79
80
  onClick: () => p("left"),
80
81
  children: /* @__PURE__ */ r(v, { direction: "left" })
81
82
  }
@@ -86,7 +87,8 @@ const B = "white", G = ({
86
87
  type: "button",
87
88
  tabIndex: -1,
88
89
  "aria-hidden": "true",
89
- className: i(e.control, e.right, e[c]),
90
+ "data-testid": "tabs-scroll-control-right",
91
+ className: a(e.control, e.right, e[c]),
90
92
  onClick: () => p("right"),
91
93
  children: /* @__PURE__ */ r(v, { direction: "right" })
92
94
  }