@alphakits/ui 2.4.3 → 2.4.5

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.
Files changed (41) hide show
  1. package/dist/calendar/component.js +32 -31
  2. package/dist/calendar/components/months-table/component.js +22 -23
  3. package/dist/calendar/components/months-table/index.css +1 -1
  4. package/dist/calendar/components/months-table/index.module.css.js +4 -6
  5. package/dist/calendar/components/select-button/index.css +1 -1
  6. package/dist/calendar/index.css +1 -1
  7. package/dist/calendar-input/component.js +124 -121
  8. package/dist/checkbox-lists/mock.data.d.ts +81 -0
  9. package/dist/checkbox-lists/mock.data.js +207 -0
  10. package/dist/collapsable-row/fixtures.data.d.ts +99 -0
  11. package/dist/collapsable-row/fixtures.data.js +196 -0
  12. package/dist/confirm-popup/component.d.ts +21 -0
  13. package/dist/confirm-popup/component.js +138 -0
  14. package/dist/confirm-popup/index.css +1 -0
  15. package/dist/confirm-popup/index.d.ts +1 -0
  16. package/dist/confirm-popup/index.js +6 -0
  17. package/dist/confirm-popup/index.module.css.js +23 -0
  18. package/dist/form/component.js +16 -16
  19. package/dist/form/templates/filters-form/index.js +17 -17
  20. package/dist/form/templates/rest-form/form.d.ts +1 -1
  21. package/dist/form/templates/rest-form/form.js +72 -67
  22. package/dist/form/templates/rest-form/index.d.ts +1 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +298 -293
  25. package/dist/modal/components/modals/modal.js +50 -40
  26. package/dist/modal/hooks/use-modal.js +11 -11
  27. package/dist/modal/types.d.ts +2 -1
  28. package/dist/popover/component.js +72 -55
  29. package/dist/radio-groups/mock.data.d.ts +9 -0
  30. package/dist/radio-groups/mock.data.js +82 -0
  31. package/dist/select/components/base-select/component.js +73 -73
  32. package/dist/select/utils.js +23 -23
  33. package/dist/theme-provider/default-themes.d.ts +4 -0
  34. package/dist/theme-provider/default-themes.js +4 -0
  35. package/dist/toast-plate/component.js +47 -46
  36. package/dist/toast-plate/index.css +1 -1
  37. package/dist/toast-plate/index.module.css.js +26 -24
  38. package/dist/utils/index.js +26 -25
  39. package/dist/utils/show-toast/index.d.ts +1 -0
  40. package/dist/utils/show-toast/index.js +17 -9
  41. package/package.json +9 -27
@@ -1,67 +1,77 @@
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";
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 d } from "../../../button-arrow/component.js";
5
+ import { showConfirm as g } from "../../../confirm-popup/component.js";
6
+ import s from "./index.module.css.js";
6
7
  const C = {
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, F = (e) => e === "full" ? `calc(-96vw - ${h}px)` : -C[e] - h, R = ({ modal: e, t: r, index: a, dirtyModals: m, closeModal: l, currentModalId: c }) => {
12
+ const f = F(e.props.size), [y, 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] ? g({
19
+ title: r("common:exitConfirm"),
20
+ confirmText: r("common:Да"),
21
+ cancelText: r("common:Нет"),
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,
55
+ zIndex: 9999999 + a,
53
56
  width: C[e.props.size],
54
- right: b
57
+ right: y
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(
61
+ e.modal,
62
+ {
63
+ ...e.props,
64
+ modalId: e.id,
65
+ close: () => t()
66
+ }
67
+ ),
58
68
  e.props.showCloser !== !1 && /* @__PURE__ */ i(
59
- x,
69
+ d,
60
70
  {
61
- className: t.button,
71
+ className: s.button,
62
72
  size: "s",
63
73
  type: "close",
64
- onClick: () => n()
74
+ onClick: () => t()
65
75
  }
66
76
  )
67
77
  ] })
@@ -70,10 +80,10 @@ const C = {
70
80
  /* @__PURE__ */ i(
71
81
  "button",
72
82
  {
73
- className: t.bg,
83
+ className: s.bg,
74
84
  "aria-label": "close_backdrop",
75
85
  type: "button",
76
- onClick: () => n()
86
+ onClick: () => t()
77
87
  }
78
88
  )
79
89
  ]
@@ -81,5 +91,5 @@ const C = {
81
91
  );
82
92
  };
83
93
  export {
84
- O as Modal
94
+ R as Modal
85
95
  };
@@ -2,42 +2,42 @@ import d, { useRef as S, useCallback as s, useEffect as b } from "react";
2
2
  import { v4 as h } from "uuid";
3
3
  import { deletePropertyById as v } from "../utils/delete-property-by-id.js";
4
4
  const x = (n) => {
5
- const [r, l] = d.useState([]), [M, f] = d.useState(""), [p, a] = d.useState({}), c = S(n);
6
- c.current = n;
5
+ const [r, l] = d.useState([]), [f, a] = d.useState(""), [p, c] = d.useState({}), u = S(n);
6
+ u.current = n;
7
7
  const i = s((t) => {
8
- a((e) => v(e, t)), l((e) => e.filter((o) => o.id !== t));
9
- }, []), u = s((t) => {
10
- l((e) => [...e, t]);
8
+ c((e) => v(e, t)), l((e) => e.filter((o) => o.id !== t));
9
+ }, []), M = s((t) => {
10
+ l((e) => [...e, t]), a(t.id);
11
11
  }, []), m = s((t, e) => {
12
- t && a((o) => o[t] === e ? o : {
12
+ t && c((o) => o[t] === e ? o : {
13
13
  ...o,
14
14
  [t]: e
15
15
  });
16
16
  }, []);
17
17
  return b(() => {
18
18
  const t = [...r].pop()?.id;
19
- f(t || ""), document.body.style.overflow = r.length ? "hidden" : "unset";
19
+ a(t || ""), document.body.style.overflow = r.length ? "hidden" : "unset";
20
20
  }, [r]), {
21
21
  openModal: s(
22
22
  (t, e = "s", o = !0) => (y, I) => {
23
23
  const R = h();
24
- u({
24
+ M({
25
25
  id: R,
26
26
  modal: t,
27
27
  props: {
28
28
  size: e,
29
29
  showCloser: o,
30
30
  closeCallback: I,
31
- t: c.current,
31
+ t: u.current,
32
32
  ...y
33
33
  }
34
34
  });
35
35
  },
36
- [u]
36
+ [M]
37
37
  ),
38
38
  modals: r,
39
39
  setModalDirty: m,
40
- currentModalId: M,
40
+ currentModalId: f,
41
41
  dirtyModals: p,
42
42
  closeModal: i
43
43
  };
@@ -2,6 +2,7 @@
2
2
  type ModalProps = {
3
3
  closeCallback: () => void;
4
4
  close: () => void;
5
+ modalId?: string;
5
6
  size: ModalSize;
6
7
  showCloser?: boolean;
7
8
  t: TFunction;
@@ -12,7 +13,7 @@ export type TFunction = (field: string, options?: {
12
13
  [optionName: string]: any;
13
14
  }) => string;
14
15
  export type ModalSize = 's' | 'm' | 'full';
15
- export type OwnModalProps<T> = Omit<T, 'close' | 't'>;
16
+ export type OwnModalProps<T> = Omit<T, 'close' | 't' | 'modalId'>;
16
17
  export type ModalObject = {
17
18
  modal: React.FC<ModalProps>;
18
19
  id: string;
@@ -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
+ };