@pagamio/frontend-commons-lib 0.8.207 → 0.8.208
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.
|
@@ -5,8 +5,13 @@ import React, { useEffect, useState } from 'react';
|
|
|
5
5
|
import { useAppSidebarContext } from '../../context';
|
|
6
6
|
import { useLibTranslations, useTranslation } from '../../translations';
|
|
7
7
|
const AppSidebarMenu = () => {
|
|
8
|
-
const { pages } = useAppSidebarContext();
|
|
9
|
-
|
|
8
|
+
const { pages, groupByItem } = useAppSidebarContext();
|
|
9
|
+
// If groupByItem is true each item gets its own ItemGroup
|
|
10
|
+
if (groupByItem) {
|
|
11
|
+
return (_jsx(Sidebar.Items, { children: pages.map((item) => (_jsx(Sidebar.ItemGroup, { children: _jsx(AppSidebarItem, { ...item }) }, item.label))) }));
|
|
12
|
+
}
|
|
13
|
+
// Default behavior all items in one ItemGroup
|
|
14
|
+
return (_jsx(Sidebar.Items, { children: _jsx(Sidebar.ItemGroup, { children: pages.map((item) => (_jsx(AppSidebarItem, { ...item }, item.label))) }) }));
|
|
10
15
|
};
|
|
11
16
|
const AppSidebarItem = ({ href, target, icon, label, items, badge, forceDropdown }) => {
|
|
12
17
|
const { pathname, linkComponent: Link } = useAppSidebarContext();
|
|
@@ -20,6 +20,7 @@ interface AppSidebarPageItem {
|
|
|
20
20
|
* @property {React.ElementType} linkComponent - Component used for navigation links
|
|
21
21
|
* @property {React.ReactNode} sidebarHeader - Optional custom header to render at top of sidebar
|
|
22
22
|
* @property {React.ReactNode} sidebarFooter - Optional custom footer to render at bottom of sidebar
|
|
23
|
+
* @property {boolean} groupByItem - If true, each sidebar item gets its own ItemGroup. If false, all items share one ItemGroup.
|
|
23
24
|
*/
|
|
24
25
|
interface AppSidebarContextProps {
|
|
25
26
|
desktop: {
|
|
@@ -37,6 +38,7 @@ interface AppSidebarContextProps {
|
|
|
37
38
|
linkComponent: React.ElementType;
|
|
38
39
|
sidebarHeader?: React.ReactNode;
|
|
39
40
|
sidebarFooter?: React.ReactNode;
|
|
41
|
+
groupByItem?: boolean;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Props for the AppSidebarProvider component
|
|
@@ -48,6 +50,7 @@ interface AppSidebarContextProps {
|
|
|
48
50
|
* @property {ReactNode} children - Child components
|
|
49
51
|
* @property {React.ReactNode} sidebarHeader - Optional custom header to render at top of sidebar
|
|
50
52
|
* @property {React.ReactNode} sidebarFooter - Optional custom footer to render at bottom of sidebar
|
|
53
|
+
* @property {boolean} groupByItem - If true, each sidebar item gets its own ItemGroup. If false (default), all items share one ItemGroup.
|
|
51
54
|
*/
|
|
52
55
|
interface AppSidebarProviderProps extends PropsWithChildren {
|
|
53
56
|
initialCollapsed: boolean;
|
|
@@ -56,12 +59,13 @@ interface AppSidebarProviderProps extends PropsWithChildren {
|
|
|
56
59
|
linkComponent: React.ElementType;
|
|
57
60
|
sidebarHeader?: React.ReactNode;
|
|
58
61
|
sidebarFooter?: React.ReactNode;
|
|
62
|
+
groupByItem?: boolean;
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
65
|
* Provider component for sidebar state management
|
|
62
66
|
* @param {AppSidebarProviderProps} props - Component props
|
|
63
67
|
*/
|
|
64
|
-
declare const AppSidebarProvider: ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, }: AppSidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
declare const AppSidebarProvider: ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, groupByItem, }: AppSidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
65
69
|
/**
|
|
66
70
|
* Hook for accessing sidebar context
|
|
67
71
|
* @throws {Error} When used outside AppSidebarProvider
|
|
@@ -8,7 +8,7 @@ const AppSidebarContext = createContext(null);
|
|
|
8
8
|
* Provider component for sidebar state management
|
|
9
9
|
* @param {AppSidebarProviderProps} props - Component props
|
|
10
10
|
*/
|
|
11
|
-
const AppSidebarProvider = ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, }) => {
|
|
11
|
+
const AppSidebarProvider = ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, groupByItem = false, }) => {
|
|
12
12
|
const [isOpenMobile, setIsOpenMobile] = useState(false);
|
|
13
13
|
const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);
|
|
14
14
|
function handleSetCollapsed(value) {
|
|
@@ -30,7 +30,8 @@ const AppSidebarProvider = ({ initialCollapsed, children, pages, pathname, linkC
|
|
|
30
30
|
linkComponent,
|
|
31
31
|
sidebarHeader,
|
|
32
32
|
sidebarFooter,
|
|
33
|
-
|
|
33
|
+
groupByItem,
|
|
34
|
+
}), [isCollapsed, isOpenMobile, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, groupByItem]);
|
|
34
35
|
return _jsx(AppSidebarContext.Provider, { value: value, children: children });
|
|
35
36
|
};
|
|
36
37
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.208",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|