@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.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +60 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -261,6 +262,10 @@ interface SidebarLayoutProps {
|
|
|
261
262
|
menuItems: MenuItem[];
|
|
262
263
|
/** Width of the sidebar */
|
|
263
264
|
sidebarWidth?: string | number;
|
|
265
|
+
/** Header component to display at the top of the sidebar */
|
|
266
|
+
header?: ReactNode;
|
|
267
|
+
/** Footer component to display at the bottom of the sidebar */
|
|
268
|
+
footer?: ReactNode;
|
|
264
269
|
/** Additional CSS class for container */
|
|
265
270
|
className?: string;
|
|
266
271
|
/** Default selected menu item ID (for non-router mode) */
|
|
@@ -445,6 +450,20 @@ interface ConfirmDialogProps {
|
|
|
445
450
|
}
|
|
446
451
|
declare const ConfirmDialog: ({ open, title, message, confirmText, cancelText, confirmColor, onConfirm, onCancel, }: ConfirmDialogProps) => react_jsx_runtime.JSX.Element;
|
|
447
452
|
|
|
453
|
+
interface SidebarHeaderProps {
|
|
454
|
+
/** The text to display in the header */
|
|
455
|
+
title: string;
|
|
456
|
+
/** Path for the home button redirection (defaults to "/") */
|
|
457
|
+
homePath?: string;
|
|
458
|
+
/** Whether to show the home button */
|
|
459
|
+
showHome?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* A standardized header component to be used with SidebarLayout.
|
|
463
|
+
* It includes a title and an optional home button that redirects to a specified path.
|
|
464
|
+
*/
|
|
465
|
+
declare const SidebarHeader: React__default.FC<SidebarHeaderProps>;
|
|
466
|
+
|
|
448
467
|
/**
|
|
449
468
|
* Theme mode options
|
|
450
469
|
* - 'light': Always use light theme
|
|
@@ -798,4 +817,4 @@ declare class LocalStorage {
|
|
|
798
817
|
|
|
799
818
|
declare const getHighlighter: () => Promise<Highlighter>;
|
|
800
819
|
|
|
801
|
-
export { AuthService, ConfirmDialog, type ConfirmDialogProps, type ErrorData, type GenerateLoginTokenRequest, type GenerateLoginTokenResponse, HttpClient, type HttpClientConfig, type HttpError, type HttpResponse, type IAuthService, type ISessionManager, LocalStorage, LoginCallbackPage, type LoginCallbackPageProps, type LogoutRequest, type LogoutResponse, type MenuItem, NotFoundPage, type Notification, type NotificationContextType, NotificationProvider, type NotificationProviderProps, ProtectedRoute, type ProtectedRouteProps, ReadmeViewer, type RefreshTokenRequest, type RefreshTokenResponse, type RequestConfig, type ResolvedThemeMode, SessionManager, SidebarLayout, type SidebarLayoutProps, type SignInMetadata, type SignInRequest, type SignInResponse, type SignInWithLoginTokenRequest, type Theme, type ThemeContextValue, type ThemeMode, ThemeProvider, ThemeToggle, type User, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens, transition, useNotification, useTheme, zIndex };
|
|
820
|
+
export { AuthService, ConfirmDialog, type ConfirmDialogProps, type ErrorData, type GenerateLoginTokenRequest, type GenerateLoginTokenResponse, HttpClient, type HttpClientConfig, type HttpError, type HttpResponse, type IAuthService, type ISessionManager, LocalStorage, LoginCallbackPage, type LoginCallbackPageProps, type LogoutRequest, type LogoutResponse, type MenuItem, NotFoundPage, type Notification, type NotificationContextType, NotificationProvider, type NotificationProviderProps, ProtectedRoute, type ProtectedRouteProps, ReadmeViewer, type RefreshTokenRequest, type RefreshTokenResponse, type RequestConfig, type ResolvedThemeMode, SessionManager, SidebarHeader, type SidebarHeaderProps, SidebarLayout, type SidebarLayoutProps, type SignInMetadata, type SignInRequest, type SignInResponse, type SignInWithLoginTokenRequest, type Theme, type ThemeContextValue, type ThemeMode, ThemeProvider, ThemeToggle, type User, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens, transition, useNotification, useTheme, zIndex };
|
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
|
|
@@ -261,6 +262,10 @@ interface SidebarLayoutProps {
|
|
|
261
262
|
menuItems: MenuItem[];
|
|
262
263
|
/** Width of the sidebar */
|
|
263
264
|
sidebarWidth?: string | number;
|
|
265
|
+
/** Header component to display at the top of the sidebar */
|
|
266
|
+
header?: ReactNode;
|
|
267
|
+
/** Footer component to display at the bottom of the sidebar */
|
|
268
|
+
footer?: ReactNode;
|
|
264
269
|
/** Additional CSS class for container */
|
|
265
270
|
className?: string;
|
|
266
271
|
/** Default selected menu item ID (for non-router mode) */
|
|
@@ -445,6 +450,20 @@ interface ConfirmDialogProps {
|
|
|
445
450
|
}
|
|
446
451
|
declare const ConfirmDialog: ({ open, title, message, confirmText, cancelText, confirmColor, onConfirm, onCancel, }: ConfirmDialogProps) => react_jsx_runtime.JSX.Element;
|
|
447
452
|
|
|
453
|
+
interface SidebarHeaderProps {
|
|
454
|
+
/** The text to display in the header */
|
|
455
|
+
title: string;
|
|
456
|
+
/** Path for the home button redirection (defaults to "/") */
|
|
457
|
+
homePath?: string;
|
|
458
|
+
/** Whether to show the home button */
|
|
459
|
+
showHome?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* A standardized header component to be used with SidebarLayout.
|
|
463
|
+
* It includes a title and an optional home button that redirects to a specified path.
|
|
464
|
+
*/
|
|
465
|
+
declare const SidebarHeader: React__default.FC<SidebarHeaderProps>;
|
|
466
|
+
|
|
448
467
|
/**
|
|
449
468
|
* Theme mode options
|
|
450
469
|
* - 'light': Always use light theme
|
|
@@ -798,4 +817,4 @@ declare class LocalStorage {
|
|
|
798
817
|
|
|
799
818
|
declare const getHighlighter: () => Promise<Highlighter>;
|
|
800
819
|
|
|
801
|
-
export { AuthService, ConfirmDialog, type ConfirmDialogProps, type ErrorData, type GenerateLoginTokenRequest, type GenerateLoginTokenResponse, HttpClient, type HttpClientConfig, type HttpError, type HttpResponse, type IAuthService, type ISessionManager, LocalStorage, LoginCallbackPage, type LoginCallbackPageProps, type LogoutRequest, type LogoutResponse, type MenuItem, NotFoundPage, type Notification, type NotificationContextType, NotificationProvider, type NotificationProviderProps, ProtectedRoute, type ProtectedRouteProps, ReadmeViewer, type RefreshTokenRequest, type RefreshTokenResponse, type RequestConfig, type ResolvedThemeMode, SessionManager, SidebarLayout, type SidebarLayoutProps, type SignInMetadata, type SignInRequest, type SignInResponse, type SignInWithLoginTokenRequest, type Theme, type ThemeContextValue, type ThemeMode, ThemeProvider, ThemeToggle, type User, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens, transition, useNotification, useTheme, zIndex };
|
|
820
|
+
export { AuthService, ConfirmDialog, type ConfirmDialogProps, type ErrorData, type GenerateLoginTokenRequest, type GenerateLoginTokenResponse, HttpClient, type HttpClientConfig, type HttpError, type HttpResponse, type IAuthService, type ISessionManager, LocalStorage, LoginCallbackPage, type LoginCallbackPageProps, type LogoutRequest, type LogoutResponse, type MenuItem, NotFoundPage, type Notification, type NotificationContextType, NotificationProvider, type NotificationProviderProps, ProtectedRoute, type ProtectedRouteProps, ReadmeViewer, type RefreshTokenRequest, type RefreshTokenResponse, type RequestConfig, type ResolvedThemeMode, SessionManager, SidebarHeader, type SidebarHeaderProps, SidebarLayout, type SidebarLayoutProps, type SignInMetadata, type SignInRequest, type SignInResponse, type SignInWithLoginTokenRequest, type Theme, type ThemeContextValue, type ThemeMode, ThemeProvider, ThemeToggle, type User, borderRadius, cn, darkTheme, debounce, elevation, extractErrorMessage, fontSize, fontWeight, formatDate, getHighlighter, lightTheme, lineHeight, spacing, throttle, tokens, transition, useNotification, useTheme, zIndex };
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var ContentCopyIcon = require('@mui/icons-material/ContentCopy');
|
|
|
14
14
|
var CheckIcon = require('@mui/icons-material/Check');
|
|
15
15
|
var shiki = require('shiki');
|
|
16
16
|
var WarningAmberIcon = require('@mui/icons-material/WarningAmber');
|
|
17
|
+
var HomeIcon = require('@mui/icons-material/Home');
|
|
17
18
|
|
|
18
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
20
|
|
|
@@ -24,6 +25,7 @@ var rehypeKatex__default = /*#__PURE__*/_interopDefault(rehypeKatex);
|
|
|
24
25
|
var ContentCopyIcon__default = /*#__PURE__*/_interopDefault(ContentCopyIcon);
|
|
25
26
|
var CheckIcon__default = /*#__PURE__*/_interopDefault(CheckIcon);
|
|
26
27
|
var WarningAmberIcon__default = /*#__PURE__*/_interopDefault(WarningAmberIcon);
|
|
28
|
+
var HomeIcon__default = /*#__PURE__*/_interopDefault(HomeIcon);
|
|
27
29
|
|
|
28
30
|
var __defProp = Object.defineProperty;
|
|
29
31
|
var __export = (target, all) => {
|
|
@@ -727,12 +729,16 @@ function LoginCallbackPage({ authService, navigateTo = "/", onLoginFailed }) {
|
|
|
727
729
|
}
|
|
728
730
|
|
|
729
731
|
// src/components/ProtectedRoute.tsx
|
|
730
|
-
function ProtectedRoute({ children, sessionManager, loginUrl }) {
|
|
732
|
+
function ProtectedRoute({ children, sessionManager, loginUrl, callbackPath = "/login-callback" }) {
|
|
731
733
|
if (!sessionManager.isAuthenticated()) {
|
|
732
|
-
const callbackUrl = `${window.location.origin}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
const callbackUrl = `${window.location.origin}${callbackPath}`;
|
|
735
|
+
try {
|
|
736
|
+
const url = new URL(loginUrl);
|
|
737
|
+
url.searchParams.set("redirect", callbackUrl);
|
|
738
|
+
window.location.href = url.toString();
|
|
739
|
+
} catch {
|
|
740
|
+
window.location.href = loginUrl;
|
|
741
|
+
}
|
|
736
742
|
return null;
|
|
737
743
|
}
|
|
738
744
|
return children;
|
|
@@ -810,6 +816,8 @@ var flattenMenuRoutes = (items) => {
|
|
|
810
816
|
var SidebarLayoutRouterInner = ({
|
|
811
817
|
menuItems,
|
|
812
818
|
sidebarWidth = 250,
|
|
819
|
+
header,
|
|
820
|
+
footer,
|
|
813
821
|
className = "",
|
|
814
822
|
onMenuChange,
|
|
815
823
|
style,
|
|
@@ -865,7 +873,7 @@ var SidebarLayoutRouterInner = ({
|
|
|
865
873
|
...style
|
|
866
874
|
},
|
|
867
875
|
children: [
|
|
868
|
-
/* @__PURE__ */ jsxRuntime.
|
|
876
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
869
877
|
material.Drawer,
|
|
870
878
|
{
|
|
871
879
|
variant: "permanent",
|
|
@@ -878,18 +886,24 @@ var SidebarLayoutRouterInner = ({
|
|
|
878
886
|
position: "relative",
|
|
879
887
|
borderRight: "1px solid",
|
|
880
888
|
borderColor: "divider",
|
|
889
|
+
display: "flex",
|
|
890
|
+
flexDirection: "column",
|
|
881
891
|
...sidebarStyle
|
|
882
892
|
}
|
|
883
893
|
},
|
|
884
|
-
children:
|
|
885
|
-
|
|
886
|
-
{
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
894
|
+
children: [
|
|
895
|
+
header && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { className: "sidebar-header", children: header }),
|
|
896
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.List, { sx: { p: 0, flexGrow: 1, overflowY: "auto" }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
897
|
+
RouterMenuItem,
|
|
898
|
+
{
|
|
899
|
+
item,
|
|
900
|
+
expanded,
|
|
901
|
+
onToggle: handleToggle
|
|
902
|
+
},
|
|
903
|
+
item.id
|
|
904
|
+
)) }),
|
|
905
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { className: "sidebar-footer", children: footer })
|
|
906
|
+
]
|
|
893
907
|
}
|
|
894
908
|
),
|
|
895
909
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -993,6 +1007,8 @@ var StateMenuItem = ({ item, selectedId, depth = 0, expanded, onToggle, onClick
|
|
|
993
1007
|
var SidebarLayoutWithState = ({
|
|
994
1008
|
menuItems,
|
|
995
1009
|
sidebarWidth = 250,
|
|
1010
|
+
header,
|
|
1011
|
+
footer,
|
|
996
1012
|
className = "",
|
|
997
1013
|
defaultSelected,
|
|
998
1014
|
onMenuChange,
|
|
@@ -1044,7 +1060,7 @@ var SidebarLayoutWithState = ({
|
|
|
1044
1060
|
...style
|
|
1045
1061
|
},
|
|
1046
1062
|
children: [
|
|
1047
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1048
1064
|
material.Drawer,
|
|
1049
1065
|
{
|
|
1050
1066
|
variant: "permanent",
|
|
@@ -1057,20 +1073,26 @@ var SidebarLayoutWithState = ({
|
|
|
1057
1073
|
position: "relative",
|
|
1058
1074
|
borderRight: "1px solid",
|
|
1059
1075
|
borderColor: "divider",
|
|
1076
|
+
display: "flex",
|
|
1077
|
+
flexDirection: "column",
|
|
1060
1078
|
...sidebarStyle
|
|
1061
1079
|
}
|
|
1062
1080
|
},
|
|
1063
|
-
children:
|
|
1064
|
-
|
|
1065
|
-
{
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1081
|
+
children: [
|
|
1082
|
+
header && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { className: "sidebar-header", children: header }),
|
|
1083
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.List, { sx: { p: 0, flexGrow: 1, overflowY: "auto" }, children: menuItems.filter((item) => item.label).map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1084
|
+
StateMenuItem,
|
|
1085
|
+
{
|
|
1086
|
+
item,
|
|
1087
|
+
selectedId,
|
|
1088
|
+
expanded,
|
|
1089
|
+
onToggle: handleToggle,
|
|
1090
|
+
onClick: handleMenuClick
|
|
1091
|
+
},
|
|
1092
|
+
item.id
|
|
1093
|
+
)) }),
|
|
1094
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { className: "sidebar-footer", children: footer })
|
|
1095
|
+
]
|
|
1074
1096
|
}
|
|
1075
1097
|
),
|
|
1076
1098
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1328,6 +1350,16 @@ var ConfirmDialog = ({
|
|
|
1328
1350
|
] })
|
|
1329
1351
|
] });
|
|
1330
1352
|
};
|
|
1353
|
+
var SidebarHeader = ({
|
|
1354
|
+
title,
|
|
1355
|
+
homePath = "/",
|
|
1356
|
+
showHome = true
|
|
1357
|
+
}) => {
|
|
1358
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { padding: "16px", display: "flex", alignItems: "center", borderBottom: "1px solid rgba(255, 255, 255, 0.12)", gap: "8px" }, children: [
|
|
1359
|
+
showHome && /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { component: reactRouterDom.Link, to: homePath, size: "small", sx: { color: "text.primary", ml: -1 }, children: /* @__PURE__ */ jsxRuntime.jsx(HomeIcon__default.default, {}) }),
|
|
1360
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h6", sx: { fontWeight: "bold", color: "primary.main" }, children: title })
|
|
1361
|
+
] });
|
|
1362
|
+
};
|
|
1331
1363
|
|
|
1332
1364
|
// src/utils/cn.ts
|
|
1333
1365
|
function cn(...classes) {
|
|
@@ -1534,6 +1566,7 @@ exports.NotificationProvider = NotificationProvider;
|
|
|
1534
1566
|
exports.ProtectedRoute = ProtectedRoute;
|
|
1535
1567
|
exports.ReadmeViewer = ReadmeViewer_default;
|
|
1536
1568
|
exports.SessionManager = SessionManager;
|
|
1569
|
+
exports.SidebarHeader = SidebarHeader;
|
|
1537
1570
|
exports.SidebarLayout = SidebarLayout;
|
|
1538
1571
|
exports.ThemeProvider = ThemeProvider;
|
|
1539
1572
|
exports.ThemeToggle = ThemeToggle;
|