@grasp-labs/ds-react-components 0.16.0 → 0.18.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.
- package/dist/components/{menu/Menu.d.ts → sidebar/Sidebar.d.ts} +17 -17
- package/dist/components/{menu/MenuEntry.d.ts → sidebar/SidebarEntry.d.ts} +18 -18
- package/dist/components/sidebar/index.d.ts +11 -0
- package/dist/{index-Kt3P7VYT.js → index-B-Odpfhq.js} +502 -502
- package/dist/index.d.ts +1 -1
- package/dist/{index.esm-CbCRZkhP.js → index.esm-Dvqs323u.js} +1 -1
- package/dist/index.js +20 -20
- package/package.json +1 -1
- package/dist/components/menu/MenuFooter.d.ts +0 -23
- package/dist/components/menu/index.d.ts +0 -11
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { JSX, ReactElement, ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* Represents a single route in the
|
|
3
|
+
* Represents a single route in the sidebar.
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type SidebarRoute = {
|
|
6
6
|
/** Unique path of the route, used as key and for navigation */
|
|
7
7
|
path: string;
|
|
8
|
-
/** Display title of the
|
|
8
|
+
/** Display title of the sidebar item */
|
|
9
9
|
title: string;
|
|
10
10
|
/** Optional icon element to render next to the title */
|
|
11
11
|
icon?: ReactNode;
|
|
12
12
|
/** Nested children entries for submenus */
|
|
13
|
-
children?:
|
|
13
|
+
children?: SidebarRoute[];
|
|
14
14
|
/** Permissions required to display this route */
|
|
15
15
|
permissions?: string[];
|
|
16
|
-
/** Whether this route should be hidden from the
|
|
17
|
-
|
|
16
|
+
/** Whether this route should be hidden from the sidebar */
|
|
17
|
+
isHidden?: boolean;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Props for the `
|
|
20
|
+
* Props for the `Sidebar` component.
|
|
21
21
|
*/
|
|
22
|
-
export type
|
|
23
|
-
/** React element to display as the
|
|
22
|
+
export type SidebarProps = {
|
|
23
|
+
/** React element to display as the sidebar logo (e.g. an SVG component or img element) */
|
|
24
24
|
logo: ReactElement;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/** Array of routes to display in the
|
|
28
|
-
routes:
|
|
25
|
+
/** Content to display in the footer */
|
|
26
|
+
footerContent: React.ReactNode;
|
|
27
|
+
/** Array of routes to display in the sidebar */
|
|
28
|
+
routes: SidebarRoute[];
|
|
29
29
|
/** Current user permissions used to filter routes */
|
|
30
30
|
permissions?: string[];
|
|
31
31
|
/** Optional additional class names for styling */
|
|
32
32
|
className?: string;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
* `
|
|
35
|
+
* `Sidebar` is a vertical navigation component that displays a header with a logo,
|
|
36
36
|
* a list of navigable entries (filtered by permissions), and a footer.
|
|
37
37
|
*
|
|
38
38
|
* @example
|
|
39
39
|
* ```tsx
|
|
40
|
-
* <
|
|
40
|
+
* <Sidebar
|
|
41
41
|
* logo={<MyLogo />}
|
|
42
|
-
*
|
|
42
|
+
* footerContent="© 2025 My Company"
|
|
43
43
|
* routes={[
|
|
44
44
|
* { path: "/dashboard", title: "Dashboard", icon: <DashboardIcon /> },
|
|
45
45
|
* { path: "/settings", title: "Settings", icon: <SettingsIcon />, permissions: ["admin"] }
|
|
@@ -48,4 +48,4 @@ export type MenuProps = {
|
|
|
48
48
|
* />
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export declare const
|
|
51
|
+
export declare const Sidebar: ({ logo, footerContent, routes, permissions, className, }: SidebarProps) => JSX.Element;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { JSX, ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* Represents a child route/entry in the
|
|
3
|
+
* Represents a child route/entry in the sidebar hierarchy.
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type SidebarChild = {
|
|
6
6
|
/** Unique path of the child entry (if navigable) */
|
|
7
7
|
path?: string;
|
|
8
|
-
/** Display title of the
|
|
8
|
+
/** Display title of the sidebar item */
|
|
9
9
|
title: string;
|
|
10
|
-
/** Optional icon for the
|
|
10
|
+
/** Optional icon for the sidebar item */
|
|
11
11
|
icon?: ReactNode;
|
|
12
12
|
/** Nested children for submenus */
|
|
13
|
-
children?:
|
|
13
|
+
children?: SidebarChild[];
|
|
14
14
|
/** Required permissions for the entry */
|
|
15
15
|
permissions?: string[];
|
|
16
|
-
/** Whether this entry should be hidden from the
|
|
17
|
-
|
|
16
|
+
/** Whether this entry should be hidden from the sidebar */
|
|
17
|
+
isHidden?: boolean;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Props for the `
|
|
20
|
+
* Props for the `SidebarEntry` component.
|
|
21
21
|
*/
|
|
22
|
-
export type
|
|
22
|
+
export type SidebarEntryProps = {
|
|
23
23
|
/** Icon to display before the title */
|
|
24
24
|
icon?: ReactNode;
|
|
25
|
-
/** Title text of the
|
|
25
|
+
/** Title text of the sidebar item */
|
|
26
26
|
title: string;
|
|
27
27
|
/** Path used for navigation when clicked (ignored if it has children) */
|
|
28
28
|
path?: string;
|
|
29
|
-
/** Nested children
|
|
30
|
-
childrenEntries?:
|
|
29
|
+
/** Nested children sidebar entries */
|
|
30
|
+
childrenEntries?: SidebarChild[];
|
|
31
31
|
/** Current user permissions for filtering children */
|
|
32
32
|
permissions?: string[];
|
|
33
33
|
/** The currently active path to highlight the entry */
|
|
@@ -40,15 +40,15 @@ export type MenuEntryProps = {
|
|
|
40
40
|
depth?: number;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
|
-
* `
|
|
43
|
+
* `SidebarEntry` renders a single sidebar item.
|
|
44
44
|
*
|
|
45
45
|
* - If the entry has children, it can expand/collapse to reveal them.
|
|
46
46
|
* - If it has a `path`, clicking navigates to that path via `onNavigate`.
|
|
47
|
-
* - Entries are filtered by `permissions` and `
|
|
47
|
+
* - Entries are filtered by `permissions` and `isHidden` before rendering.
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
50
|
* ```tsx
|
|
51
|
-
* <
|
|
51
|
+
* <SidebarEntry
|
|
52
52
|
* title="Settings"
|
|
53
53
|
* path="/settings"
|
|
54
54
|
* icon={<SettingsIcon />}
|
|
@@ -56,7 +56,7 @@ export type MenuEntryProps = {
|
|
|
56
56
|
* onNavigate={(path) => console.log("Navigate to:", path)}
|
|
57
57
|
* />
|
|
58
58
|
*
|
|
59
|
-
* <
|
|
59
|
+
* <SidebarEntry
|
|
60
60
|
* title="Admin"
|
|
61
61
|
* icon={<AdminIcon />}
|
|
62
62
|
* childrenEntries={[
|
|
@@ -69,5 +69,5 @@ export type MenuEntryProps = {
|
|
|
69
69
|
* />
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
declare const
|
|
73
|
-
export default
|
|
72
|
+
declare const SidebarEntry: ({ icon, title, path, childrenEntries, permissions, className, activePath, onNavigate, depth, }: SidebarEntryProps) => JSX.Element;
|
|
73
|
+
export default SidebarEntry;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel exports for the Sidebar system.
|
|
3
|
+
* Allows importing the main Sidebar component.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* import { Sidebar } from "@/components/Sidebar";
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export { Sidebar } from './Sidebar';
|
|
11
|
+
export type { SidebarProps, SidebarRoute } from './Sidebar';
|