@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.
- package/dist/form/templates/rest-form/form.js +67 -65
- package/dist/modal/hooks/use-modal.js +22 -22
- package/dist/popover/component.js +63 -65
- package/dist/table/components/empty-list/index.d.ts +2 -1
- package/dist/table/components/empty-list/index.js +6 -3
- package/dist/table/components/error/index.d.ts +2 -1
- package/dist/table/components/error/index.js +8 -5
- package/dist/table/hooks/use-table-data.js +65 -63
- package/dist/table/table.js +96 -96
- package/package.json +1 -1
|
@@ -1,109 +1,111 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Flex as
|
|
6
|
-
import { FlexColumns as
|
|
7
|
-
import { IconButton as
|
|
8
|
-
import { ModalContext as
|
|
9
|
-
import { Sidepanel as
|
|
10
|
-
import { ToastPlate as
|
|
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:
|
|
13
|
-
title:
|
|
12
|
+
recordId: R,
|
|
13
|
+
title: M,
|
|
14
14
|
subtitle: T,
|
|
15
|
-
headerBottomAddons:
|
|
15
|
+
headerBottomAddons: b,
|
|
16
16
|
initialValues: w,
|
|
17
17
|
submitButtonText: y,
|
|
18
|
-
customFooter:
|
|
19
|
-
loading:
|
|
20
|
-
updating:
|
|
18
|
+
customFooter: B,
|
|
19
|
+
loading: n,
|
|
20
|
+
updating: i,
|
|
21
21
|
removing: s,
|
|
22
|
-
customValidationFields:
|
|
23
|
-
validate:
|
|
24
|
-
save:
|
|
22
|
+
customValidationFields: Q,
|
|
23
|
+
validate: U,
|
|
24
|
+
save: W,
|
|
25
25
|
remove: a,
|
|
26
|
-
close:
|
|
27
|
-
back:
|
|
26
|
+
close: S,
|
|
27
|
+
back: z,
|
|
28
28
|
t: r,
|
|
29
|
-
children:
|
|
30
|
-
headerAddon:
|
|
31
|
-
error:
|
|
29
|
+
children: P,
|
|
30
|
+
headerAddon: h,
|
|
31
|
+
error: X,
|
|
32
32
|
softError: d,
|
|
33
|
-
...
|
|
33
|
+
...g
|
|
34
34
|
}) {
|
|
35
|
-
const { setModalDirty: e, currentModalId:
|
|
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(
|
|
39
|
+
e(t, !1), C();
|
|
38
40
|
},
|
|
39
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
[
|
|
41
|
-
),
|
|
42
|
-
e(
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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:
|
|
56
|
+
disabled: i,
|
|
55
57
|
loading: s,
|
|
56
|
-
onClick:
|
|
57
|
-
icon:
|
|
58
|
+
onClick: j,
|
|
59
|
+
icon: V
|
|
58
60
|
}
|
|
59
61
|
)
|
|
60
62
|
] }) : null;
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
|
|
63
|
+
return /* @__PURE__ */ o(
|
|
64
|
+
O,
|
|
63
65
|
{
|
|
64
|
-
headerRightAddons:
|
|
65
|
-
title:
|
|
66
|
+
headerRightAddons: A,
|
|
67
|
+
title: M,
|
|
66
68
|
subtitle: T,
|
|
67
|
-
loading:
|
|
68
|
-
headerBottomAddons: (
|
|
69
|
-
|
|
70
|
-
!!d && /* @__PURE__ */
|
|
71
|
-
!
|
|
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:
|
|
75
|
+
back: z,
|
|
74
76
|
t: r,
|
|
75
|
-
bottomAddons:
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
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:
|
|
83
|
-
disabled:
|
|
84
|
+
loading: n,
|
|
85
|
+
disabled: i || s,
|
|
84
86
|
dataTestId: "buttonSave",
|
|
85
|
-
onClick: () =>
|
|
87
|
+
onClick: () => k(),
|
|
86
88
|
children: r(y || "save")
|
|
87
89
|
}
|
|
88
90
|
),
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
|
|
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:
|
|
98
|
+
onClick: S,
|
|
97
99
|
children: r("cancel")
|
|
98
100
|
}
|
|
99
101
|
)
|
|
100
102
|
] }),
|
|
101
|
-
children:
|
|
102
|
-
submitCount:
|
|
103
|
-
isValid:
|
|
104
|
-
handleSubmit:
|
|
103
|
+
children: P({
|
|
104
|
+
submitCount: m,
|
|
105
|
+
isValid: f,
|
|
106
|
+
handleSubmit: k,
|
|
105
107
|
initialValues: w,
|
|
106
|
-
...
|
|
108
|
+
...u
|
|
107
109
|
})
|
|
108
110
|
}
|
|
109
111
|
);
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import n, {
|
|
2
|
-
import { v4 as
|
|
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 [
|
|
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
|
-
},
|
|
7
|
+
}, i = (t) => {
|
|
8
8
|
l((o) => [...o, t]);
|
|
9
|
-
},
|
|
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
|
|
16
|
-
const t = [...
|
|
17
|
-
M(t || ""), document.body.style.overflow =
|
|
18
|
-
}, [
|
|
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 = (
|
|
21
|
-
id:
|
|
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:
|
|
26
|
+
closeCallback: d,
|
|
27
27
|
t: c,
|
|
28
|
-
...
|
|
28
|
+
...s
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
return (
|
|
32
|
-
|
|
31
|
+
return (s, d) => {
|
|
32
|
+
i(y(s, d));
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
|
-
modals:
|
|
36
|
-
setModalDirty:
|
|
35
|
+
modals: r,
|
|
36
|
+
setModalDirty: m,
|
|
37
37
|
currentModalId: u,
|
|
38
|
-
dirtyModals:
|
|
39
|
-
closeModal:
|
|
38
|
+
dirtyModals: p,
|
|
39
|
+
closeModal: f
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { useRef as g,
|
|
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:
|
|
25
|
-
transition:
|
|
26
|
-
anchorElement:
|
|
27
|
-
offset:
|
|
28
|
-
withArrow:
|
|
29
|
-
withTransition:
|
|
30
|
-
position:
|
|
31
|
-
preventFlip:
|
|
32
|
-
popperClassName:
|
|
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:
|
|
35
|
+
open: i,
|
|
36
36
|
dataTestId: C,
|
|
37
37
|
update: l,
|
|
38
|
-
transitionDuration: F = `${
|
|
39
|
-
zIndex:
|
|
38
|
+
transitionDuration: F = `${m.timeout}ms`,
|
|
39
|
+
zIndex: I = Q.POPOVER
|
|
40
40
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
}, [
|
|
66
|
-
|
|
67
|
-
|
|
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 } =
|
|
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
|
-
[
|
|
78
|
+
[w]: "-4px"
|
|
81
79
|
};
|
|
82
|
-
}, [
|
|
80
|
+
}, [o, a.arrow, x]), $ = G(
|
|
83
81
|
(t) => {
|
|
84
|
-
|
|
82
|
+
u.current = t, p(t);
|
|
85
83
|
},
|
|
86
|
-
[
|
|
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
|
-
...
|
|
91
|
+
..._
|
|
94
92
|
},
|
|
95
|
-
className:
|
|
96
|
-
children: /* @__PURE__ */
|
|
93
|
+
className: c(e.component, O),
|
|
94
|
+
children: /* @__PURE__ */ D(
|
|
97
95
|
"div",
|
|
98
96
|
{
|
|
99
97
|
"data-test-id": C,
|
|
100
|
-
className:
|
|
98
|
+
className: c(e.inner, y),
|
|
101
99
|
style: s,
|
|
102
100
|
children: [
|
|
103
101
|
R,
|
|
104
|
-
|
|
102
|
+
o && /* @__PURE__ */ r(
|
|
105
103
|
"div",
|
|
106
104
|
{
|
|
107
|
-
ref:
|
|
108
|
-
style:
|
|
109
|
-
className:
|
|
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:
|
|
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
|
-
...
|
|
123
|
-
in:
|
|
124
|
-
nodeRef:
|
|
120
|
+
...m,
|
|
121
|
+
in: i,
|
|
122
|
+
nodeRef: u,
|
|
125
123
|
children: v(t, { transitionDuration: F })
|
|
126
124
|
}
|
|
127
|
-
) :
|
|
125
|
+
) : i && v(t) }) });
|
|
128
126
|
};
|
|
129
127
|
export {
|
|
130
128
|
ct as Popover
|
|
@@ -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
|
|
5
|
-
const
|
|
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
|
-
|
|
10
|
+
c as EmptyList
|
|
8
11
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { Typography as
|
|
3
|
-
import { translate as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
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
|
-
|
|
10
|
+
c as TableError
|
|
8
11
|
};
|
|
@@ -1,115 +1,117 @@
|
|
|
1
|
-
import { useState as u, useCallback as c, useEffect as
|
|
2
|
-
import { addQueryParam as
|
|
3
|
-
import { getQueryFromUrl as
|
|
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
|
|
6
|
-
import { resetQueryParam as
|
|
7
|
-
import { serializeData as
|
|
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
|
|
15
|
-
const
|
|
16
|
-
...
|
|
14
|
+
function E(f, s) {
|
|
15
|
+
const r = f ?? A, a = {
|
|
16
|
+
...r,
|
|
17
17
|
...s,
|
|
18
18
|
where: {
|
|
19
|
-
...
|
|
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
|
|
26
|
-
const [a, Q] = u([]), [
|
|
27
|
-
(t) =>
|
|
28
|
-
|
|
29
|
-
|
|
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 =
|
|
32
|
-
if (Array.isArray(s) && (
|
|
33
|
-
d(!1),
|
|
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:
|
|
38
|
+
data: { items: o, meta: g }
|
|
37
39
|
} = await f(e);
|
|
38
|
-
|
|
40
|
+
T(g.totalItems), q(g.totalPages), Q(o || []);
|
|
39
41
|
} catch {
|
|
40
42
|
d(!0);
|
|
41
43
|
} finally {
|
|
42
|
-
|
|
44
|
+
w(!1);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
+
[m, s, f]
|
|
49
|
+
), F = c(
|
|
48
50
|
(t) => {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
+
if (r) {
|
|
52
|
+
I(t), n();
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
|
-
const e =
|
|
54
|
-
|
|
55
|
+
const e = E(i, t);
|
|
56
|
+
y(e), n(e);
|
|
55
57
|
},
|
|
56
|
-
[
|
|
58
|
+
[r, i, n]
|
|
57
59
|
), p = c(
|
|
58
|
-
(t, e,
|
|
59
|
-
const
|
|
60
|
-
...
|
|
61
|
-
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) &&
|
|
64
|
-
const
|
|
65
|
-
|
|
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
|
-
),
|
|
73
|
+
), h = c(
|
|
72
74
|
(t, e) => {
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
+
if (r) {
|
|
76
|
+
V(t, e), n();
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
+
const o = p(i, t, e);
|
|
80
|
+
y(o), n(o);
|
|
79
81
|
},
|
|
80
|
-
[
|
|
81
|
-
),
|
|
82
|
+
[r, i, n, p]
|
|
83
|
+
), k = c(
|
|
82
84
|
(t) => {
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
+
if (r) {
|
|
86
|
+
Y(t), n();
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
87
|
-
const e =
|
|
88
|
-
|
|
89
|
+
const e = E(A, t);
|
|
90
|
+
y(e), n(e);
|
|
89
91
|
},
|
|
90
|
-
[
|
|
92
|
+
[r, n]
|
|
91
93
|
);
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
}, [
|
|
94
|
+
return b(() => {
|
|
95
|
+
n();
|
|
96
|
+
}, [n]), b(() => {
|
|
95
97
|
if (Array.isArray(s)) {
|
|
96
|
-
const t =
|
|
97
|
-
|
|
98
|
+
const t = m();
|
|
99
|
+
r || y(t), w(!1), Q(v(s, t));
|
|
98
100
|
}
|
|
99
|
-
}, [s,
|
|
100
|
-
loading:
|
|
101
|
-
error:
|
|
101
|
+
}, [s, m]), {
|
|
102
|
+
loading: C,
|
|
103
|
+
error: L,
|
|
102
104
|
data: a,
|
|
103
|
-
total:
|
|
104
|
-
params:
|
|
105
|
-
pagesCount:
|
|
106
|
-
updateData:
|
|
105
|
+
total: S,
|
|
106
|
+
params: i,
|
|
107
|
+
pagesCount: U,
|
|
108
|
+
updateData: n,
|
|
107
109
|
// НОВОЕ: наружу отдаём универсальные методы для управления параметрами
|
|
108
|
-
addParam:
|
|
109
|
-
removeParam:
|
|
110
|
-
resetParams:
|
|
110
|
+
addParam: F,
|
|
111
|
+
removeParam: h,
|
|
112
|
+
resetParams: k
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
115
|
export {
|
|
114
|
-
|
|
116
|
+
M as useTableData
|
|
115
117
|
};
|
package/dist/table/table.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Cells as
|
|
5
|
-
import { EmptyList as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
function
|
|
15
|
-
columns:
|
|
16
|
-
searchPlaceholder:
|
|
17
|
-
records:
|
|
18
|
-
hideSearch:
|
|
19
|
-
rightHeaderAddons:
|
|
20
|
-
leftHeaderAddons:
|
|
21
|
-
filtersButtonLabel:
|
|
22
|
-
createButtonLabel:
|
|
23
|
-
loading:
|
|
24
|
-
height:
|
|
25
|
-
view:
|
|
26
|
-
tagsBuilder:
|
|
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:
|
|
29
|
-
onCreateClick:
|
|
28
|
+
onRowClick: L,
|
|
29
|
+
onCreateClick: i,
|
|
30
30
|
onFiltersClick: m,
|
|
31
|
-
refetch:
|
|
32
|
-
language:
|
|
33
|
-
fromPath:
|
|
31
|
+
refetch: B,
|
|
32
|
+
language: n,
|
|
33
|
+
fromPath: F = !0
|
|
34
34
|
}) {
|
|
35
35
|
const {
|
|
36
|
-
loading:
|
|
37
|
-
error:
|
|
36
|
+
loading: M,
|
|
37
|
+
error: T,
|
|
38
38
|
data: y,
|
|
39
39
|
total: V,
|
|
40
|
-
params:
|
|
40
|
+
params: a,
|
|
41
41
|
pagesCount: q,
|
|
42
42
|
updateData: c,
|
|
43
43
|
addParam: z,
|
|
44
44
|
removeParam: G,
|
|
45
|
-
resetParams:
|
|
46
|
-
} =
|
|
45
|
+
resetParams: C
|
|
46
|
+
} = rt({
|
|
47
47
|
promise: u,
|
|
48
|
-
records:
|
|
49
|
-
fromPath:
|
|
50
|
-
}), k =
|
|
48
|
+
records: j,
|
|
49
|
+
fromPath: F
|
|
50
|
+
}), k = E(
|
|
51
51
|
() => [...y || []].sort(
|
|
52
|
-
(
|
|
52
|
+
(t, l) => (t.sortPosition || 0) - (l.sortPosition || 0)
|
|
53
53
|
),
|
|
54
54
|
[y]
|
|
55
|
-
), I = (
|
|
56
|
-
(
|
|
57
|
-
|
|
55
|
+
), I = (t) => L?.(t, c), J = i ? () => i(c) : void 0, K = Y(
|
|
56
|
+
(t) => {
|
|
57
|
+
C(t);
|
|
58
58
|
},
|
|
59
|
-
[
|
|
60
|
-
),
|
|
61
|
-
submitCallback: (
|
|
62
|
-
initialValues:
|
|
63
|
-
}) : null, d = (
|
|
64
|
-
z(
|
|
65
|
-
}, O = (
|
|
66
|
-
G(
|
|
67
|
-
}, Q =
|
|
68
|
-
params:
|
|
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:
|
|
71
|
-
onClick:
|
|
72
|
-
}),
|
|
73
|
-
() =>
|
|
74
|
-
columns:
|
|
75
|
-
view:
|
|
70
|
+
tagsBuilder: w,
|
|
71
|
+
onClick: x
|
|
72
|
+
}), v = E(
|
|
73
|
+
() => et({
|
|
74
|
+
columns: o,
|
|
75
|
+
view: s,
|
|
76
76
|
data: k,
|
|
77
|
-
refetch:
|
|
77
|
+
refetch: B || c
|
|
78
78
|
}),
|
|
79
79
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
-
[k,
|
|
81
|
-
), p =
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
-
(!
|
|
84
|
-
|
|
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:
|
|
87
|
-
hideSearch:
|
|
88
|
-
rightHeaderAddons:
|
|
89
|
-
leftHeaderAddons:
|
|
90
|
-
searchText:
|
|
86
|
+
language: n,
|
|
87
|
+
hideSearch: P,
|
|
88
|
+
rightHeaderAddons: g,
|
|
89
|
+
leftHeaderAddons: b,
|
|
90
|
+
searchText: a?.searchText || "",
|
|
91
91
|
addParam: d,
|
|
92
|
-
searchPlaceholder:
|
|
93
|
-
filtersButtonLabel:
|
|
92
|
+
searchPlaceholder: N,
|
|
93
|
+
filtersButtonLabel: H,
|
|
94
94
|
tags: Q,
|
|
95
95
|
onCreateClick: J,
|
|
96
|
-
createButtonLabel:
|
|
97
|
-
onFiltersClick:
|
|
96
|
+
createButtonLabel: R,
|
|
97
|
+
onFiltersClick: x,
|
|
98
98
|
showFiltersButton: !!m,
|
|
99
|
-
compact:
|
|
99
|
+
compact: s === "compact"
|
|
100
100
|
}
|
|
101
101
|
),
|
|
102
|
-
/* @__PURE__ */ r("div", { className:
|
|
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
|
-
|
|
104
|
+
Z,
|
|
105
105
|
{
|
|
106
|
-
sort:
|
|
107
|
-
order:
|
|
106
|
+
sort: a?.sort,
|
|
107
|
+
order: a?.order,
|
|
108
108
|
addParam: d,
|
|
109
|
-
columns:
|
|
110
|
-
compact:
|
|
109
|
+
columns: o,
|
|
110
|
+
compact: s === "compact"
|
|
111
111
|
}
|
|
112
112
|
),
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
!
|
|
116
|
-
p && /* @__PURE__ */ r(
|
|
117
|
-
|
|
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(
|
|
121
|
-
className:
|
|
120
|
+
onClick: () => I(t),
|
|
121
|
+
className: f({ [e.clickable]: !!L }),
|
|
122
122
|
style: { visibility: p ? "collapse" : "visible" },
|
|
123
|
-
children:
|
|
123
|
+
children: l.map((U, W) => X.cloneElement(U, { key: W }))
|
|
124
124
|
},
|
|
125
|
-
String(
|
|
125
|
+
String(t.id)
|
|
126
126
|
))
|
|
127
127
|
] })
|
|
128
128
|
] }) }),
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
D && /* @__PURE__ */ r(
|
|
130
|
+
tt,
|
|
131
131
|
{
|
|
132
|
-
language:
|
|
133
|
-
currentPage:
|
|
134
|
-
recordsPerPage:
|
|
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
|
-
|
|
143
|
+
Lt as Table
|
|
144
144
|
};
|