@gofreego/tsutils 0.1.18 → 0.1.20

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createTheme, ThemeProvider as ThemeProvider$1, CssBaseline, IconButton, Tooltip, Box, Typography, Button, CircularProgress, Snackbar, Alert, Dialog, DialogTitle, DialogContent, DialogActions, Drawer, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Collapse } from '@mui/material';
2
2
  import { SentimentDissatisfied, BrightnessAuto, DarkMode, LightMode, ExpandLess, ExpandMore } from '@mui/icons-material';
3
- import { useNavigate, useSearchParams, BrowserRouter, useLocation, Routes, Route, Outlet, NavLink } from 'react-router-dom';
3
+ import { useNavigate, useSearchParams, Link, BrowserRouter, useLocation, Routes, Route, Outlet, NavLink } from 'react-router-dom';
4
4
  import { createContext, useState, useMemo, useEffect, useCallback, useContext } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import ReactMarkdown from 'react-markdown';
@@ -12,6 +12,7 @@ import ContentCopyIcon from '@mui/icons-material/ContentCopy';
12
12
  import CheckIcon from '@mui/icons-material/Check';
13
13
  import { createHighlighter } from 'shiki';
14
14
  import WarningAmberIcon from '@mui/icons-material/WarningAmber';
15
+ import HomeIcon from '@mui/icons-material/Home';
15
16
 
16
17
  var __defProp = Object.defineProperty;
17
18
  var __export = (target, all) => {
@@ -715,12 +716,16 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
715
716
  }
716
717
 
717
718
  // src/components/ProtectedRoute.tsx
718
- function ProtectedRoute({ children, sessionManager, loginUrl }) {
719
+ function ProtectedRoute({ children, sessionManager, loginUrl, callbackPath = "/login-callback" }) {
719
720
  if (!sessionManager.isAuthenticated()) {
720
- const callbackUrl = `${window.location.origin}/login-callback`;
721
- const url = new URL(loginUrl);
722
- url.searchParams.set("redirect", callbackUrl);
723
- window.location.href = url.toString();
721
+ const callbackUrl = `${window.location.origin}${callbackPath}`;
722
+ try {
723
+ const url = new URL(loginUrl);
724
+ url.searchParams.set("redirect", callbackUrl);
725
+ window.location.href = url.toString();
726
+ } catch {
727
+ window.location.href = loginUrl;
728
+ }
724
729
  return null;
725
730
  }
726
731
  return children;
@@ -798,6 +803,8 @@ var flattenMenuRoutes = (items) => {
798
803
  var SidebarLayoutRouterInner = ({
799
804
  menuItems,
800
805
  sidebarWidth = 250,
806
+ header,
807
+ footer,
801
808
  className = "",
802
809
  onMenuChange,
803
810
  style,
@@ -853,7 +860,7 @@ var SidebarLayoutRouterInner = ({
853
860
  ...style
854
861
  },
855
862
  children: [
856
- /* @__PURE__ */ jsx(
863
+ /* @__PURE__ */ jsxs(
857
864
  Drawer,
858
865
  {
859
866
  variant: "permanent",
@@ -866,18 +873,24 @@ var SidebarLayoutRouterInner = ({
866
873
  position: "relative",
867
874
  borderRight: "1px solid",
868
875
  borderColor: "divider",
876
+ display: "flex",
877
+ flexDirection: "column",
869
878
  ...sidebarStyle
870
879
  }
871
880
  },
872
- children: /* @__PURE__ */ jsx(List, { sx: { p: 0 }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsx(
873
- RouterMenuItem,
874
- {
875
- item,
876
- expanded,
877
- onToggle: handleToggle
878
- },
879
- item.id
880
- )) })
881
+ children: [
882
+ header && /* @__PURE__ */ jsx(Box, { className: "sidebar-header", children: header }),
883
+ /* @__PURE__ */ jsx(List, { sx: { p: 0, flexGrow: 1, overflowY: "auto" }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsx(
884
+ RouterMenuItem,
885
+ {
886
+ item,
887
+ expanded,
888
+ onToggle: handleToggle
889
+ },
890
+ item.id
891
+ )) }),
892
+ footer && /* @__PURE__ */ jsx(Box, { className: "sidebar-footer", children: footer })
893
+ ]
881
894
  }
882
895
  ),
883
896
  /* @__PURE__ */ jsx(
@@ -981,6 +994,8 @@ var StateMenuItem = ({ item, selectedId, depth = 0, expanded, onToggle, onClick
981
994
  var SidebarLayoutWithState = ({
982
995
  menuItems,
983
996
  sidebarWidth = 250,
997
+ header,
998
+ footer,
984
999
  className = "",
985
1000
  defaultSelected,
986
1001
  onMenuChange,
@@ -1032,7 +1047,7 @@ var SidebarLayoutWithState = ({
1032
1047
  ...style
1033
1048
  },
1034
1049
  children: [
1035
- /* @__PURE__ */ jsx(
1050
+ /* @__PURE__ */ jsxs(
1036
1051
  Drawer,
1037
1052
  {
1038
1053
  variant: "permanent",
@@ -1045,20 +1060,26 @@ var SidebarLayoutWithState = ({
1045
1060
  position: "relative",
1046
1061
  borderRight: "1px solid",
1047
1062
  borderColor: "divider",
1063
+ display: "flex",
1064
+ flexDirection: "column",
1048
1065
  ...sidebarStyle
1049
1066
  }
1050
1067
  },
1051
- children: /* @__PURE__ */ jsx(List, { sx: { p: 0 }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsx(
1052
- StateMenuItem,
1053
- {
1054
- item,
1055
- selectedId,
1056
- expanded,
1057
- onToggle: handleToggle,
1058
- onClick: handleMenuClick
1059
- },
1060
- item.id
1061
- )) })
1068
+ children: [
1069
+ header && /* @__PURE__ */ jsx(Box, { className: "sidebar-header", children: header }),
1070
+ /* @__PURE__ */ jsx(List, { sx: { p: 0, flexGrow: 1, overflowY: "auto" }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsx(
1071
+ StateMenuItem,
1072
+ {
1073
+ item,
1074
+ selectedId,
1075
+ expanded,
1076
+ onToggle: handleToggle,
1077
+ onClick: handleMenuClick
1078
+ },
1079
+ item.id
1080
+ )) }),
1081
+ footer && /* @__PURE__ */ jsx(Box, { className: "sidebar-footer", children: footer })
1082
+ ]
1062
1083
  }
1063
1084
  ),
1064
1085
  /* @__PURE__ */ jsx(
@@ -1316,6 +1337,16 @@ var ConfirmDialog = ({
1316
1337
  ] })
1317
1338
  ] });
1318
1339
  };
1340
+ var SidebarHeader = ({
1341
+ title,
1342
+ homePath = "/",
1343
+ showHome = true
1344
+ }) => {
1345
+ return /* @__PURE__ */ jsxs(Box, { sx: { padding: "16px", display: "flex", alignItems: "center", borderBottom: "1px solid rgba(255, 255, 255, 0.12)", gap: "8px" }, children: [
1346
+ showHome && /* @__PURE__ */ jsx(IconButton, { component: Link, to: homePath, size: "small", sx: { color: "text.primary", ml: -1 }, children: /* @__PURE__ */ jsx(HomeIcon, {}) }),
1347
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontWeight: "bold", color: "primary.main" }, children: title })
1348
+ ] });
1349
+ };
1319
1350
 
1320
1351
  // src/utils/cn.ts
1321
1352
  function cn(...classes) {
@@ -1512,6 +1543,6 @@ var AuthService = class _AuthService {
1512
1543
  }
1513
1544
  };
1514
1545
 
1515
- export { AuthService, ConfirmDialog, HttpClient, LocalStorage, LoginCallbackPage, NotFoundPage, NotificationProvider, ProtectedRoute, ReadmeViewer_default as ReadmeViewer, SessionManager, SidebarLayout, ThemeProvider, ThemeToggle, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens_exports as tokens, transition, useNotification, useTheme, zIndex };
1546
+ export { AuthService, ConfirmDialog, HttpClient, LocalStorage, LoginCallbackPage, NotFoundPage, NotificationProvider, ProtectedRoute, ReadmeViewer_default as ReadmeViewer, SessionManager, SidebarHeader, SidebarLayout, ThemeProvider, ThemeToggle, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens_exports as tokens, transition, useNotification, useTheme, zIndex };
1516
1547
  //# sourceMappingURL=index.mjs.map
1517
1548
  //# sourceMappingURL=index.mjs.map