@memobit/libs 3.4.3 → 3.6.0
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/components/AngleSlider/AngleSlider2.js +27 -27
- package/dist/components/AppHeader/AppHeader2.js +39 -36
- package/dist/components/Auth/ChangePasswordModal/ChangePasswordModal2.js +48 -52
- package/dist/components/Auth/MfaSetupModal/MfaSetupModal2.js +64 -65
- package/dist/components/Blockquote/Blockquote2.js +14 -14
- package/dist/components/BulkActionBar/BulkActionBar2.js +34 -30
- package/dist/components/Calendar/Calendar2.js +10 -8
- package/dist/components/Card/Card.css +1 -1
- package/dist/components/Confetti/Confetti2.js +2 -3
- package/dist/components/ControlPanel/ControlPanelFilter.js +26 -26
- package/dist/components/DataView/DataView.CardView.js +8 -4
- package/dist/components/DataView/DataView.ColumnSelector.js +24 -21
- package/dist/components/DataView/DataView.MiniSort.js +18 -16
- package/dist/components/DataView/DataView2.js +90 -86
- package/dist/components/DiffViewer/DiffViewer2.js +124 -118
- package/dist/components/Dropdown/Dropdown2.js +0 -3
- package/dist/components/EventCalendar/EventCalendar.Chip.js +21 -21
- package/dist/components/EventCalendar/EventCalendar.Month.js +19 -19
- package/dist/components/FloatingWindow/FloatingWindow2.js +60 -60
- package/dist/components/Grid/Grid2.js +18 -18
- package/dist/components/InputPIN/InputPIN2.js +42 -42
- package/dist/components/MiniSort/MiniSort2.js +47 -43
- package/dist/components/MiniStatsCard/MiniStatsCard2.js +20 -20
- package/dist/components/Pagination/Pagination2.js +18 -18
- package/dist/components/Popover/Popover2.js +23 -21
- package/dist/components/ProtectedRoute/ProtectedRoute.css +1 -0
- package/dist/components/ProtectedRoute/ProtectedRoute2.js +19 -0
- package/dist/components/RangeSlider/RangeSlider2.js +25 -25
- package/dist/components/Rating/RatingIcon.js +9 -9
- package/dist/components/RichTextEditor/hooks/useLinkPrompt.js +7 -6
- package/dist/components/RollingNumber/RollingNumber2.js +33 -31
- package/dist/components/Separator/Separator2.js +27 -23
- package/dist/components/Skeleton/Skeleton2.js +6 -8
- package/dist/components/Slider/Slider2.js +32 -32
- package/dist/components/Splitter/Splitter2.js +34 -34
- package/dist/components/StackedBar/StackedBar2.js +36 -34
- package/dist/components/Stats/Stats2.js +20 -16
- package/dist/components/StickyBar/StickyBar2.js +26 -22
- package/dist/components/Timeline/Timeline2.js +53 -47
- package/dist/components/Tooltip/Tooltip2.js +7 -8
- package/dist/components/TourHud/TourHud2.js +20 -20
- package/dist/components/Transition/Transition2.js +20 -20
- package/dist/components/Tree/Tree2.js +23 -23
- package/dist/contexts/AuthContext/AuthContext.js +33 -32
- package/dist/helpers/Charts.js +18 -0
- package/dist/helpers/Http.js +102 -0
- package/dist/helpers/Images.js +19 -0
- package/dist/helpers/Numbers.js +5 -4
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/hooks/useAccountMenu.js +58 -0
- package/dist/http.d.ts +97 -0
- package/dist/http.js +14 -0
- package/dist/index.d.ts +152 -5
- package/dist/index.js +334 -309
- package/dist/node_modules/qrcode.react/lib/esm/index.js +2 -2
- package/dist/router.d.ts +18 -0
- package/dist/router.js +4 -0
- package/dist/version.js +2 -2
- package/dist/version.json +4 -4
- package/package.json +38 -23
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import './Transition.css';
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { useCallback as f, useEffect as h, useRef as n, useState as A } from "react";
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
6
|
-
const H = p ? C ? "entering" : "entered" : "unmounted", [r, x] = A(H), [S, e] = A("auto"),
|
|
4
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
5
|
+
var I = ({ appear: C = !1, as: j = "div", children: q, className: D = "", delay: m = 0, duration: o = 250, easing: b = "ease", keepMounted: F = !1, onEntered: g, onExited: d, show: p, type: a = "fade" }) => {
|
|
6
|
+
const H = p ? C ? "entering" : "entered" : "unmounted", [r, x] = A(H), [S, e] = A("auto"), s = n(null), R = n(H), $ = n(g), v = n(d), u = n(null), i = n(null);
|
|
7
7
|
h(() => {
|
|
8
8
|
$.current = g, v.current = d;
|
|
9
9
|
}, [g, d]);
|
|
10
10
|
const c = f((t) => {
|
|
11
11
|
R.current = t, x(t);
|
|
12
12
|
}, []), l = f(() => {
|
|
13
|
-
|
|
13
|
+
u.current !== null && (clearTimeout(u.current), u.current = null), i.current !== null && (cancelAnimationFrame(i.current), i.current = null);
|
|
14
14
|
}, []), T = f((t) => {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
i.current = requestAnimationFrame(() => {
|
|
16
|
+
i.current = requestAnimationFrame(t);
|
|
17
17
|
});
|
|
18
18
|
}, []);
|
|
19
19
|
h(() => l, [l]), h(() => {
|
|
@@ -22,13 +22,13 @@ var G = ({ appear: C = !1, as: j = "div", children: q, className: D = "", delay:
|
|
|
22
22
|
if (p) {
|
|
23
23
|
if (R.current === "entered") return;
|
|
24
24
|
c("entering"), t && e(0), T(() => {
|
|
25
|
-
c("entered"), t &&
|
|
26
|
-
}),
|
|
25
|
+
c("entered"), t && s.current && e(s.current.scrollHeight);
|
|
26
|
+
}), u.current = setTimeout(() => {
|
|
27
27
|
t && e("auto"), $.current?.();
|
|
28
28
|
}, o + m);
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
R.current !== "unmounted" && (t &&
|
|
31
|
+
R.current !== "unmounted" && (t && s.current && (e(s.current.scrollHeight), T(() => e(0))), c("exiting"), u.current = setTimeout(() => {
|
|
32
32
|
c("unmounted"), e("auto"), v.current?.();
|
|
33
33
|
}, o));
|
|
34
34
|
}, [
|
|
@@ -41,7 +41,7 @@ var G = ({ appear: C = !1, as: j = "div", children: q, className: D = "", delay:
|
|
|
41
41
|
a
|
|
42
42
|
]);
|
|
43
43
|
const B = f((t) => {
|
|
44
|
-
|
|
44
|
+
s.current = t;
|
|
45
45
|
}, []);
|
|
46
46
|
if (r === "unmounted" && !F) return null;
|
|
47
47
|
const N = {
|
|
@@ -49,20 +49,20 @@ var G = ({ appear: C = !1, as: j = "div", children: q, className: D = "", delay:
|
|
|
49
49
|
transitionDuration: `${o}ms`,
|
|
50
50
|
transitionTimingFunction: b,
|
|
51
51
|
...a === "collapse" && S !== "auto" ? { height: S } : {}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
}, P = [
|
|
53
|
+
"transition",
|
|
54
|
+
`transition--${a}`,
|
|
55
|
+
`transition--${r}`,
|
|
56
|
+
F && r === "unmounted" ? "transition--hidden" : "",
|
|
57
|
+
D
|
|
58
|
+
].filter(Boolean).join(" ");
|
|
59
|
+
return /* @__PURE__ */ k(j, {
|
|
60
|
+
className: P,
|
|
61
61
|
ref: B,
|
|
62
62
|
style: N,
|
|
63
63
|
children: q
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
I as Transition
|
|
68
68
|
};
|
|
@@ -2,7 +2,7 @@ import './Tree.css';
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { useCallback as f, useState as v } from "react";
|
|
4
4
|
import { jsx as r, jsxs as u } from "react/jsx-runtime";
|
|
5
|
-
var
|
|
5
|
+
var b = ({ open: e }) => /* @__PURE__ */ r("svg", {
|
|
6
6
|
className: `tree__chevron ${e ? "tree__chevron--open" : ""}`,
|
|
7
7
|
viewBox: "0 0 16 16",
|
|
8
8
|
width: "12",
|
|
@@ -15,22 +15,22 @@ var N = ({ open: e }) => /* @__PURE__ */ r("svg", {
|
|
|
15
15
|
strokeLinecap: "round",
|
|
16
16
|
strokeLinejoin: "round"
|
|
17
17
|
})
|
|
18
|
-
}), g = ({ node: e, depth: i, selectable: t, showGuides: c, animated: d, selectedId:
|
|
19
|
-
const [
|
|
20
|
-
e.disabled || "key" in l && l.key !== "Enter" && l.key !== " " || (
|
|
18
|
+
}), g = ({ node: e, depth: i, selectable: t, showGuides: c, animated: d, selectedId: o, onSelect: n }) => {
|
|
19
|
+
const [_, p] = v(e.defaultExpanded ?? !1), s = Array.isArray(e.children) && e.children.length > 0, a = t && o === e.id, m = f((l) => {
|
|
20
|
+
e.disabled || "key" in l && l.key !== "Enter" && l.key !== " " || (s && p((h) => !h), t && n(e));
|
|
21
21
|
}, [
|
|
22
|
-
|
|
22
|
+
s,
|
|
23
23
|
e,
|
|
24
24
|
t,
|
|
25
|
-
|
|
26
|
-
])
|
|
25
|
+
n
|
|
26
|
+
]), N = [
|
|
27
|
+
"tree__row",
|
|
28
|
+
a ? "tree__row--selected" : "",
|
|
29
|
+
e.disabled ? "tree__row--disabled" : "",
|
|
30
|
+
e.variant && e.variant !== "default" ? `tree__row--${e.variant}` : ""
|
|
31
|
+
].filter(Boolean).join(" ");
|
|
27
32
|
return /* @__PURE__ */ u("li", { children: [/* @__PURE__ */ u("div", {
|
|
28
|
-
className:
|
|
29
|
-
"tree__row",
|
|
30
|
-
a ? "tree__row--selected" : "",
|
|
31
|
-
e.disabled ? "tree__row--disabled" : "",
|
|
32
|
-
e.variant && e.variant !== "default" ? `tree__row--${e.variant}` : ""
|
|
33
|
-
].filter(Boolean).join(" "),
|
|
33
|
+
className: N,
|
|
34
34
|
style: { "--depth": i },
|
|
35
35
|
tabIndex: e.disabled ? -1 : 0,
|
|
36
36
|
onClick: m,
|
|
@@ -42,7 +42,7 @@ var N = ({ open: e }) => /* @__PURE__ */ r("svg", {
|
|
|
42
42
|
}, h)),
|
|
43
43
|
/* @__PURE__ */ r("span", {
|
|
44
44
|
className: "tree__toggle",
|
|
45
|
-
children:
|
|
45
|
+
children: s ? /* @__PURE__ */ r(b, { open: _ }) : /* @__PURE__ */ r("span", { className: "tree__leaf-dot" })
|
|
46
46
|
}),
|
|
47
47
|
e.icon && /* @__PURE__ */ r("span", {
|
|
48
48
|
className: "tree__icon",
|
|
@@ -57,10 +57,10 @@ var N = ({ open: e }) => /* @__PURE__ */ r("svg", {
|
|
|
57
57
|
children: e.badge
|
|
58
58
|
})
|
|
59
59
|
]
|
|
60
|
-
}),
|
|
60
|
+
}), s && /* @__PURE__ */ r("ul", {
|
|
61
61
|
className: [
|
|
62
62
|
"tree__children",
|
|
63
|
-
|
|
63
|
+
_ ? "tree__children--open" : "",
|
|
64
64
|
d ? "tree__children--animated" : ""
|
|
65
65
|
].filter(Boolean).join(" "),
|
|
66
66
|
children: e.children.map((l) => /* @__PURE__ */ r(g, {
|
|
@@ -69,24 +69,24 @@ var N = ({ open: e }) => /* @__PURE__ */ r("svg", {
|
|
|
69
69
|
selectable: t,
|
|
70
70
|
showGuides: c,
|
|
71
71
|
animated: d,
|
|
72
|
-
selectedId:
|
|
73
|
-
onSelect:
|
|
72
|
+
selectedId: o,
|
|
73
|
+
onSelect: n
|
|
74
74
|
}, l.id))
|
|
75
75
|
})] });
|
|
76
|
-
}, j = ({ nodes: e, selectable: i = !1, onSelect: t, showGuides: c = !0, animated: d = !0, defaultSelectedId:
|
|
77
|
-
const [
|
|
76
|
+
}, j = ({ nodes: e, selectable: i = !1, onSelect: t, showGuides: c = !0, animated: d = !0, defaultSelectedId: o = null, className: n = "" }) => {
|
|
77
|
+
const [_, p] = v(o), s = f((a) => {
|
|
78
78
|
a.disabled || (p(a.id), t?.(a));
|
|
79
79
|
}, [t]);
|
|
80
80
|
return /* @__PURE__ */ r("ul", {
|
|
81
|
-
className: ["tree",
|
|
81
|
+
className: ["tree", n].filter(Boolean).join(" "),
|
|
82
82
|
children: e.map((a) => /* @__PURE__ */ r(g, {
|
|
83
83
|
node: a,
|
|
84
84
|
depth: 0,
|
|
85
85
|
selectable: i,
|
|
86
86
|
showGuides: c,
|
|
87
87
|
animated: d,
|
|
88
|
-
selectedId:
|
|
89
|
-
onSelect:
|
|
88
|
+
selectedId: _,
|
|
89
|
+
onSelect: s
|
|
90
90
|
}, a.id))
|
|
91
91
|
});
|
|
92
92
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpMethod as s, buildRequestHeaders as w } from "../../helpers/Http.js";
|
|
2
|
+
import { createContext as A, useCallback as i, useEffect as U, useState as d } from "react";
|
|
2
3
|
import { jsx as j } from "react/jsx-runtime";
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
const [
|
|
6
|
-
|
|
4
|
+
var v = A(void 0);
|
|
5
|
+
function P({ children: h, config: a }) {
|
|
6
|
+
const [c, l] = d(null), [f, o] = d(!0);
|
|
7
|
+
U(() => {
|
|
7
8
|
(async () => {
|
|
8
9
|
try {
|
|
9
10
|
const t = await fetch(`${a.apiBaseUrl}/auth/verify`, {
|
|
10
|
-
method:
|
|
11
|
+
method: s.Get,
|
|
11
12
|
credentials: "include",
|
|
12
13
|
headers: { "Content-Type": "application/json" }
|
|
13
14
|
});
|
|
14
15
|
if (t.ok) {
|
|
15
16
|
const e = await t.json();
|
|
16
|
-
|
|
17
|
+
l({
|
|
17
18
|
id: e.user.id,
|
|
18
19
|
username: e.user.username,
|
|
19
20
|
createdAt: new Date(e.user.createdAt)
|
|
@@ -26,17 +27,17 @@ function T({ children: d, config: a }) {
|
|
|
26
27
|
}
|
|
27
28
|
})();
|
|
28
29
|
}, [a.apiBaseUrl]);
|
|
29
|
-
const
|
|
30
|
-
r.user &&
|
|
30
|
+
const n = i((r) => {
|
|
31
|
+
r.user && l({
|
|
31
32
|
id: r.user.id,
|
|
32
33
|
username: r.user.username,
|
|
33
34
|
createdAt: new Date(r.user.createdAt)
|
|
34
35
|
});
|
|
35
|
-
}, []),
|
|
36
|
+
}, []), p = i(async (r) => {
|
|
36
37
|
o(!0);
|
|
37
38
|
try {
|
|
38
39
|
const t = await fetch(`${a.apiBaseUrl}/auth/login`, {
|
|
39
|
-
method:
|
|
40
|
+
method: s.Post,
|
|
40
41
|
credentials: "include",
|
|
41
42
|
headers: { "Content-Type": "application/json" },
|
|
42
43
|
body: JSON.stringify({
|
|
@@ -46,24 +47,24 @@ function T({ children: d, config: a }) {
|
|
|
46
47
|
})
|
|
47
48
|
});
|
|
48
49
|
if (!t.ok) {
|
|
49
|
-
const
|
|
50
|
-
throw new Error(
|
|
50
|
+
const u = await t.json();
|
|
51
|
+
throw new Error(u.error || "Login failed");
|
|
51
52
|
}
|
|
52
53
|
const e = await t.json();
|
|
53
54
|
return e.mfaRequired ? {
|
|
54
55
|
mfaRequired: !0,
|
|
55
56
|
method: e.method
|
|
56
|
-
} : (
|
|
57
|
+
} : (n(e), { mfaRequired: !1 });
|
|
57
58
|
} catch (t) {
|
|
58
59
|
throw console.error("Login failed:", t), t;
|
|
59
60
|
} finally {
|
|
60
61
|
o(!1);
|
|
61
62
|
}
|
|
62
|
-
}, [a.apiBaseUrl,
|
|
63
|
+
}, [a.apiBaseUrl, n]), m = i(async (r, t) => {
|
|
63
64
|
o(!0);
|
|
64
65
|
try {
|
|
65
66
|
const e = await fetch(`${a.apiBaseUrl}/auth/verifyMfa`, {
|
|
66
|
-
method:
|
|
67
|
+
method: s.Post,
|
|
67
68
|
credentials: "include",
|
|
68
69
|
headers: { "Content-Type": "application/json" },
|
|
69
70
|
body: JSON.stringify({
|
|
@@ -72,42 +73,42 @@ function T({ children: d, config: a }) {
|
|
|
72
73
|
})
|
|
73
74
|
});
|
|
74
75
|
if (!e.ok) {
|
|
75
|
-
const
|
|
76
|
-
throw new Error(
|
|
76
|
+
const u = await e.json();
|
|
77
|
+
throw new Error(u.error || "Verification failed");
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
n(await e.json());
|
|
79
80
|
} catch (e) {
|
|
80
81
|
throw console.error("MFA verification failed:", e), e;
|
|
81
82
|
} finally {
|
|
82
83
|
o(!1);
|
|
83
84
|
}
|
|
84
|
-
}, [a.apiBaseUrl,
|
|
85
|
+
}, [a.apiBaseUrl, n]), y = i(async () => {
|
|
85
86
|
try {
|
|
86
87
|
await fetch(`${a.apiBaseUrl}/auth/logout`, {
|
|
87
|
-
method:
|
|
88
|
+
method: s.Post,
|
|
88
89
|
credentials: "include",
|
|
89
|
-
headers:
|
|
90
|
+
headers: w(s.Post)
|
|
90
91
|
});
|
|
91
92
|
} catch (r) {
|
|
92
93
|
console.error("Logout error:", r);
|
|
93
94
|
} finally {
|
|
94
|
-
|
|
95
|
+
l(null);
|
|
95
96
|
}
|
|
96
97
|
}, [a.apiBaseUrl]);
|
|
97
|
-
return /* @__PURE__ */ j(
|
|
98
|
+
return /* @__PURE__ */ j(v.Provider, {
|
|
98
99
|
value: {
|
|
99
|
-
user:
|
|
100
|
-
isAuthenticated: !!
|
|
101
|
-
isLoading:
|
|
100
|
+
user: c,
|
|
101
|
+
isAuthenticated: !!c,
|
|
102
|
+
isLoading: f,
|
|
102
103
|
config: a,
|
|
103
|
-
login:
|
|
104
|
-
verifyMfa:
|
|
104
|
+
login: p,
|
|
105
|
+
verifyMfa: m,
|
|
105
106
|
logout: y
|
|
106
107
|
},
|
|
107
|
-
children:
|
|
108
|
+
children: h
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
v as AuthContext,
|
|
113
|
+
P as AuthProvider
|
|
113
114
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var o = {
|
|
2
|
+
contentStyle: {
|
|
3
|
+
backgroundColor: "var(--tooltip-background-color)",
|
|
4
|
+
border: "1px solid var(--tooltip-border-color)",
|
|
5
|
+
borderRadius: "var(--radius-sm)",
|
|
6
|
+
color: "var(--tooltip-color)"
|
|
7
|
+
},
|
|
8
|
+
itemStyle: { color: "var(--tooltip-color)" },
|
|
9
|
+
labelStyle: { color: "var(--tooltip-color)" }
|
|
10
|
+
}, r = {
|
|
11
|
+
axis: "var(--body-color-muted)",
|
|
12
|
+
grid: "var(--border-color)",
|
|
13
|
+
text: "var(--body-color)"
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
r as chartColors,
|
|
17
|
+
o as chartTooltipStyle
|
|
18
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var l = {
|
|
2
|
+
Continue: 100,
|
|
3
|
+
SwitchingProtocols: 101,
|
|
4
|
+
Ok: 200,
|
|
5
|
+
Created: 201,
|
|
6
|
+
Accepted: 202,
|
|
7
|
+
NoContent: 204,
|
|
8
|
+
PartialContent: 206,
|
|
9
|
+
MovedPermanently: 301,
|
|
10
|
+
Found: 302,
|
|
11
|
+
SeeOther: 303,
|
|
12
|
+
NotModified: 304,
|
|
13
|
+
TemporaryRedirect: 307,
|
|
14
|
+
PermanentRedirect: 308,
|
|
15
|
+
BadRequest: 400,
|
|
16
|
+
Unauthorized: 401,
|
|
17
|
+
PaymentRequired: 402,
|
|
18
|
+
Forbidden: 403,
|
|
19
|
+
NotFound: 404,
|
|
20
|
+
MethodNotAllowed: 405,
|
|
21
|
+
NotAcceptable: 406,
|
|
22
|
+
RequestTimeout: 408,
|
|
23
|
+
Conflict: 409,
|
|
24
|
+
Gone: 410,
|
|
25
|
+
PayloadTooLarge: 413,
|
|
26
|
+
UnsupportedMediaType: 415,
|
|
27
|
+
UnprocessableEntity: 422,
|
|
28
|
+
Locked: 423,
|
|
29
|
+
TooManyRequests: 429,
|
|
30
|
+
InternalServerError: 500,
|
|
31
|
+
NotImplemented: 501,
|
|
32
|
+
BadGateway: 502,
|
|
33
|
+
ServiceUnavailable: 503,
|
|
34
|
+
GatewayTimeout: 504
|
|
35
|
+
}, n = {
|
|
36
|
+
Get: "GET",
|
|
37
|
+
Post: "POST",
|
|
38
|
+
Put: "PUT",
|
|
39
|
+
Patch: "PATCH",
|
|
40
|
+
Delete: "DELETE"
|
|
41
|
+
}, w = (e) => e >= 200 && e < 300, C = (e) => e >= 400 && e < 500, E = (e) => e >= 500 && e < 600, f = "csrf_token", h = "X-CSRF-Token", v = () => {
|
|
42
|
+
const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${f}=([^;]+)`));
|
|
43
|
+
return e ? decodeURIComponent(e[1]) : null;
|
|
44
|
+
}, m = (e, r = !0) => {
|
|
45
|
+
const s = r ? { "Content-Type": "application/json" } : {};
|
|
46
|
+
if (e !== n.Get) {
|
|
47
|
+
const i = v();
|
|
48
|
+
i && (s[h] = i);
|
|
49
|
+
}
|
|
50
|
+
return s;
|
|
51
|
+
}, y = class extends Error {
|
|
52
|
+
constructor(e, r) {
|
|
53
|
+
super(e), this.name = "ApiError", this.status = r;
|
|
54
|
+
}
|
|
55
|
+
}, T = async (e) => {
|
|
56
|
+
try {
|
|
57
|
+
const r = await e.json();
|
|
58
|
+
if (r && typeof r == "object") {
|
|
59
|
+
if ("error" in r && typeof r.error == "string") return r.error;
|
|
60
|
+
if ("message" in r && typeof r.message == "string") return r.message;
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return `Request failed (${e.status}${e.statusText ? ` ${e.statusText}` : ""})`;
|
|
65
|
+
}, P = ({ baseUrl: e, loginPath: r = "/login" }) => {
|
|
66
|
+
let s = !1;
|
|
67
|
+
const i = (t) => `${e.replace(/\/$/, "")}/${t.replace(/^\//, "")}`, c = async (t, o, u, p = !0) => {
|
|
68
|
+
const a = await fetch(i(t), {
|
|
69
|
+
method: o,
|
|
70
|
+
headers: m(o, p),
|
|
71
|
+
credentials: "include",
|
|
72
|
+
body: u
|
|
73
|
+
});
|
|
74
|
+
if (a.status === l.Unauthorized && !window.location.pathname.startsWith(r))
|
|
75
|
+
return s || (s = !0, window.location.href = `${r}?session_expired=true`), new Promise(() => {
|
|
76
|
+
});
|
|
77
|
+
if (!a.ok) throw new y(await T(a), a.status);
|
|
78
|
+
if (a.status !== l.NoContent)
|
|
79
|
+
return await a.json();
|
|
80
|
+
}, d = (t, o, u) => c(t, o, u === void 0 ? void 0 : JSON.stringify(u));
|
|
81
|
+
return {
|
|
82
|
+
get: (t) => c(t, n.Get),
|
|
83
|
+
post: (t, o) => d(t, n.Post, o),
|
|
84
|
+
put: (t, o) => d(t, n.Put, o),
|
|
85
|
+
patch: (t, o) => d(t, n.Patch, o),
|
|
86
|
+
delete: (t) => c(t, n.Delete),
|
|
87
|
+
upload: (t, o) => c(t, n.Post, o, !1)
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
y as ApiError,
|
|
92
|
+
h as CSRF_HEADER,
|
|
93
|
+
n as HttpMethod,
|
|
94
|
+
l as HttpStatus,
|
|
95
|
+
m as buildRequestHeaders,
|
|
96
|
+
P as createApiClient,
|
|
97
|
+
v as getCsrfToken,
|
|
98
|
+
C as isClientErrorStatus,
|
|
99
|
+
E as isServerErrorStatus,
|
|
100
|
+
w as isSuccessStatus,
|
|
101
|
+
T as readErrorMessage
|
|
102
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var s = "/data-files/images", g = () => `${s}/default.jpg`, i = (t) => `${s}/category/${t}.jpg`, c = (t, a) => typeof t != "string" ? URL.createObjectURL(t) : t ? t.includes("/data-files/images") || t.startsWith("blob:") || t.startsWith("http") ? t : `${s}/specific/${t}` : a ? i(a) : g(), l = (t, a) => {
|
|
2
|
+
const r = g(), e = a ? i(a) : r;
|
|
3
|
+
return t ? t.endsWith(r) ? null : t.includes("/data-files/images/category/") ? r : e : e;
|
|
4
|
+
}, u = (t, a) => {
|
|
5
|
+
const r = t.currentTarget, e = l(r.src, a);
|
|
6
|
+
if (e && !r.src.endsWith(e)) {
|
|
7
|
+
r.src = e;
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
r.onerror = null;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
s as IMAGES_BASE_PATH,
|
|
14
|
+
u as applyImageFallback,
|
|
15
|
+
i as getCategoryImageUrl,
|
|
16
|
+
g as getDefaultImageUrl,
|
|
17
|
+
c as getImageUrl,
|
|
18
|
+
l as getNextImageFallback
|
|
19
|
+
};
|
package/dist/helpers/Numbers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var o = (r) => Number((typeof r == "number" ? r : Number(r)).toFixed(2)),
|
|
1
|
+
var o = (r) => Number((typeof r == "number" ? r : Number(r)).toFixed(2)), a = (r, e) => (r > e && console.warn(`Could not get percent of value ${r} from a total ${e}. Total must be higher or at least equal to value.`), r === e ? r === 0 ? 0 : 100 : r / (e / 100)), n = (r, e) => {
|
|
2
2
|
const t = r + e;
|
|
3
3
|
return t === 0 ? {
|
|
4
4
|
a: 0,
|
|
@@ -7,9 +7,10 @@ var o = (r) => Number((typeof r == "number" ? r : Number(r)).toFixed(2)), n = (r
|
|
|
7
7
|
a: Math.round(r / t * 100 * 10) / 10,
|
|
8
8
|
b: Math.round(e / t * 100 * 10) / 10
|
|
9
9
|
};
|
|
10
|
-
};
|
|
10
|
+
}, m = (r, e, t) => Math.min(t, Math.max(e, r));
|
|
11
11
|
export {
|
|
12
|
+
m as clamp,
|
|
12
13
|
o as format2Digits,
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
a as getPercent,
|
|
15
|
+
n as getPercentsOf2Numbers
|
|
15
16
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ThemeSettings as d } from "../components/ThemeSettings/ThemeSettings2.js";
|
|
2
|
+
import { useAuth as w } from "./useAuth/useAuth.js";
|
|
3
|
+
import { ChangePasswordModal as A } from "../components/Auth/ChangePasswordModal/ChangePasswordModal2.js";
|
|
4
|
+
import { useState as s } from "react";
|
|
5
|
+
import { Fragment as k, jsx as o, jsxs as v } from "react/jsx-runtime";
|
|
6
|
+
var j = ({ appName: l, mfaModal: e, themeLabel: c = "Theme", loginPath: m = "/login" }) => {
|
|
7
|
+
const { user: u, logout: p } = w(), [f, t] = s(!1), [h, n] = s(!1), [g, a] = s(!1), C = async () => {
|
|
8
|
+
await p(), window.location.href = m;
|
|
9
|
+
}, i = {
|
|
10
|
+
label: c,
|
|
11
|
+
icon: "theme-picker",
|
|
12
|
+
onClick: () => t(!0),
|
|
13
|
+
isActive: !1,
|
|
14
|
+
separator: !0
|
|
15
|
+
}, r = [
|
|
16
|
+
{
|
|
17
|
+
label: "Change Password",
|
|
18
|
+
icon: "lock",
|
|
19
|
+
onClick: () => n(!0),
|
|
20
|
+
isActive: !1
|
|
21
|
+
},
|
|
22
|
+
...e ? [{
|
|
23
|
+
label: "Two-factor Authentication",
|
|
24
|
+
icon: "key",
|
|
25
|
+
onClick: () => a(!0),
|
|
26
|
+
isActive: !1
|
|
27
|
+
}] : [],
|
|
28
|
+
{
|
|
29
|
+
label: `Logout ${u?.username ?? ""}`.trim(),
|
|
30
|
+
icon: "logout",
|
|
31
|
+
onClick: C,
|
|
32
|
+
isActive: !1
|
|
33
|
+
}
|
|
34
|
+
], O = /* @__PURE__ */ v(k, { children: [
|
|
35
|
+
/* @__PURE__ */ o(d, {
|
|
36
|
+
isOpen: f,
|
|
37
|
+
onClose: () => t(!1),
|
|
38
|
+
currentApp: l
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ o(A, {
|
|
41
|
+
isOpen: h,
|
|
42
|
+
onClose: () => n(!1)
|
|
43
|
+
}),
|
|
44
|
+
e && /* @__PURE__ */ o(e, {
|
|
45
|
+
isOpen: g,
|
|
46
|
+
onClose: () => a(!1)
|
|
47
|
+
})
|
|
48
|
+
] });
|
|
49
|
+
return {
|
|
50
|
+
themeItem: i,
|
|
51
|
+
accountItems: r,
|
|
52
|
+
items: [i, ...r],
|
|
53
|
+
modals: O
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
j as useAccountMenu
|
|
58
|
+
};
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare interface ApiClient {
|
|
2
|
+
get: <T>(path: string) => Promise<T>;
|
|
3
|
+
post: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
4
|
+
put: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
5
|
+
patch: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
6
|
+
delete: <T>(path: string) => Promise<T>;
|
|
7
|
+
upload: <T>(path: string, formData: FormData) => Promise<T>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare interface ApiClientConfig {
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
loginPath?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class ApiError extends Error {
|
|
16
|
+
readonly status: number;
|
|
17
|
+
constructor(message: string, status: number);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export declare const buildRequestHeaders: (method: HttpMethod, json?: boolean) => Record<string, string>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Cookie-session API client shared by the memobit apps: sends credentials, adds the CSRF
|
|
24
|
+
* header on mutating requests, surfaces the server's `error` message, and on 401 navigates
|
|
25
|
+
* to the login page. The 401 path returns a promise that never settles so callers don't
|
|
26
|
+
* flash an error toast while the browser is already leaving the page.
|
|
27
|
+
*/
|
|
28
|
+
export declare const createApiClient: ({ baseUrl, loginPath }: ApiClientConfig) => ApiClient;
|
|
29
|
+
|
|
30
|
+
export declare const CSRF_HEADER = "X-CSRF-Token";
|
|
31
|
+
|
|
32
|
+
export declare const getCsrfToken: () => string | null;
|
|
33
|
+
|
|
34
|
+
export declare const HttpMethod: {
|
|
35
|
+
readonly Get: "GET";
|
|
36
|
+
readonly Post: "POST";
|
|
37
|
+
readonly Put: "PUT";
|
|
38
|
+
readonly Patch: "PATCH";
|
|
39
|
+
readonly Delete: "DELETE";
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
|
|
43
|
+
|
|
44
|
+
export declare const HttpStatus: {
|
|
45
|
+
readonly Continue: 100;
|
|
46
|
+
readonly SwitchingProtocols: 101;
|
|
47
|
+
readonly Ok: 200;
|
|
48
|
+
readonly Created: 201;
|
|
49
|
+
readonly Accepted: 202;
|
|
50
|
+
readonly NoContent: 204;
|
|
51
|
+
readonly PartialContent: 206;
|
|
52
|
+
readonly MovedPermanently: 301;
|
|
53
|
+
readonly Found: 302;
|
|
54
|
+
readonly SeeOther: 303;
|
|
55
|
+
readonly NotModified: 304;
|
|
56
|
+
readonly TemporaryRedirect: 307;
|
|
57
|
+
readonly PermanentRedirect: 308;
|
|
58
|
+
readonly BadRequest: 400;
|
|
59
|
+
readonly Unauthorized: 401;
|
|
60
|
+
readonly PaymentRequired: 402;
|
|
61
|
+
readonly Forbidden: 403;
|
|
62
|
+
readonly NotFound: 404;
|
|
63
|
+
readonly MethodNotAllowed: 405;
|
|
64
|
+
readonly NotAcceptable: 406;
|
|
65
|
+
readonly RequestTimeout: 408;
|
|
66
|
+
readonly Conflict: 409;
|
|
67
|
+
readonly Gone: 410;
|
|
68
|
+
readonly PayloadTooLarge: 413;
|
|
69
|
+
readonly UnsupportedMediaType: 415;
|
|
70
|
+
readonly UnprocessableEntity: 422;
|
|
71
|
+
readonly Locked: 423;
|
|
72
|
+
readonly TooManyRequests: 429;
|
|
73
|
+
readonly InternalServerError: 500;
|
|
74
|
+
readonly NotImplemented: 501;
|
|
75
|
+
readonly BadGateway: 502;
|
|
76
|
+
readonly ServiceUnavailable: 503;
|
|
77
|
+
readonly GatewayTimeout: 504;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export declare type HttpStatus = (typeof HttpStatus)[keyof typeof HttpStatus];
|
|
81
|
+
|
|
82
|
+
export declare const isClientErrorStatus: (status: number) => boolean;
|
|
83
|
+
|
|
84
|
+
export declare const isServerErrorStatus: (status: number) => boolean;
|
|
85
|
+
|
|
86
|
+
export declare const isSuccessStatus: (status: number) => boolean;
|
|
87
|
+
|
|
88
|
+
export declare const readErrorMessage: (response: Response) => Promise<string>;
|
|
89
|
+
|
|
90
|
+
export { }
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
declare global {
|
|
94
|
+
interface Window {
|
|
95
|
+
__VERSIONS__: FullVersionInfo;
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiError as t, CSRF_HEADER as e, HttpMethod as s, HttpStatus as i, buildRequestHeaders as o, createApiClient as a, getCsrfToken as u, isClientErrorStatus as S, isServerErrorStatus as p, isSuccessStatus as E, readErrorMessage as d } from "./helpers/Http.js";
|
|
2
|
+
export {
|
|
3
|
+
t as ApiError,
|
|
4
|
+
e as CSRF_HEADER,
|
|
5
|
+
s as HttpMethod,
|
|
6
|
+
i as HttpStatus,
|
|
7
|
+
o as buildRequestHeaders,
|
|
8
|
+
a as createApiClient,
|
|
9
|
+
u as getCsrfToken,
|
|
10
|
+
S as isClientErrorStatus,
|
|
11
|
+
p as isServerErrorStatus,
|
|
12
|
+
E as isSuccessStatus,
|
|
13
|
+
d as readErrorMessage
|
|
14
|
+
};
|