@moh-sso/microfrontend 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
@@ -1,122 +1,125 @@
1
1
  import { jsxs as y, jsx as a } from "react/jsx-runtime";
2
- import p from "react";
3
- import d from "react-dom/client";
4
- import { Provider as w } from "react-redux";
5
- import { loginSuccess as P, authLoaded as L, HealthContextProvider as v } from "@moh-sso/auth";
6
- import { store as s } from "@moh-sso/state";
7
- import { MicrofrontendErrorBoundary as E, MohThemeProvider as M, HeaderPanelProvider as g, ModalProvider as N, ToastProvider as _ } from "@moh-sso/ui";
8
- function l(r) {
9
- return (r.startsWith("/") ? r : `/${r}`).replace(/\/+$/, "") || "/";
2
+ import w from "react";
3
+ import s from "react-dom/client";
4
+ import { Provider as p } from "react-redux";
5
+ import { loginSuccess as P, authLoaded as L, HealthContextProvider as g } from "@moh-sso/auth";
6
+ import { store as d } from "@moh-sso/state";
7
+ import { MicrofrontendErrorBoundary as v, MohThemeProvider as E, HeaderPanelProvider as M, ModalProvider as N, ToastProvider as x } from "@moh-sso/ui";
8
+ function l(e) {
9
+ return (e.startsWith("/") ? e : `/${e}`).replace(/\/+$/, "") || "/";
10
10
  }
11
- function b(r, t, e) {
12
- const o = t === 0 ? "" : r[t - 1], n = r[t + e] ?? "";
13
- return (!o || o === "/") && (!n || n === "/" || n === "?" || n === "#");
11
+ function O(e, t) {
12
+ return e === t || e.startsWith(`${t}/`);
14
13
  }
15
- function G(r, t) {
16
- const e = l(r), o = t ? l(t) : "";
17
- if (o && o !== "/" && !e.startsWith(`${o}/`) && e !== o)
18
- return `${o}${e}`;
19
- if (typeof window > "u")
20
- return e;
21
- const n = l(window.location.pathname);
22
- if (n === e || n.startsWith(`${e}/`))
23
- return e;
24
- const u = n.indexOf(e);
25
- return u > 0 && b(n, u, e.length) ? `${n.slice(0, u)}${e}` : e;
14
+ function V(e, t) {
15
+ const r = l(e), n = t ? l(t) : "";
16
+ if (n && n !== "/")
17
+ return r === "/" ? n : O(r, n) ? r : `${n}${r}`;
18
+ if (typeof window > "u" || r === "/")
19
+ return r;
20
+ const o = l(window.location.pathname);
21
+ let u = o.indexOf(r);
22
+ for (; u !== -1; ) {
23
+ const i = u + r.length;
24
+ if (i === o.length || o[i] === "/")
25
+ return o.slice(0, i);
26
+ u = o.indexOf(r, u + 1);
27
+ }
28
+ return r;
26
29
  }
27
- const x = {
30
+ const _ = {
28
31
  withRedux: !0,
29
32
  withModal: !0,
30
33
  withToast: !0,
31
34
  withHeaderPanel: !0
32
35
  };
33
- function f(r) {
34
- return r.displayName || r.name || "microfrontend";
36
+ function f(e) {
37
+ return e.displayName || e.name || "microfrontend";
35
38
  }
36
- function I(r, t) {
37
- let e = r;
38
- return t.withHeaderPanel && (e = /* @__PURE__ */ a(g, { children: e })), t.withModal && (e = /* @__PURE__ */ a(N, { children: e })), t.withToast && (e = /* @__PURE__ */ a(_, { children: e })), t.withRedux && (e = /* @__PURE__ */ a(w, { store: s, children: /* @__PURE__ */ a(v, { children: e }) })), /* @__PURE__ */ a(M, { theme: "white", children: e });
39
+ function R(e, t) {
40
+ let r = e;
41
+ return t.withHeaderPanel && (r = /* @__PURE__ */ a(M, { children: r })), t.withModal && (r = /* @__PURE__ */ a(N, { children: r })), t.withToast && (r = /* @__PURE__ */ a(x, { children: r })), t.withRedux && (r = /* @__PURE__ */ a(p, { store: d, children: /* @__PURE__ */ a(g, { children: r }) })), /* @__PURE__ */ a(E, { theme: "white", children: r });
39
42
  }
40
- function m(r, t, e) {
41
- const { domElement: o, ...n } = t;
42
- return I(
43
- /* @__PURE__ */ a(E, { appName: f(r), children: /* @__PURE__ */ a(r, { ...n }) }),
44
- e
43
+ function m(e, t, r) {
44
+ const { domElement: n, ...o } = t;
45
+ return R(
46
+ /* @__PURE__ */ a(v, { appName: f(e), children: /* @__PURE__ */ a(e, { ...o }) }),
47
+ r
45
48
  );
46
49
  }
47
- function O(r, t, e, o) {
50
+ function T(e, t, r, n) {
48
51
  return /* @__PURE__ */ y("div", { className: "moh-microfrontend-error-boundary", role: "alert", children: [
49
52
  "Unable to load ",
50
- f(r),
53
+ f(e),
51
54
  ". ",
52
55
  t.message
53
56
  ] });
54
57
  }
55
- function R(r) {
56
- return !!(r && typeof r == "object" && "id" in r && "username" in r);
58
+ function A(e) {
59
+ return !!(e && typeof e == "object" && "id" in e && "username" in e);
57
60
  }
58
- function h(r) {
59
- const t = r.auth ?? window.__MOH_SSO_AUTH__;
60
- if (t?.isAuthenticated && R(t.user)) {
61
- s.dispatch(P({ user: t.user }));
61
+ function h(e) {
62
+ const t = e.auth ?? window.__MOH_SSO_AUTH__;
63
+ if (t?.isAuthenticated && A(t.user)) {
64
+ d.dispatch(P({ user: t.user }));
62
65
  return;
63
66
  }
64
- s.dispatch(L());
67
+ d.dispatch(L());
65
68
  }
66
- function T(r, t) {
67
- let e = null;
69
+ function I(e, t) {
70
+ let r = null;
68
71
  return {
69
72
  async bootstrap() {
70
73
  },
71
- async mount(o) {
72
- h(o), e = d.createRoot(o.domElement), e.render(m(r, o, t));
74
+ async mount(n) {
75
+ h(n), r = s.createRoot(n.domElement), r.render(m(e, n, t));
73
76
  },
74
77
  async unmount() {
75
- e?.unmount(), e = null;
78
+ r?.unmount(), r = null;
76
79
  }
77
80
  };
78
81
  }
79
- async function $() {
82
+ async function S() {
80
83
  try {
81
84
  return (await new Function("specifier", "return import(specifier)")("single-spa-react")).default ?? null;
82
85
  } catch {
83
86
  return null;
84
87
  }
85
88
  }
86
- function V(r, t = {}) {
87
- const e = { ...x, ...t }, o = T(r, e);
88
- let n = null;
89
+ function W(e, t = {}) {
90
+ const r = { ..._, ...t }, n = I(e, r);
91
+ let o = null;
89
92
  async function u() {
90
- if (n)
91
- return n;
92
- const c = await $();
93
- return n = c ? c({
94
- React: p,
95
- ReactDOMClient: d,
96
- rootComponent: (i) => (h(i), m(r, i, e)),
97
- domElementGetter: ({ domElement: i }) => i,
98
- errorBoundary: (i, S, B) => O(r, i)
99
- }) : o, n;
93
+ if (o)
94
+ return o;
95
+ const i = await S();
96
+ return o = i ? i({
97
+ React: w,
98
+ ReactDOMClient: s,
99
+ rootComponent: (c) => (h(c), m(e, c, r)),
100
+ domElementGetter: ({ domElement: c }) => c,
101
+ errorBoundary: (c, b, $) => T(e, c)
102
+ }) : n, o;
100
103
  }
101
104
  return {
102
- async bootstrap(c) {
103
- return (await u()).bootstrap(c);
105
+ async bootstrap(i) {
106
+ return (await u()).bootstrap(i);
104
107
  },
105
- async mount(c) {
106
- return (await u()).mount(c);
108
+ async mount(i) {
109
+ return (await u()).mount(i);
107
110
  },
108
- async unmount(c) {
109
- return (n ?? o).unmount(c);
111
+ async unmount(i) {
112
+ return (o ?? n).unmount(i);
110
113
  }
111
114
  };
112
115
  }
113
- const A = "moh-sso:navigation";
116
+ const H = "moh-sso:navigation";
114
117
  function k() {
115
- window.dispatchEvent(new Event(A));
118
+ window.dispatchEvent(new Event(H));
116
119
  }
117
120
  export {
118
- A as MICROFRONTEND_NAVIGATION_EVENT,
119
- V as createReactMicrofrontendLifecycle,
121
+ H as MICROFRONTEND_NAVIGATION_EVENT,
122
+ W as createReactMicrofrontendLifecycle,
120
123
  k as notifyMicrofrontendNavigation,
121
- G as resolveRuntimeBasename
124
+ V as resolveRuntimeBasename
122
125
  };
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": [
@@ -31,9 +31,9 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@moh-sso/state": "^1.4.1",
35
- "@moh-sso/ui": "^1.4.1",
36
- "@moh-sso/auth": "^1.4.1"
34
+ "@moh-sso/state": "^1.6.0",
35
+ "@moh-sso/ui": "^1.6.0",
36
+ "@moh-sso/auth": "^1.6.0"
37
37
  },
38
38
  "private": false,
39
39
  "repository": {