@moh-sso/auth 1.4.1 → 1.6.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.
@@ -1,10 +1,11 @@
1
1
  import { type RefObject } from "react";
2
2
  type FocusTrapOptions = {
3
3
  active: boolean;
4
+ trapFocus?: boolean;
4
5
  containerRef: RefObject<HTMLElement | null>;
5
6
  restoreFocus?: boolean;
6
7
  initialFocusRef?: RefObject<HTMLElement | HTMLButtonElement | null>;
7
8
  initialFocusSelector?: string;
8
9
  };
9
- export declare function useFocusTrap({ active, containerRef, restoreFocus, initialFocusRef, initialFocusSelector, }: FocusTrapOptions): void;
10
+ export declare function useFocusTrap({ active, trapFocus, containerRef, restoreFocus, initialFocusRef, initialFocusSelector, }: FocusTrapOptions): void;
10
11
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { PanelSize } from "./header-panel.context";
2
2
  type Props = {
3
3
  isOpen: boolean;
4
+ dockOnDesktop?: boolean;
4
5
  title?: string;
5
6
  content?: React.ReactNode;
6
7
  onClose: () => void;
@@ -13,5 +14,5 @@ type Props = {
13
14
  maximizable?: boolean;
14
15
  defaultMaximized?: boolean;
15
16
  };
16
- export declare function ReusableHeaderPanel({ isOpen, title, content, onClose, size, primaryActionLabel, secondaryActionLabel, onPrimaryAction, onSecondaryAction, disablePrimaryAction, maximizable, defaultMaximized, }: Props): import("react").JSX.Element;
17
+ export declare function ReusableHeaderPanel({ isOpen, dockOnDesktop, title, content, onClose, size, primaryActionLabel, secondaryActionLabel, onPrimaryAction, onSecondaryAction, disablePrimaryAction, maximizable, defaultMaximized, }: Props): import("react").JSX.Element;
17
18
  export {};
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  export type PanelSize = "sm" | "md" | "lg";
3
3
  type OpenPanelOptions = {
4
+ dockOnDesktop?: boolean;
4
5
  title?: string;
5
6
  content: React.ReactNode;
6
7
  size?: PanelSize;
@@ -16,8 +17,9 @@ type HeaderPanelContextType = {
16
17
  openPanel: (opts: OpenPanelOptions) => void;
17
18
  closePanel: () => void;
18
19
  };
19
- export declare function HeaderPanelProvider({ children }: {
20
+ export declare function HeaderPanelProvider({ children, dockOnDesktop, }: {
20
21
  children: React.ReactNode;
22
+ dockOnDesktop?: boolean;
21
23
  }): React.JSX.Element;
22
24
  export declare function useHeaderPanel(): HeaderPanelContextType;
23
25
  export {};
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ const K = {
51
51
  * Get current user
52
52
  * ----------------------------- */
53
53
  me: e.query({
54
+ providesTags: ["Auth"],
54
55
  query: () => ({
55
56
  url: p.auth.me(),
56
57
  method: "GET",
@@ -137,7 +138,7 @@ const Y = f.injectEndpoints({
137
138
  invalidatesTags: ["HealthContext"]
138
139
  })
139
140
  })
140
- }), { useMyHealthContextsQuery: F, useSelectHealthContextMutation: J } = Y, y = (e) => e.auth, Ae = i(y, (e) => e.accessToken), g = i(y, (e) => e.user), Z = i(y, (e) => e.isAuthenticated), xe = i(g, (e) => e?.isAdmin === !0), ke = i(g, (e) => e?.isUser === !0), I = i(g, (e) => e?.permissions ?? []), ee = i(g, (e) => e?.systems ?? []), Te = (e) => i(I, (t) => t.includes(e)), Le = (e) => i(
141
+ }), { useMyHealthContextsQuery: F, useSelectHealthContextMutation: J } = Y, y = (e) => e.auth, Ae = i(y, (e) => e.accessToken), g = i(y, (e) => e.user), Z = i(y, (e) => e.isAuthenticated), xe = i(g, (e) => e?.isAdmin === !0), Te = i(g, (e) => e?.isUser === !0), I = i(g, (e) => e?.permissions ?? []), ee = i(g, (e) => e?.systems ?? []), ke = (e) => i(I, (t) => t.includes(e)), Le = (e) => i(
141
142
  I,
142
143
  (t) => e.some((n) => t.includes(n))
143
144
  ), _e = (e) => i(ee, (t) => t.includes(e)), be = i(y, (e) => e.loading), te = i(y, (e) => e.loaded), se = {
@@ -256,17 +257,17 @@ function Pe({
256
257
  const { can: o, canAny: c } = ce();
257
258
  return (e ? o(e) : !0) && (t && t.length > 0 ? c(t) : !0) ? s : n;
258
259
  }
259
- function le() {
260
+ function ue() {
260
261
  return typeof window > "u" ? "/portal" : `${window.location.pathname}${window.location.search}${window.location.hash}`;
261
262
  }
262
- function He(e, t = le()) {
263
+ function He(e, t = ue()) {
263
264
  const n = new URL(
264
265
  e,
265
266
  typeof window > "u" ? "http://localhost" : window.location.origin
266
267
  );
267
268
  return n.searchParams.set("returnTo", t), n.toString();
268
269
  }
269
- function ue(e) {
270
+ function le(e) {
270
271
  try {
271
272
  const t = new URL(e);
272
273
  return ["http:", "https:"].includes(t.protocol) && !t.username && !t.password;
@@ -276,7 +277,7 @@ function ue(e) {
276
277
  }
277
278
  function P(e, t) {
278
279
  const n = t.trim().replace(/\/$/, "");
279
- return !n || ue(e) ? e : `${n}${e.startsWith("/") ? e : `/${e}`}`;
280
+ return !n || le(e) ? e : `${n}${e.startsWith("/") ? e : `/${e}`}`;
280
281
  }
281
282
  function Ee(e, t) {
282
283
  const n = e.launchUrl?.trim() ?? "", s = e.authenticatedLaunchUrl?.trim() ?? "";
@@ -286,49 +287,49 @@ const h = "moh.activeHealthContextId", B = D(void 0);
286
287
  function Ue({ children: e }) {
287
288
  const t = H(), n = v(Z), s = v(te), [o, c] = j(
288
289
  () => typeof window > "u" ? null : window.localStorage.getItem(h)
289
- ), u = G(o), {
290
+ ), l = G(o), {
290
291
  data: a = [],
291
292
  isLoading: x,
292
- isSuccess: k
293
+ isSuccess: T
293
294
  } = F(void 0, {
294
295
  skip: !n
295
- }), [T, { isLoading: L }] = J(), l = C(() => a.find((r) => r.id === o) ?? a.find((r) => r.isActive) ?? a.find((r) => r.isDefault) ?? a[0], [a, o]);
296
+ }), [k, { isLoading: L }] = J(), u = C(() => a.find((r) => r.id === o) ?? a.find((r) => r.isActive) ?? a.find((r) => r.isDefault) ?? a[0], [a, o]);
296
297
  S(() => {
297
298
  if (!(typeof window > "u")) {
298
299
  if (s && !n) {
299
- window.localStorage.removeItem(h), u.current = null, c(null);
300
+ window.localStorage.removeItem(h), l.current = null, c(null);
300
301
  return;
301
302
  }
302
- if (n && k && a.length === 0) {
303
- window.localStorage.removeItem(h), u.current = null, c(null);
303
+ if (n && T && a.length === 0) {
304
+ window.localStorage.removeItem(h), l.current = null, c(null);
304
305
  return;
305
306
  }
306
- l && (u.current = l.id, window.localStorage.setItem(h, l.id), o !== l.id && c(l.id), window.dispatchEvent(
307
- new CustomEvent("moh:health-context-changed", { detail: l })
307
+ u && (l.current = u.id, window.localStorage.setItem(h, u.id), o !== u.id && c(u.id), window.dispatchEvent(
308
+ new CustomEvent("moh:health-context-changed", { detail: u })
308
309
  ));
309
310
  }
310
- }, [l, n, s, a.length, k, o]), S(() => {
311
+ }, [u, n, s, a.length, T, o]), S(() => {
311
312
  const r = (d) => {
312
- d.key === h && (u.current = d.newValue, c(d.newValue), t(f.util.resetApiState()));
313
+ d.key === h && (l.current = d.newValue, c(d.newValue), t(f.util.resetApiState()));
313
314
  };
314
315
  return window.addEventListener("storage", r), () => window.removeEventListener("storage", r);
315
316
  }, [t]), S(() => {
316
317
  const r = (d) => {
317
318
  const m = d.detail;
318
- !m?.id || !a.some((Q) => Q.id === m.id) || u.current !== m.id && (u.current = m.id, c(m.id), t(f.util.resetApiState()));
319
+ !m?.id || !a.some((Q) => Q.id === m.id) || l.current !== m.id && (l.current = m.id, c(m.id), t(f.util.resetApiState()));
319
320
  };
320
321
  return window.addEventListener("moh:health-context-changed", r), () => window.removeEventListener("moh:health-context-changed", r);
321
322
  }, [a, t]);
322
323
  const _ = O(
323
324
  async (r) => {
324
- await T(r).unwrap(), u.current = r, window.localStorage.setItem(h, r), c(r), t(f.util.resetApiState());
325
+ await k(r).unwrap(), l.current = r, window.localStorage.setItem(h, r), c(r), t(f.util.resetApiState());
325
326
  const d = a.find((m) => m.id === r);
326
327
  window.dispatchEvent(new CustomEvent("moh:health-context-changed", { detail: d }));
327
328
  },
328
- [a, t, T]
329
+ [a, t, k]
329
330
  ), $ = C(
330
- () => ({ contexts: a, activeContext: l, isLoading: x, isUpdating: L, selectContext: _ }),
331
- [l, a, x, L, _]
331
+ () => ({ contexts: a, activeContext: u, isLoading: x, isUpdating: L, selectContext: _ }),
332
+ [u, a, x, L, _]
332
333
  );
333
334
  return /* @__PURE__ */ N(B.Provider, { value: $, children: e });
334
335
  }
@@ -359,7 +360,7 @@ export {
359
360
  ge as authReducer,
360
361
  He as buildLoginURL,
361
362
  ae as canLaunchSystem,
362
- le as currentPortalReturnTo,
363
+ ue as currentPortalReturnTo,
363
364
  ie as getAccessibleSystems,
364
365
  re as hasAllPermissions,
365
366
  ne as hasAnyPermission,
@@ -376,10 +377,10 @@ export {
376
377
  be as selectAuthLoading,
377
378
  Z as selectAuthenticated,
378
379
  Le as selectHasAnyPermission,
379
- Te as selectHasPermission,
380
+ ke as selectHasPermission,
380
381
  _e as selectHasSystem,
381
382
  xe as selectIsAdmin,
382
- ke as selectIsUser,
383
+ Te as selectIsUser,
383
384
  I as selectPermissions,
384
385
  ee as selectSystems,
385
386
  g as selectUser,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
- "version": "1.4.1",
6
+ "version": "1.6.0",
7
7
  "license": "UNLICENSED",
8
8
  "module": "./dist/index.js",
9
9
  "files": [
@@ -24,9 +24,9 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@moh-sso/api": "^1.4.1",
28
- "@moh-sso/state": "^1.4.1",
29
- "@moh-sso/config": "^1.4.1"
27
+ "@moh-sso/api": "^1.6.0",
28
+ "@moh-sso/state": "^1.6.0",
29
+ "@moh-sso/config": "^1.6.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@reduxjs/toolkit": "^2.11.2",