@sensorario/sg-components 0.0.68 → 0.0.69

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.
Files changed (2) hide show
  1. package/dist/index.es.js +24 -15
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -145,39 +145,48 @@ var a = ({ label: e, ...t }) => /* @__PURE__ */ r("button", {
145
145
  ]
146
146
  })
147
147
  });
148
- }, g = "simonegentili.com-access-token", _ = (e) => document.cookie.split("; ").some((t) => t.startsWith(`${e}=`) && t.slice(e.length + 1).length > 0), v = ({ title: a = "Quadrato", homePageKey: o = "home", onNavigate: s, cookieName: c = g, username: u = null, onLogin: f, onLogout: p, onUserAuthenticated: m }) => {
149
- let [v, y] = t(() => _(c)), [b, x] = t(!1);
148
+ }, g = "simonegentili.com-access-token", _ = (e) => document.cookie.split("; ").some((t) => t.startsWith(`${e}=`) && t.slice(e.length + 1).length > 0), v = (e) => {
149
+ let t = document.cookie.split("; ").find((t) => t.startsWith(`${e}=`));
150
+ return t ? t.slice(e.length + 1) : null;
151
+ }, y = (e, t) => {
152
+ try {
153
+ return JSON.parse(atob(e.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")))[t] ?? null;
154
+ } catch {
155
+ return null;
156
+ }
157
+ }, b = ({ title: a = "Quadrato", homePageKey: o = "home", onNavigate: s, cookieName: c = g, username: u = null, usernameJwtField: f = "sub", onLogin: p, onLogout: m, onUserAuthenticated: b }) => {
158
+ let [x, S] = t(() => _(c)), [C, w] = t(!1), T = u ?? (x ? y(v(c) ?? "", f) : null);
150
159
  return e(() => {
151
- m?.(v, v ? u : null);
160
+ b?.(x, x ? T : null);
152
161
  }, []), /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r(l, {
153
162
  onNavigate: s,
154
163
  title: a,
155
164
  homePageKey: o,
156
165
  children: /* @__PURE__ */ i("div", {
157
166
  className: "quadrato-header-auth",
158
- children: [v && u && /* @__PURE__ */ r("span", {
167
+ children: [x && T && /* @__PURE__ */ r("span", {
159
168
  className: "quadrato-header-username",
160
- children: u
169
+ children: T
161
170
  }), /* @__PURE__ */ r(d, {
162
- isLoggedIn: v,
163
- handleLogin: () => x(!0),
171
+ isLoggedIn: x,
172
+ handleLogin: () => w(!0),
164
173
  handleLogout: () => {
165
- p?.();
174
+ m?.();
166
175
  let e = _(c);
167
- y(e), m?.(e, null);
176
+ S(e), b?.(e, null);
168
177
  }
169
178
  })]
170
179
  })
171
180
  }), /* @__PURE__ */ r(h, {
172
- open: b,
173
- onClose: () => x(!1),
181
+ open: C,
182
+ onClose: () => w(!1),
174
183
  onLogin: async (e, t) => {
175
- await f(e, t);
184
+ await p(e, t);
176
185
  let n = _(c);
177
- y(n), x(!1), m?.(n, n ? e : null);
186
+ S(n), w(!1), b?.(n, n ? u ?? e : null);
178
187
  }
179
188
  })] });
180
- }, y = ({ open: e, onClose: n, onSubmit: o }) => {
189
+ }, x = ({ open: e, onClose: n, onSubmit: o }) => {
181
190
  let [s, c] = t(""), [l, u] = t(""), [d, p] = t("");
182
191
  return /* @__PURE__ */ r(f, {
183
192
  open: e,
@@ -222,4 +231,4 @@ var a = ({ label: e, ...t }) => /* @__PURE__ */ r("button", {
222
231
  });
223
232
  };
224
233
  //#endregion
225
- export { d as Authenticator, a as Button, o as Footer, l as Header, v as QuadratoHeader, c as SGFooter, u as SGHeader, y as SetPasswordModal };
234
+ export { d as Authenticator, a as Button, o as Footer, l as Header, b as QuadratoHeader, c as SGFooter, u as SGHeader, x as SetPasswordModal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sensorario/sg-components",
3
- "version": "0.0.68",
3
+ "version": "0.0.69",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "scripts": {