astrogators-shared-ui 0.4.2 → 0.4.4
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/layout/Container.d.ts +2 -1
- package/dist/index.js +46 -44
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
2
|
|
|
3
3
|
export interface ContainerProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
6
6
|
padding?: boolean;
|
|
7
7
|
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Container component
|
package/dist/index.js
CHANGED
|
@@ -15,11 +15,13 @@ const ye = "_container_u3o0e_1", ve = "_padding_u3o0e_7", X = {
|
|
|
15
15
|
children: e,
|
|
16
16
|
maxWidth: s = "xl",
|
|
17
17
|
padding: t = !0,
|
|
18
|
-
className: o = ""
|
|
18
|
+
className: o = "",
|
|
19
|
+
style: d
|
|
19
20
|
}) => /* @__PURE__ */ r(
|
|
20
21
|
"div",
|
|
21
22
|
{
|
|
22
23
|
className: `${X.container} ${X[`maxWidth-${s}`]} ${t ? X.padding : ""} ${o}`,
|
|
24
|
+
style: d,
|
|
23
25
|
children: e
|
|
24
26
|
}
|
|
25
27
|
), $e = "_topBar_10g3c_1", be = "_content_10g3c_13", we = "_left_10g3c_23", Ne = "_right_10g3c_30", Ae = "_logo_10g3c_36", P = {
|
|
@@ -73,17 +75,17 @@ const ye = "_container_u3o0e_1", ve = "_padding_u3o0e_7", X = {
|
|
|
73
75
|
variant: s = "primary",
|
|
74
76
|
size: t = "md",
|
|
75
77
|
fullWidth: o = !1,
|
|
76
|
-
loading:
|
|
78
|
+
loading: d = !1,
|
|
77
79
|
disabled: g = !1,
|
|
78
80
|
className: c = "",
|
|
79
81
|
...l
|
|
80
82
|
}) => /* @__PURE__ */ r(
|
|
81
83
|
"button",
|
|
82
84
|
{
|
|
83
|
-
className: `${x.button} ${x[s]} ${x[t]} ${o ? x.fullWidth : ""} ${
|
|
84
|
-
disabled: g ||
|
|
85
|
+
className: `${x.button} ${x[s]} ${x[t]} ${o ? x.fullWidth : ""} ${d ? x.loading : ""} ${c}`,
|
|
86
|
+
disabled: g || d,
|
|
85
87
|
...l,
|
|
86
|
-
children:
|
|
88
|
+
children: d ? /* @__PURE__ */ m("span", { className: x.loadingSpinner, children: [
|
|
87
89
|
/* @__PURE__ */ r("span", { className: x.spinner }),
|
|
88
90
|
/* @__PURE__ */ r("span", { className: x.loadingText, children: e })
|
|
89
91
|
] }) : e
|
|
@@ -103,12 +105,12 @@ const ye = "_container_u3o0e_1", ve = "_padding_u3o0e_7", X = {
|
|
|
103
105
|
error: s,
|
|
104
106
|
helperText: t,
|
|
105
107
|
fullWidth: o = !1,
|
|
106
|
-
className:
|
|
108
|
+
className: d = "",
|
|
107
109
|
id: g,
|
|
108
110
|
...c
|
|
109
111
|
}, l) => {
|
|
110
112
|
const i = g || `input-${Math.random().toString(36).substr(2, 9)}`, h = !!s;
|
|
111
|
-
return /* @__PURE__ */ m("div", { className: `${T.inputWrapper} ${o ? T.fullWidth : ""} ${
|
|
113
|
+
return /* @__PURE__ */ m("div", { className: `${T.inputWrapper} ${o ? T.fullWidth : ""} ${d}`, children: [
|
|
112
114
|
e && /* @__PURE__ */ m("label", { htmlFor: i, className: T.label, children: [
|
|
113
115
|
e,
|
|
114
116
|
c.required && /* @__PURE__ */ r("span", { className: T.required, children: "*" })
|
|
@@ -145,7 +147,7 @@ const Ze = "_selectWrapper_ir4bq_1", et = "_fullWidth_ir4bq_7", tt = "_label_ir4
|
|
|
145
147
|
error: s,
|
|
146
148
|
helperText: t,
|
|
147
149
|
options: o,
|
|
148
|
-
placeholder:
|
|
150
|
+
placeholder: d,
|
|
149
151
|
fullWidth: g = !1,
|
|
150
152
|
className: c = "",
|
|
151
153
|
id: l,
|
|
@@ -166,7 +168,7 @@ const Ze = "_selectWrapper_ir4bq_1", et = "_fullWidth_ir4bq_7", tt = "_label_ir4
|
|
|
166
168
|
className: `${w.select} ${N ? w.error : ""}`,
|
|
167
169
|
...i,
|
|
168
170
|
children: [
|
|
169
|
-
|
|
171
|
+
d && /* @__PURE__ */ r("option", { value: "", disabled: !0, children: d }),
|
|
170
172
|
o && o.map((f) => /* @__PURE__ */ r(
|
|
171
173
|
"option",
|
|
172
174
|
{
|
|
@@ -210,7 +212,7 @@ class gt {
|
|
|
210
212
|
this.baseURL = s.baseURL, this.onUnauthorized = s.onUnauthorized;
|
|
211
213
|
}
|
|
212
214
|
async refreshAccessToken() {
|
|
213
|
-
var
|
|
215
|
+
var d;
|
|
214
216
|
const s = _t();
|
|
215
217
|
if (!s)
|
|
216
218
|
throw new Error("No refresh token available");
|
|
@@ -222,20 +224,20 @@ class gt {
|
|
|
222
224
|
body: JSON.stringify({ refresh_token: s })
|
|
223
225
|
});
|
|
224
226
|
if (!t.ok)
|
|
225
|
-
throw ee(), (
|
|
227
|
+
throw ee(), (d = this.onUnauthorized) == null || d.call(this), new Error("Token refresh failed");
|
|
226
228
|
const o = await t.json();
|
|
227
229
|
return ie(o.access_token, s), o.access_token;
|
|
228
230
|
}
|
|
229
231
|
async request(s, t = {}) {
|
|
230
|
-
const o = ce(),
|
|
232
|
+
const o = ce(), d = {
|
|
231
233
|
"Content-Type": "application/json",
|
|
232
234
|
...t.headers
|
|
233
235
|
};
|
|
234
|
-
o && (
|
|
236
|
+
o && (d.Authorization = `Bearer ${o}`);
|
|
235
237
|
const g = `${this.baseURL}${s}`;
|
|
236
238
|
let c = await fetch(g, {
|
|
237
239
|
...t,
|
|
238
|
-
headers:
|
|
240
|
+
headers: d
|
|
239
241
|
});
|
|
240
242
|
if (c.status === 401 && o) {
|
|
241
243
|
this.isRefreshing || (this.isRefreshing = !0, this.refreshPromise = this.refreshAccessToken().finally(() => {
|
|
@@ -243,9 +245,9 @@ class gt {
|
|
|
243
245
|
}));
|
|
244
246
|
try {
|
|
245
247
|
const l = await this.refreshPromise;
|
|
246
|
-
|
|
248
|
+
d.Authorization = `Bearer ${l}`, c = await fetch(g, {
|
|
247
249
|
...t,
|
|
248
|
-
headers:
|
|
250
|
+
headers: d
|
|
249
251
|
});
|
|
250
252
|
} catch {
|
|
251
253
|
throw new Error("Authentication failed");
|
|
@@ -337,7 +339,7 @@ const ft = (e) => {
|
|
|
337
339
|
}, bt = () => {
|
|
338
340
|
localStorage.removeItem(F), localStorage.removeItem(H);
|
|
339
341
|
}, de = fe(void 0), ws = ({ children: e, apiBaseUrl: s }) => {
|
|
340
|
-
const [t, o] = b(null), [
|
|
342
|
+
const [t, o] = b(null), [d, g] = b(!0), [c, l] = b([]), [i, h] = b(null), [p, N] = b(!1), [f, k] = b({
|
|
341
343
|
show: !1,
|
|
342
344
|
localStorageCodes: []
|
|
343
345
|
});
|
|
@@ -409,7 +411,7 @@ const ft = (e) => {
|
|
|
409
411
|
} catch (n) {
|
|
410
412
|
throw console.error("Resend verification failed:", n), n;
|
|
411
413
|
}
|
|
412
|
-
},
|
|
414
|
+
}, _ = S(async () => {
|
|
413
415
|
N(!0);
|
|
414
416
|
try {
|
|
415
417
|
if (t) {
|
|
@@ -460,8 +462,8 @@ const ft = (e) => {
|
|
|
460
462
|
n && "id" in n && oe(n.id);
|
|
461
463
|
} else a && !t && re(a);
|
|
462
464
|
}, [t, c]), oe = S(async (a) => {
|
|
463
|
-
t && typeof a == "number" ? (await y.put(`/api/v1/users/me/ally-codes/${a}/use`, {}), await
|
|
464
|
-
}, [t,
|
|
465
|
+
t && typeof a == "number" ? (await y.put(`/api/v1/users/me/ally-codes/${a}/use`, {}), await _()) : !t && typeof a == "string" && (re(a), l(A()));
|
|
466
|
+
}, [t, _]), Q = S(() => {
|
|
465
467
|
k({ show: !1, localStorageCodes: [] });
|
|
466
468
|
}, []), _e = S(async () => {
|
|
467
469
|
if (!t) return;
|
|
@@ -475,12 +477,12 @@ const ft = (e) => {
|
|
|
475
477
|
bt(), Q();
|
|
476
478
|
}, [t, v, Q]);
|
|
477
479
|
j(() => {
|
|
478
|
-
|
|
479
|
-
}, [
|
|
480
|
+
_();
|
|
481
|
+
}, [_]);
|
|
480
482
|
const me = {
|
|
481
483
|
user: t,
|
|
482
484
|
isAuthenticated: !!t,
|
|
483
|
-
isLoading:
|
|
485
|
+
isLoading: d,
|
|
484
486
|
login: I,
|
|
485
487
|
register: D,
|
|
486
488
|
logout: O,
|
|
@@ -492,7 +494,7 @@ const ft = (e) => {
|
|
|
492
494
|
allyCodes: c,
|
|
493
495
|
selectedAllyCode: i,
|
|
494
496
|
isLoadingAllyCodes: p,
|
|
495
|
-
fetchAllyCodes:
|
|
497
|
+
fetchAllyCodes: _,
|
|
496
498
|
addAllyCode: v,
|
|
497
499
|
removeAllyCode: L,
|
|
498
500
|
selectAllyCode: z,
|
|
@@ -526,18 +528,18 @@ const ft = (e) => {
|
|
|
526
528
|
const {
|
|
527
529
|
allyCodes: t,
|
|
528
530
|
selectedAllyCode: o,
|
|
529
|
-
selectAllyCode:
|
|
531
|
+
selectAllyCode: d,
|
|
530
532
|
removeAllyCode: g,
|
|
531
533
|
addAllyCode: c,
|
|
532
534
|
isLoadingAllyCodes: l
|
|
533
|
-
} = wt(), [i, h] = b(!1), [p, N] = b(""), [f, k] = b(""), [W, I] = b(""), [D, O] = b(!1), Y = t.map((
|
|
534
|
-
value:
|
|
535
|
-
label:
|
|
536
|
-
})), G = (
|
|
537
|
-
const v =
|
|
538
|
-
|
|
539
|
-
}, K = async (
|
|
540
|
-
const v = t.find((L) => L.ally_code ===
|
|
535
|
+
} = wt(), [i, h] = b(!1), [p, N] = b(""), [f, k] = b(""), [W, I] = b(""), [D, O] = b(!1), Y = t.map((_) => ({
|
|
536
|
+
value: _.ally_code,
|
|
537
|
+
label: _.player_name ? `${_.player_name} (${J(_.ally_code)})` : J(_.ally_code)
|
|
538
|
+
})), G = (_) => {
|
|
539
|
+
const v = _.target.value || null;
|
|
540
|
+
d(v), e == null || e(v);
|
|
541
|
+
}, K = async (_) => {
|
|
542
|
+
const v = t.find((L) => L.ally_code === _);
|
|
541
543
|
if (v) {
|
|
542
544
|
const L = "id" in v ? v.id : v.ally_code;
|
|
543
545
|
await g(L);
|
|
@@ -550,8 +552,8 @@ const ft = (e) => {
|
|
|
550
552
|
O(!0);
|
|
551
553
|
try {
|
|
552
554
|
await c(p), I("Added successfully!"), N(""), setTimeout(() => I(""), 2e3);
|
|
553
|
-
} catch (
|
|
554
|
-
k(
|
|
555
|
+
} catch (_) {
|
|
556
|
+
k(_.message || "Failed to add ally code");
|
|
555
557
|
} finally {
|
|
556
558
|
O(!1);
|
|
557
559
|
}
|
|
@@ -578,7 +580,7 @@ const ft = (e) => {
|
|
|
578
580
|
type: "text",
|
|
579
581
|
placeholder: "9-digit ally code",
|
|
580
582
|
value: p,
|
|
581
|
-
onChange: (
|
|
583
|
+
onChange: (_) => N(_.target.value.replace(/\D/g, "").slice(0, 9)),
|
|
582
584
|
disabled: D
|
|
583
585
|
}
|
|
584
586
|
),
|
|
@@ -597,18 +599,18 @@ const ft = (e) => {
|
|
|
597
599
|
f && /* @__PURE__ */ r("div", { className: $.error, children: f }),
|
|
598
600
|
W && /* @__PURE__ */ r("div", { className: $.success, children: W })
|
|
599
601
|
] }),
|
|
600
|
-
/* @__PURE__ */ r("div", { className: $.codesList, children: t.map((
|
|
601
|
-
/* @__PURE__ */ r("span", { children:
|
|
602
|
+
/* @__PURE__ */ r("div", { className: $.codesList, children: t.map((_) => /* @__PURE__ */ m("div", { className: $.codeItem, children: [
|
|
603
|
+
/* @__PURE__ */ r("span", { children: _.player_name ? `${_.player_name} (${J(_.ally_code)})` : J(_.ally_code) }),
|
|
602
604
|
/* @__PURE__ */ r(
|
|
603
605
|
M,
|
|
604
606
|
{
|
|
605
607
|
variant: "ghost",
|
|
606
608
|
size: "sm",
|
|
607
|
-
onClick: () => K(
|
|
609
|
+
onClick: () => K(_.ally_code),
|
|
608
610
|
children: "Remove"
|
|
609
611
|
}
|
|
610
612
|
)
|
|
611
|
-
] },
|
|
613
|
+
] }, _.ally_code)) }),
|
|
612
614
|
/* @__PURE__ */ r(
|
|
613
615
|
M,
|
|
614
616
|
{
|
|
@@ -647,7 +649,7 @@ const ft = (e) => {
|
|
|
647
649
|
variant: s = "default",
|
|
648
650
|
chamfered: t = !1,
|
|
649
651
|
chamferSize: o = "md",
|
|
650
|
-
padding:
|
|
652
|
+
padding: d = "md",
|
|
651
653
|
hoverable: g = !1,
|
|
652
654
|
showDiagonalBorders: c = !1,
|
|
653
655
|
diagonalBorderColor: l,
|
|
@@ -659,7 +661,7 @@ const ft = (e) => {
|
|
|
659
661
|
return /* @__PURE__ */ m(
|
|
660
662
|
"div",
|
|
661
663
|
{
|
|
662
|
-
className: `${U.card} ${t ? U.chamfered : ""} ${U[s]} ${U[`padding-${
|
|
664
|
+
className: `${U.card} ${t ? U.chamfered : ""} ${U[s]} ${U[`padding-${d}`]} ${N} ${g ? U.hoverable : ""} ${i}`,
|
|
663
665
|
onClick: h,
|
|
664
666
|
role: h ? "button" : void 0,
|
|
665
667
|
tabIndex: h ? 0 : void 0,
|
|
@@ -710,7 +712,7 @@ const ft = (e) => {
|
|
|
710
712
|
onClose: s,
|
|
711
713
|
title: t,
|
|
712
714
|
children: o,
|
|
713
|
-
size:
|
|
715
|
+
size: d = "md",
|
|
714
716
|
closeOnOverlayClick: g = !0,
|
|
715
717
|
className: c = ""
|
|
716
718
|
}) => {
|
|
@@ -725,7 +727,7 @@ const ft = (e) => {
|
|
|
725
727
|
const l = (i) => {
|
|
726
728
|
g && i.target === i.currentTarget && s();
|
|
727
729
|
};
|
|
728
|
-
return /* @__PURE__ */ r("div", { className: E.overlay, onClick: l, children: /* @__PURE__ */ m("div", { className: `${E.modal} ${E[
|
|
730
|
+
return /* @__PURE__ */ r("div", { className: E.overlay, onClick: l, children: /* @__PURE__ */ m("div", { className: `${E.modal} ${E[d]} ${c}`, role: "dialog", "aria-modal": "true", children: [
|
|
729
731
|
t && /* @__PURE__ */ m("div", { className: E.header, children: [
|
|
730
732
|
/* @__PURE__ */ r("h2", { className: E.title, children: t }),
|
|
731
733
|
/* @__PURE__ */ r("button", { className: E.closeButton, onClick: s, "aria-label": "Close modal", children: "✕" })
|