@memobit/libs 3.12.0 → 3.12.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/components/ErrorBoundary/ErrorBoundary2.js +2 -2
- package/dist/components/Icon/Icon2.js +16 -15
- package/dist/components/QuickOptionUpdate/QuickOptionUpdate2.js +4 -4
- package/dist/contexts/AuthContext/AuthContext.js +1 -1
- package/dist/helpers/Http.js +57 -48
- package/dist/helpers/Numbers.js +10 -6
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/version.js +2 -2
- package/dist/version.json +4 -4
- package/package.json +2 -1
|
@@ -2,8 +2,8 @@ import './ErrorBoundary.css';
|
|
|
2
2
|
import { EmptyState as s } from "../EmptyState/EmptyState2.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { Component as a } from "react";
|
|
5
|
+
import { logger as c } from "@memobit/core";
|
|
5
6
|
import { jsx as o } from "react/jsx-runtime";
|
|
6
|
-
import { reportError as c } from "@memobit/core";
|
|
7
7
|
var h = class extends a {
|
|
8
8
|
constructor(...r) {
|
|
9
9
|
super(...r), this.state = { error: null }, this.reset = () => {
|
|
@@ -14,7 +14,7 @@ var h = class extends a {
|
|
|
14
14
|
return { error: r };
|
|
15
15
|
}
|
|
16
16
|
componentDidCatch(r, t) {
|
|
17
|
-
c(r, { componentStack: t.componentStack ?? void 0 }),
|
|
17
|
+
c.error("ErrorBoundary caught an error", r, { componentStack: t.componentStack ?? void 0 }), this.props.onError?.(r, t);
|
|
18
18
|
}
|
|
19
19
|
render() {
|
|
20
20
|
const { error: r } = this.state, { children: t, title: n, resetLabel: i, fallback: e } = this.props;
|
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import './Icon.css';
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { useEffect as g, useState as I } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { logger as y } from "@memobit/core";
|
|
5
|
+
import { canLoadMoreIcons as n, getIcon as N, loadIcon as w } from "@memobit/icons/map";
|
|
6
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
7
|
+
var c = /* @__PURE__ */ new Set(), a = (e) => {
|
|
8
|
+
c.has(e) || (c.add(e), y.warn(n ? "[@memobit/libs] No icon named <name>." : "[@memobit/libs] No icon named <name>. If this app trims icons with @memobit/icons/vite, add it to the plugin's `include` option or use `lazy` — a name that only exists at runtime cannot be found by the source scan.", { name: e }));
|
|
9
|
+
}, C = ({ className: e = "", fade: l, fadeOnHover: d, name: o, pulse: u, pulseOnHover: f, size: r, spin: p, spinOnHover: m, variant: t }) => {
|
|
10
|
+
const h = [
|
|
10
11
|
"icon",
|
|
11
12
|
r ? `icon--${r}` : "",
|
|
12
13
|
t && t !== "default" ? `icon--${t}` : "",
|
|
13
14
|
p ? "icon--spin" : "",
|
|
14
15
|
l ? "icon--fade" : "",
|
|
15
16
|
u ? "icon--pulse" : "",
|
|
16
|
-
|
|
17
|
+
m ? "icon--spin-hover" : "",
|
|
17
18
|
d ? "icon--fade-hover" : "",
|
|
18
19
|
f ? "icon--pulse-hover" : "",
|
|
19
|
-
|
|
20
|
-
].filter(Boolean).join(" "), [, v] = I(null), i =
|
|
20
|
+
e
|
|
21
|
+
].filter(Boolean).join(" "), [, v] = I(null), i = N(o);
|
|
21
22
|
return g(() => {
|
|
22
23
|
if (i !== void 0 || !n) return;
|
|
23
24
|
let s = !0;
|
|
24
|
-
return
|
|
25
|
+
return w(o).then((b) => {
|
|
25
26
|
if (s) {
|
|
26
27
|
if (b === void 0) {
|
|
27
|
-
a(
|
|
28
|
+
a(o);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
|
-
v(
|
|
31
|
+
v(o);
|
|
31
32
|
}
|
|
32
33
|
}, () => {
|
|
33
34
|
}), () => {
|
|
34
35
|
s = !1;
|
|
35
36
|
};
|
|
36
|
-
}, [i,
|
|
37
|
-
className:
|
|
37
|
+
}, [i, o]), i === void 0 && !n && a(o), /* @__PURE__ */ x("span", {
|
|
38
|
+
className: h,
|
|
38
39
|
children: i
|
|
39
40
|
});
|
|
40
41
|
};
|
|
41
42
|
export {
|
|
42
|
-
|
|
43
|
+
C as Icon
|
|
43
44
|
};
|
|
@@ -3,8 +3,8 @@ import { Modal as x } from "../Modal/Modal2.js";
|
|
|
3
3
|
import { Radio as C } from "../Radio/Radio2.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import { useEffect as S, useState as n } from "react";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { logger as b } from "@memobit/core";
|
|
7
|
+
import { jsx as a, jsxs as q } from "react/jsx-runtime";
|
|
8
8
|
var U = ({ isOpen: m = !1, list: c, title: f, onClose: t, onSave: u, icon: v, value: i }) => {
|
|
9
9
|
const [r, l] = n(i), [s, d] = n(!1), [p, o] = n("");
|
|
10
10
|
S(() => {
|
|
@@ -24,11 +24,11 @@ var U = ({ isOpen: m = !1, list: c, title: f, onClose: t, onSave: u, icon: v, va
|
|
|
24
24
|
d(!1);
|
|
25
25
|
}
|
|
26
26
|
}, h = (e) => {
|
|
27
|
-
typeof e == "string" || typeof e == "number" ? l(e) :
|
|
27
|
+
typeof e == "string" || typeof e == "number" ? l(e) : b.error("QuickOptionUpdate received an unsupported value type", void 0, { type: typeof e });
|
|
28
28
|
};
|
|
29
29
|
return /* @__PURE__ */ a("div", {
|
|
30
30
|
className: "quick-set",
|
|
31
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ q(x, {
|
|
32
32
|
isOpen: m,
|
|
33
33
|
titleIcon: v,
|
|
34
34
|
title: f,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpMethod as o, buildRequestHeaders as A } from "../../helpers/Http.js";
|
|
2
2
|
import { AuthContext as U } from "./AuthContext.context.js";
|
|
3
3
|
import { useCallback as i, useEffect as j, useState as c } from "react";
|
|
4
|
-
import { jsx as B } from "react/jsx-runtime";
|
|
5
4
|
import { logger as h } from "@memobit/core";
|
|
5
|
+
import { jsx as B } from "react/jsx-runtime";
|
|
6
6
|
function C({ children: f, config: a }) {
|
|
7
7
|
const [d, u] = c(null), [p, s] = c(!0);
|
|
8
8
|
j(() => {
|
package/dist/helpers/Http.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
var
|
|
1
|
+
import { logger as c } from "@memobit/core";
|
|
2
|
+
var u = {
|
|
3
3
|
Continue: 100,
|
|
4
4
|
SwitchingProtocols: 101,
|
|
5
5
|
Ok: 200,
|
|
@@ -39,21 +39,21 @@ var c = {
|
|
|
39
39
|
Put: "PUT",
|
|
40
40
|
Patch: "PATCH",
|
|
41
41
|
Delete: "DELETE"
|
|
42
|
-
},
|
|
43
|
-
const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${
|
|
42
|
+
}, U = (e) => e >= 200 && e < 300, N = (e) => e >= 400 && e < 500, b = (e) => e >= 500 && e < 600, S = "csrf_token", y = "X-CSRF-Token", T = () => {
|
|
43
|
+
const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${S}=([^;]+)`));
|
|
44
44
|
return e ? decodeURIComponent(e[1]) : null;
|
|
45
45
|
}, m = (e, t = !0) => {
|
|
46
46
|
const n = t ? { "Content-Type": "application/json" } : {};
|
|
47
47
|
if (e !== s.Get) {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const d = T();
|
|
49
|
+
d && (n[y] = d);
|
|
50
50
|
}
|
|
51
51
|
return n;
|
|
52
|
-
},
|
|
52
|
+
}, w = class extends Error {
|
|
53
53
|
constructor(e, t) {
|
|
54
54
|
super(e), this.name = "ApiError", this.status = t;
|
|
55
55
|
}
|
|
56
|
-
},
|
|
56
|
+
}, g = async (e) => {
|
|
57
57
|
try {
|
|
58
58
|
const t = await e.json();
|
|
59
59
|
if (t && typeof t == "object") {
|
|
@@ -63,68 +63,77 @@ var c = {
|
|
|
63
63
|
} catch {
|
|
64
64
|
}
|
|
65
65
|
return `Request failed (${e.status}${e.statusText ? ` ${e.statusText}` : ""})`;
|
|
66
|
-
},
|
|
67
|
-
t instanceof
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
}, v = (e) => e instanceof DOMException && e.name === "AbortError", A = /^(Failed to fetch|NetworkError when attempting to fetch resource\.?|Load failed)$/, P = (e) => e instanceof TypeError && A.test(e.message), G = (e, t, n) => {
|
|
67
|
+
if (!(t instanceof w || v(t))) {
|
|
68
|
+
if (P(t)) {
|
|
69
|
+
c.warn(e, {
|
|
70
|
+
...n,
|
|
71
|
+
error: String(t)
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
c.error(e, t, n);
|
|
76
|
+
}
|
|
77
|
+
}, C = /* @__PURE__ */ new Set([
|
|
78
|
+
u.BadGateway,
|
|
79
|
+
u.ServiceUnavailable,
|
|
80
|
+
u.GatewayTimeout
|
|
81
|
+
]), F = ({ baseUrl: e, loginPath: t = "/login" }) => {
|
|
73
82
|
let n = !1;
|
|
74
|
-
const
|
|
83
|
+
const d = (r) => `${e.replace(/\/$/, "")}/${r.replace(/^\//, "")}`, l = async (r, a, f, E = !0) => {
|
|
75
84
|
const h = {
|
|
76
|
-
method:
|
|
85
|
+
method: a,
|
|
77
86
|
path: r.split("?")[0]
|
|
78
87
|
};
|
|
79
|
-
let
|
|
88
|
+
let o;
|
|
80
89
|
try {
|
|
81
|
-
|
|
82
|
-
method:
|
|
83
|
-
headers: m(
|
|
90
|
+
o = await fetch(d(r), {
|
|
91
|
+
method: a,
|
|
92
|
+
headers: m(a, E),
|
|
84
93
|
credentials: "include",
|
|
85
|
-
body:
|
|
94
|
+
body: f
|
|
86
95
|
});
|
|
87
96
|
} catch (i) {
|
|
88
|
-
throw
|
|
97
|
+
throw v(i) ? i : (c.warn("API request could not reach the server", h), new w("Could not reach the server", 0));
|
|
89
98
|
}
|
|
90
|
-
if (
|
|
99
|
+
if (o.status === u.Unauthorized && !window.location.pathname.startsWith(t))
|
|
91
100
|
return n || (n = !0, window.location.href = `${t}?session_expired=true`), new Promise(() => {
|
|
92
101
|
});
|
|
93
|
-
if (!
|
|
94
|
-
throw
|
|
102
|
+
if (!o.ok)
|
|
103
|
+
throw C.has(o.status) && c.warn("API gateway failure", {
|
|
95
104
|
...h,
|
|
96
|
-
status:
|
|
97
|
-
}), new
|
|
98
|
-
if (
|
|
105
|
+
status: o.status
|
|
106
|
+
}), new w(await g(o), o.status);
|
|
107
|
+
if (o.status !== u.NoContent)
|
|
99
108
|
try {
|
|
100
|
-
return await
|
|
109
|
+
return await o.json();
|
|
101
110
|
} catch (i) {
|
|
102
|
-
throw
|
|
111
|
+
throw c.error("API response was not valid JSON", i, {
|
|
103
112
|
...h,
|
|
104
|
-
status:
|
|
113
|
+
status: o.status
|
|
105
114
|
}), i;
|
|
106
115
|
}
|
|
107
|
-
},
|
|
116
|
+
}, p = (r, a, f) => l(r, a, f === void 0 ? void 0 : JSON.stringify(f));
|
|
108
117
|
return {
|
|
109
|
-
get: (r) =>
|
|
110
|
-
post: (r,
|
|
111
|
-
put: (r,
|
|
112
|
-
patch: (r,
|
|
113
|
-
delete: (r) =>
|
|
114
|
-
upload: (r,
|
|
118
|
+
get: (r) => l(r, s.Get),
|
|
119
|
+
post: (r, a) => p(r, s.Post, a),
|
|
120
|
+
put: (r, a) => p(r, s.Put, a),
|
|
121
|
+
patch: (r, a) => p(r, s.Patch, a),
|
|
122
|
+
delete: (r) => l(r, s.Delete),
|
|
123
|
+
upload: (r, a) => l(r, s.Post, a, !1)
|
|
115
124
|
};
|
|
116
125
|
};
|
|
117
126
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
w as ApiError,
|
|
128
|
+
y as CSRF_HEADER,
|
|
120
129
|
s as HttpMethod,
|
|
121
|
-
|
|
130
|
+
u as HttpStatus,
|
|
122
131
|
m as buildRequestHeaders,
|
|
123
|
-
|
|
132
|
+
F as createApiClient,
|
|
124
133
|
T as getCsrfToken,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
N as isClientErrorStatus,
|
|
135
|
+
b as isServerErrorStatus,
|
|
136
|
+
U as isSuccessStatus,
|
|
137
|
+
G as logUnexpectedError,
|
|
138
|
+
g as readErrorMessage
|
|
130
139
|
};
|
package/dist/helpers/Numbers.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { logger as n } from "@memobit/core";
|
|
2
|
+
var m = (r) => Number((typeof r == "number" ? r : Number(r)).toFixed(2)), o = (r, e) => (r > e && n.warn("getPercent: value is higher than total", {
|
|
3
|
+
value: r,
|
|
4
|
+
total: e
|
|
5
|
+
}), r === e ? r === 0 ? 0 : 100 : r / (e / 100)), a = (r, e) => {
|
|
2
6
|
const t = r + e;
|
|
3
7
|
return t === 0 ? {
|
|
4
8
|
a: 0,
|
|
@@ -7,10 +11,10 @@ var o = (r) => Number((typeof r == "number" ? r : Number(r)).toFixed(2)), a = (r
|
|
|
7
11
|
a: Math.round(r / t * 100 * 10) / 10,
|
|
8
12
|
b: Math.round(e / t * 100 * 10) / 10
|
|
9
13
|
};
|
|
10
|
-
},
|
|
14
|
+
}, f = (r, e, t) => Math.min(t, Math.max(e, r));
|
|
11
15
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
f as clamp,
|
|
17
|
+
m as format2Digits,
|
|
18
|
+
o as getPercent,
|
|
19
|
+
a as getPercentsOf2Numbers
|
|
16
20
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2394,8 +2394,9 @@ export declare interface LoginResponse {
|
|
|
2394
2394
|
|
|
2395
2395
|
/**
|
|
2396
2396
|
* For the catch around an API call: reports `error` unless it is an `ApiError` (the client and
|
|
2397
|
-
* the backend already report those that matter) or an aborted request.
|
|
2398
|
-
* the code around the call, e.g.
|
|
2397
|
+
* the backend already report those that matter) or an aborted request. A bare fetch() that could
|
|
2398
|
+
* not reach the server is a warning. What is left is a bug in the code around the call, e.g.
|
|
2399
|
+
* mapping the response.
|
|
2399
2400
|
*/
|
|
2400
2401
|
export declare const logUnexpectedError: (message: string, error: unknown, context?: ErrorReportContext) => void;
|
|
2401
2402
|
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var I = "3.12.
|
|
1
|
+
var I = "3.12.2", B = 520, L = "4308de2", _ = "2026-10-17T07:54:26.042Z", r = "520";
|
|
2
2
|
export {
|
|
3
3
|
_ as LIB_BUILD_DATE,
|
|
4
|
-
|
|
4
|
+
r as LIB_BUILD_ID,
|
|
5
5
|
B as LIB_BUILD_NUMBER,
|
|
6
6
|
L as LIB_COMMIT,
|
|
7
7
|
I as LIB_VERSION
|
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"@memobit/icons": "file:../memobit-react-icons",
|
|
99
99
|
"@memobit/themes": "file:../memobit-react-themes",
|
|
100
100
|
"@microsoft/api-extractor": "7.59.2",
|
|
101
|
+
"@types/node": "25.9.8",
|
|
101
102
|
"@types/react": "19.3.0",
|
|
102
103
|
"@types/react-dom": "19.3.0",
|
|
103
104
|
"@vitejs/plugin-react": "6.1.1",
|