@memobit/libs 2.0.1 → 3.0.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/index.css +1 -1
- package/dist/index.d.ts +6 -17
- package/dist/index.esm.js +5339 -7599
- package/dist/memobit-icons.json +25 -0
- package/dist/mfa.d.ts +17 -0
- package/dist/mfa.esm.js +1293 -0
- package/dist/useAuth-BBqdDG2z.js +467 -0
- package/dist/version.json +4 -4
- package/package.json +11 -74
- package/dist/styles/themes.scss +0 -74
- package/dist/styles/theming/_profile-theme.scss +0 -317
- package/dist/styles/theming/amber-meridian.scss +0 -271
- package/dist/styles/theming/archive-indigo.scss +0 -270
- package/dist/styles/theming/arctic-blue.scss +0 -266
- package/dist/styles/theming/asphalt-code.scss +0 -271
- package/dist/styles/theming/atelier-media.scss +0 -272
- package/dist/styles/theming/audit-ember.scss +0 -286
- package/dist/styles/theming/azure-night.scss +0 -269
- package/dist/styles/theming/blossom-meadow.scss +0 -273
- package/dist/styles/theming/blueprint-clay.scss +0 -271
- package/dist/styles/theming/blush-market.scss +0 -271
- package/dist/styles/theming/brass-chronicle.scss +0 -271
- package/dist/styles/theming/carbon-velocity.scss +0 -270
- package/dist/styles/theming/chalk-circuit.scss +0 -271
- package/dist/styles/theming/chrono-atlas.scss +0 -279
- package/dist/styles/theming/citrus-vital.scss +0 -34
- package/dist/styles/theming/clinical-aqua.scss +0 -270
- package/dist/styles/theming/cobalt-pulse.scss +0 -272
- package/dist/styles/theming/command-slate.scss +0 -34
- package/dist/styles/theming/crawler-dusk.scss +0 -270
- package/dist/styles/theming/crimson-dusk.scss +0 -269
- package/dist/styles/theming/cyber-forest.scss +0 -269
- package/dist/styles/theming/dashdarkx.scss +0 -269
- package/dist/styles/theming/ember-night.scss +0 -269
- package/dist/styles/theming/emerald-ledger.scss +0 -271
- package/dist/styles/theming/frost-petal.scss +0 -269
- package/dist/styles/theming/garden-harvest.scss +0 -271
- package/dist/styles/theming/gilded-bear.scss +0 -271
- package/dist/styles/theming/graphite-shell.scss +0 -270
- package/dist/styles/theming/horizon-amber.scss +0 -270
- package/dist/styles/theming/horizon-drift.scss +0 -271
- package/dist/styles/theming/ivory-serif.scss +0 -271
- package/dist/styles/theming/lavender-mist.scss +0 -269
- package/dist/styles/theming/light-blue.scss +0 -269
- package/dist/styles/theming/lumen.scss +0 -276
- package/dist/styles/theming/luna.scss +0 -269
- package/dist/styles/theming/mesh-circuit.scss +0 -271
- package/dist/styles/theming/midnight-amber.scss +0 -273
- package/dist/styles/theming/midnight-atlas.scss +0 -35
- package/dist/styles/theming/midnight-folio.scss +0 -34
- package/dist/styles/theming/mint-meadow.scss +0 -269
- package/dist/styles/theming/mintone.scss +0 -269
- package/dist/styles/theming/neon-tokyo.scss +0 -269
- package/dist/styles/theming/noir-marquee.scss +0 -34
- package/dist/styles/theming/ocean-breeze.scss +0 -269
- package/dist/styles/theming/ocean-depths.scss +0 -269
- package/dist/styles/theming/orbital-night.scss +0 -276
- package/dist/styles/theming/sandstone.scss +0 -269
- package/dist/styles/theming/sandy-parchment.scss +0 -270
- package/dist/styles/theming/screening-room.scss +0 -34
- package/dist/styles/theming/signal-burst.scss +0 -271
- package/dist/styles/theming/signal-clarity.scss +0 -34
- package/dist/styles/theming/slate-bazaar.scss +0 -34
- package/dist/styles/theming/slate-focus.scss +0 -270
- package/dist/styles/theming/spectrum-vault.scss +0 -271
- package/dist/styles/theming/tailwind-vue-dark.scss +0 -269
- package/dist/styles/theming/terminal-phosphor.scss +0 -272
- package/dist/styles/theming/terracotta-kitchen.scss +0 -271
- package/dist/styles/theming/twilight-pulse.scss +0 -269
- package/dist/styles/theming/vault-guard.scss +0 -271
- package/dist/styles/theming/velvet-reel.scss +0 -272
- package/dist/styles/theming/velvet-tome.scss +0 -271
- package/dist/styles/theming/verdant-pulse.scss +0 -34
- package/dist/styles/theming/vital-aurora.scss +0 -45
- package/dist/styles/theming/vital-signal.scss +0 -270
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import Q, { createContext as z, forwardRef as q, useCallback as A, useContext as O, useEffect as _, useRef as E, useState as j } from "react";
|
|
2
|
+
import { iconMap as W } from "@memobit/icons/map";
|
|
3
|
+
import { Fragment as F, jsx as n, jsxs as b } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as Y } from "react-dom";
|
|
5
|
+
var U = ({ className: s = "", fade: e, fadeOnHover: f, name: a, pulse: m, pulseOnHover: o, size: i, spin: l, spinOnHover: c, variant: u }) => /* @__PURE__ */ n("span", {
|
|
6
|
+
className: [
|
|
7
|
+
"icon",
|
|
8
|
+
i ? `icon--${i}` : "",
|
|
9
|
+
u && u !== "default" ? `icon--${u}` : "",
|
|
10
|
+
l ? "icon--spin" : "",
|
|
11
|
+
e ? "icon--fade" : "",
|
|
12
|
+
m ? "icon--pulse" : "",
|
|
13
|
+
c ? "icon--spin-hover" : "",
|
|
14
|
+
f ? "icon--fade-hover" : "",
|
|
15
|
+
o ? "icon--pulse-hover" : "",
|
|
16
|
+
s
|
|
17
|
+
].filter(Boolean).join(" "),
|
|
18
|
+
children: W[a]
|
|
19
|
+
}), X = (s) => {
|
|
20
|
+
const e = E(null);
|
|
21
|
+
_(() => {
|
|
22
|
+
const f = () => {
|
|
23
|
+
if (!e.current) return;
|
|
24
|
+
const { overflow: a, position: m, top: o, left: i, right: l, width: c, scrollY: u } = e.current;
|
|
25
|
+
document.body.style.overflow = a, document.body.style.position = m, document.body.style.top = o, document.body.style.left = i, document.body.style.right = l, document.body.style.width = c, window.scrollTo(0, u), e.current = null;
|
|
26
|
+
};
|
|
27
|
+
if (s) {
|
|
28
|
+
if (!e.current) {
|
|
29
|
+
const a = window.scrollY;
|
|
30
|
+
e.current = {
|
|
31
|
+
overflow: document.body.style.overflow,
|
|
32
|
+
position: document.body.style.position,
|
|
33
|
+
top: document.body.style.top,
|
|
34
|
+
left: document.body.style.left,
|
|
35
|
+
right: document.body.style.right,
|
|
36
|
+
width: document.body.style.width,
|
|
37
|
+
scrollY: a
|
|
38
|
+
}, document.body.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.top = `-${a}px`, document.body.style.left = "0", document.body.style.right = "0", document.body.style.width = "100%";
|
|
39
|
+
}
|
|
40
|
+
} else f();
|
|
41
|
+
return () => {
|
|
42
|
+
f();
|
|
43
|
+
};
|
|
44
|
+
}, [s]);
|
|
45
|
+
}, Z = z(void 0), H = () => {
|
|
46
|
+
const s = O(Z);
|
|
47
|
+
if (s === void 0) throw new Error("useTheme must be used within a ThemeProvider");
|
|
48
|
+
return s;
|
|
49
|
+
}, ee = (s) => {
|
|
50
|
+
const { effects: e } = H();
|
|
51
|
+
return e.effect && e.components.includes(s) ? e.effect : "";
|
|
52
|
+
}, B = Q.forwardRef(({ borders: s = "rounded", children: e, className: f, disabled: a = !1, fullWidth: m = !1, icon: o, iconVariant: i = "default", loading: l = !1, onClick: c, emojiIcon: u, size: r = "medium", style: d, sufixIcon: t, title: h, type: v = "button", variant: g = "default" }, w) => /* @__PURE__ */ n("button", {
|
|
53
|
+
ref: w,
|
|
54
|
+
className: `button button-${r} button-${g} ${s === "rounded" ? "button-rounded" : ""} ${m ? "is-full-width" : ""} ${f || ""}`,
|
|
55
|
+
disabled: a,
|
|
56
|
+
onClick: c,
|
|
57
|
+
style: d,
|
|
58
|
+
title: h,
|
|
59
|
+
type: v,
|
|
60
|
+
children: l ? /* @__PURE__ */ b(F, { children: [/* @__PURE__ */ n("span", { className: "button__spinner" }), /* @__PURE__ */ n("span", { children: e || "Loading..." })] }) : /* @__PURE__ */ b(F, { children: [
|
|
61
|
+
o !== void 0 && (typeof o == "string" ? /* @__PURE__ */ n(U, {
|
|
62
|
+
size: "lg",
|
|
63
|
+
name: o,
|
|
64
|
+
variant: i
|
|
65
|
+
}) : o),
|
|
66
|
+
u && /* @__PURE__ */ n("span", { children: u }),
|
|
67
|
+
e && /* @__PURE__ */ n("span", { children: e }),
|
|
68
|
+
t !== void 0 && (typeof t == "string" ? /* @__PURE__ */ n(U, {
|
|
69
|
+
size: "lg",
|
|
70
|
+
name: t,
|
|
71
|
+
variant: i
|
|
72
|
+
}) : t)
|
|
73
|
+
] })
|
|
74
|
+
}));
|
|
75
|
+
B.displayName = "Button";
|
|
76
|
+
var I = ({ title: s, position: e = "top", delay: f = 200, children: a, disabled: m = !1, className: o = "", maxWidth: i, maxHeight: l }) => {
|
|
77
|
+
const [c, u] = j(!1), [r, d] = j({
|
|
78
|
+
top: 0,
|
|
79
|
+
left: 0
|
|
80
|
+
}), t = E(null), h = E(null), v = E(null), g = E(null), w = E(!1), T = l !== void 0, $ = T ? 150 : 0, y = () => {
|
|
81
|
+
if (!v.current || !g.current) return;
|
|
82
|
+
const N = v.current.firstElementChild?.getBoundingClientRect();
|
|
83
|
+
let p = N && N.width > 0 ? N : v.current.getBoundingClientRect();
|
|
84
|
+
if (p.width === 0 && p.height === 0) {
|
|
85
|
+
const D = document.createRange();
|
|
86
|
+
D.selectNodeContents(v.current);
|
|
87
|
+
const S = D.getBoundingClientRect();
|
|
88
|
+
(S.width > 0 || S.height > 0) && (p = S);
|
|
89
|
+
}
|
|
90
|
+
const C = g.current.getBoundingClientRect(), M = 8;
|
|
91
|
+
let k = 0, R = 0;
|
|
92
|
+
switch (e) {
|
|
93
|
+
case "top":
|
|
94
|
+
k = p.top - C.height - M, R = p.left + p.width / 2 - C.width / 2;
|
|
95
|
+
break;
|
|
96
|
+
case "bottom":
|
|
97
|
+
k = p.bottom + M, R = p.left + p.width / 2 - C.width / 2;
|
|
98
|
+
break;
|
|
99
|
+
case "left":
|
|
100
|
+
k = p.top + p.height / 2 - C.height / 2, R = p.left - C.width - M;
|
|
101
|
+
break;
|
|
102
|
+
case "right":
|
|
103
|
+
k = p.top + p.height / 2 - C.height / 2, R = p.right + M;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
const x = 8;
|
|
107
|
+
R < x && (R = x), R + C.width > window.innerWidth - x && (R = window.innerWidth - C.width - x), k < x && (k = x), k + C.height > window.innerHeight - x && (k = window.innerHeight - C.height - x), d({
|
|
108
|
+
top: k,
|
|
109
|
+
left: R
|
|
110
|
+
});
|
|
111
|
+
}, L = () => {
|
|
112
|
+
m || w.current || (h.current && (clearTimeout(h.current), h.current = null), t.current = setTimeout(() => {
|
|
113
|
+
u(!0);
|
|
114
|
+
}, f));
|
|
115
|
+
}, P = () => {
|
|
116
|
+
w.current || (t.current && clearTimeout(t.current), $ > 0 ? h.current = setTimeout(() => u(!1), $) : u(!1));
|
|
117
|
+
}, V = (N) => {
|
|
118
|
+
N.pointerType !== "touch" && N.pointerType !== "pen" || m || (w.current = !0, t.current && (clearTimeout(t.current), t.current = null), N.stopPropagation(), u((p) => !p));
|
|
119
|
+
};
|
|
120
|
+
_(() => (c && (y(), window.addEventListener("scroll", y, !0), window.addEventListener("resize", y)), () => {
|
|
121
|
+
window.removeEventListener("scroll", y, !0), window.removeEventListener("resize", y);
|
|
122
|
+
}), [c]), _(() => {
|
|
123
|
+
if (!c) return;
|
|
124
|
+
const N = (p) => {
|
|
125
|
+
v.current?.contains(p.target) || g.current?.contains(p.target) || u(!1);
|
|
126
|
+
};
|
|
127
|
+
return document.addEventListener("pointerdown", N), () => {
|
|
128
|
+
document.removeEventListener("pointerdown", N), w.current = !1;
|
|
129
|
+
};
|
|
130
|
+
}, [c]), _(() => () => {
|
|
131
|
+
t.current && clearTimeout(t.current), h.current && clearTimeout(h.current);
|
|
132
|
+
}, []);
|
|
133
|
+
const G = () => {
|
|
134
|
+
T && h.current && (clearTimeout(h.current), h.current = null);
|
|
135
|
+
}, K = () => {
|
|
136
|
+
T && (h.current = setTimeout(() => u(!1), $));
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ b(F, { children: [/* @__PURE__ */ n("span", {
|
|
139
|
+
ref: v,
|
|
140
|
+
className: "tooltip-trigger",
|
|
141
|
+
onMouseEnter: L,
|
|
142
|
+
onMouseLeave: P,
|
|
143
|
+
onFocus: L,
|
|
144
|
+
onBlur: P,
|
|
145
|
+
onPointerDown: V,
|
|
146
|
+
children: a
|
|
147
|
+
}), c && s && Y(/* @__PURE__ */ b("div", {
|
|
148
|
+
ref: g,
|
|
149
|
+
className: `tooltip tooltip--${e} ${T ? "tooltip--scrollable" : ""} ${o}`,
|
|
150
|
+
style: {
|
|
151
|
+
top: `${r.top}px`,
|
|
152
|
+
left: `${r.left}px`,
|
|
153
|
+
...i !== void 0 && { maxWidth: typeof i == "number" ? `${i}px` : i },
|
|
154
|
+
...l !== void 0 && { maxHeight: typeof l == "number" ? `${l}px` : l }
|
|
155
|
+
},
|
|
156
|
+
onMouseEnter: G,
|
|
157
|
+
onMouseLeave: K,
|
|
158
|
+
children: [s, /* @__PURE__ */ n("div", { className: `tooltip__arrow tooltip__arrow--${e}` })]
|
|
159
|
+
}), document.body)] });
|
|
160
|
+
}, se = ({ children: s, className: e, fullHeight: f = !1, isOpen: a, noPadding: m = !1, onClose: o, onOverlayClick: i, primary: l, secondary: c, size: u = "auto", tertiary: r, title: d, titleIcon: t, usePortal: h = !1 }) => {
|
|
161
|
+
const v = ee("Modal");
|
|
162
|
+
X(a);
|
|
163
|
+
const g = E(null), w = E(null);
|
|
164
|
+
if (_(() => {
|
|
165
|
+
if (!a) return;
|
|
166
|
+
const y = (L) => {
|
|
167
|
+
if (L.key !== "Escape" || !o) return;
|
|
168
|
+
const P = document.querySelectorAll(".modal-overlay");
|
|
169
|
+
P[P.length - 1] === w.current && (L.stopPropagation(), o());
|
|
170
|
+
};
|
|
171
|
+
return document.addEventListener("keydown", y), () => document.removeEventListener("keydown", y);
|
|
172
|
+
}, [a, o]), !a) return null;
|
|
173
|
+
const T = l || c || r, $ = /* @__PURE__ */ n("div", {
|
|
174
|
+
ref: w,
|
|
175
|
+
className: "modal-overlay",
|
|
176
|
+
onClick: i,
|
|
177
|
+
children: /* @__PURE__ */ b("div", {
|
|
178
|
+
ref: g,
|
|
179
|
+
className: `modal modal--${u} ${f ? "modal--full-height" : ""} ${e || ""} ${v}`,
|
|
180
|
+
onClick: (y) => y.stopPropagation(),
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ b("div", {
|
|
183
|
+
className: "modal__header",
|
|
184
|
+
children: [/* @__PURE__ */ b("h2", { children: [
|
|
185
|
+
t ? /* @__PURE__ */ n(U, { name: t }) : null,
|
|
186
|
+
" ",
|
|
187
|
+
d
|
|
188
|
+
] }), /* @__PURE__ */ n(I, {
|
|
189
|
+
title: "Close modal",
|
|
190
|
+
children: /* @__PURE__ */ n(B, {
|
|
191
|
+
className: "modal__close",
|
|
192
|
+
icon: "clear",
|
|
193
|
+
onClick: o,
|
|
194
|
+
size: "medium",
|
|
195
|
+
variant: "ghost"
|
|
196
|
+
})
|
|
197
|
+
})]
|
|
198
|
+
}),
|
|
199
|
+
s != null && /* @__PURE__ */ n("div", {
|
|
200
|
+
className: `modal__body ${m ? "modal__body--no-padding" : ""}`,
|
|
201
|
+
children: s
|
|
202
|
+
}),
|
|
203
|
+
T && /* @__PURE__ */ b("div", {
|
|
204
|
+
className: "modal__footer",
|
|
205
|
+
children: [
|
|
206
|
+
r && /* @__PURE__ */ n(B, {
|
|
207
|
+
variant: r.variant || "default",
|
|
208
|
+
icon: r.icon,
|
|
209
|
+
onClick: r.onClick,
|
|
210
|
+
disabled: r.disabled,
|
|
211
|
+
children: r.text
|
|
212
|
+
}),
|
|
213
|
+
c && /* @__PURE__ */ n(B, {
|
|
214
|
+
variant: c.variant || "default",
|
|
215
|
+
icon: c.icon || "clear",
|
|
216
|
+
onClick: c.onClick,
|
|
217
|
+
disabled: c.disabled,
|
|
218
|
+
children: c.text
|
|
219
|
+
}),
|
|
220
|
+
l && /* @__PURE__ */ n(B, {
|
|
221
|
+
variant: l.variant || "success",
|
|
222
|
+
icon: l.icon || "checkmark",
|
|
223
|
+
onClick: l.onClick,
|
|
224
|
+
disabled: l.disabled,
|
|
225
|
+
children: l.text
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
})
|
|
231
|
+
});
|
|
232
|
+
return h ? Y($, document.body) : $;
|
|
233
|
+
}, ae = q(({ autoComplete: s = "on", autoFocus: e, disabled: f, error: a, highlighted: m, id: o, label: i, maxLength: l, onBlur: c, onChange: u, onClick: r, onKeyDown: d, onKeyUp: t, placeholder: h, readOnly: v = !1, required: g = !1, success: w, value: T }, $) => /* @__PURE__ */ b("div", {
|
|
234
|
+
className: `input-text-wrapper${m ? " input-text-highlighted" : ""}`,
|
|
235
|
+
children: [
|
|
236
|
+
i && /* @__PURE__ */ b("label", {
|
|
237
|
+
htmlFor: o,
|
|
238
|
+
className: "input-text-label",
|
|
239
|
+
children: [i, g && /* @__PURE__ */ n("span", {
|
|
240
|
+
className: "input-text-required",
|
|
241
|
+
children: "*"
|
|
242
|
+
})]
|
|
243
|
+
}),
|
|
244
|
+
/* @__PURE__ */ n("input", {
|
|
245
|
+
autoComplete: s,
|
|
246
|
+
autoFocus: e,
|
|
247
|
+
disabled: f,
|
|
248
|
+
type: "text",
|
|
249
|
+
className: `input-text ${a ? "input-text-error" : ""} ${w ? "input-text-success" : ""}`,
|
|
250
|
+
id: o,
|
|
251
|
+
maxLength: l,
|
|
252
|
+
placeholder: h,
|
|
253
|
+
ref: $,
|
|
254
|
+
value: T,
|
|
255
|
+
onBlur: c,
|
|
256
|
+
onChange: (y) => u?.(y.target.value),
|
|
257
|
+
onClick: r,
|
|
258
|
+
onKeyDown: d,
|
|
259
|
+
onKeyUp: t,
|
|
260
|
+
readOnly: v,
|
|
261
|
+
required: g
|
|
262
|
+
}),
|
|
263
|
+
a && /* @__PURE__ */ n("span", {
|
|
264
|
+
className: "input-text-error-message",
|
|
265
|
+
children: a
|
|
266
|
+
}),
|
|
267
|
+
w && /* @__PURE__ */ n("span", {
|
|
268
|
+
className: "input-text-success-message",
|
|
269
|
+
children: w
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
})), ie = q(({ autoComplete: s = "on", autoFocus: e, disabled: f, error: a, highlighted: m, id: o, label: i, maxLength: l, onBlur: c, onChange: u, onClick: r, onKeyDown: d, onKeyUp: t, placeholder: h, readOnly: v = !1, required: g = !1, success: w, value: T }, $) => /* @__PURE__ */ b("div", {
|
|
273
|
+
className: `input-password-wrapper${m ? " input-password-highlighted" : ""}`,
|
|
274
|
+
children: [
|
|
275
|
+
i && /* @__PURE__ */ b("label", {
|
|
276
|
+
htmlFor: o,
|
|
277
|
+
className: "input-password-label",
|
|
278
|
+
children: [i, g && /* @__PURE__ */ n("span", {
|
|
279
|
+
className: "input-password-required",
|
|
280
|
+
children: "*"
|
|
281
|
+
})]
|
|
282
|
+
}),
|
|
283
|
+
/* @__PURE__ */ n("input", {
|
|
284
|
+
autoComplete: s,
|
|
285
|
+
autoFocus: e,
|
|
286
|
+
disabled: f,
|
|
287
|
+
type: "password",
|
|
288
|
+
className: `input-password${a ? " input-password-error" : ""}${w ? " input-password-success" : ""}`,
|
|
289
|
+
id: o,
|
|
290
|
+
maxLength: l,
|
|
291
|
+
placeholder: h,
|
|
292
|
+
ref: $,
|
|
293
|
+
value: T,
|
|
294
|
+
onBlur: c,
|
|
295
|
+
onChange: (y) => u?.(y.target.value),
|
|
296
|
+
onClick: r,
|
|
297
|
+
onKeyDown: d,
|
|
298
|
+
onKeyUp: t,
|
|
299
|
+
readOnly: v,
|
|
300
|
+
required: g
|
|
301
|
+
}),
|
|
302
|
+
a && /* @__PURE__ */ n("span", {
|
|
303
|
+
className: "input-password-error-message",
|
|
304
|
+
children: a
|
|
305
|
+
}),
|
|
306
|
+
w && /* @__PURE__ */ n("span", {
|
|
307
|
+
className: "input-password-success-message",
|
|
308
|
+
children: w
|
|
309
|
+
})
|
|
310
|
+
]
|
|
311
|
+
})), le = ({ message: s, type: e = "success", onClose: f, position: a = "top-right", showDismissButton: m = !0, timeout: o = 3e3, action: i }) => (_(() => {
|
|
312
|
+
const l = setTimeout(() => {
|
|
313
|
+
f();
|
|
314
|
+
}, o);
|
|
315
|
+
return () => clearTimeout(l);
|
|
316
|
+
}, [f, o]), /* @__PURE__ */ b("div", {
|
|
317
|
+
className: `toast toast--fixed toast-${e} toast--${a}`,
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ n("span", {
|
|
320
|
+
className: "toast__message",
|
|
321
|
+
children: s
|
|
322
|
+
}),
|
|
323
|
+
i && /* @__PURE__ */ n("button", {
|
|
324
|
+
className: "toast__action",
|
|
325
|
+
onClick: i.onClick,
|
|
326
|
+
children: i.label
|
|
327
|
+
}),
|
|
328
|
+
m && /* @__PURE__ */ n(I, {
|
|
329
|
+
title: "Close",
|
|
330
|
+
children: /* @__PURE__ */ n("button", {
|
|
331
|
+
className: "toast__close",
|
|
332
|
+
onClick: f,
|
|
333
|
+
children: /* @__PURE__ */ n(U, {
|
|
334
|
+
name: "clear",
|
|
335
|
+
size: "sm"
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
]
|
|
340
|
+
})), J = z(void 0);
|
|
341
|
+
function ce({ children: s, config: e }) {
|
|
342
|
+
const [f, a] = j(null), [m, o] = j(!0);
|
|
343
|
+
_(() => {
|
|
344
|
+
(async () => {
|
|
345
|
+
try {
|
|
346
|
+
const d = await fetch(`${e.apiBaseUrl}/auth/verify`, {
|
|
347
|
+
method: "GET",
|
|
348
|
+
credentials: "include",
|
|
349
|
+
headers: { "Content-Type": "application/json" }
|
|
350
|
+
});
|
|
351
|
+
if (d.ok) {
|
|
352
|
+
const t = await d.json();
|
|
353
|
+
a({
|
|
354
|
+
id: t.user.id,
|
|
355
|
+
username: t.user.username,
|
|
356
|
+
createdAt: new Date(t.user.createdAt)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
} catch (d) {
|
|
360
|
+
console.error("Failed to restore auth state:", d);
|
|
361
|
+
} finally {
|
|
362
|
+
o(!1);
|
|
363
|
+
}
|
|
364
|
+
})();
|
|
365
|
+
}, [e.apiBaseUrl]);
|
|
366
|
+
const i = A((r) => {
|
|
367
|
+
r.user && a({
|
|
368
|
+
id: r.user.id,
|
|
369
|
+
username: r.user.username,
|
|
370
|
+
createdAt: new Date(r.user.createdAt)
|
|
371
|
+
});
|
|
372
|
+
}, []), l = A(async (r) => {
|
|
373
|
+
o(!0);
|
|
374
|
+
try {
|
|
375
|
+
const d = await fetch(`${e.apiBaseUrl}/auth/login`, {
|
|
376
|
+
method: "POST",
|
|
377
|
+
credentials: "include",
|
|
378
|
+
headers: { "Content-Type": "application/json" },
|
|
379
|
+
body: JSON.stringify({
|
|
380
|
+
username: r.username,
|
|
381
|
+
password: r.password,
|
|
382
|
+
rememberMe: r.rememberMe
|
|
383
|
+
})
|
|
384
|
+
});
|
|
385
|
+
if (!d.ok) {
|
|
386
|
+
const h = await d.json();
|
|
387
|
+
throw new Error(h.error || "Login failed");
|
|
388
|
+
}
|
|
389
|
+
const t = await d.json();
|
|
390
|
+
return t.mfaRequired ? {
|
|
391
|
+
mfaRequired: !0,
|
|
392
|
+
method: t.method
|
|
393
|
+
} : (i(t), { mfaRequired: !1 });
|
|
394
|
+
} catch (d) {
|
|
395
|
+
throw console.error("Login failed:", d), d;
|
|
396
|
+
} finally {
|
|
397
|
+
o(!1);
|
|
398
|
+
}
|
|
399
|
+
}, [e.apiBaseUrl, i]), c = A(async (r, d) => {
|
|
400
|
+
o(!0);
|
|
401
|
+
try {
|
|
402
|
+
const t = await fetch(`${e.apiBaseUrl}/auth/verifyMfa`, {
|
|
403
|
+
method: "POST",
|
|
404
|
+
credentials: "include",
|
|
405
|
+
headers: { "Content-Type": "application/json" },
|
|
406
|
+
body: JSON.stringify({
|
|
407
|
+
code: r,
|
|
408
|
+
trustDevice: d
|
|
409
|
+
})
|
|
410
|
+
});
|
|
411
|
+
if (!t.ok) {
|
|
412
|
+
const h = await t.json();
|
|
413
|
+
throw new Error(h.error || "Verification failed");
|
|
414
|
+
}
|
|
415
|
+
i(await t.json());
|
|
416
|
+
} catch (t) {
|
|
417
|
+
throw console.error("MFA verification failed:", t), t;
|
|
418
|
+
} finally {
|
|
419
|
+
o(!1);
|
|
420
|
+
}
|
|
421
|
+
}, [e.apiBaseUrl, i]), u = A(async () => {
|
|
422
|
+
try {
|
|
423
|
+
await fetch(`${e.apiBaseUrl}/auth/logout`, {
|
|
424
|
+
method: "POST",
|
|
425
|
+
credentials: "include",
|
|
426
|
+
headers: { "Content-Type": "application/json" }
|
|
427
|
+
});
|
|
428
|
+
} catch (r) {
|
|
429
|
+
console.error("Logout error:", r);
|
|
430
|
+
} finally {
|
|
431
|
+
a(null);
|
|
432
|
+
}
|
|
433
|
+
}, [e.apiBaseUrl]);
|
|
434
|
+
return /* @__PURE__ */ n(J.Provider, {
|
|
435
|
+
value: {
|
|
436
|
+
user: f,
|
|
437
|
+
isAuthenticated: !!f,
|
|
438
|
+
isLoading: m,
|
|
439
|
+
config: e,
|
|
440
|
+
login: l,
|
|
441
|
+
verifyMfa: c,
|
|
442
|
+
logout: u
|
|
443
|
+
},
|
|
444
|
+
children: s
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
var ue = () => {
|
|
448
|
+
const s = O(J);
|
|
449
|
+
if (s === void 0) throw new Error("useAuth must be used within an AuthProvider");
|
|
450
|
+
return s;
|
|
451
|
+
};
|
|
452
|
+
export {
|
|
453
|
+
ie as a,
|
|
454
|
+
I as c,
|
|
455
|
+
H as d,
|
|
456
|
+
Z as f,
|
|
457
|
+
le as i,
|
|
458
|
+
B as l,
|
|
459
|
+
U as m,
|
|
460
|
+
J as n,
|
|
461
|
+
ae as o,
|
|
462
|
+
X as p,
|
|
463
|
+
ce as r,
|
|
464
|
+
se as s,
|
|
465
|
+
ue as t,
|
|
466
|
+
ee as u
|
|
467
|
+
};
|
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "React component library powering the Memobit apps — 100+ components,
|
|
3
|
+
"version": "3.0.0",
|
|
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",
|
|
7
7
|
"react-components",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"ui-kit",
|
|
11
11
|
"design-system",
|
|
12
12
|
"typescript",
|
|
13
|
-
"themes",
|
|
14
13
|
"hooks",
|
|
15
14
|
"memobit"
|
|
16
15
|
],
|
|
@@ -40,6 +39,10 @@
|
|
|
40
39
|
"types": "./dist/index.d.ts",
|
|
41
40
|
"import": "./dist/index.esm.js"
|
|
42
41
|
},
|
|
42
|
+
"./mfa": {
|
|
43
|
+
"types": "./dist/mfa.d.ts",
|
|
44
|
+
"import": "./dist/mfa.esm.js"
|
|
45
|
+
},
|
|
43
46
|
"./dist/index.css": "./dist/index.css",
|
|
44
47
|
"./dist/styles/variables.scss": "./dist/styles/variables.scss",
|
|
45
48
|
"./dist/styles/base.scss": "./dist/styles/base.scss",
|
|
@@ -47,73 +50,7 @@
|
|
|
47
50
|
"./dist/styles/highlight.scss": "./dist/styles/highlight.scss",
|
|
48
51
|
"./dist/styles/scrollbars.scss": "./dist/styles/scrollbars.scss",
|
|
49
52
|
"./dist/styles/utilities.scss": "./dist/styles/utilities.scss",
|
|
50
|
-
"./dist/styles/utility-classes.scss": "./dist/styles/utility-classes.scss"
|
|
51
|
-
"./dist/styles/themes.scss": "./dist/styles/themes.scss",
|
|
52
|
-
"./dist/styles/theming/_profile-theme.scss": "./dist/styles/theming/_profile-theme.scss",
|
|
53
|
-
"./dist/styles/theming/amber-meridian.scss": "./dist/styles/theming/amber-meridian.scss",
|
|
54
|
-
"./dist/styles/theming/archive-indigo.scss": "./dist/styles/theming/archive-indigo.scss",
|
|
55
|
-
"./dist/styles/theming/arctic-blue.scss": "./dist/styles/theming/arctic-blue.scss",
|
|
56
|
-
"./dist/styles/theming/asphalt-code.scss": "./dist/styles/theming/asphalt-code.scss",
|
|
57
|
-
"./dist/styles/theming/atelier-media.scss": "./dist/styles/theming/atelier-media.scss",
|
|
58
|
-
"./dist/styles/theming/audit-ember.scss": "./dist/styles/theming/audit-ember.scss",
|
|
59
|
-
"./dist/styles/theming/azure-night.scss": "./dist/styles/theming/azure-night.scss",
|
|
60
|
-
"./dist/styles/theming/blossom-meadow.scss": "./dist/styles/theming/blossom-meadow.scss",
|
|
61
|
-
"./dist/styles/theming/blueprint-clay.scss": "./dist/styles/theming/blueprint-clay.scss",
|
|
62
|
-
"./dist/styles/theming/blush-market.scss": "./dist/styles/theming/blush-market.scss",
|
|
63
|
-
"./dist/styles/theming/brass-chronicle.scss": "./dist/styles/theming/brass-chronicle.scss",
|
|
64
|
-
"./dist/styles/theming/carbon-velocity.scss": "./dist/styles/theming/carbon-velocity.scss",
|
|
65
|
-
"./dist/styles/theming/chalk-circuit.scss": "./dist/styles/theming/chalk-circuit.scss",
|
|
66
|
-
"./dist/styles/theming/chrono-atlas.scss": "./dist/styles/theming/chrono-atlas.scss",
|
|
67
|
-
"./dist/styles/theming/clinical-aqua.scss": "./dist/styles/theming/clinical-aqua.scss",
|
|
68
|
-
"./dist/styles/theming/cobalt-pulse.scss": "./dist/styles/theming/cobalt-pulse.scss",
|
|
69
|
-
"./dist/styles/theming/citrus-vital.scss": "./dist/styles/theming/citrus-vital.scss",
|
|
70
|
-
"./dist/styles/theming/command-slate.scss": "./dist/styles/theming/command-slate.scss",
|
|
71
|
-
"./dist/styles/theming/crawler-dusk.scss": "./dist/styles/theming/crawler-dusk.scss",
|
|
72
|
-
"./dist/styles/theming/crimson-dusk.scss": "./dist/styles/theming/crimson-dusk.scss",
|
|
73
|
-
"./dist/styles/theming/cyber-forest.scss": "./dist/styles/theming/cyber-forest.scss",
|
|
74
|
-
"./dist/styles/theming/dashdarkx.scss": "./dist/styles/theming/dashdarkx.scss",
|
|
75
|
-
"./dist/styles/theming/ember-night.scss": "./dist/styles/theming/ember-night.scss",
|
|
76
|
-
"./dist/styles/theming/emerald-ledger.scss": "./dist/styles/theming/emerald-ledger.scss",
|
|
77
|
-
"./dist/styles/theming/frost-petal.scss": "./dist/styles/theming/frost-petal.scss",
|
|
78
|
-
"./dist/styles/theming/garden-harvest.scss": "./dist/styles/theming/garden-harvest.scss",
|
|
79
|
-
"./dist/styles/theming/gilded-bear.scss": "./dist/styles/theming/gilded-bear.scss",
|
|
80
|
-
"./dist/styles/theming/graphite-shell.scss": "./dist/styles/theming/graphite-shell.scss",
|
|
81
|
-
"./dist/styles/theming/horizon-amber.scss": "./dist/styles/theming/horizon-amber.scss",
|
|
82
|
-
"./dist/styles/theming/horizon-drift.scss": "./dist/styles/theming/horizon-drift.scss",
|
|
83
|
-
"./dist/styles/theming/ivory-serif.scss": "./dist/styles/theming/ivory-serif.scss",
|
|
84
|
-
"./dist/styles/theming/lavender-mist.scss": "./dist/styles/theming/lavender-mist.scss",
|
|
85
|
-
"./dist/styles/theming/light-blue.scss": "./dist/styles/theming/light-blue.scss",
|
|
86
|
-
"./dist/styles/theming/lumen.scss": "./dist/styles/theming/lumen.scss",
|
|
87
|
-
"./dist/styles/theming/luna.scss": "./dist/styles/theming/luna.scss",
|
|
88
|
-
"./dist/styles/theming/mesh-circuit.scss": "./dist/styles/theming/mesh-circuit.scss",
|
|
89
|
-
"./dist/styles/theming/midnight-atlas.scss": "./dist/styles/theming/midnight-atlas.scss",
|
|
90
|
-
"./dist/styles/theming/midnight-amber.scss": "./dist/styles/theming/midnight-amber.scss",
|
|
91
|
-
"./dist/styles/theming/midnight-folio.scss": "./dist/styles/theming/midnight-folio.scss",
|
|
92
|
-
"./dist/styles/theming/mint-meadow.scss": "./dist/styles/theming/mint-meadow.scss",
|
|
93
|
-
"./dist/styles/theming/mintone.scss": "./dist/styles/theming/mintone.scss",
|
|
94
|
-
"./dist/styles/theming/neon-tokyo.scss": "./dist/styles/theming/neon-tokyo.scss",
|
|
95
|
-
"./dist/styles/theming/noir-marquee.scss": "./dist/styles/theming/noir-marquee.scss",
|
|
96
|
-
"./dist/styles/theming/ocean-breeze.scss": "./dist/styles/theming/ocean-breeze.scss",
|
|
97
|
-
"./dist/styles/theming/ocean-depths.scss": "./dist/styles/theming/ocean-depths.scss",
|
|
98
|
-
"./dist/styles/theming/orbital-night.scss": "./dist/styles/theming/orbital-night.scss",
|
|
99
|
-
"./dist/styles/theming/sandstone.scss": "./dist/styles/theming/sandstone.scss",
|
|
100
|
-
"./dist/styles/theming/sandy-parchment.scss": "./dist/styles/theming/sandy-parchment.scss",
|
|
101
|
-
"./dist/styles/theming/screening-room.scss": "./dist/styles/theming/screening-room.scss",
|
|
102
|
-
"./dist/styles/theming/signal-burst.scss": "./dist/styles/theming/signal-burst.scss",
|
|
103
|
-
"./dist/styles/theming/signal-clarity.scss": "./dist/styles/theming/signal-clarity.scss",
|
|
104
|
-
"./dist/styles/theming/slate-focus.scss": "./dist/styles/theming/slate-focus.scss",
|
|
105
|
-
"./dist/styles/theming/slate-bazaar.scss": "./dist/styles/theming/slate-bazaar.scss",
|
|
106
|
-
"./dist/styles/theming/spectrum-vault.scss": "./dist/styles/theming/spectrum-vault.scss",
|
|
107
|
-
"./dist/styles/theming/tailwind-vue-dark.scss": "./dist/styles/theming/tailwind-vue-dark.scss",
|
|
108
|
-
"./dist/styles/theming/terminal-phosphor.scss": "./dist/styles/theming/terminal-phosphor.scss",
|
|
109
|
-
"./dist/styles/theming/terracotta-kitchen.scss": "./dist/styles/theming/terracotta-kitchen.scss",
|
|
110
|
-
"./dist/styles/theming/twilight-pulse.scss": "./dist/styles/theming/twilight-pulse.scss",
|
|
111
|
-
"./dist/styles/theming/vault-guard.scss": "./dist/styles/theming/vault-guard.scss",
|
|
112
|
-
"./dist/styles/theming/velvet-reel.scss": "./dist/styles/theming/velvet-reel.scss",
|
|
113
|
-
"./dist/styles/theming/velvet-tome.scss": "./dist/styles/theming/velvet-tome.scss",
|
|
114
|
-
"./dist/styles/theming/verdant-pulse.scss": "./dist/styles/theming/verdant-pulse.scss",
|
|
115
|
-
"./dist/styles/theming/vital-aurora.scss": "./dist/styles/theming/vital-aurora.scss",
|
|
116
|
-
"./dist/styles/theming/vital-signal.scss": "./dist/styles/theming/vital-signal.scss"
|
|
53
|
+
"./dist/styles/utility-classes.scss": "./dist/styles/utility-classes.scss"
|
|
117
54
|
},
|
|
118
55
|
"files": [
|
|
119
56
|
"dist"
|
|
@@ -135,12 +72,14 @@
|
|
|
135
72
|
},
|
|
136
73
|
"peerDependencies": {
|
|
137
74
|
"@memobit/icons": "^1.0.0",
|
|
75
|
+
"@memobit/themes": "^1.0.0",
|
|
138
76
|
"react": "19.2.7",
|
|
139
77
|
"react-dom": "19.2.7"
|
|
140
78
|
},
|
|
141
79
|
"devDependencies": {
|
|
142
|
-
"@memobit/icons": "file:../memobit-react-icons",
|
|
143
80
|
"@eslint/js": "9.39.4",
|
|
81
|
+
"@memobit/icons": "file:../memobit-react-icons",
|
|
82
|
+
"@memobit/themes": "file:../memobit-react-themes",
|
|
144
83
|
"@microsoft/api-extractor": "7.58.8",
|
|
145
84
|
"@types/react": "19.2.14",
|
|
146
85
|
"@types/react-dom": "19.2.3",
|
|
@@ -154,6 +93,7 @@
|
|
|
154
93
|
"eslint-plugin-simple-import-sort": "13.0.0",
|
|
155
94
|
"globals": "17.6.0",
|
|
156
95
|
"prettier": "3.8.3",
|
|
96
|
+
"qrcode.react": "4.2.0",
|
|
157
97
|
"react": "19.2.7",
|
|
158
98
|
"react-dom": "19.2.7",
|
|
159
99
|
"react-router": "8.3.0",
|
|
@@ -165,9 +105,6 @@
|
|
|
165
105
|
"vite-plugin-dts": "5.0.0",
|
|
166
106
|
"vite-plugin-static-copy": "3.4.0"
|
|
167
107
|
},
|
|
168
|
-
"dependencies": {
|
|
169
|
-
"qrcode.react": "4.2.0"
|
|
170
|
-
},
|
|
171
108
|
"overrides": {
|
|
172
109
|
"brace-expansion@1": "1.1.18",
|
|
173
110
|
"brace-expansion@5": "5.0.9",
|