@alphakits/ui 2.4.0 → 2.4.1

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,109 +1,111 @@
1
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
- import A from "@alphakits/icons/dist/TrashM";
3
- import V, { useContext as D, useState as H, useCallback as v, useEffect as q } from "react";
4
- import { Button as k } from "../../../button/component.js";
5
- import { Flex as G } from "../../../flex/component.js";
6
- import { FlexColumns as J } from "../../../flex-columns/component.js";
7
- import { IconButton as K } from "../../../icon-button/component.js";
8
- import { ModalContext as L } from "../../../modal/context.js";
9
- import { Sidepanel as N } from "../../../sidepanel/component.js";
10
- import { ToastPlate as x } from "../../../toast-plate/component.js";
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import V from "@alphakits/icons/dist/TrashM";
3
+ import D, { useContext as H, useRef as q, useCallback as x, useEffect as G } from "react";
4
+ import { Button as F } from "../../../button/component.js";
5
+ import { Flex as J } from "../../../flex/component.js";
6
+ import { FlexColumns as K } from "../../../flex-columns/component.js";
7
+ import { IconButton as L } from "../../../icon-button/component.js";
8
+ import { ModalContext as N } from "../../../modal/context.js";
9
+ import { Sidepanel as O } from "../../../sidepanel/component.js";
10
+ import { ToastPlate as I } from "../../../toast-plate/component.js";
11
11
  function ie({
12
- recordId: F,
13
- title: I,
12
+ recordId: R,
13
+ title: M,
14
14
  subtitle: T,
15
- headerBottomAddons: u,
15
+ headerBottomAddons: b,
16
16
  initialValues: w,
17
17
  submitButtonText: y,
18
- customFooter: M,
19
- loading: i,
20
- updating: n,
18
+ customFooter: B,
19
+ loading: n,
20
+ updating: i,
21
21
  removing: s,
22
- customValidationFields: O,
23
- validate: Q,
24
- save: U,
22
+ customValidationFields: Q,
23
+ validate: U,
24
+ save: W,
25
25
  remove: a,
26
- close: R,
27
- back: S,
26
+ close: S,
27
+ back: z,
28
28
  t: r,
29
- children: B,
30
- headerAddon: b,
31
- error: W,
29
+ children: P,
30
+ headerAddon: h,
31
+ error: X,
32
32
  softError: d,
33
- ...z
33
+ ...g
34
34
  }) {
35
- const { setModalDirty: e, currentModalId: P } = D(L), [o] = H(P), { submitCount: l, handleSubmit: h, isValid: m, ...c } = z, p = !!F && !!a, C = v(
35
+ const { setModalDirty: e, currentModalId: l } = H(N), c = q("");
36
+ !c.current && l && (c.current = l);
37
+ const t = c.current || l, { submitCount: m, handleSubmit: C, isValid: f, ...u } = g, v = !!R && !!a, k = x(
36
38
  () => {
37
- e(o, !1), h();
39
+ e(t, !1), C();
38
40
  },
39
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
40
- [o, e, h]
41
- ), g = v(() => {
42
- e(o, !1), confirm(r("common:deleteConfirm")) && a?.();
43
- }, [o, r, e, a]);
44
- q(() => {
45
- i || e(o, c.dirty);
46
- }, [c.dirty, i, o, e]);
47
- const j = p || b ? /* @__PURE__ */ f(V.Fragment, { children: [
48
- b,
49
- p && /* @__PURE__ */ t(
50
- K,
42
+ [t, e, C]
43
+ ), j = x(() => {
44
+ e(t, !1), confirm(r("common:deleteConfirm")) && a?.();
45
+ }, [t, r, e, a]);
46
+ G(() => {
47
+ n || e(t, u.dirty);
48
+ }, [u.dirty, n, t, e]);
49
+ const A = v || h ? /* @__PURE__ */ p(D.Fragment, { children: [
50
+ h,
51
+ v && /* @__PURE__ */ o(
52
+ L,
51
53
  {
52
54
  dataTestId: "removeTariffBtn",
53
55
  size: "m",
54
- disabled: n,
56
+ disabled: i,
55
57
  loading: s,
56
- onClick: g,
57
- icon: A
58
+ onClick: j,
59
+ icon: V
58
60
  }
59
61
  )
60
62
  ] }) : null;
61
- return /* @__PURE__ */ t(
62
- N,
63
+ return /* @__PURE__ */ o(
64
+ O,
63
65
  {
64
- headerRightAddons: j,
65
- title: I,
66
+ headerRightAddons: A,
67
+ title: M,
66
68
  subtitle: T,
67
- loading: n || s || i,
68
- headerBottomAddons: (u || !!d || !m && !!l) && /* @__PURE__ */ f(J, { columns: 1, gr: 8, children: [
69
- u,
70
- !!d && /* @__PURE__ */ t(x, { view: "negative", children: d }),
71
- !m && !!l && /* @__PURE__ */ t(x, { view: "negative", children: "Please correct errors before submitting form." })
69
+ loading: i || s || n,
70
+ headerBottomAddons: (b || !!d || !f && !!m) && /* @__PURE__ */ p(K, { columns: 1, gr: 8, children: [
71
+ b,
72
+ !!d && /* @__PURE__ */ o(I, { view: "negative", children: d }),
73
+ !f && !!m && /* @__PURE__ */ o(I, { view: "negative", children: "Please correct errors before submitting form." })
72
74
  ] }),
73
- back: S,
75
+ back: z,
74
76
  t: r,
75
- bottomAddons: M || /* @__PURE__ */ f(G, { gap: "md", children: [
76
- /* @__PURE__ */ t(
77
- k,
77
+ bottomAddons: B || /* @__PURE__ */ p(J, { gap: "md", children: [
78
+ /* @__PURE__ */ o(
79
+ F,
78
80
  {
79
81
  view: "primary",
80
82
  size: "s",
81
83
  block: !0,
82
- loading: i,
83
- disabled: n || s,
84
+ loading: n,
85
+ disabled: i || s,
84
86
  dataTestId: "buttonSave",
85
- onClick: () => C(),
87
+ onClick: () => k(),
86
88
  children: r(y || "save")
87
89
  }
88
90
  ),
89
- /* @__PURE__ */ t(
90
- k,
91
+ /* @__PURE__ */ o(
92
+ F,
91
93
  {
92
94
  block: !0,
93
95
  view: "secondary",
94
96
  size: "s",
95
97
  dataTestId: "buttonCancel",
96
- onClick: R,
98
+ onClick: S,
97
99
  children: r("cancel")
98
100
  }
99
101
  )
100
102
  ] }),
101
- children: B({
102
- submitCount: l,
103
- isValid: m,
104
- handleSubmit: C,
103
+ children: P({
104
+ submitCount: m,
105
+ isValid: f,
106
+ handleSubmit: k,
105
107
  initialValues: w,
106
- ...c
108
+ ...u
107
109
  })
108
110
  }
109
111
  );
@@ -1,42 +1,42 @@
1
- import n, { useEffect as I } from "react";
2
- import { v4 as S } from "uuid";
1
+ import n, { useCallback as I, useEffect as S } from "react";
2
+ import { v4 as b } from "uuid";
3
3
  import { deletePropertyById as g } from "../utils/delete-property-by-id.js";
4
4
  const x = (c) => {
5
- const [s, l] = n.useState([]), [u, M] = n.useState(""), [i, a] = n.useState({}), p = (t) => {
5
+ const [r, l] = n.useState([]), [u, M] = n.useState(""), [p, a] = n.useState({}), f = (t) => {
6
6
  a((o) => g(o, t)), l((o) => o.filter((e) => e.id !== t));
7
- }, m = (t) => {
7
+ }, i = (t) => {
8
8
  l((o) => [...o, t]);
9
- }, f = (t, o) => {
10
- a((e) => ({
9
+ }, m = I((t, o) => {
10
+ t && a((e) => e[t] === o ? e : {
11
11
  ...e,
12
12
  [t]: o
13
- }));
14
- };
15
- return I(() => {
16
- const t = [...s].pop()?.id;
17
- M(t || ""), document.body.style.overflow = s.length ? "hidden" : "unset";
18
- }, [s]), {
13
+ });
14
+ }, []);
15
+ return S(() => {
16
+ const t = [...r].pop()?.id;
17
+ M(t || ""), document.body.style.overflow = r.length ? "hidden" : "unset";
18
+ }, [r]), {
19
19
  openModal: (t, o = "s", e = !0) => {
20
- const y = (d, r) => ({
21
- id: S(),
20
+ const y = (s, d) => ({
21
+ id: b(),
22
22
  modal: t,
23
23
  props: {
24
24
  size: o,
25
25
  showCloser: e,
26
- closeCallback: r,
26
+ closeCallback: d,
27
27
  t: c,
28
- ...d
28
+ ...s
29
29
  }
30
30
  });
31
- return (d, r) => {
32
- m(y(d, r));
31
+ return (s, d) => {
32
+ i(y(s, d));
33
33
  };
34
34
  },
35
- modals: s,
36
- setModalDirty: f,
35
+ modals: r,
36
+ setModalDirty: m,
37
37
  currentModalId: u,
38
- dirtyModals: i,
39
- closeModal: p
38
+ dirtyModals: p,
39
+ closeModal: f
40
40
  };
41
41
  };
42
42
  export {
@@ -1,7 +1,7 @@
1
- import { jsx as r, jsxs as P } from "react/jsx-runtime";
2
- import { useFloating as $, autoUpdate as j, offset as D, flip as U, shift as z, arrow as V } from "@floating-ui/react-dom";
3
- import m from "classnames";
4
- import { useRef as g, useLayoutEffect as q, useEffect as N, useMemo as B, useCallback as G } from "react";
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";
3
+ import c from "classnames";
4
+ import { useRef as g, useMemo as N, useEffect as B, useCallback as G } from "react";
5
5
  import { CSSTransition as H } from "react-transition-group";
6
6
  import { Portal as J } from "../portal/component.js";
7
7
  import { Stack as K } from "../stack/component.js";
@@ -21,92 +21,90 @@ const W = {
21
21
  left: "right"
22
22
  }, ct = ({
23
23
  children: R,
24
- getPortalContainer: A,
25
- transition: f = W,
26
- anchorElement: d,
27
- offset: a = [0, 0],
28
- withArrow: i = !1,
29
- withTransition: b = !0,
30
- position: y = "left",
31
- preventFlip: T,
32
- popperClassName: h,
24
+ getPortalContainer: b,
25
+ transition: m = W,
26
+ anchorElement: A,
27
+ offset: n = [0, 0],
28
+ withArrow: o = !1,
29
+ withTransition: T = !0,
30
+ position: h = "left",
31
+ preventFlip: f,
32
+ popperClassName: y,
33
33
  arrowClassName: E,
34
34
  className: O,
35
- open: u,
35
+ open: i,
36
36
  dataTestId: C,
37
37
  update: l,
38
- transitionDuration: F = `${f.timeout}ms`,
39
- zIndex: w = Q.POPOVER
38
+ transitionDuration: F = `${m.timeout}ms`,
39
+ zIndex: I = Q.POPOVER
40
40
  }) => {
41
- const p = g(null), x = g(null), {
42
- refs: n,
43
- floatingStyles: I,
44
- middlewareData: c,
45
- placement: S,
46
- update: o
47
- } = $({
48
- placement: y,
49
- whileElementsMounted: j,
50
- middleware: [
51
- D(
52
- {
53
- crossAxis: a[0],
54
- mainAxis: a[1]
55
- },
56
- [a]
57
- ),
58
- ...T ? [] : [U()],
59
- z({ padding: 4 }),
60
- ...i ? [V({ element: p })] : []
61
- ]
41
+ const d = g(null), u = g(null), M = N(
42
+ () => [
43
+ L({
44
+ crossAxis: n[0],
45
+ mainAxis: n[1]
46
+ }),
47
+ ...f ? [] : [P()],
48
+ U({ padding: 4 }),
49
+ ...o ? [z({ element: d })] : []
50
+ ],
51
+ [n[0], n[1], f, o]
52
+ ), {
53
+ refs: { setFloating: p },
54
+ floatingStyles: _,
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,
63
+ middleware: M
62
64
  });
63
- q(() => {
64
- n.setReference(d);
65
- }, [d, n]), N(() => {
66
- l && o && (l.current = o);
67
- }, [o, l]), N(() => {
68
- o();
69
- }, [o]);
70
- const M = B(() => {
71
- if (!i || !c.arrow)
65
+ B(() => {
66
+ l && (l.current = S);
67
+ }, [S, l]);
68
+ const k = N(() => {
69
+ if (!o || !a.arrow)
72
70
  return {};
73
- const { x: t, y: s } = c.arrow, k = S.split("-")[0], L = Z[k] ?? "bottom";
71
+ const { x: t, y: s } = a.arrow, j = x.split("-")[0], w = Z[j] ?? "bottom";
74
72
  return {
75
73
  position: "absolute",
76
74
  left: t != null ? `${t}px` : void 0,
77
75
  top: s != null ? `${s}px` : void 0,
78
76
  right: "",
79
77
  bottom: "",
80
- [L]: "-4px"
78
+ [w]: "-4px"
81
79
  };
82
- }, [i, c.arrow, S]), _ = G(
80
+ }, [o, a.arrow, x]), $ = G(
83
81
  (t) => {
84
- x.current = t, n.setFloating(t);
82
+ u.current = t, p(t);
85
83
  },
86
- [n]
84
+ [p]
87
85
  ), v = (t, s) => /* @__PURE__ */ r(
88
86
  "div",
89
87
  {
90
- ref: _,
88
+ ref: $,
91
89
  style: {
92
90
  zIndex: t,
93
- ...I
91
+ ..._
94
92
  },
95
- className: m(e.component, O),
96
- children: /* @__PURE__ */ P(
93
+ className: c(e.component, O),
94
+ children: /* @__PURE__ */ D(
97
95
  "div",
98
96
  {
99
97
  "data-test-id": C,
100
- className: m(e.inner, h),
98
+ className: c(e.inner, y),
101
99
  style: s,
102
100
  children: [
103
101
  R,
104
- i && /* @__PURE__ */ r(
102
+ o && /* @__PURE__ */ r(
105
103
  "div",
106
104
  {
107
- ref: p,
108
- style: M,
109
- className: m(e.arrow, E)
105
+ ref: d,
106
+ style: k,
107
+ className: c(e.arrow, E)
110
108
  }
111
109
  )
112
110
  ]
@@ -114,17 +112,17 @@ const W = {
114
112
  )
115
113
  }
116
114
  );
117
- return /* @__PURE__ */ r(K, { value: w, children: (t) => /* @__PURE__ */ r(J, { getPortalContainer: A, children: b ? /* @__PURE__ */ r(
115
+ return /* @__PURE__ */ r(K, { value: I, children: (t) => /* @__PURE__ */ r(J, { getPortalContainer: b, children: T ? /* @__PURE__ */ r(
118
116
  Y,
119
117
  {
120
118
  unmountOnExit: !0,
121
119
  classNames: X,
122
- ...f,
123
- in: u,
124
- nodeRef: x,
120
+ ...m,
121
+ in: i,
122
+ nodeRef: u,
125
123
  children: v(t, { transitionDuration: F })
126
124
  }
127
- ) : u && v(t) }) });
125
+ ) : i && v(t) }) });
128
126
  };
129
127
  export {
130
128
  ct as Popover
@@ -1,3 +1,4 @@
1
- export declare const EmptyList: ({ language }: {
1
+ export declare const EmptyList: ({ language, columnsLength, }: {
2
2
  language: 'en' | 'de' | 'ru';
3
+ columnsLength: number;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,11 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
2
  import { Typography as i } from "../../../typography/component.js";
3
3
  import { translate as m } from "../../languages/index.js";
4
- import o from "./index.module.css.js";
5
- const y = ({ language: r }) => /* @__PURE__ */ t("div", { className: o.empty_list, children: /* @__PURE__ */ t(i.Text, { color: "primary", view: "title", children: m(r)("emptyList") }) });
4
+ import e from "./index.module.css.js";
5
+ const c = ({
6
+ language: r,
7
+ columnsLength: o
8
+ }) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { colSpan: o, className: e.empty_list, children: /* @__PURE__ */ t(i.Text, { color: "primary", view: "title", children: m(r)("emptyList") }) }) });
6
9
  export {
7
- y as EmptyList
10
+ c as EmptyList
8
11
  };
@@ -1,3 +1,4 @@
1
- export declare const TableError: ({ language }: {
1
+ export declare const TableError: ({ language, columnsLength, }: {
2
2
  language: 'en' | 'de' | 'ru';
3
+ columnsLength: number;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,11 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { Typography as t } from "../../../typography/component.js";
3
- import { translate as e } from "../../languages/index.js";
4
- import i from "./index.module.css.js";
5
- const a = ({ language: o }) => /* @__PURE__ */ r("div", { className: i.empty_list, children: /* @__PURE__ */ r(t.Text, { color: "primary", view: "title", children: e(o)("error") }) });
2
+ import { Typography as e } from "../../../typography/component.js";
3
+ import { translate as i } from "../../languages/index.js";
4
+ import l from "./index.module.css.js";
5
+ const c = ({
6
+ language: o,
7
+ columnsLength: t
8
+ }) => /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: t, className: l.empty_list, children: /* @__PURE__ */ r(e.Text, { color: "primary", view: "title", children: i(o)("error") }) }) });
6
9
  export {
7
- a as TableError
10
+ c as TableError
8
11
  };
@@ -1,115 +1,117 @@
1
- import { useState as u, useCallback as c, useEffect as D } from "react";
2
- import { addQueryParam as z } from "../utils/add-query-param.js";
3
- import { getQueryFromUrl as I } from "../utils/get-query-from-url.js";
1
+ import { useState as u, useCallback as c, useEffect as b } 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";
4
4
  import "query-string";
5
- import { removeQueryParam as R } from "../utils/remove-query-param.js";
6
- import { resetQueryParam as V } from "../utils/reset-query-param.js";
7
- import { serializeData as b } from "../utils/serialize-data.js";
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 v } from "../utils/serialize-data.js";
8
8
  const A = {
9
9
  page: 1,
10
10
  limit: 10,
11
11
  where: {}
12
12
  // остальное добавится по мере нужды (searchText, sort, order и т.д.)
13
13
  };
14
- function v(f, s) {
15
- const n = f ?? A, a = {
16
- ...n,
14
+ function E(f, s) {
15
+ const r = f ?? A, a = {
16
+ ...r,
17
17
  ...s,
18
18
  where: {
19
- ...n.where ?? {},
19
+ ...r.where ?? {},
20
20
  ...s.where ?? {}
21
21
  }
22
22
  };
23
23
  return a.page && (a.page = +a.page), a.limit && (a.limit = +a.limit), a;
24
24
  }
25
- function K({ promise: f, records: s, fromPath: n = !0 }) {
26
- const [a, Q] = u([]), [E, g] = u(!0), [C, d] = u(!1), [L, P] = u(0), [S, T] = u(1), [o, m] = u(void 0), w = c(
27
- (t) => n ? I() : t ?? o ?? A,
28
- [n, o]
29
- ), r = c(
25
+ function M({ promise: f, records: s, fromPath: r = !0 }) {
26
+ const [a, Q] = u([]), [C, w] = u(!0), [L, d] = u(!1), [S, T] = u(0), [U, q] = u(1), [i, y] = u(void 0), m = c(
27
+ (t) => r ? R() : t ?? i ?? A,
28
+ // params не включаем при fromPath: иначе setParams на каждом fetch
29
+ // даёт новую ссылку → computeQuery/updateData меняются → бесконечный цикл.
30
+ r ? [r] : [r, i]
31
+ ), n = c(
30
32
  async (t) => {
31
- const e = w(t);
32
- if (Array.isArray(s) && (g(!1), Q(b(s, e))), m(e), f) {
33
- d(!1), g(!0);
33
+ const e = m(t);
34
+ if (Array.isArray(s) && (w(!1), Q(v(s, e))), r || y(e), f) {
35
+ d(!1), w(!0);
34
36
  try {
35
37
  const {
36
- data: { items: i, meta: y }
38
+ data: { items: o, meta: g }
37
39
  } = await f(e);
38
- P(y.totalItems), T(y.totalPages), Q(i || []);
40
+ T(g.totalItems), q(g.totalPages), Q(o || []);
39
41
  } catch {
40
42
  d(!0);
41
43
  } finally {
42
- g(!1);
44
+ w(!1);
43
45
  }
44
46
  }
45
47
  },
46
- [w, s, f]
47
- ), U = c(
48
+ [m, s, f]
49
+ ), F = c(
48
50
  (t) => {
49
- if (n) {
50
- z(t), r();
51
+ if (r) {
52
+ I(t), n();
51
53
  return;
52
54
  }
53
- const e = v(o, t);
54
- m(e), r(e);
55
+ const e = E(i, t);
56
+ y(e), n(e);
55
57
  },
56
- [n, o, r]
58
+ [r, i, n]
57
59
  ), p = c(
58
- (t, e, i) => {
59
- const y = t ?? A, l = {
60
- ...y,
61
- where: { ...y.where ?? {} }
60
+ (t, e, o) => {
61
+ const g = t ?? A, l = {
62
+ ...g,
63
+ where: { ...g.where ?? {} }
62
64
  }, x = l.where?.[e];
63
- if (Array.isArray(x) && i != null) {
64
- const h = x.filter((k) => String(k) !== String(i));
65
- h.length ? l.where[e] = h : delete l.where[e];
65
+ if (Array.isArray(x) && o != null) {
66
+ const D = x.filter((z) => String(z) !== String(o));
67
+ D.length ? l.where[e] = D : delete l.where[e];
66
68
  } else
67
69
  l.where && e in l.where && delete l.where[e];
68
70
  return l;
69
71
  },
70
72
  []
71
- ), q = c(
73
+ ), h = c(
72
74
  (t, e) => {
73
- if (n) {
74
- R(t, e), r();
75
+ if (r) {
76
+ V(t, e), n();
75
77
  return;
76
78
  }
77
- const i = p(o, t, e);
78
- m(i), r(i);
79
+ const o = p(i, t, e);
80
+ y(o), n(o);
79
81
  },
80
- [n, o, r, p]
81
- ), F = c(
82
+ [r, i, n, p]
83
+ ), k = c(
82
84
  (t) => {
83
- if (n) {
84
- V(t), r();
85
+ if (r) {
86
+ Y(t), n();
85
87
  return;
86
88
  }
87
- const e = v(A, t);
88
- m(e), r(e);
89
+ const e = E(A, t);
90
+ y(e), n(e);
89
91
  },
90
- [n, r]
92
+ [r, n]
91
93
  );
92
- return D(() => {
93
- r();
94
- }, [r]), D(() => {
94
+ return b(() => {
95
+ n();
96
+ }, [n]), b(() => {
95
97
  if (Array.isArray(s)) {
96
- const t = w();
97
- m(t), g(!1), Q(b(s, t));
98
+ const t = m();
99
+ r || y(t), w(!1), Q(v(s, t));
98
100
  }
99
- }, [s, w]), {
100
- loading: E,
101
- error: C,
101
+ }, [s, m]), {
102
+ loading: C,
103
+ error: L,
102
104
  data: a,
103
- total: L,
104
- params: o,
105
- pagesCount: S,
106
- updateData: r,
105
+ total: S,
106
+ params: i,
107
+ pagesCount: U,
108
+ updateData: n,
107
109
  // НОВОЕ: наружу отдаём универсальные методы для управления параметрами
108
- addParam: U,
109
- removeParam: q,
110
- resetParams: F
110
+ addParam: F,
111
+ removeParam: h,
112
+ resetParams: k
111
113
  };
112
114
  }
113
115
  export {
114
- K as useTableData
116
+ M as useTableData
115
117
  };
@@ -1,137 +1,137 @@
1
- import { jsxs as f, jsx as r } from "react/jsx-runtime";
2
- import P from "classnames";
3
- import { useMemo as j, useCallback as U } from "react";
4
- import { Cells as W } from "./components/cells/index.js";
5
- import { EmptyList as X } from "./components/empty-list/index.js";
6
- import { TableError as Y } from "./components/error/index.js";
7
- import { Loading as Z } from "./components/loading/index.js";
8
- import { Pagination as $ } from "./components/pagination/index.js";
9
- import { TableHeader as A } from "./components/table-header/index.js";
10
- import { useTableData as aa } from "./hooks/use-table-data.js";
11
- import o from "./index.module.css.js";
12
- import { getTags as ta } from "./utils/get-tags.js";
13
- import { prepareRows as ra } from "./utils/prepare-rows.js";
14
- function ha({
15
- columns: l,
16
- searchPlaceholder: E = "Поиск по таблице",
17
- records: H,
18
- hideSearch: b,
19
- rightHeaderAddons: h,
20
- leftHeaderAddons: g,
21
- filtersButtonLabel: S,
22
- createButtonLabel: _,
23
- loading: w,
24
- height: B = "fill",
25
- view: e = "default",
26
- tagsBuilder: F,
1
+ import { jsxs as h, jsx as r } from "react/jsx-runtime";
2
+ import X, { useMemo as E, useCallback as Y } from "react";
3
+ import f from "classnames";
4
+ import { Cells as Z } from "./components/cells/index.js";
5
+ import { EmptyList as $ } from "./components/empty-list/index.js";
6
+ import { Loading as A } from "./components/loading/index.js";
7
+ import { Pagination as tt } from "./components/pagination/index.js";
8
+ import { TableHeader as at } from "./components/table-header/index.js";
9
+ import { useTableData as rt } from "./hooks/use-table-data.js";
10
+ import { getTags as ot } from "./utils/get-tags.js";
11
+ import { prepareRows as et } from "./utils/prepare-rows.js";
12
+ import e from "./index.module.css.js";
13
+ import { TableError as st } from "./components/error/index.js";
14
+ function Lt({
15
+ columns: o,
16
+ searchPlaceholder: N = "Поиск по таблице",
17
+ records: j,
18
+ hideSearch: P,
19
+ rightHeaderAddons: g,
20
+ leftHeaderAddons: b,
21
+ filtersButtonLabel: H,
22
+ createButtonLabel: R,
23
+ loading: S,
24
+ height: _ = "fill",
25
+ view: s = "default",
26
+ tagsBuilder: w,
27
27
  promise: u,
28
- onRowClick: T,
29
- onCreateClick: n,
28
+ onRowClick: L,
29
+ onCreateClick: i,
30
30
  onFiltersClick: m,
31
- refetch: C,
32
- language: i,
33
- fromPath: M = !0
31
+ refetch: B,
32
+ language: n,
33
+ fromPath: F = !0
34
34
  }) {
35
35
  const {
36
- loading: R,
37
- error: x,
36
+ loading: M,
37
+ error: T,
38
38
  data: y,
39
39
  total: V,
40
- params: t,
40
+ params: a,
41
41
  pagesCount: q,
42
42
  updateData: c,
43
43
  addParam: z,
44
44
  removeParam: G,
45
- resetParams: L
46
- } = aa({
45
+ resetParams: C
46
+ } = rt({
47
47
  promise: u,
48
- records: H,
49
- fromPath: M
50
- }), k = j(
48
+ records: j,
49
+ fromPath: F
50
+ }), k = E(
51
51
  () => [...y || []].sort(
52
- (a, s) => (a.sortPosition || 0) - (s.sortPosition || 0)
52
+ (t, l) => (t.sortPosition || 0) - (l.sortPosition || 0)
53
53
  ),
54
54
  [y]
55
- ), I = (a) => T?.(a, c), J = n ? () => n(c) : void 0, K = U(
56
- (a) => {
57
- L(a);
55
+ ), I = (t) => L?.(t, c), J = i ? () => i(c) : void 0, K = Y(
56
+ (t) => {
57
+ C(t);
58
58
  },
59
- [L]
60
- ), v = () => m ? m({
61
- submitCallback: (a) => K(a),
62
- initialValues: t
63
- }) : null, d = (a) => {
64
- z(a);
65
- }, O = (a, s) => {
66
- G(a, s);
67
- }, Q = ta({
68
- params: t?.where || {},
59
+ [C]
60
+ ), x = () => m ? m({
61
+ submitCallback: (t) => K(t),
62
+ initialValues: a
63
+ }) : null, d = (t) => {
64
+ z(t);
65
+ }, O = (t, l) => {
66
+ G(t, l);
67
+ }, Q = ot({
68
+ params: a?.where || {},
69
69
  onDelete: O,
70
- tagsBuilder: F,
71
- onClick: v
72
- }), D = j(
73
- () => ra({
74
- columns: l,
75
- view: e,
70
+ tagsBuilder: w,
71
+ onClick: x
72
+ }), v = E(
73
+ () => et({
74
+ columns: o,
75
+ view: s,
76
76
  data: k,
77
- refetch: C || c
77
+ refetch: B || c
78
78
  }),
79
79
  // eslint-disable-next-line react-hooks/exhaustive-deps
80
- [k, l, e, c, C]
81
- ), p = R || w, N = !!u;
82
- return /* @__PURE__ */ f("div", { className: P(o.table_wrapper, o[B], o[e]), children: [
83
- (!b || h || g || n || m) && /* @__PURE__ */ r(
84
- A,
80
+ [k, o, s]
81
+ ), p = M || S, D = !!u;
82
+ return /* @__PURE__ */ h("div", { className: f(e.table_wrapper, e[_], e[s]), children: [
83
+ (!P || g || b || i || m) && /* @__PURE__ */ r(
84
+ at,
85
85
  {
86
- language: i,
87
- hideSearch: b,
88
- rightHeaderAddons: h,
89
- leftHeaderAddons: g,
90
- searchText: t?.searchText || "",
86
+ language: n,
87
+ hideSearch: P,
88
+ rightHeaderAddons: g,
89
+ leftHeaderAddons: b,
90
+ searchText: a?.searchText || "",
91
91
  addParam: d,
92
- searchPlaceholder: E,
93
- filtersButtonLabel: S,
92
+ searchPlaceholder: N,
93
+ filtersButtonLabel: H,
94
94
  tags: Q,
95
95
  onCreateClick: J,
96
- createButtonLabel: _,
97
- onFiltersClick: v,
96
+ createButtonLabel: R,
97
+ onFiltersClick: x,
98
98
  showFiltersButton: !!m,
99
- compact: e === "compact"
99
+ compact: s === "compact"
100
100
  }
101
101
  ),
102
- /* @__PURE__ */ r("div", { className: P(o.table, { [o.no_footer]: !N }), children: /* @__PURE__ */ f("table", { cellSpacing: "0", cellPadding: "0", children: [
102
+ /* @__PURE__ */ r("div", { className: f(e.table, { [e.no_footer]: !D }), children: /* @__PURE__ */ h("table", { cellSpacing: "0", cellPadding: "0", children: [
103
103
  /* @__PURE__ */ r(
104
- W,
104
+ Z,
105
105
  {
106
- sort: t?.sort,
107
- order: t?.order,
106
+ sort: a?.sort,
107
+ order: a?.order,
108
108
  addParam: d,
109
- columns: l,
110
- compact: e === "compact"
109
+ columns: o,
110
+ compact: s === "compact"
111
111
  }
112
112
  ),
113
- /* @__PURE__ */ f("tbody", { children: [
114
- x && /* @__PURE__ */ r(Y, { language: i }),
115
- !D.length && !p && !x && /* @__PURE__ */ r(X, { language: i }),
116
- p && /* @__PURE__ */ r(Z, { columnsLength: l.length }),
117
- D.map(({ row: a, cells: s }) => /* @__PURE__ */ r(
113
+ /* @__PURE__ */ h("tbody", { children: [
114
+ T && /* @__PURE__ */ r(st, { columnsLength: o.length, language: n }),
115
+ !v.length && !p && !T && /* @__PURE__ */ r($, { columnsLength: o.length, language: n }),
116
+ p && /* @__PURE__ */ r(A, { columnsLength: o.length }),
117
+ v.map(({ row: t, cells: l }) => /* @__PURE__ */ r(
118
118
  "tr",
119
119
  {
120
- onClick: () => I(a),
121
- className: P({ [o.clickable]: !!T }),
120
+ onClick: () => I(t),
121
+ className: f({ [e.clickable]: !!L }),
122
122
  style: { visibility: p ? "collapse" : "visible" },
123
- children: s
123
+ children: l.map((U, W) => X.cloneElement(U, { key: W }))
124
124
  },
125
- String(a.id)
125
+ String(t.id)
126
126
  ))
127
127
  ] })
128
128
  ] }) }),
129
- N && /* @__PURE__ */ r(
130
- $,
129
+ D && /* @__PURE__ */ r(
130
+ tt,
131
131
  {
132
- language: i,
133
- currentPage: t ? +t.page : 1,
134
- recordsPerPage: t ? +t.limit : 10,
132
+ language: n,
133
+ currentPage: a ? +a.page : 1,
134
+ recordsPerPage: a ? +a.limit : 10,
135
135
  pagesCount: +q,
136
136
  addParam: d,
137
137
  total: +V
@@ -140,5 +140,5 @@ function ha({
140
140
  ] });
141
141
  }
142
142
  export {
143
- ha as Table
143
+ Lt as Table
144
144
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphakits/ui",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],