@gofreego/tsutils 0.1.17 → 0.1.19

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/index.d.mts CHANGED
@@ -236,8 +236,9 @@ interface ProtectedRouteProps {
236
236
  children: ReactElement;
237
237
  sessionManager: ISessionManager;
238
238
  loginUrl: string;
239
+ callbackPath?: string;
239
240
  }
240
- declare function ProtectedRoute({ children, sessionManager, loginUrl }: ProtectedRouteProps): ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
241
+ declare function ProtectedRoute({ children, sessionManager, loginUrl, callbackPath }: ProtectedRouteProps): ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
241
242
 
242
243
  /**
243
244
  * Menu item configuration
@@ -277,6 +278,8 @@ interface SidebarLayoutProps {
277
278
  defaultExpanded?: string[];
278
279
  /** If true, wraps SidebarLayout in BrowserRouter and enables router-based navigation */
279
280
  isRouter?: boolean;
281
+ /** If true (default), wraps the router layout in BrowserRouter. Set to false when a BrowserRouter already exists higher in the tree. */
282
+ isBrowserRouter?: boolean;
280
283
  }
281
284
  /**
282
285
  * SidebarLayout Component
package/dist/index.d.ts CHANGED
@@ -236,8 +236,9 @@ interface ProtectedRouteProps {
236
236
  children: ReactElement;
237
237
  sessionManager: ISessionManager;
238
238
  loginUrl: string;
239
+ callbackPath?: string;
239
240
  }
240
- declare function ProtectedRoute({ children, sessionManager, loginUrl }: ProtectedRouteProps): ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
241
+ declare function ProtectedRoute({ children, sessionManager, loginUrl, callbackPath }: ProtectedRouteProps): ReactElement<unknown, string | React.JSXElementConstructor<any>> | null;
241
242
 
242
243
  /**
243
244
  * Menu item configuration
@@ -277,6 +278,8 @@ interface SidebarLayoutProps {
277
278
  defaultExpanded?: string[];
278
279
  /** If true, wraps SidebarLayout in BrowserRouter and enables router-based navigation */
279
280
  isRouter?: boolean;
281
+ /** If true (default), wraps the router layout in BrowserRouter. Set to false when a BrowserRouter already exists higher in the tree. */
282
+ isBrowserRouter?: boolean;
280
283
  }
281
284
  /**
282
285
  * SidebarLayout Component
package/dist/index.js CHANGED
@@ -727,12 +727,16 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
727
727
  }
728
728
 
729
729
  // src/components/ProtectedRoute.tsx
730
- function ProtectedRoute({ children, sessionManager, loginUrl }) {
730
+ function ProtectedRoute({ children, sessionManager, loginUrl, callbackPath = "/login-callback" }) {
731
731
  if (!sessionManager.isAuthenticated()) {
732
- const callbackUrl = `${window.location.origin}/login-callback`;
733
- const url = new URL(loginUrl);
734
- url.searchParams.set("redirect", callbackUrl);
735
- window.location.href = url.toString();
732
+ const callbackUrl = `${window.location.origin}${callbackPath}`;
733
+ try {
734
+ const url = new URL(loginUrl);
735
+ url.searchParams.set("redirect", callbackUrl);
736
+ window.location.href = url.toString();
737
+ } catch {
738
+ window.location.href = loginUrl;
739
+ }
736
740
  return null;
737
741
  }
738
742
  return children;
@@ -916,6 +920,9 @@ var SidebarLayoutRouterInner = ({
916
920
  );
917
921
  };
918
922
  var SidebarLayoutWithRouter = (props) => {
923
+ if (props.isBrowserRouter === false) {
924
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarLayoutRouterInner, { ...props });
925
+ }
919
926
  return (
920
927
  // @ts-expect-error - future prop exists in v6 for v7 migration, but is removed from v7 types
921
928
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.BrowserRouter, { future: { v7_startTransition: true, v7_relativeSplatPath: true }, children: /* @__PURE__ */ jsxRuntime.jsx(SidebarLayoutRouterInner, { ...props }) })