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.
@@ -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: _ = !1,
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 : ""} ${_ ? x.loading : ""} ${c}`,
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: _ ? /* @__PURE__ */ m("span", { className: x.loadingSpinner, 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 : ""} ${_}`, children: [
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
- _ && /* @__PURE__ */ r("option", { value: "", disabled: !0, children: _ }),
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(), (_ = this.onUnauthorized) == null || _.call(this), new Error("Token refresh failed");
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 && (_.Authorization = `Bearer ${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
- _.Authorization = `Bearer ${l}`, c = await fetch(g, {
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), [_, g] = b(!0), [c, l] = b([]), [i, h] = b(null), [p, N] = b(!1), [f, k] = b({
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
- }, d = S(async () => {
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 d()) : !t && typeof a == "string" && (re(a), l(A()));
464
- }, [t, d]), Q = S(() => {
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
- d();
479
- }, [d]);
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: d,
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((d) => ({
534
- value: d.ally_code,
535
- label: d.player_name ? `${d.player_name} (${J(d.ally_code)})` : J(d.ally_code)
536
- })), G = (d) => {
537
- const v = d.target.value || null;
538
- _(v), e == null || e(v);
539
- }, K = async (d) => {
540
- const v = t.find((L) => L.ally_code === d);
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 (d) {
554
- k(d.message || "Failed to add ally code");
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: (d) => N(d.target.value.replace(/\D/g, "").slice(0, 9)),
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((d) => /* @__PURE__ */ m("div", { className: $.codeItem, children: [
601
- /* @__PURE__ */ r("span", { children: d.player_name ? `${d.player_name} (${J(d.ally_code)})` : J(d.ally_code) }),
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(d.ally_code),
609
+ onClick: () => K(_.ally_code),
608
610
  children: "Remove"
609
611
  }
610
612
  )
611
- ] }, d.ally_code)) }),
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: _ = "md",
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-${_}`]} ${N} ${g ? U.hoverable : ""} ${i}`,
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: _ = "md",
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[_]} ${c}`, role: "dialog", "aria-modal": "true", children: [
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: "✕" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astrogators-shared-ui",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Shared UI components and utilities for Astrogator's Table applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",