@pagamio/frontend-commons-lib 0.8.198 → 0.8.200

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.
@@ -1,13 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Sidebar, TextInput } from 'flowbite-react';
3
- import { HiSearch } from 'react-icons/hi';
2
+ import { Sidebar } from 'flowbite-react';
4
3
  import { twMerge } from 'tailwind-merge';
5
4
  import React, { useEffect, useState } from 'react';
6
5
  import { useAppSidebarContext } from '../../context';
7
6
  import { useLibTranslations, useTranslation } from '../../translations';
8
7
  const AppSidebarMenu = () => {
9
8
  const { pages } = useAppSidebarContext();
10
- return (_jsx(Sidebar.Items, { children: _jsx(Sidebar.ItemGroup, { className: "mt-0 border-t-0 pb-1 pt-0", children: pages.map((item) => (_jsx(AppSidebarItem, { ...item }, item.label))) }) }));
9
+ return (_jsx(Sidebar.Items, { children: pages.map((section, index) => (_jsx(Sidebar.ItemGroup, { className: twMerge('mt-0 pb-2 pt-0', index > 0 && 'border-t border-gray-200 dark:border-gray-700 pt-4 mt-4'), children: section.items?.map((item) => _jsx(AppSidebarItem, { ...item }, item.label)) }, section.label || index))) }));
11
10
  };
12
11
  const AppSidebarItem = ({ href, target, icon, label, items, badge, forceDropdown }) => {
13
12
  const { pathname, linkComponent: Link } = useAppSidebarContext();
@@ -27,6 +26,10 @@ const AppSidebarItem = ({ href, target, icon, label, items, badge, forceDropdown
27
26
  // If there's exactly one item, render it as a direct link instead of a dropdown
28
27
  if (items?.length === 1 && !forceDropdown) {
29
28
  const singleItem = items[0];
29
+ if (!singleItem.href) {
30
+ // If single item has no href, render without link
31
+ return (_jsx(Sidebar.Item, { icon: icon, label: badge && t(badge), className: twMerge('text-gray-600 cursor-default', 'dark:text-gray-400'), children: t(label) }));
32
+ }
30
33
  return (_jsx(Sidebar.Item, { as: Link, href: singleItem.href, target: target, icon: icon, label: badge && t(badge), className: twMerge('text-gray-600 hover:text-primary-700 hover:bg-primary-50/70', 'dark:text-gray-400 dark:hover:text-primary-300 dark:hover:bg-primary-900/30', pathname === singleItem.href &&
31
34
  'text-primary-700 bg-primary-100/80 hover:bg-primary-100/80 dark:text-primary-300 dark:bg-primary-900/40 dark:hover:bg-primary-900/40'), children: t(label) }));
32
35
  }
@@ -40,25 +43,30 @@ const AppSidebarItem = ({ href, target, icon, label, items, badge, forceDropdown
40
43
  !hasActiveChild(items) &&
41
44
  'text-primary-700 bg-primary-100/80 hover:bg-primary-100/80 dark:text-primary-300 dark:bg-primary-900/40 dark:hover:bg-primary-900/40'), theme: { list: 'space-y-2 py-2 [&>li>div]:w-full' }, children: items.map((child) => (_jsx(React.Fragment, { children: child.items?.length ? (
42
45
  // Recursively render nested items
43
- _jsx("div", { className: "pl-3", children: _jsx(AppSidebarItem, { ...child }) })) : (
44
- // Render leaf item
46
+ _jsx("div", { className: "pl-3", children: _jsx(AppSidebarItem, { ...child }) })) : child.href ? (
47
+ // Render leaf item with link
45
48
  _jsx(Sidebar.Item, { as: Link, href: child.href, target: child.target, icon: child.icon, className: twMerge('justify-center [&>*]:font-normal', 'text-gray-600 hover:text-primary-700 hover:bg-primary-50/70', 'dark:text-gray-400 dark:hover:text-primary-300 dark:hover:bg-primary-900/30', pathname === child.href &&
46
- 'text-primary-700 bg-primary-100/80 hover:bg-primary-100/80 dark:text-primary-300 dark:bg-primary-900/40 dark:hover:bg-primary-900/40'), children: t(child.label) })) }, child.label))) }));
49
+ 'text-primary-700 bg-primary-100/80 hover:bg-primary-100/80 dark:text-primary-300 dark:bg-primary-900/40 dark:hover:bg-primary-900/40'), children: t(child.label) })) : (
50
+ // Render leaf item without link
51
+ _jsx(Sidebar.Item, { icon: child.icon, className: twMerge('justify-center [&>*]:font-normal', 'text-gray-600 cursor-default', 'dark:text-gray-400'), children: t(child.label) })) }, child.label))) }));
47
52
  }
48
53
  // Render leaf item
54
+ // If no href, render as a non-link item
55
+ if (!href) {
56
+ return (_jsx(Sidebar.Item, { icon: icon, label: badge && t(badge), className: twMerge('text-gray-600 hover:text-primary-700 hover:bg-primary-50/70', 'dark:text-gray-400 dark:hover:text-primary-300 dark:hover:bg-primary-900/30', 'cursor-default'), children: t(label) }));
57
+ }
49
58
  return (_jsx(Sidebar.Item, { as: Link, href: href, target: target, icon: icon, label: badge && t(badge), className: twMerge('text-gray-600 hover:text-primary-700 hover:bg-primary-50/70', 'dark:text-gray-400 dark:hover:text-primary-300 dark:hover:bg-primary-900/30', isParentActive &&
50
59
  'text-primary-700 bg-primary-100/80 hover:bg-primary-100/80 dark:text-primary-300 dark:bg-primary-900/40 dark:hover:bg-primary-900/40'), children: t(label) }));
51
60
  };
52
61
  const AppMobileSidebar = () => {
53
- const { mobile: { isOpen, close }, sidebarHeader, } = useAppSidebarContext();
62
+ const { mobile: { isOpen, close }, sidebarHeader, sidebarFooter, } = useAppSidebarContext();
54
63
  const { t } = useTranslation();
55
- const { tLib } = useLibTranslations();
56
64
  if (!isOpen)
57
65
  return null;
58
- return (_jsxs(_Fragment, { children: [_jsx(Sidebar, { "aria-label": t('sidebar.mobileAriaLabel', 'Sidebar with multi-level dropdown example'), className: twMerge('fixed inset-y-0 left-0 z-20 hidden h-full shrink-0 flex-col border-r border-gray-200 pt-16 dark:border-gray-700 md:flex', isOpen && 'flex'), id: "sidebar", children: _jsx("div", { className: "flex h-full flex-col justify-between", children: _jsxs("div", { className: "py-2", children: [sidebarHeader && _jsx("div", { className: "mb-4 px-3", children: sidebarHeader }), _jsx("form", { className: "pb-3", children: _jsx(TextInput, { icon: HiSearch, type: "search", placeholder: tLib('sidebar.searchPlaceholder', 'Search'), required: true, size: 32 }) }), _jsx(AppSidebarMenu, {})] }) }) }), _jsx("div", { onClick: close, "aria-hidden": "true", className: "fixed inset-0 z-10 h-full w-full bg-gray-900/50 pt-16 dark:bg-gray-900/90" })] }));
66
+ return (_jsxs(_Fragment, { children: [_jsx(Sidebar, { "aria-label": t('sidebar.mobileAriaLabel', 'Sidebar with multi-level dropdown example'), className: twMerge('fixed inset-y-0 left-0 z-20 hidden h-full shrink-0 flex-col border-r border-gray-200 pt-16 dark:border-gray-700 md:flex', isOpen && 'flex'), id: "sidebar", children: _jsxs("div", { className: "flex h-full flex-col justify-between", children: [_jsxs("div", { className: "flex-1 overflow-y-auto py-2", children: [sidebarHeader && _jsx("div", { className: "mb-4 px-3", children: sidebarHeader }), _jsx("div", { className: "px-3", children: _jsx(AppSidebarMenu, {}) })] }), sidebarFooter && _jsx("div", { className: "border-t border-gray-200 dark:border-gray-700 p-3", children: sidebarFooter })] }) }), _jsx("div", { onClick: close, "aria-hidden": "true", className: "fixed inset-0 z-10 h-full w-full bg-gray-900/50 pt-16 dark:bg-gray-900/90" })] }));
59
67
  };
60
68
  const AppDesktopSidebar = () => {
61
- const { desktop: { isCollapsed, setCollapsed }, sidebarHeader, } = useAppSidebarContext();
69
+ const { desktop: { isCollapsed, setCollapsed }, sidebarHeader, sidebarFooter, } = useAppSidebarContext();
62
70
  const [isPreview, setIsPreview] = useState(isCollapsed);
63
71
  const { tLib } = useLibTranslations();
64
72
  useEffect(() => {
@@ -78,7 +86,7 @@ const AppDesktopSidebar = () => {
78
86
  setCollapsed(true);
79
87
  },
80
88
  };
81
- return (_jsx(Sidebar, { onMouseEnter: preview.enable, onMouseLeave: preview.disable, "aria-label": tLib('sidebar.desktopAriaLabel', 'Sidebar with multi-level dropdown example'), collapsed: isCollapsed, className: twMerge('fixed inset-y-0 left-0 z-20 flex h-full shrink-0 flex-col border-r border-gray-200 pt-16 duration-75 dark:border-gray-700', isCollapsed && 'hidden w-16'), id: "sidebar", children: _jsx("div", { className: "flex h-full flex-col justify-between", children: _jsxs("div", { className: "py-2", children: [sidebarHeader && _jsx("div", { className: "mb-4 px-3", children: sidebarHeader }), _jsx(AppSidebarMenu, {})] }) }) }));
89
+ return (_jsx(Sidebar, { onMouseEnter: preview.enable, onMouseLeave: preview.disable, "aria-label": tLib('sidebar.desktopAriaLabel', 'Sidebar with multi-level dropdown example'), collapsed: isCollapsed, className: twMerge('fixed inset-y-0 left-0 z-20 flex h-full shrink-0 flex-col border-r border-gray-200 pt-16 duration-75 dark:border-gray-700 bg-white dark:bg-gray-900', isCollapsed && 'hidden w-16'), id: "sidebar", children: _jsxs("div", { className: "flex h-full flex-col justify-between", children: [_jsxs("div", { className: "flex-1 overflow-y-auto py-2", children: [sidebarHeader && _jsx("div", { className: "mb-4 px-3", children: sidebarHeader }), _jsx("div", { className: "px-2", children: _jsx(AppSidebarMenu, {}) })] }), sidebarFooter && _jsx("div", { className: "border-t border-gray-200 dark:border-gray-700 p-3", children: sidebarFooter })] }) }));
82
90
  };
83
91
  const AppDashboardSidebar = () => {
84
92
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: "md:hidden", children: _jsx(AppMobileSidebar, {}) }), _jsx("div", { className: "hidden md:block", children: _jsx(AppDesktopSidebar, {}) })] }));
@@ -15,10 +15,11 @@ interface AppSidebarPageItem {
15
15
  * @interface AppSidebarContextProps
16
16
  * @property {Object} desktop - Desktop sidebar state and controls
17
17
  * @property {Object} mobile - Mobile sidebar state and controls
18
- * @property {AppSidebarPageItem[]} pages - Array of sidebar page items
18
+ * @property {AppSidebarPageItem[]} pages - Array of sidebar section items (each section has items property)
19
19
  * @property {string} pathname - Current route pathname
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
+ * @property {React.ReactNode} sidebarFooter - Optional custom footer to render at bottom of sidebar
22
23
  */
23
24
  interface AppSidebarContextProps {
24
25
  desktop: {
@@ -35,16 +36,18 @@ interface AppSidebarContextProps {
35
36
  pathname: string;
36
37
  linkComponent: React.ElementType;
37
38
  sidebarHeader?: React.ReactNode;
39
+ sidebarFooter?: React.ReactNode;
38
40
  }
39
41
  /**
40
42
  * Props for the AppSidebarProvider component
41
43
  * @interface AppSidebarProviderProps
42
44
  * @property {boolean} initialCollapsed - Initial collapsed state of desktop sidebar
43
- * @property {AppSidebarPageItem[]} pages - Array of sidebar page items
45
+ * @property {AppSidebarPageItem[]} pages - Array of sidebar section items (each section has items property)
44
46
  * @property {string} pathname - Current route pathname
45
47
  * @property {React.ElementType} linkComponent - Component used for navigation links
46
48
  * @property {ReactNode} children - Child components
47
49
  * @property {React.ReactNode} sidebarHeader - Optional custom header to render at top of sidebar
50
+ * @property {React.ReactNode} sidebarFooter - Optional custom footer to render at bottom of sidebar
48
51
  */
49
52
  interface AppSidebarProviderProps extends PropsWithChildren {
50
53
  initialCollapsed: boolean;
@@ -52,12 +55,13 @@ interface AppSidebarProviderProps extends PropsWithChildren {
52
55
  pathname: string;
53
56
  linkComponent: React.ElementType;
54
57
  sidebarHeader?: React.ReactNode;
58
+ sidebarFooter?: React.ReactNode;
55
59
  }
56
60
  /**
57
61
  * Provider component for sidebar state management
58
62
  * @param {AppSidebarProviderProps} props - Component props
59
63
  */
60
- declare const AppSidebarProvider: ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, }: AppSidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
64
+ declare const AppSidebarProvider: ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, }: AppSidebarProviderProps) => import("react/jsx-runtime").JSX.Element;
61
65
  /**
62
66
  * Hook for accessing sidebar context
63
67
  * @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, }) => {
11
+ const AppSidebarProvider = ({ initialCollapsed, children, pages, pathname, linkComponent, sidebarHeader, sidebarFooter, }) => {
12
12
  const [isOpenMobile, setIsOpenMobile] = useState(false);
13
13
  const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);
14
14
  function handleSetCollapsed(value) {
@@ -29,7 +29,8 @@ const AppSidebarProvider = ({ initialCollapsed, children, pages, pathname, linkC
29
29
  pathname,
30
30
  linkComponent,
31
31
  sidebarHeader,
32
- }), [isCollapsed, isOpenMobile, pages, pathname, linkComponent, sidebarHeader]);
32
+ sidebarFooter,
33
+ }), [isCollapsed, isOpenMobile, pages, pathname, linkComponent, sidebarHeader, sidebarFooter]);
33
34
  return _jsx(AppSidebarContext.Provider, { value: value, children: children });
34
35
  };
35
36
  /**
package/lib/styles.css CHANGED
@@ -2208,9 +2208,6 @@ input[type="range"]::-ms-fill-lower {
2208
2208
  .border-t {
2209
2209
  border-top-width: 1px;
2210
2210
  }
2211
- .border-t-0 {
2212
- border-top-width: 0px;
2213
- }
2214
2211
  .border-t-4 {
2215
2212
  border-top-width: 4px;
2216
2213
  }
@@ -2923,8 +2920,8 @@ input[type="range"]::-ms-fill-lower {
2923
2920
  .pb-0 {
2924
2921
  padding-bottom: 0px;
2925
2922
  }
2926
- .pb-1 {
2927
- padding-bottom: 0.25rem;
2923
+ .pb-2 {
2924
+ padding-bottom: 0.5rem;
2928
2925
  }
2929
2926
  .pb-2\.5 {
2930
2927
  padding-bottom: 0.625rem;
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.198",
4
+ "version": "0.8.200",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false