@alphakits/ui 2.4.1 → 2.4.3
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/modal/components/modals/modal.js +40 -39
- package/dist/modal/context.js +30 -33
- package/dist/modal/hooks/use-modal.js +35 -32
- package/dist/table/hooks/use-table-data.d.ts +1 -1
- package/dist/table/hooks/use-table-data.js +74 -68
- package/dist/table/index.css +1 -1
- package/package.json +1 -1
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as h, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import y from "classnames";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { ButtonArrow as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
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 = {
|
|
7
7
|
s: 488,
|
|
8
8
|
m: 888,
|
|
9
9
|
full: "96%"
|
|
10
|
-
},
|
|
11
|
-
const c =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
15
|
+
}, [e.id]);
|
|
16
|
+
const u = k(
|
|
16
17
|
(s) => (
|
|
17
18
|
// eslint-disable-next-line no-restricted-globals
|
|
18
|
-
!
|
|
19
|
+
!p[s] || confirm(f("common:exitConfirm"))
|
|
19
20
|
),
|
|
20
21
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
-
[
|
|
22
|
-
),
|
|
22
|
+
[p, f]
|
|
23
|
+
), n = k(
|
|
23
24
|
(s) => {
|
|
24
|
-
const { id:
|
|
25
|
-
u(s ||
|
|
26
|
-
e.props.closeCallback && e.props.closeCallback(),
|
|
25
|
+
const { id: o } = e;
|
|
26
|
+
u(s || o) && (m(c), setTimeout(() => {
|
|
27
|
+
e.props.closeCallback && e.props.closeCallback(), a(s || o);
|
|
27
28
|
}, 250));
|
|
28
29
|
},
|
|
29
|
-
[
|
|
30
|
+
[a, u, e, c]
|
|
30
31
|
);
|
|
31
|
-
return
|
|
32
|
-
const s = (
|
|
33
|
-
(
|
|
32
|
+
return v(() => {
|
|
33
|
+
const s = (o) => {
|
|
34
|
+
(o.key === "27" || o.key === "Escape") && n(r);
|
|
34
35
|
};
|
|
35
36
|
return e.id === r && window?.addEventListener("keydown", s), () => {
|
|
36
37
|
window?.removeEventListener("keydown", s);
|
|
37
38
|
};
|
|
38
|
-
}, [
|
|
39
|
+
}, [n, r, e.id]), /* @__PURE__ */ h(
|
|
39
40
|
"div",
|
|
40
41
|
{
|
|
41
|
-
className:
|
|
42
|
+
className: t.container,
|
|
42
43
|
style: {
|
|
43
|
-
zIndex: 9999998 +
|
|
44
|
+
zIndex: 9999998 + l
|
|
44
45
|
},
|
|
45
46
|
children: [
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
+
/* @__PURE__ */ i(
|
|
47
48
|
"div",
|
|
48
49
|
{
|
|
49
|
-
className: y(
|
|
50
|
+
className: y(t.right, t.content),
|
|
50
51
|
style: {
|
|
51
|
-
zIndex: 9999999 +
|
|
52
|
-
width:
|
|
53
|
-
right:
|
|
52
|
+
zIndex: 9999999 + l,
|
|
53
|
+
width: C[e.props.size],
|
|
54
|
+
right: b
|
|
54
55
|
},
|
|
55
|
-
children: /* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
e.props.showCloser !== !1 && /* @__PURE__ */
|
|
58
|
-
|
|
56
|
+
children: /* @__PURE__ */ h("div", { className: t.inner, children: [
|
|
57
|
+
/* @__PURE__ */ i(e.modal, { ...e.props, close: () => n() }),
|
|
58
|
+
e.props.showCloser !== !1 && /* @__PURE__ */ i(
|
|
59
|
+
x,
|
|
59
60
|
{
|
|
60
|
-
className:
|
|
61
|
+
className: t.button,
|
|
61
62
|
size: "s",
|
|
62
63
|
type: "close",
|
|
63
|
-
onClick: () =>
|
|
64
|
+
onClick: () => n()
|
|
64
65
|
}
|
|
65
66
|
)
|
|
66
67
|
] })
|
|
67
68
|
}
|
|
68
69
|
),
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ i(
|
|
70
71
|
"button",
|
|
71
72
|
{
|
|
72
|
-
className:
|
|
73
|
+
className: t.bg,
|
|
73
74
|
"aria-label": "close_backdrop",
|
|
74
75
|
type: "button",
|
|
75
|
-
onClick: () =>
|
|
76
|
+
onClick: () => n()
|
|
76
77
|
}
|
|
77
78
|
)
|
|
78
79
|
]
|
|
@@ -80,5 +81,5 @@ const h = {
|
|
|
80
81
|
);
|
|
81
82
|
};
|
|
82
83
|
export {
|
|
83
|
-
|
|
84
|
+
O as Modal
|
|
84
85
|
};
|
package/dist/modal/context.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Portal as
|
|
4
|
-
import { Modals as
|
|
1
|
+
import { jsxs as M, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import c, { useMemo as p } from "react";
|
|
3
|
+
import { Portal as u } from "../portal/component.js";
|
|
4
|
+
import { Modals as x } from "./components/modals/index.js";
|
|
5
5
|
import { useModal as f } from "./hooks/use-modal.js";
|
|
6
|
-
const
|
|
6
|
+
const v = c.createContext({
|
|
7
7
|
modals: [],
|
|
8
8
|
currentModalId: "",
|
|
9
9
|
openModal: () => () => {
|
|
10
10
|
},
|
|
11
11
|
setModalDirty: () => {
|
|
12
12
|
}
|
|
13
|
-
}),
|
|
14
|
-
const { modals:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
currentModalId: e
|
|
23
|
-
},
|
|
24
|
-
children: [
|
|
25
|
-
/* @__PURE__ */ a(c, { getPortalContainer: o ? () => o : void 0, children: /* @__PURE__ */ a(
|
|
26
|
-
p,
|
|
27
|
-
{
|
|
28
|
-
modals: r,
|
|
29
|
-
dirtyModals: n,
|
|
30
|
-
closeModal: s,
|
|
31
|
-
openModal: t,
|
|
32
|
-
setModalDirty: d,
|
|
33
|
-
currentModalId: e
|
|
34
|
-
}
|
|
35
|
-
) }),
|
|
36
|
-
l
|
|
37
|
-
]
|
|
38
|
-
}
|
|
13
|
+
}), D = ({ children: l, t: n, portal: d }) => {
|
|
14
|
+
const { modals: o, openModal: r, setModalDirty: t, currentModalId: e, dirtyModals: s, closeModal: i } = f(n), m = p(
|
|
15
|
+
() => ({
|
|
16
|
+
modals: o,
|
|
17
|
+
openModal: r,
|
|
18
|
+
setModalDirty: t,
|
|
19
|
+
currentModalId: e
|
|
20
|
+
}),
|
|
21
|
+
[o, r, t, e]
|
|
39
22
|
);
|
|
23
|
+
return /* @__PURE__ */ M(v.Provider, { value: m, children: [
|
|
24
|
+
/* @__PURE__ */ a(u, { getPortalContainer: d ? () => d : void 0, children: /* @__PURE__ */ a(
|
|
25
|
+
x,
|
|
26
|
+
{
|
|
27
|
+
modals: o,
|
|
28
|
+
dirtyModals: s,
|
|
29
|
+
closeModal: i,
|
|
30
|
+
openModal: r,
|
|
31
|
+
setModalDirty: t,
|
|
32
|
+
currentModalId: e
|
|
33
|
+
}
|
|
34
|
+
) }),
|
|
35
|
+
l
|
|
36
|
+
] });
|
|
40
37
|
};
|
|
41
38
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
v as ModalContext,
|
|
40
|
+
D as ModalProvider
|
|
44
41
|
};
|
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { v4 as
|
|
3
|
-
import { deletePropertyById as
|
|
4
|
-
const x = (
|
|
5
|
-
const [r, l] =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
l((o) =>
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import d, { useRef as S, useCallback as s, useEffect as b } from "react";
|
|
2
|
+
import { v4 as h } from "uuid";
|
|
3
|
+
import { deletePropertyById as v } from "../utils/delete-property-by-id.js";
|
|
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;
|
|
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]);
|
|
11
|
+
}, []), m = s((t, e) => {
|
|
12
|
+
t && a((o) => o[t] === e ? o : {
|
|
13
|
+
...o,
|
|
14
|
+
[t]: e
|
|
13
15
|
});
|
|
14
16
|
}, []);
|
|
15
|
-
return
|
|
17
|
+
return b(() => {
|
|
16
18
|
const t = [...r].pop()?.id;
|
|
17
|
-
|
|
19
|
+
f(t || ""), document.body.style.overflow = r.length ? "hidden" : "unset";
|
|
18
20
|
}, [r]), {
|
|
19
|
-
openModal: (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
21
|
+
openModal: s(
|
|
22
|
+
(t, e = "s", o = !0) => (y, I) => {
|
|
23
|
+
const R = h();
|
|
24
|
+
u({
|
|
25
|
+
id: R,
|
|
26
|
+
modal: t,
|
|
27
|
+
props: {
|
|
28
|
+
size: e,
|
|
29
|
+
showCloser: o,
|
|
30
|
+
closeCallback: I,
|
|
31
|
+
t: c.current,
|
|
32
|
+
...y
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
[u]
|
|
37
|
+
),
|
|
35
38
|
modals: r,
|
|
36
39
|
setModalDirty: m,
|
|
37
|
-
currentModalId:
|
|
40
|
+
currentModalId: M,
|
|
38
41
|
dirtyModals: p,
|
|
39
|
-
closeModal:
|
|
42
|
+
closeModal: i
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
45
|
export {
|
|
@@ -10,7 +10,7 @@ export declare function useTableData<T extends object>({ promise, records, fromP
|
|
|
10
10
|
error: boolean;
|
|
11
11
|
data: T[];
|
|
12
12
|
total: number;
|
|
13
|
-
params: QueryDTO
|
|
13
|
+
params: QueryDTO;
|
|
14
14
|
pagesCount: number;
|
|
15
15
|
updateData: (forcedQuery?: QueryDTO) => Promise<void>;
|
|
16
16
|
addParam: (patch: Query) => void;
|
|
@@ -1,117 +1,123 @@
|
|
|
1
|
-
import { useState as u, useCallback as
|
|
2
|
-
import { addQueryParam as
|
|
3
|
-
import { getQueryFromUrl as
|
|
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
|
|
6
|
-
import { resetQueryParam as
|
|
7
|
-
import { serializeData as
|
|
8
|
-
const
|
|
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
|
|
15
|
-
const r =
|
|
14
|
+
function L(w, a) {
|
|
15
|
+
const r = w ?? p, n = {
|
|
16
16
|
...r,
|
|
17
|
-
...
|
|
17
|
+
...a,
|
|
18
18
|
where: {
|
|
19
19
|
...r.where ?? {},
|
|
20
|
-
...
|
|
20
|
+
...a.where ?? {}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
return
|
|
23
|
+
return n.page && (n.page = +n.page), n.limit && (n.limit = +n.limit), n;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const [
|
|
27
|
-
|
|
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,
|
|
31
|
-
),
|
|
34
|
+
r ? [r] : [r, c]
|
|
35
|
+
), s = l(
|
|
32
36
|
async (t) => {
|
|
33
|
-
const e = m(t);
|
|
34
|
-
if (Array.isArray(
|
|
35
|
-
|
|
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
42
|
data: { items: o, meta: g }
|
|
39
|
-
} = await
|
|
40
|
-
|
|
43
|
+
} = await y(e);
|
|
44
|
+
q(g.totalItems), k(g.totalPages), A(o || []);
|
|
41
45
|
} catch {
|
|
42
|
-
|
|
46
|
+
Q(!0);
|
|
43
47
|
} finally {
|
|
44
|
-
|
|
48
|
+
d(!1);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
|
-
[m,
|
|
49
|
-
),
|
|
52
|
+
[m, r]
|
|
53
|
+
), z = l(
|
|
50
54
|
(t) => {
|
|
51
55
|
if (r) {
|
|
52
|
-
|
|
56
|
+
h(t), s();
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
const e =
|
|
56
|
-
|
|
59
|
+
const e = L(c, t);
|
|
60
|
+
f(e), s(e);
|
|
57
61
|
},
|
|
58
|
-
[r,
|
|
59
|
-
),
|
|
60
|
-
(t, e,
|
|
61
|
-
const
|
|
62
|
-
...
|
|
63
|
-
where: { ...
|
|
64
|
-
},
|
|
65
|
-
if (Array.isArray(
|
|
66
|
-
const
|
|
67
|
-
|
|
62
|
+
[r, c, s]
|
|
63
|
+
), D = l(
|
|
64
|
+
(t, e, i) => {
|
|
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
|
-
|
|
70
|
-
return
|
|
73
|
+
o.where && e in o.where && delete o.where[e];
|
|
74
|
+
return o;
|
|
71
75
|
},
|
|
72
76
|
[]
|
|
73
|
-
),
|
|
77
|
+
), I = l(
|
|
74
78
|
(t, e) => {
|
|
75
79
|
if (r) {
|
|
76
|
-
|
|
80
|
+
B(t, e), s();
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
83
|
+
const i = D(c, t, e);
|
|
84
|
+
f(i), s(i);
|
|
81
85
|
},
|
|
82
|
-
[r,
|
|
83
|
-
),
|
|
86
|
+
[r, c, s, D]
|
|
87
|
+
), V = l(
|
|
84
88
|
(t) => {
|
|
85
89
|
if (r) {
|
|
86
|
-
|
|
90
|
+
G(t), s();
|
|
87
91
|
return;
|
|
88
92
|
}
|
|
89
|
-
const e =
|
|
90
|
-
|
|
93
|
+
const e = L(p, t);
|
|
94
|
+
f(e), s(e);
|
|
91
95
|
},
|
|
92
|
-
[r,
|
|
96
|
+
[r, s]
|
|
93
97
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, [
|
|
97
|
-
if (Array.isArray(
|
|
98
|
+
E(() => {
|
|
99
|
+
s();
|
|
100
|
+
}, [s]), E(() => {
|
|
101
|
+
if (Array.isArray(a)) {
|
|
98
102
|
const t = m();
|
|
99
|
-
r ||
|
|
103
|
+
r || f(t), d(!1), A(C(a, t));
|
|
100
104
|
}
|
|
101
|
-
}, [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
}, [a, m]);
|
|
106
|
+
const Y = c ?? m();
|
|
107
|
+
return {
|
|
108
|
+
loading: S,
|
|
109
|
+
error: T,
|
|
110
|
+
data: n,
|
|
111
|
+
total: U,
|
|
112
|
+
params: Y,
|
|
113
|
+
pagesCount: F,
|
|
114
|
+
updateData: s,
|
|
109
115
|
// НОВОЕ: наружу отдаём универсальные методы для управления параметрами
|
|
110
|
-
addParam:
|
|
111
|
-
removeParam:
|
|
112
|
-
resetParams:
|
|
116
|
+
addParam: z,
|
|
117
|
+
removeParam: I,
|
|
118
|
+
resetParams: V
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
export {
|
|
116
|
-
|
|
122
|
+
X as useTableData
|
|
117
123
|
};
|
package/dist/table/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--text-primary-color: var(--color-text-primary);--text-secondary-color: var(--color-text-secondary);--text-tertiary-color: var(--color-text-tertiary);--border-radius: 4px;--focus-color: var(--color-border-link);--font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, sans-serif;--disabled-cursor: not-allowed;--arrow-transform: rotate(180deg)}.table_wrapper_SeB5{width:100%;box-sizing:border-box;position:relative}.table_9sbd{position:relative;box-sizing:border-box;border:1px solid var(--color-border-secondary);border-radius:12px 12px 0 0;background:var(--color-bg-primary);box-shadow:var(--shadow-xs);overflow:hidden}.table_9sbd table{width:100%;border-collapse:collapse;background:var(--color-bg-primary);table-layout:
|
|
1
|
+
:root{--text-primary-color: var(--color-text-primary);--text-secondary-color: var(--color-text-secondary);--text-tertiary-color: var(--color-text-tertiary);--border-radius: 4px;--focus-color: var(--color-border-link);--font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, sans-serif;--disabled-cursor: not-allowed;--arrow-transform: rotate(180deg)}.table_wrapper_SeB5{width:100%;box-sizing:border-box;position:relative}.table_9sbd{position:relative;box-sizing:border-box;border:1px solid var(--color-border-secondary);border-radius:12px 12px 0 0;background:var(--color-bg-primary);box-shadow:var(--shadow-xs);overflow:hidden}.table_9sbd table{width:100%;border-collapse:collapse;background:var(--color-bg-primary);table-layout:auto}.table_9sbd tbody tr td{transition:background-color .15s ease}.table_9sbd.no_footer_julO{border-radius:12px}.fill_Q-ic{height:-webkit-fill-available;flex-grow:1;display:flex;flex-direction:column}.fill_Q-ic .table_9sbd{flex-grow:1;overflow:hidden}.fill_Q-ic .table_9sbd:hover{overflow:auto}.clickable_k4S8{cursor:pointer}.clickable_k4S8:hover td{background-color:color-mix(in srgb,var(--color-bg-secondary) 92%,var(--color-bg-primary))}
|