@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.
@@ -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 }), console.error("ErrorBoundary caught:", r, t.componentStack), this.props.onError?.(r, t);
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 { canLoadMoreIcons as n, getIcon as y, loadIcon as N } from "@memobit/icons/map";
5
- import { jsx as $ } from "react/jsx-runtime";
6
- var c = /* @__PURE__ */ new Set(), a = (o) => {
7
- c.has(o) || (c.add(o), console.warn(n ? `[@memobit/libs] No icon named "${o}".` : `[@memobit/libs] No icon named "${o}". 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.`));
8
- }, S = ({ className: o = "", fade: l, fadeOnHover: d, name: e, pulse: u, pulseOnHover: f, size: r, spin: p, spinOnHover: h, variant: t }) => {
9
- const m = [
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
- h ? "icon--spin-hover" : "",
17
+ m ? "icon--spin-hover" : "",
17
18
  d ? "icon--fade-hover" : "",
18
19
  f ? "icon--pulse-hover" : "",
19
- o
20
- ].filter(Boolean).join(" "), [, v] = I(null), i = y(e);
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 N(e).then((b) => {
25
+ return w(o).then((b) => {
25
26
  if (s) {
26
27
  if (b === void 0) {
27
- a(e);
28
+ a(o);
28
29
  return;
29
30
  }
30
- v(e);
31
+ v(o);
31
32
  }
32
33
  }, () => {
33
34
  }), () => {
34
35
  s = !1;
35
36
  };
36
- }, [i, e]), i === void 0 && !n && a(e), /* @__PURE__ */ $("span", {
37
- className: m,
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
- S as Icon
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 { jsx as a, jsxs as b } from "react/jsx-runtime";
7
- import { logger as q } from "@memobit/core";
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) : q.error("QuickOptionUpdate received an unsupported value type", void 0, { type: typeof 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__ */ b(x, {
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(() => {
@@ -1,5 +1,5 @@
1
- import { logger as p } from "@memobit/core";
2
- var c = {
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
- }, A = (e) => e >= 200 && e < 300, R = (e) => e >= 400 && e < 500, U = (e) => e >= 500 && e < 600, y = "csrf_token", S = "X-CSRF-Token", T = () => {
43
- const e = document.cookie.match(new RegExp(`(?:^|;\\s*)${y}=([^;]+)`));
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 u = T();
49
- u && (n[S] = u);
48
+ const d = T();
49
+ d && (n[y] = d);
50
50
  }
51
51
  return n;
52
- }, v = class extends Error {
52
+ }, w = class extends Error {
53
53
  constructor(e, t) {
54
54
  super(e), this.name = "ApiError", this.status = t;
55
55
  }
56
- }, P = async (e) => {
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
- }, w = (e) => e instanceof DOMException && e.name === "AbortError", b = (e, t, n) => {
67
- t instanceof v || w(t) || p.error(e, t, n);
68
- }, g = /* @__PURE__ */ new Set([
69
- c.BadGateway,
70
- c.ServiceUnavailable,
71
- c.GatewayTimeout
72
- ]), G = ({ baseUrl: e, loginPath: t = "/login" }) => {
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 u = (r) => `${e.replace(/\/$/, "")}/${r.replace(/^\//, "")}`, d = async (r, o, l, E = !0) => {
83
+ const d = (r) => `${e.replace(/\/$/, "")}/${r.replace(/^\//, "")}`, l = async (r, a, f, E = !0) => {
75
84
  const h = {
76
- method: o,
85
+ method: a,
77
86
  path: r.split("?")[0]
78
87
  };
79
- let a;
88
+ let o;
80
89
  try {
81
- a = await fetch(u(r), {
82
- method: o,
83
- headers: m(o, E),
90
+ o = await fetch(d(r), {
91
+ method: a,
92
+ headers: m(a, E),
84
93
  credentials: "include",
85
- body: l
94
+ body: f
86
95
  });
87
96
  } catch (i) {
88
- throw w(i) ? i : (p.warn("API request could not reach the server", h), new v("Could not reach the server", 0));
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 (a.status === c.Unauthorized && !window.location.pathname.startsWith(t))
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 (!a.ok)
94
- throw g.has(a.status) && p.warn("API gateway failure", {
102
+ if (!o.ok)
103
+ throw C.has(o.status) && c.warn("API gateway failure", {
95
104
  ...h,
96
- status: a.status
97
- }), new v(await P(a), a.status);
98
- if (a.status !== c.NoContent)
105
+ status: o.status
106
+ }), new w(await g(o), o.status);
107
+ if (o.status !== u.NoContent)
99
108
  try {
100
- return await a.json();
109
+ return await o.json();
101
110
  } catch (i) {
102
- throw p.error("API response was not valid JSON", i, {
111
+ throw c.error("API response was not valid JSON", i, {
103
112
  ...h,
104
- status: a.status
113
+ status: o.status
105
114
  }), i;
106
115
  }
107
- }, f = (r, o, l) => d(r, o, l === void 0 ? void 0 : JSON.stringify(l));
116
+ }, p = (r, a, f) => l(r, a, f === void 0 ? void 0 : JSON.stringify(f));
108
117
  return {
109
- get: (r) => d(r, s.Get),
110
- post: (r, o) => f(r, s.Post, o),
111
- put: (r, o) => f(r, s.Put, o),
112
- patch: (r, o) => f(r, s.Patch, o),
113
- delete: (r) => d(r, s.Delete),
114
- upload: (r, o) => d(r, s.Post, o, !1)
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
- v as ApiError,
119
- S as CSRF_HEADER,
127
+ w as ApiError,
128
+ y as CSRF_HEADER,
120
129
  s as HttpMethod,
121
- c as HttpStatus,
130
+ u as HttpStatus,
122
131
  m as buildRequestHeaders,
123
- G as createApiClient,
132
+ F as createApiClient,
124
133
  T as getCsrfToken,
125
- R as isClientErrorStatus,
126
- U as isServerErrorStatus,
127
- A as isSuccessStatus,
128
- b as logUnexpectedError,
129
- P as readErrorMessage
134
+ N as isClientErrorStatus,
135
+ b as isServerErrorStatus,
136
+ U as isSuccessStatus,
137
+ G as logUnexpectedError,
138
+ g as readErrorMessage
130
139
  };
@@ -1,4 +1,8 @@
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) => {
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
- }, m = (r, e, t) => Math.min(t, Math.max(e, r));
14
+ }, f = (r, e, t) => Math.min(t, Math.max(e, r));
11
15
  export {
12
- m as clamp,
13
- o as format2Digits,
14
- a as getPercent,
15
- n as getPercentsOf2Numbers
16
+ f as clamp,
17
+ m as format2Digits,
18
+ o as getPercent,
19
+ a as getPercentsOf2Numbers
16
20
  };
@@ -23,7 +23,7 @@ var r = (i) => {
23
23
  const o = {
24
24
  ...i,
25
25
  lib: d,
26
- libBuildNumber: 515,
26
+ libBuildNumber: 520,
27
27
  libCommit: n,
28
28
  libBuildDate: t
29
29
  };
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. What is left is a bug in
2398
- * the code around the call, e.g. mapping the response.
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.0", B = 515, L = "3e853ab", _ = "2026-10-16T19:55:36.011Z", a = "515";
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
- a as LIB_BUILD_ID,
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
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "3.12.0",
3
- "buildNumber": 515,
4
- "commit": "3e853ab",
5
- "buildDate": "2026-10-16T19:55:36.011Z"
2
+ "version": "3.12.2",
3
+ "buildNumber": 520,
4
+ "commit": "4308de2",
5
+ "buildDate": "2026-10-17T07:54:26.042Z"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memobit/libs",
3
- "version": "3.12.0",
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",