@alphakits/ui 2.4.1 → 2.4.2
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 +58 -56
- 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,115 +1,117 @@
|
|
|
1
|
-
import { useState as u, useCallback as c, useEffect as
|
|
1
|
+
import { useState as u, useCallback as c, useEffect as D } from "react";
|
|
2
2
|
import { addQueryParam as I } from "../utils/add-query-param.js";
|
|
3
3
|
import { getQueryFromUrl as R } from "../utils/get-query-from-url.js";
|
|
4
4
|
import "query-string";
|
|
5
5
|
import { removeQueryParam as V } from "../utils/remove-query-param.js";
|
|
6
6
|
import { resetQueryParam as Y } from "../utils/reset-query-param.js";
|
|
7
|
-
import { serializeData as
|
|
8
|
-
const
|
|
7
|
+
import { serializeData as b } from "../utils/serialize-data.js";
|
|
8
|
+
const d = {
|
|
9
9
|
page: 1,
|
|
10
10
|
limit: 10,
|
|
11
11
|
where: {}
|
|
12
12
|
// остальное добавится по мере нужды (searchText, sort, order и т.д.)
|
|
13
13
|
};
|
|
14
|
-
function E(f,
|
|
15
|
-
const r = f ??
|
|
14
|
+
function E(f, n) {
|
|
15
|
+
const r = f ?? d, a = {
|
|
16
16
|
...r,
|
|
17
|
-
...
|
|
17
|
+
...n,
|
|
18
18
|
where: {
|
|
19
19
|
...r.where ?? {},
|
|
20
|
-
...
|
|
20
|
+
...n.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 M({ promise: f, records:
|
|
26
|
-
const [a,
|
|
27
|
-
(t) => r ? R() : t ??
|
|
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,
|
|
28
28
|
// params не включаем при fromPath: иначе setParams на каждом fetch
|
|
29
29
|
// даёт новую ссылку → computeQuery/updateData меняются → бесконечный цикл.
|
|
30
|
-
r ? [r] : [r,
|
|
31
|
-
),
|
|
30
|
+
r ? [r] : [r, o]
|
|
31
|
+
), s = c(
|
|
32
32
|
async (t) => {
|
|
33
|
-
const e =
|
|
34
|
-
if (Array.isArray(
|
|
35
|
-
|
|
33
|
+
const e = y(t);
|
|
34
|
+
if (Array.isArray(n) && (w(!1), p(b(n, e))), m(e), f) {
|
|
35
|
+
A(!1), w(!0);
|
|
36
36
|
try {
|
|
37
37
|
const {
|
|
38
|
-
data: { items:
|
|
38
|
+
data: { items: i, meta: g }
|
|
39
39
|
} = await f(e);
|
|
40
|
-
|
|
40
|
+
S(g.totalItems), U(g.totalPages), p(i || []);
|
|
41
41
|
} catch {
|
|
42
|
-
|
|
42
|
+
A(!0);
|
|
43
43
|
} finally {
|
|
44
44
|
w(!1);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
[
|
|
49
|
-
),
|
|
48
|
+
[y, n, f]
|
|
49
|
+
), q = c(
|
|
50
50
|
(t) => {
|
|
51
51
|
if (r) {
|
|
52
|
-
I(t),
|
|
52
|
+
I(t), s();
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const e = E(
|
|
56
|
-
|
|
55
|
+
const e = E(o, t);
|
|
56
|
+
m(e), s(e);
|
|
57
57
|
},
|
|
58
|
-
[r,
|
|
59
|
-
),
|
|
60
|
-
(t, e,
|
|
61
|
-
const g = t ??
|
|
58
|
+
[r, o, s]
|
|
59
|
+
), Q = c(
|
|
60
|
+
(t, e, i) => {
|
|
61
|
+
const g = t ?? d, l = {
|
|
62
62
|
...g,
|
|
63
63
|
where: { ...g.where ?? {} }
|
|
64
64
|
}, x = l.where?.[e];
|
|
65
|
-
if (Array.isArray(x) &&
|
|
66
|
-
const
|
|
67
|
-
|
|
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];
|
|
68
68
|
} else
|
|
69
69
|
l.where && e in l.where && delete l.where[e];
|
|
70
70
|
return l;
|
|
71
71
|
},
|
|
72
72
|
[]
|
|
73
|
-
),
|
|
73
|
+
), F = c(
|
|
74
74
|
(t, e) => {
|
|
75
75
|
if (r) {
|
|
76
|
-
V(t, e),
|
|
76
|
+
V(t, e), s();
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
79
|
+
const i = Q(o, t, e);
|
|
80
|
+
m(i), s(i);
|
|
81
81
|
},
|
|
82
|
-
[r,
|
|
83
|
-
),
|
|
82
|
+
[r, o, s, Q]
|
|
83
|
+
), P = c(
|
|
84
84
|
(t) => {
|
|
85
85
|
if (r) {
|
|
86
|
-
Y(t),
|
|
86
|
+
Y(t), s();
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const e = E(
|
|
90
|
-
|
|
89
|
+
const e = E(d, t);
|
|
90
|
+
m(e), s(e);
|
|
91
91
|
},
|
|
92
|
-
[r,
|
|
92
|
+
[r, s]
|
|
93
93
|
);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, [
|
|
97
|
-
if (Array.isArray(
|
|
98
|
-
const t =
|
|
99
|
-
|
|
94
|
+
D(() => {
|
|
95
|
+
s();
|
|
96
|
+
}, [s]), D(() => {
|
|
97
|
+
if (Array.isArray(n)) {
|
|
98
|
+
const t = y();
|
|
99
|
+
m(t), w(!1), p(b(n, t));
|
|
100
100
|
}
|
|
101
|
-
}, [
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
}, [n, y]);
|
|
102
|
+
const k = o ?? y();
|
|
103
|
+
return {
|
|
104
|
+
loading: h,
|
|
105
|
+
error: C,
|
|
104
106
|
data: a,
|
|
105
|
-
total:
|
|
106
|
-
params:
|
|
107
|
-
pagesCount:
|
|
108
|
-
updateData:
|
|
107
|
+
total: L,
|
|
108
|
+
params: k,
|
|
109
|
+
pagesCount: T,
|
|
110
|
+
updateData: s,
|
|
109
111
|
// НОВОЕ: наружу отдаём универсальные методы для управления параметрами
|
|
110
|
-
addParam:
|
|
111
|
-
removeParam:
|
|
112
|
-
resetParams:
|
|
112
|
+
addParam: q,
|
|
113
|
+
removeParam: F,
|
|
114
|
+
resetParams: P
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
117
|
export {
|
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))}
|