@alphakits/ui 2.4.2 → 2.4.4

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,67 +1,70 @@
1
- import { jsxs as h, jsx as i } from "react/jsx-runtime";
2
- import y from "classnames";
3
- import { useState as E, useLayoutEffect as g, useCallback as k, useEffect as v } from "react";
4
- import { ButtonArrow as x } from "../../../button-arrow/component.js";
5
- import t from "./index.module.css.js";
6
- const C = {
1
+ import { jsxs as w, jsx as i } from "react/jsx-runtime";
2
+ import b from "classnames";
3
+ import { useState as v, useLayoutEffect as x, useCallback as k, useEffect as E } from "react";
4
+ import { ButtonArrow as g } from "../../../button-arrow/component.js";
5
+ import { showConfirm as F } from "../../../confirm-popup/component.js";
6
+ import s from "./index.module.css.js";
7
+ const y = {
7
8
  s: 488,
8
9
  m: 888,
9
10
  full: "96%"
10
- }, w = 102, F = (e) => e === "full" ? `calc(-96vw - ${w}px)` : -C[e] - w, O = ({ modal: e, t: f, index: l, dirtyModals: p, closeModal: a, currentModalId: r }) => {
11
- const c = F(e.props.size), [b, m] = E(c);
12
- g(() => {
13
- const s = requestAnimationFrame(() => m(0));
14
- return () => cancelAnimationFrame(s);
11
+ }, h = 102, N = (e) => e === "full" ? `calc(-96vw - ${h}px)` : -y[e] - h, R = ({ modal: e, t: r, index: a, dirtyModals: m, closeModal: l, currentModalId: c }) => {
12
+ const f = N(e.props.size), [C, p] = v(f);
13
+ x(() => {
14
+ const o = requestAnimationFrame(() => p(0));
15
+ return () => cancelAnimationFrame(o);
15
16
  }, [e.id]);
16
17
  const u = k(
17
- (s) => (
18
- // eslint-disable-next-line no-restricted-globals
19
- !p[s] || confirm(f("common:exitConfirm"))
20
- ),
18
+ (o) => m[o] ? F({
19
+ title: r("common:exitConfirm"),
20
+ confirmText: r("common:yes"),
21
+ cancelText: r("common:no"),
22
+ confirmView: "negative"
23
+ }) : Promise.resolve(!0),
21
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
22
- [p, f]
23
- ), n = k(
24
- (s) => {
25
- const { id: o } = e;
26
- u(s || o) && (m(c), setTimeout(() => {
27
- e.props.closeCallback && e.props.closeCallback(), a(s || o);
25
+ [m, r]
26
+ ), t = k(
27
+ async (o) => {
28
+ const { id: n } = e;
29
+ await u(o || n) && (p(f), setTimeout(() => {
30
+ e.props.closeCallback && e.props.closeCallback(), l(o || n);
28
31
  }, 250));
29
32
  },
30
- [a, u, e, c]
33
+ [l, u, e, f]
31
34
  );
32
- return v(() => {
33
- const s = (o) => {
34
- (o.key === "27" || o.key === "Escape") && n(r);
35
+ return E(() => {
36
+ const o = (n) => {
37
+ (n.key === "27" || n.key === "Escape") && t(c);
35
38
  };
36
- return e.id === r && window?.addEventListener("keydown", s), () => {
37
- window?.removeEventListener("keydown", s);
39
+ return e.id === c && window?.addEventListener("keydown", o), () => {
40
+ window?.removeEventListener("keydown", o);
38
41
  };
39
- }, [n, r, e.id]), /* @__PURE__ */ h(
42
+ }, [t, c, e.id]), /* @__PURE__ */ w(
40
43
  "div",
41
44
  {
42
- className: t.container,
45
+ className: s.container,
43
46
  style: {
44
- zIndex: 9999998 + l
47
+ zIndex: 9999998 + a
45
48
  },
46
49
  children: [
47
50
  /* @__PURE__ */ i(
48
51
  "div",
49
52
  {
50
- className: y(t.right, t.content),
53
+ className: b(s.right, s.content),
51
54
  style: {
52
- zIndex: 9999999 + l,
53
- width: C[e.props.size],
54
- right: b
55
+ zIndex: 9999999 + a,
56
+ width: y[e.props.size],
57
+ right: C
55
58
  },
56
- children: /* @__PURE__ */ h("div", { className: t.inner, children: [
57
- /* @__PURE__ */ i(e.modal, { ...e.props, close: () => n() }),
59
+ children: /* @__PURE__ */ w("div", { className: s.inner, children: [
60
+ /* @__PURE__ */ i(e.modal, { ...e.props, close: () => t() }),
58
61
  e.props.showCloser !== !1 && /* @__PURE__ */ i(
59
- x,
62
+ g,
60
63
  {
61
- className: t.button,
64
+ className: s.button,
62
65
  size: "s",
63
66
  type: "close",
64
- onClick: () => n()
67
+ onClick: () => t()
65
68
  }
66
69
  )
67
70
  ] })
@@ -70,10 +73,10 @@ const C = {
70
73
  /* @__PURE__ */ i(
71
74
  "button",
72
75
  {
73
- className: t.bg,
76
+ className: s.bg,
74
77
  "aria-label": "close_backdrop",
75
78
  type: "button",
76
- onClick: () => n()
79
+ onClick: () => t()
77
80
  }
78
81
  )
79
82
  ]
@@ -81,5 +84,5 @@ const C = {
81
84
  );
82
85
  };
83
86
  export {
84
- O as Modal
87
+ R as Modal
85
88
  };
@@ -1,109 +1,126 @@
1
- import { jsx as r, jsxs as D } from "react/jsx-runtime";
2
- import { offset as L, flip as P, shift as U, arrow as z, useFloating as V, autoUpdate as q } from "@floating-ui/react-dom";
1
+ import { jsx as i, jsxs as D } from "react/jsx-runtime";
2
+ import { offset as L, flip as U, shift as z, arrow as V, useFloating as q, autoUpdate as B } from "@floating-ui/react-dom";
3
3
  import c from "classnames";
4
- import { useRef as g, useMemo as N, useEffect as B, useCallback as G } from "react";
5
- import { CSSTransition as H } from "react-transition-group";
6
- import { Portal as J } from "../portal/component.js";
7
- import { Stack as K } from "../stack/component.js";
8
- import { stackingOrder as Q } from "../stack/context.js";
4
+ import { useRef as g, useMemo as N, useEffect as G, useCallback as H } from "react";
5
+ import { CSSTransition as J } from "react-transition-group";
6
+ import { Portal as K } from "../portal/component.js";
7
+ import { Stack as Q } from "../stack/component.js";
8
+ import { stackingOrder as W } from "../stack/context.js";
9
9
  import e from "./index.module.css.js";
10
- const W = {
10
+ const X = {
11
11
  timeout: 150
12
- }, X = {
12
+ }, Y = {
13
13
  enter: e.enter,
14
14
  enterActive: e.enterActive,
15
15
  exit: e.exit,
16
16
  exitActive: e.exitActive
17
- }, Y = H, Z = {
17
+ }, Z = J, tt = {
18
18
  top: "bottom",
19
19
  right: "left",
20
20
  bottom: "top",
21
21
  left: "right"
22
- }, ct = ({
23
- children: R,
24
- getPortalContainer: b,
25
- transition: m = W,
26
- anchorElement: A,
22
+ }, mt = ({
23
+ children: b,
24
+ getPortalContainer: R,
25
+ transition: m = X,
26
+ anchorElement: h,
27
27
  offset: n = [0, 0],
28
28
  withArrow: o = !1,
29
- withTransition: T = !0,
30
- position: h = "left",
31
- preventFlip: f,
32
- popperClassName: y,
29
+ withTransition: y = !0,
30
+ position: A = "left",
31
+ preventFlip: d,
32
+ popperClassName: T,
33
33
  arrowClassName: E,
34
34
  className: O,
35
- open: i,
35
+ open: s,
36
36
  dataTestId: C,
37
37
  update: l,
38
38
  transitionDuration: F = `${m.timeout}ms`,
39
- zIndex: I = Q.POPOVER
39
+ zIndex: I = W.POPOVER
40
40
  }) => {
41
- const d = g(null), u = g(null), M = N(
41
+ const f = g(null), u = g(null), M = N(
42
42
  () => [
43
43
  L({
44
44
  crossAxis: n[0],
45
45
  mainAxis: n[1]
46
46
  }),
47
- ...f ? [] : [P()],
48
- U({ padding: 4 }),
49
- ...o ? [z({ element: d })] : []
47
+ ...d ? [] : [U()],
48
+ z({ padding: 4 }),
49
+ ...o ? [V({ element: f })] : []
50
50
  ],
51
- [n[0], n[1], f, o]
51
+ [n[0], n[1], d, o]
52
52
  ), {
53
53
  refs: { setFloating: p },
54
54
  floatingStyles: _,
55
55
  middlewareData: a,
56
- placement: x,
57
- update: S
58
- } = V({
59
- placement: h,
60
- open: i,
61
- elements: { reference: A },
62
- whileElementsMounted: i ? q : void 0,
56
+ placement: v,
57
+ update: x,
58
+ isPositioned: k
59
+ } = q({
60
+ placement: A,
61
+ open: s,
62
+ elements: { reference: h },
63
+ whileElementsMounted: s ? B : void 0,
63
64
  middleware: M
64
65
  });
65
- B(() => {
66
- l && (l.current = S);
67
- }, [S, l]);
68
- const k = N(() => {
66
+ G(() => {
67
+ l && (l.current = x);
68
+ }, [x, l]);
69
+ const P = N(() => {
69
70
  if (!o || !a.arrow)
70
71
  return {};
71
- const { x: t, y: s } = a.arrow, j = x.split("-")[0], w = Z[j] ?? "bottom";
72
+ const { x: t, y: r } = a.arrow, j = v.split("-")[0], w = tt[j] ?? "bottom";
72
73
  return {
73
74
  position: "absolute",
74
75
  left: t != null ? `${t}px` : void 0,
75
- top: s != null ? `${s}px` : void 0,
76
+ top: r != null ? `${r}px` : void 0,
76
77
  right: "",
77
78
  bottom: "",
78
79
  [w]: "-4px"
79
80
  };
80
- }, [o, a.arrow, x]), $ = G(
81
+ }, [o, a.arrow, v]), $ = H(
81
82
  (t) => {
82
83
  u.current = t, p(t);
83
84
  },
84
85
  [p]
85
- ), v = (t, s) => /* @__PURE__ */ r(
86
+ ), S = (t, r) => /* @__PURE__ */ i(
86
87
  "div",
87
88
  {
88
89
  ref: $,
89
90
  style: {
90
91
  zIndex: t,
91
- ..._
92
+ ..._,
93
+ /**
94
+ * Скрываем поповер до первого замера floating-ui: иначе
95
+ * на первом рендере `floatingStyles` ещё содержат дефолт
96
+ * `top: 0, left: 0, transform: translate(0, 0)`, а CSSTransition
97
+ * уже стартует fade-in. Получается визуальный "прыжок" из
98
+ * угла портала в правильную позицию. `isPositioned` становится
99
+ * `true` после первого измерения — к этому моменту координаты
100
+ * корректные и можно показывать.
101
+ *
102
+ * Не используем `display: none` или `opacity`, потому что:
103
+ * — `display: none` ломает измерения floating-ui (нулевые
104
+ * размеры) и блокирует CSSTransition;
105
+ * — `opacity` уже используется CSSTransition'ом для fade-in,
106
+ * переписывать его здесь — испортить анимацию.
107
+ */
108
+ visibility: k ? "visible" : "hidden"
92
109
  },
93
110
  className: c(e.component, O),
94
111
  children: /* @__PURE__ */ D(
95
112
  "div",
96
113
  {
97
114
  "data-test-id": C,
98
- className: c(e.inner, y),
99
- style: s,
115
+ className: c(e.inner, T),
116
+ style: r,
100
117
  children: [
101
- R,
102
- o && /* @__PURE__ */ r(
118
+ b,
119
+ o && /* @__PURE__ */ i(
103
120
  "div",
104
121
  {
105
- ref: d,
106
- style: k,
122
+ ref: f,
123
+ style: P,
107
124
  className: c(e.arrow, E)
108
125
  }
109
126
  )
@@ -112,18 +129,18 @@ const W = {
112
129
  )
113
130
  }
114
131
  );
115
- return /* @__PURE__ */ r(K, { value: I, children: (t) => /* @__PURE__ */ r(J, { getPortalContainer: b, children: T ? /* @__PURE__ */ r(
116
- Y,
132
+ return /* @__PURE__ */ i(Q, { value: I, children: (t) => /* @__PURE__ */ i(K, { getPortalContainer: R, children: y ? /* @__PURE__ */ i(
133
+ Z,
117
134
  {
118
135
  unmountOnExit: !0,
119
- classNames: X,
136
+ classNames: Y,
120
137
  ...m,
121
- in: i,
138
+ in: s,
122
139
  nodeRef: u,
123
- children: v(t, { transitionDuration: F })
140
+ children: S(t, { transitionDuration: F })
124
141
  }
125
- ) : i && v(t) }) });
142
+ ) : s && S(t) }) });
126
143
  };
127
144
  export {
128
- ct as Popover
145
+ mt as Popover
129
146
  };
@@ -0,0 +1,9 @@
1
+ export declare const locations: {
2
+ id: number;
3
+ title: string;
4
+ }[];
5
+ export declare const questrooms: {
6
+ id: number;
7
+ title: string;
8
+ locationId: number;
9
+ }[];
@@ -0,0 +1,82 @@
1
+ const t = [
2
+ {
3
+ id: 1,
4
+ title: "Tambov"
5
+ },
6
+ {
7
+ id: 2,
8
+ title: "Moscow"
9
+ },
10
+ {
11
+ id: 3,
12
+ title: "Voronezh"
13
+ },
14
+ {
15
+ id: 4,
16
+ title: "Lipetsk"
17
+ },
18
+ {
19
+ id: 5,
20
+ title: "SPB"
21
+ }
22
+ ], o = [
23
+ {
24
+ id: 1,
25
+ title: "Questroom 1",
26
+ locationId: 1
27
+ },
28
+ {
29
+ id: 4,
30
+ title: "Questroom 4",
31
+ locationId: 2
32
+ },
33
+ {
34
+ id: 5,
35
+ title: "Questroom 5",
36
+ locationId: 2
37
+ },
38
+ {
39
+ id: 6,
40
+ title: "Questroom 6",
41
+ locationId: 2
42
+ },
43
+ {
44
+ id: 7,
45
+ title: "Questroom 7",
46
+ locationId: 3
47
+ },
48
+ {
49
+ id: 10,
50
+ title: "Questroom 10",
51
+ locationId: 4
52
+ },
53
+ {
54
+ id: 11,
55
+ title: "Questroom 11",
56
+ locationId: 4
57
+ },
58
+ {
59
+ id: 12,
60
+ title: "Questroom 12",
61
+ locationId: 4
62
+ },
63
+ {
64
+ id: 13,
65
+ title: "Questroom 13",
66
+ locationId: 5
67
+ },
68
+ {
69
+ id: 14,
70
+ title: "Questroom 14",
71
+ locationId: 5
72
+ },
73
+ {
74
+ id: 15,
75
+ title: "Questroom 15",
76
+ locationId: 5
77
+ }
78
+ ];
79
+ export {
80
+ t as locations,
81
+ o as questrooms
82
+ };
@@ -1,119 +1,123 @@
1
- import { useState as u, useCallback as c, useEffect as D } from "react";
2
- import { addQueryParam as I } from "../utils/add-query-param.js";
3
- import { getQueryFromUrl as R } from "../utils/get-query-from-url.js";
1
+ import { useState as u, useRef as b, useCallback as l, useEffect as E } from "react";
2
+ import { addQueryParam as h } from "../utils/add-query-param.js";
3
+ import { getQueryFromUrl as j } from "../utils/get-query-from-url.js";
4
4
  import "query-string";
5
- import { removeQueryParam as V } from "../utils/remove-query-param.js";
6
- import { resetQueryParam as Y } from "../utils/reset-query-param.js";
7
- import { serializeData as b } from "../utils/serialize-data.js";
8
- const d = {
5
+ import { removeQueryParam as B } from "../utils/remove-query-param.js";
6
+ import { resetQueryParam as G } from "../utils/reset-query-param.js";
7
+ import { serializeData as C } from "../utils/serialize-data.js";
8
+ const p = {
9
9
  page: 1,
10
10
  limit: 10,
11
11
  where: {}
12
12
  // остальное добавится по мере нужды (searchText, sort, order и т.д.)
13
13
  };
14
- function E(f, n) {
15
- const r = f ?? d, a = {
14
+ function L(w, a) {
15
+ const r = w ?? p, n = {
16
16
  ...r,
17
- ...n,
17
+ ...a,
18
18
  where: {
19
19
  ...r.where ?? {},
20
- ...n.where ?? {}
20
+ ...a.where ?? {}
21
21
  }
22
22
  };
23
- return a.page && (a.page = +a.page), a.limit && (a.limit = +a.limit), a;
23
+ return n.page && (n.page = +n.page), n.limit && (n.limit = +n.limit), n;
24
24
  }
25
- function M({ promise: f, records: n, fromPath: r = !0 }) {
26
- const [a, p] = u([]), [h, w] = u(!0), [C, A] = u(!1), [L, S] = u(0), [T, U] = u(1), [o, m] = u(void 0), y = c(
27
- (t) => r ? R() : t ?? o ?? d,
25
+ function X({ promise: w, records: a, fromPath: r = !0 }) {
26
+ const [n, A] = u([]), [S, d] = u(!0), [T, Q] = u(!1), [U, q] = u(0), [F, k] = u(1), [c, f] = u(void 0), x = b(w);
27
+ x.current = w;
28
+ const v = b(a);
29
+ v.current = a;
30
+ const m = l(
31
+ (t) => r ? j() : t ?? c ?? p,
28
32
  // params не включаем при fromPath: иначе setParams на каждом fetch
29
33
  // даёт новую ссылку → computeQuery/updateData меняются → бесконечный цикл.
30
- r ? [r] : [r, o]
31
- ), s = c(
34
+ r ? [r] : [r, c]
35
+ ), s = l(
32
36
  async (t) => {
33
- const e = y(t);
34
- if (Array.isArray(n) && (w(!1), p(b(n, e))), m(e), f) {
35
- A(!1), w(!0);
37
+ const e = m(t), i = v.current, y = x.current;
38
+ if (Array.isArray(i) && (d(!1), A(C(i, e))), r || f(e), y) {
39
+ Q(!1), d(!0);
36
40
  try {
37
41
  const {
38
- data: { items: i, meta: g }
39
- } = await f(e);
40
- S(g.totalItems), U(g.totalPages), p(i || []);
42
+ data: { items: o, meta: g }
43
+ } = await y(e);
44
+ q(g.totalItems), k(g.totalPages), A(o || []);
41
45
  } catch {
42
- A(!0);
46
+ Q(!0);
43
47
  } finally {
44
- w(!1);
48
+ d(!1);
45
49
  }
46
50
  }
47
51
  },
48
- [y, n, f]
49
- ), q = c(
52
+ [m, r]
53
+ ), z = l(
50
54
  (t) => {
51
55
  if (r) {
52
- I(t), s();
56
+ h(t), s();
53
57
  return;
54
58
  }
55
- const e = E(o, t);
56
- m(e), s(e);
59
+ const e = L(c, t);
60
+ f(e), s(e);
57
61
  },
58
- [r, o, s]
59
- ), Q = c(
62
+ [r, c, s]
63
+ ), D = l(
60
64
  (t, e, i) => {
61
- const g = t ?? d, l = {
62
- ...g,
63
- where: { ...g.where ?? {} }
64
- }, x = l.where?.[e];
65
- if (Array.isArray(x) && i != null) {
66
- const v = x.filter((z) => String(z) !== String(i));
67
- v.length ? l.where[e] = v : delete l.where[e];
65
+ const y = t ?? p, o = {
66
+ ...y,
67
+ where: { ...y.where ?? {} }
68
+ }, g = o.where?.[e];
69
+ if (Array.isArray(g) && i != null) {
70
+ const R = g.filter((_) => String(_) !== String(i));
71
+ R.length ? o.where[e] = R : delete o.where[e];
68
72
  } else
69
- l.where && e in l.where && delete l.where[e];
70
- return l;
73
+ o.where && e in o.where && delete o.where[e];
74
+ return o;
71
75
  },
72
76
  []
73
- ), F = c(
77
+ ), I = l(
74
78
  (t, e) => {
75
79
  if (r) {
76
- V(t, e), s();
80
+ B(t, e), s();
77
81
  return;
78
82
  }
79
- const i = Q(o, t, e);
80
- m(i), s(i);
83
+ const i = D(c, t, e);
84
+ f(i), s(i);
81
85
  },
82
- [r, o, s, Q]
83
- ), P = c(
86
+ [r, c, s, D]
87
+ ), V = l(
84
88
  (t) => {
85
89
  if (r) {
86
- Y(t), s();
90
+ G(t), s();
87
91
  return;
88
92
  }
89
- const e = E(d, t);
90
- m(e), s(e);
93
+ const e = L(p, t);
94
+ f(e), s(e);
91
95
  },
92
96
  [r, s]
93
97
  );
94
- D(() => {
98
+ E(() => {
95
99
  s();
96
- }, [s]), D(() => {
97
- if (Array.isArray(n)) {
98
- const t = y();
99
- m(t), w(!1), p(b(n, t));
100
+ }, [s]), E(() => {
101
+ if (Array.isArray(a)) {
102
+ const t = m();
103
+ r || f(t), d(!1), A(C(a, t));
100
104
  }
101
- }, [n, y]);
102
- const k = o ?? y();
105
+ }, [a, m]);
106
+ const Y = c ?? m();
103
107
  return {
104
- loading: h,
105
- error: C,
106
- data: a,
107
- total: L,
108
- params: k,
109
- pagesCount: T,
108
+ loading: S,
109
+ error: T,
110
+ data: n,
111
+ total: U,
112
+ params: Y,
113
+ pagesCount: F,
110
114
  updateData: s,
111
115
  // НОВОЕ: наружу отдаём универсальные методы для управления параметрами
112
- addParam: q,
113
- removeParam: F,
114
- resetParams: P
116
+ addParam: z,
117
+ removeParam: I,
118
+ resetParams: V
115
119
  };
116
120
  }
117
121
  export {
118
- M as useTableData
122
+ X as useTableData
119
123
  };
@@ -18,6 +18,7 @@ export declare const defaultThemes: {
18
18
  readonly thirdly: "#E7E8EA";
19
19
  readonly quaternary: "#D5D6DC";
20
20
  readonly 'special-super-light': "#FDFDFD";
21
+ readonly 'primary-inverted': "#0E0E0E";
21
22
  readonly 'secondary-inverted': "#1C1C1E";
22
23
  readonly 'special-big-objects': "#F8F8F9";
23
24
  readonly positive: "#63C956";
@@ -46,6 +47,7 @@ export declare const defaultThemes: {
46
47
  readonly attention: "#F19938";
47
48
  readonly accent: "#2174EF";
48
49
  readonly 'accent-special': "#649EF4";
50
+ readonly 'primary-inverted': "#F8F8F8";
49
51
  readonly 'secondary-inverted': "#85858D";
50
52
  readonly main: "#2174ef";
51
53
  readonly static: "#FFFFFF";
@@ -92,6 +94,7 @@ export declare const defaultThemes: {
92
94
  readonly thirdly: "#27272A";
93
95
  readonly quaternary: "#36363A";
94
96
  readonly 'special-super-light': "#18181970";
97
+ readonly 'primary-inverted': "#FFFFFF";
95
98
  readonly 'secondary-inverted': "#F2F3F5";
96
99
  readonly 'special-big-objects': "#171718";
97
100
  readonly positive: "#32D74B";
@@ -120,6 +123,7 @@ export declare const defaultThemes: {
120
123
  readonly attention: "#F19938";
121
124
  readonly accent: "#2174EF";
122
125
  readonly 'accent-special': "#649EF4";
126
+ readonly 'primary-inverted': "#0E0E0E";
123
127
  readonly 'secondary-inverted': "#86868A";
124
128
  readonly main: "#2174ef";
125
129
  readonly static: "#FFFFFF";