@memobit/libs 3.5.0 → 3.7.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/Auth/ChangePasswordModal/ChangePasswordModal2.js +48 -52
- package/dist/components/Auth/MfaSetupModal/MfaSetupModal2.js +64 -65
- package/dist/components/ProtectedRoute/ProtectedRoute.css +1 -0
- package/dist/components/ProtectedRoute/ProtectedRoute2.js +19 -0
- 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 +25 -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 +148 -0
- package/dist/index.js +329 -308
- 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 +16 -2
|
@@ -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,25 @@
|
|
|
1
|
+
var u = "/data-files", p = (l) => {
|
|
2
|
+
const e = `${u}/${l.replace(/^\/+|\/+$/g, "")}`, c = () => `${e}/default.jpg`, g = (t) => `${e}/category/${t}.jpg`, o = (t, a) => typeof t != "string" ? URL.createObjectURL(t) : t ? t.includes(e) || t.startsWith("blob:") || t.startsWith("http") ? t : `${e}/specific/${t}` : a ? g(a) : c(), n = (t, a) => {
|
|
3
|
+
const r = c(), s = a ? g(a) : r;
|
|
4
|
+
return t ? t.endsWith(r) ? null : t.includes(`${e}/category/`) ? r : s : s;
|
|
5
|
+
};
|
|
6
|
+
return {
|
|
7
|
+
basePath: e,
|
|
8
|
+
getDefaultImageUrl: c,
|
|
9
|
+
getCategoryImageUrl: g,
|
|
10
|
+
getImageUrl: o,
|
|
11
|
+
getNextImageFallback: n,
|
|
12
|
+
applyImageFallback: (t, a) => {
|
|
13
|
+
const r = t.currentTarget, s = n(r.src, a);
|
|
14
|
+
if (s && !r.src.endsWith(s)) {
|
|
15
|
+
r.src = s;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
r.onerror = null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
u as DATA_FILES_PATH,
|
|
24
|
+
p as createImagePaths
|
|
25
|
+
};
|
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
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
2
3
|
import { Context } from 'react';
|
|
3
4
|
import { CSSProperties } from 'react';
|
|
4
5
|
import { default as default_2 } from 'react';
|
|
@@ -15,6 +16,7 @@ import { ReactElement } from 'react';
|
|
|
15
16
|
import { ReactNode } from 'react';
|
|
16
17
|
import { ReactPortal } from 'react';
|
|
17
18
|
import { RefAttributes } from 'react';
|
|
19
|
+
import { SyntheticEvent } from 'react';
|
|
18
20
|
import { THEME_CONFIGS } from '@memobit/themes';
|
|
19
21
|
import { ThemeConfig } from '@memobit/themes';
|
|
20
22
|
import { TouchEvent as TouchEvent_2 } from 'react';
|
|
@@ -37,6 +39,11 @@ export declare interface AccordionProps {
|
|
|
37
39
|
className?: string;
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
declare interface AccountMenuModalProps {
|
|
43
|
+
isOpen: boolean;
|
|
44
|
+
onClose: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
/**
|
|
41
48
|
* Adds days to a date
|
|
42
49
|
*/
|
|
@@ -104,6 +111,25 @@ export declare interface AngleSliderProps {
|
|
|
104
111
|
|
|
105
112
|
export declare type AngleSliderVariant = 'accent' | 'info' | 'success' | 'warning' | 'danger';
|
|
106
113
|
|
|
114
|
+
export declare interface ApiClient {
|
|
115
|
+
get: <T>(path: string) => Promise<T>;
|
|
116
|
+
post: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
117
|
+
put: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
118
|
+
patch: <T, P = unknown>(path: string, payload?: P) => Promise<T>;
|
|
119
|
+
delete: <T>(path: string) => Promise<T>;
|
|
120
|
+
upload: <T>(path: string, formData: FormData) => Promise<T>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export declare interface ApiClientConfig {
|
|
124
|
+
baseUrl: string;
|
|
125
|
+
loginPath?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare class ApiError extends Error {
|
|
129
|
+
readonly status: number;
|
|
130
|
+
constructor(message: string, status: number);
|
|
131
|
+
}
|
|
132
|
+
|
|
107
133
|
export declare const APP_DATE_FORMAT = "DD MMM YYYY";
|
|
108
134
|
|
|
109
135
|
export declare const APP_DATE_TIME_FORMAT = "DD MMM YYYY HH:mm";
|
|
@@ -303,6 +329,8 @@ export declare const breakpoints: {
|
|
|
303
329
|
};
|
|
304
330
|
};
|
|
305
331
|
|
|
332
|
+
export declare const buildRequestHeaders: (method: HttpMethod, json?: boolean) => Record<string, string>;
|
|
333
|
+
|
|
306
334
|
export declare interface BulkAction {
|
|
307
335
|
key: string;
|
|
308
336
|
label: string;
|
|
@@ -479,6 +507,20 @@ declare interface ChangePasswordModalProps {
|
|
|
479
507
|
onClose: () => void;
|
|
480
508
|
}
|
|
481
509
|
|
|
510
|
+
export declare const chartColors: {
|
|
511
|
+
readonly axis: "var(--body-color-muted)";
|
|
512
|
+
readonly grid: "var(--border-color)";
|
|
513
|
+
readonly text: "var(--body-color)";
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
declare interface ChartTooltipStyle {
|
|
517
|
+
contentStyle: CSSProperties;
|
|
518
|
+
itemStyle: CSSProperties;
|
|
519
|
+
labelStyle: CSSProperties;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export declare const chartTooltipStyle: ChartTooltipStyle;
|
|
523
|
+
|
|
482
524
|
export declare const Checkbox: FC<CheckboxProps>;
|
|
483
525
|
|
|
484
526
|
declare interface CheckboxProps {
|
|
@@ -512,6 +554,8 @@ export declare type ChipSize = 'xsmall' | 'small' | 'medium' | 'large';
|
|
|
512
554
|
|
|
513
555
|
export declare type ChipVariant = 'plain' | 'default' | 'success' | 'info' | 'warning' | 'danger';
|
|
514
556
|
|
|
557
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
558
|
+
|
|
515
559
|
export declare const Col: FC<ColProps>;
|
|
516
560
|
|
|
517
561
|
export declare const CollapsibleSection: default_2.FC<CollapsibleSectionProps>;
|
|
@@ -977,6 +1021,27 @@ declare interface CountryWithFlagProps {
|
|
|
977
1021
|
className?: string;
|
|
978
1022
|
}
|
|
979
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* Cookie-session API client shared by the memobit apps: sends credentials, adds the CSRF
|
|
1026
|
+
* header on mutating requests, surfaces the server's `error` message, and on 401 navigates
|
|
1027
|
+
* to the login page. The 401 path returns a promise that never settles so callers don't
|
|
1028
|
+
* flash an error toast while the browser is already leaving the page.
|
|
1029
|
+
*/
|
|
1030
|
+
export declare const createApiClient: ({ baseUrl, loginPath }: ApiClientConfig) => ApiClient;
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Image paths for one entity folder under /data-files, laid out as:
|
|
1034
|
+
* default.jpg — fallback for the whole folder
|
|
1035
|
+
* category/<key>.jpg — per-category fallback
|
|
1036
|
+
* specific/<filename> — uploaded images
|
|
1037
|
+
* The folder is named after what it holds (e.g. 'books'), never after the app.
|
|
1038
|
+
*/
|
|
1039
|
+
export declare const createImagePaths: (folder: string) => ImagePaths;
|
|
1040
|
+
|
|
1041
|
+
export declare const CSRF_HEADER = "X-CSRF-Token";
|
|
1042
|
+
|
|
1043
|
+
export declare const DATA_FILES_PATH = "/data-files";
|
|
1044
|
+
|
|
980
1045
|
declare function DataView_2<T>({ columns, data, rowKey, pinnedIds, selectable, onSelectionChange, selectedIds: controlledSelectedIds, pageSizeOptions, initialPageSize, showPageSize, card, actions, actionsWidth, timeline, onRowClick, rowHref, rowClassName, rowDetail, empty, initialSortKey, initialSortDirection, sortKey: controlledSortKey, sortDirection: controlledSortDirection, onSortChange, miniSort, showCardSortControls, desktopView, cardMaxWidth, className, onPageChange, onPageSizeChange, currentPage: controlledCurrentPage, totalItems: controlledTotalItems, group, showResultsCount, totalCount, itemNoun, columnSelector, }: DataViewProps<T>): default_2.JSX.Element;
|
|
981
1046
|
export { DataView_2 as DataView }
|
|
982
1047
|
|
|
@@ -1646,6 +1711,8 @@ export declare const formatSecondsToMediaTime: (seconds: number | undefined) =>
|
|
|
1646
1711
|
|
|
1647
1712
|
export declare const fuzzyMatch: (text: string, query: string) => boolean;
|
|
1648
1713
|
|
|
1714
|
+
export declare const getCsrfToken: () => string | null;
|
|
1715
|
+
|
|
1649
1716
|
/**
|
|
1650
1717
|
* Gets the number of days in a specific month
|
|
1651
1718
|
*/
|
|
@@ -1735,6 +1802,54 @@ export declare const htmlToMarkdown: (html: string) => string;
|
|
|
1735
1802
|
*/
|
|
1736
1803
|
export declare const htmlToPlainText: (html: string | undefined | null) => string;
|
|
1737
1804
|
|
|
1805
|
+
export declare const HttpMethod: {
|
|
1806
|
+
readonly Get: "GET";
|
|
1807
|
+
readonly Post: "POST";
|
|
1808
|
+
readonly Put: "PUT";
|
|
1809
|
+
readonly Patch: "PATCH";
|
|
1810
|
+
readonly Delete: "DELETE";
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1813
|
+
export declare type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
|
|
1814
|
+
|
|
1815
|
+
export declare const HttpStatus: {
|
|
1816
|
+
readonly Continue: 100;
|
|
1817
|
+
readonly SwitchingProtocols: 101;
|
|
1818
|
+
readonly Ok: 200;
|
|
1819
|
+
readonly Created: 201;
|
|
1820
|
+
readonly Accepted: 202;
|
|
1821
|
+
readonly NoContent: 204;
|
|
1822
|
+
readonly PartialContent: 206;
|
|
1823
|
+
readonly MovedPermanently: 301;
|
|
1824
|
+
readonly Found: 302;
|
|
1825
|
+
readonly SeeOther: 303;
|
|
1826
|
+
readonly NotModified: 304;
|
|
1827
|
+
readonly TemporaryRedirect: 307;
|
|
1828
|
+
readonly PermanentRedirect: 308;
|
|
1829
|
+
readonly BadRequest: 400;
|
|
1830
|
+
readonly Unauthorized: 401;
|
|
1831
|
+
readonly PaymentRequired: 402;
|
|
1832
|
+
readonly Forbidden: 403;
|
|
1833
|
+
readonly NotFound: 404;
|
|
1834
|
+
readonly MethodNotAllowed: 405;
|
|
1835
|
+
readonly NotAcceptable: 406;
|
|
1836
|
+
readonly RequestTimeout: 408;
|
|
1837
|
+
readonly Conflict: 409;
|
|
1838
|
+
readonly Gone: 410;
|
|
1839
|
+
readonly PayloadTooLarge: 413;
|
|
1840
|
+
readonly UnsupportedMediaType: 415;
|
|
1841
|
+
readonly UnprocessableEntity: 422;
|
|
1842
|
+
readonly Locked: 423;
|
|
1843
|
+
readonly TooManyRequests: 429;
|
|
1844
|
+
readonly InternalServerError: 500;
|
|
1845
|
+
readonly NotImplemented: 501;
|
|
1846
|
+
readonly BadGateway: 502;
|
|
1847
|
+
readonly ServiceUnavailable: 503;
|
|
1848
|
+
readonly GatewayTimeout: 504;
|
|
1849
|
+
};
|
|
1850
|
+
|
|
1851
|
+
export declare type HttpStatus = (typeof HttpStatus)[keyof typeof HttpStatus];
|
|
1852
|
+
|
|
1738
1853
|
export declare const Icon: default_2.FC<IconProps>;
|
|
1739
1854
|
|
|
1740
1855
|
/**
|
|
@@ -1785,6 +1900,15 @@ export declare type IconSize = 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'xxxl';
|
|
|
1785
1900
|
|
|
1786
1901
|
export declare type IconVariant = 'default' | 'muted' | 'accent' | 'info' | 'success' | 'warning' | 'danger';
|
|
1787
1902
|
|
|
1903
|
+
export declare interface ImagePaths {
|
|
1904
|
+
basePath: string;
|
|
1905
|
+
getDefaultImageUrl: () => string;
|
|
1906
|
+
getCategoryImageUrl: (categoryKey: string) => string;
|
|
1907
|
+
getImageUrl: (filename: string | File, categoryKey?: string) => string;
|
|
1908
|
+
getNextImageFallback: (currentSrc: string, categoryKey?: string) => string | null;
|
|
1909
|
+
applyImageFallback: (event: SyntheticEvent<HTMLImageElement>, categoryKey?: string) => void;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1788
1912
|
export declare const InfiniteScroll: ({ children, onLoadMore, hasMore, isLoading, threshold, rootMargin, height, onScrollChange, endMessage, className, }: InfiniteScrollProps) => JSX.Element;
|
|
1789
1913
|
|
|
1790
1914
|
declare interface InfiniteScrollProps {
|
|
@@ -2153,6 +2277,8 @@ export declare const isAfter: (date: Date, compareDate: Date) => boolean;
|
|
|
2153
2277
|
*/
|
|
2154
2278
|
export declare const isBefore: (date: Date, compareDate: Date) => boolean;
|
|
2155
2279
|
|
|
2280
|
+
export declare const isClientErrorStatus: (status: number) => boolean;
|
|
2281
|
+
|
|
2156
2282
|
/**
|
|
2157
2283
|
* Checks if a date is within a range (inclusive)
|
|
2158
2284
|
*/
|
|
@@ -2163,6 +2289,10 @@ export declare const isDateInRange: (date: Date, start: Date, end: Date) => bool
|
|
|
2163
2289
|
*/
|
|
2164
2290
|
export declare const isSameDay: (date1: Date, date2: Date) => boolean;
|
|
2165
2291
|
|
|
2292
|
+
export declare const isServerErrorStatus: (status: number) => boolean;
|
|
2293
|
+
|
|
2294
|
+
export declare const isSuccessStatus: (status: number) => boolean;
|
|
2295
|
+
|
|
2166
2296
|
/**
|
|
2167
2297
|
* Checks if a date is today
|
|
2168
2298
|
*/
|
|
@@ -2676,6 +2806,8 @@ declare interface RatingProps {
|
|
|
2676
2806
|
|
|
2677
2807
|
export declare type RatingVariant = 'success' | 'info' | 'warning' | 'danger';
|
|
2678
2808
|
|
|
2809
|
+
export declare const readErrorMessage: (response: Response) => Promise<string>;
|
|
2810
|
+
|
|
2679
2811
|
export declare const RichTextEditor: ({ advanced, error, format, id, label, onBlur, onChange, placeholder, required, value, }: RichTextEditorProps) => default_2.JSX.Element;
|
|
2680
2812
|
|
|
2681
2813
|
declare interface RichTextEditorProps {
|
|
@@ -3435,6 +3567,22 @@ declare type TreeVariant = 'default' | 'info' | 'success' | 'warning' | 'danger'
|
|
|
3435
3567
|
|
|
3436
3568
|
export declare const truncateText: (text: string, maxLength?: number, separator?: string) => string;
|
|
3437
3569
|
|
|
3570
|
+
export declare const useAccountMenu: ({ appName, mfaModal: MfaModal, themeLabel, loginPath }: UseAccountMenuOptions) => UseAccountMenuReturn;
|
|
3571
|
+
|
|
3572
|
+
export declare interface UseAccountMenuOptions {
|
|
3573
|
+
appName: string;
|
|
3574
|
+
mfaModal?: ComponentType<AccountMenuModalProps>;
|
|
3575
|
+
themeLabel?: string;
|
|
3576
|
+
loginPath?: string;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
export declare interface UseAccountMenuReturn {
|
|
3580
|
+
themeItem: MenuHamburgerItem;
|
|
3581
|
+
accountItems: MenuHamburgerItem[];
|
|
3582
|
+
items: MenuHamburgerItem[];
|
|
3583
|
+
modals: ReactElement;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3438
3586
|
export declare function useAppPersistence<TPages, TTheme>(appId: string, defaults: AppPersistenceDefaults<TPages, TTheme>): UseAppPersistenceReturn<TPages, TTheme>;
|
|
3439
3587
|
|
|
3440
3588
|
export declare interface UseAppPersistenceReturn<TPages, TTheme> {
|