@alphakits/ui 2.5.5 → 2.5.7

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.
@@ -1,16 +1,16 @@
1
1
  import { jsxs as E, jsx as l } from "react/jsx-runtime";
2
2
  import O from "@alphakits/icons/dist/CloseM";
3
3
  import C from "classnames";
4
- import { useState as L, useRef as w, useLayoutEffect as N, useEffect as k, useCallback as S } from "react";
4
+ import { useState as L, useRef as w, useLayoutEffect as N, useEffect as S, useCallback as k } from "react";
5
5
  import { Button as z } from "../../../button/component.js";
6
6
  import { showConfirm as j } from "../../../confirm-popup/component.js";
7
- import { useMatchMedia as B } from "../../../mq/use-match-media.js";
7
+ import { useMatchMedia as q } from "../../../mq/use-match-media.js";
8
8
  import s from "./index.module.css.js";
9
- const R = {
9
+ const T = {
10
10
  s: 488,
11
11
  m: 888,
12
12
  full: "96%"
13
- }, T = 102, D = "(max-width: 823px)", K = (e) => e === "full" ? `calc(-96vw - ${T}px)` : -R[e] - T, _ = [
13
+ }, A = 102, B = "(max-width: 823px)", D = (t) => t === "full" ? `calc(-96vw - ${A}px)` : -T[t] - A, K = [
14
14
  'a[href]:not([tabindex="-1"])',
15
15
  'area[href]:not([tabindex="-1"])',
16
16
  'button:not([disabled]):not([tabindex="-1"])',
@@ -25,76 +25,84 @@ const R = {
25
25
  'audio[controls]:not([tabindex="-1"])',
26
26
  'video[controls]:not([tabindex="-1"])',
27
27
  'details > summary:first-of-type:not([tabindex="-1"])'
28
- ].join(","), F = (e) => e ? Array.from(e.querySelectorAll(_)).filter((r) => {
28
+ ].join(","), F = (t) => t ? Array.from(t.querySelectorAll(K)).filter((r) => {
29
29
  if (r.hidden || r.getAttribute("aria-hidden") === "true") return !1;
30
30
  const a = window.getComputedStyle(r);
31
31
  return a.visibility === "hidden" || a.display === "none" ? !1 : r.offsetWidth > 0 || r.offsetHeight > 0 || r.getClientRects().length > 0;
32
- }) : [], W = ({ modal: e, t: c, index: r, dirtyModals: a, closeModal: m, currentModalId: u }) => {
33
- const A = K(e.props.size), [b] = B(D), [p, y] = L(!1), i = w(null), x = w(null);
32
+ }) : [], P = (t) => {
33
+ if (t.hasAttribute("data-modal-no-autofocus") || t.hasAttribute("aria-haspopup") || t.hasAttribute("aria-autocomplete")) return !0;
34
+ const n = t.getAttribute("role");
35
+ return !!(n === "combobox" || n === "listbox" || t.querySelector('[role="combobox"],[aria-haspopup],[aria-autocomplete]'));
36
+ }, _ = (t) => {
37
+ if (!t) return null;
38
+ const n = t.querySelector("[data-modal-autofocus]");
39
+ return n || F(t).find((d) => !P(d)) || t;
40
+ }, J = ({ modal: t, t: n, index: r, dirtyModals: a, closeModal: d, currentModalId: u }) => {
41
+ const R = D(t.props.size), [m] = q(B), [p, h] = L(!1), c = w(null), x = w(null);
34
42
  N(() => {
35
- const o = requestAnimationFrame(() => y(!0));
43
+ const o = requestAnimationFrame(() => h(!0));
36
44
  return () => cancelAnimationFrame(o);
37
- }, [e.id]), k(() => {
38
- if (e.id !== u) return;
45
+ }, [t.id]), S(() => {
46
+ if (t.id !== u) return;
39
47
  x.current = document.activeElement || null;
40
48
  const o = setTimeout(() => {
41
- const n = F(i.current)[0] || i.current;
42
- n && typeof n.focus == "function" && n.focus({ preventScroll: !0 });
49
+ const e = _(c.current);
50
+ e && typeof e.focus == "function" && e.focus({ preventScroll: !0 });
43
51
  }, 50);
44
52
  return () => {
45
53
  clearTimeout(o);
46
- const t = document.activeElement;
47
- if (!t || !i.current?.contains(t)) return;
48
- const n = x.current;
49
- if (n && typeof n.focus == "function" && document.body.contains(n))
54
+ const e = document.activeElement;
55
+ if (!e || !c.current?.contains(e)) return;
56
+ const i = x.current;
57
+ if (i && typeof i.focus == "function" && document.body.contains(i))
50
58
  try {
51
- n.focus({ preventScroll: !0 });
59
+ i.focus({ preventScroll: !0 });
52
60
  } catch {
53
61
  document.body.focus();
54
62
  }
55
63
  };
56
- }, [e.id, u]);
57
- const h = S(
64
+ }, [t.id, u]);
65
+ const y = k(
58
66
  (o) => a[o] ? j({
59
- title: c("common:exitConfirm"),
60
- confirmText: c("common:Да"),
61
- cancelText: c("common:Нет"),
67
+ title: n("common:exitConfirm"),
68
+ confirmText: n("common:Да"),
69
+ cancelText: n("common:Нет"),
62
70
  confirmView: "negative"
63
71
  }) : Promise.resolve(!0),
64
72
  // eslint-disable-next-line react-hooks/exhaustive-deps
65
- [a, c]
66
- ), f = S(
73
+ [a, n]
74
+ ), f = k(
67
75
  async (o) => {
68
- const { id: t } = e;
69
- await h(o || t) && (y(!1), setTimeout(() => {
70
- e.props.closeCallback && e.props.closeCallback(), m(o || t);
76
+ const { id: e } = t;
77
+ await y(o || e) && (h(!1), setTimeout(() => {
78
+ t.props.closeCallback && t.props.closeCallback(), d(o || e);
71
79
  }, 250));
72
80
  },
73
- [m, h, e]
81
+ [d, y, t]
74
82
  );
75
- return k(() => {
76
- const o = (t) => {
77
- if (t.key === "27" || t.key === "Escape") {
83
+ return S(() => {
84
+ const o = (e) => {
85
+ if (e.key === "27" || e.key === "Escape") {
78
86
  f(u);
79
87
  return;
80
88
  }
81
- if (t.key !== "Tab") return;
82
- const n = F(i.current);
83
- if (!n.length) {
84
- t.preventDefault(), i.current && i.current.focus({ preventScroll: !0 });
89
+ if (e.key !== "Tab") return;
90
+ const i = F(c.current);
91
+ if (!i.length) {
92
+ e.preventDefault(), c.current && c.current.focus({ preventScroll: !0 });
85
93
  return;
86
94
  }
87
- const v = n[0], g = n[n.length - 1], d = document.activeElement;
88
- if (t.shiftKey && (d === v || !i.current?.contains(d))) {
89
- t.preventDefault(), g.focus({ preventScroll: !0 });
95
+ const g = i[0], v = i[i.length - 1], b = document.activeElement;
96
+ if (e.shiftKey && (b === g || !c.current?.contains(b))) {
97
+ e.preventDefault(), v.focus({ preventScroll: !0 });
90
98
  return;
91
99
  }
92
- !t.shiftKey && (d === g || !i.current?.contains(d)) && (t.preventDefault(), v.focus({ preventScroll: !0 }));
100
+ !e.shiftKey && (b === v || !c.current?.contains(b)) && (e.preventDefault(), g.focus({ preventScroll: !0 }));
93
101
  };
94
- return e.id === u && window?.addEventListener("keydown", o), () => {
102
+ return t.id === u && window?.addEventListener("keydown", o), () => {
95
103
  window?.removeEventListener("keydown", o);
96
104
  };
97
- }, [f, u, e.id]), /* @__PURE__ */ E(
105
+ }, [f, u, t.id]), /* @__PURE__ */ E(
98
106
  "div",
99
107
  {
100
108
  className: s.container,
@@ -105,30 +113,30 @@ const R = {
105
113
  /* @__PURE__ */ l(
106
114
  "div",
107
115
  {
108
- ref: i,
116
+ ref: c,
109
117
  className: C(s.right, s.content, {
110
118
  [s.open]: p,
111
- [s.bottomSheet]: b
119
+ [s.bottomSheet]: m
112
120
  }),
113
121
  style: {
114
122
  zIndex: 9999999 + r,
115
- width: R[e.props.size],
123
+ width: T[t.props.size],
116
124
  // На десктопе right-slide управляется JS-ом (старая
117
125
  // схема — анимация ширины и right'а синхронны). На
118
126
  // мобиле right=0 всегда, а появление контролируется
119
127
  // CSS (.bottomSheet.open → top: 0).
120
- right: b || p ? 0 : A
128
+ right: m || p ? 0 : R
121
129
  },
122
130
  role: "dialog",
123
131
  "aria-modal": "true",
124
- "aria-labelledby": `modal-title-${e.id}`,
132
+ "aria-labelledby": `modal-title-${t.id}`,
125
133
  tabIndex: -1,
126
134
  children: /* @__PURE__ */ E("div", { className: s.inner, children: [
127
135
  /* @__PURE__ */ l(
128
- e.modal,
136
+ t.modal,
129
137
  {
130
- ...e.props,
131
- modalId: e.id,
138
+ ...t.props,
139
+ modalId: t.id,
132
140
  close: () => f()
133
141
  }
134
142
  ),
@@ -136,7 +144,7 @@ const R = {
136
144
  z,
137
145
  {
138
146
  className: C(s.button, {
139
- [s.doubleModal]: e.props.isDouble
147
+ [s.doubleModal]: t.props.isDouble
140
148
  }),
141
149
  view: "secondary",
142
150
  size: "xs",
@@ -161,5 +169,5 @@ const R = {
161
169
  );
162
170
  };
163
171
  export {
164
- W as Modal
172
+ J as Modal
165
173
  };
@@ -1,68 +1,70 @@
1
- import { jsx as b } from "react/jsx-runtime";
2
- import C from "classnames";
3
- import { createRoot as g } from "react-dom/client";
4
- import { ToastPlate as y } from "../toast-plate/component.js";
5
- import o from "./index.module.css.js";
6
- import { createTimer as w } from "./use-timer.js";
7
- let e;
8
- typeof window < "u" && (e = document.createElement("div"), e.setAttribute("id", "toast_manager"), document.body.appendChild(e));
9
- const z = ({
10
- className: m,
11
- children: E,
1
+ import { jsx as y } from "react/jsx-runtime";
2
+ import w from "classnames";
3
+ import { createRoot as E } from "react-dom/client";
4
+ import { ToastPlate as $ } from "../toast-plate/component.js";
5
+ import t from "./index.module.css.js";
6
+ import { createTimer as A } from "./use-timer.js";
7
+ let o;
8
+ typeof window < "u" && (o = document.createElement("div"), o.setAttribute("id", "toast_manager"), document.body.appendChild(o));
9
+ const R = ({
10
+ className: d,
11
+ children: L,
12
12
  offset: n = 108,
13
- hasCloser: l = !0,
14
- onClose: $,
15
- text: d,
16
- onMouseEnter: L,
17
- onMouseLeave: A,
18
- style: u,
19
- position: p = "bottom",
20
- delay: c = 3e3,
21
- ...f
13
+ hasCloser: u = !0,
14
+ onClose: M,
15
+ text: c,
16
+ onMouseEnter: T,
17
+ onMouseLeave: N,
18
+ style: p,
19
+ position: f = "bottom",
20
+ delay: v = 3e3,
21
+ ...x
22
22
  }) => {
23
23
  if (typeof window > "u") return null;
24
- const r = window.innerWidth > 600, h = () => {
25
- const a = "position: fixed; z-index: 999999999;";
26
- return r ? `${a} ${p}: ${n}px; right: 30px` : `${a} top: ${n}px; right: 30px; left: 30px`;
24
+ const r = window.innerWidth > 600, b = () => {
25
+ const m = "position: fixed; z-index: 999999999;";
26
+ return r ? `${m} ${f}: ${n}px; right: 30px` : `${m} top: ${n}px; right: 30px; left: 30px`;
27
27
  };
28
- e.setAttribute("style", h());
29
- const t = document.createElement("div");
30
- t.classList.remove(o.isClosing), t.setAttribute("id", `toast_wrap-${Math.random()}`), t.setAttribute("style", "margin-bottom: 18px"), e.appendChild(t);
31
- const i = g(t), s = () => {
32
- t.classList.add(o.isClosing), setTimeout(() => {
33
- i.unmount(), e?.removeChild(t);
34
- }, 300);
35
- }, { pause: v, resume: x } = w(s, c);
36
- return t.addEventListener("mouseenter", () => {
37
- v();
38
- }), t.addEventListener("mouseleave", () => {
39
- x();
40
- }), i.render(
41
- /* @__PURE__ */ b(
42
- y,
28
+ o.setAttribute("style", b());
29
+ const e = document.createElement("div");
30
+ e.classList.remove(t.isClosing), e.setAttribute("id", `toast_wrap-${Math.random()}`), e.setAttribute("style", "margin-bottom: 18px"), o.appendChild(e);
31
+ const s = E(e);
32
+ let i = !1, a;
33
+ const l = () => {
34
+ i || (i = !0, a?.(), e.classList.add(t.isClosing), setTimeout(() => {
35
+ s.unmount(), e.remove();
36
+ }, 300));
37
+ }, { pause: h, resume: C, cancel: g } = A(l, v);
38
+ return a = g, e.addEventListener("mouseenter", () => {
39
+ h();
40
+ }), e.addEventListener("mouseleave", () => {
41
+ C();
42
+ }), s.render(
43
+ /* @__PURE__ */ y(
44
+ $,
43
45
  {
44
- hasCloser: l,
45
- className: C(
46
+ hasCloser: u,
47
+ className: w(
46
48
  {
47
- [o.isVisible]: !0,
48
- [o.mobile]: !r
49
+ [t.isVisible]: !0,
50
+ [t.mobile]: !r
49
51
  },
50
- m
52
+ d
51
53
  ),
52
- contentClassName: o.toastContent,
54
+ contentClassName: t.toastContent,
53
55
  style: {
54
56
  right: 0,
55
57
  position: "relative",
56
- ...u
58
+ ...p
57
59
  },
58
60
  role: "alert",
59
- onClose: s,
60
- ...f,
61
- children: d
61
+ onClose: l,
62
+ ...x,
63
+ children: c
62
64
  }
63
65
  )
64
66
  ), null;
65
67
  };
66
68
  export {
67
- z as ToastNotifier
69
+ R as ToastNotifier
68
70
  };
@@ -1,7 +1,7 @@
1
1
  const K = {
2
2
  EUR: "€",
3
- RUR: "₽",
4
- RUB: "₽",
3
+ RUR: "руб.",
4
+ RUB: "руб.",
5
5
  USD: "$",
6
6
  GBP: "£",
7
7
  // Фунт стерлингов
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphakits/ui",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "files": [
5
5
  "dist"
6
6
  ],