eai-frontend-components 2.0.5 → 2.0.7

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.
Files changed (104) hide show
  1. package/dist/index.esm.js +2 -2
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/package.json +3 -3
  6. package/src/components/ui/accordion.tsx +0 -48
  7. package/src/components/ui/alert-dialog.tsx +0 -138
  8. package/src/components/ui/alert.tsx +0 -36
  9. package/src/components/ui/avatar.tsx +0 -48
  10. package/src/components/ui/badge.tsx +0 -35
  11. package/src/components/ui/breadcrumb.tsx +0 -115
  12. package/src/components/ui/button.tsx +0 -43
  13. package/src/components/ui/calendar.tsx +0 -142
  14. package/src/components/ui/card.tsx +0 -35
  15. package/src/components/ui/carousel.tsx +0 -257
  16. package/src/components/ui/chart.tsx +0 -363
  17. package/src/components/ui/checkbox.tsx +0 -26
  18. package/src/components/ui/collapsible.tsx +0 -9
  19. package/src/components/ui/command.tsx +0 -145
  20. package/src/components/ui/context-menu.tsx +0 -198
  21. package/src/components/ui/custom/date-picker.tsx +0 -97
  22. package/src/components/ui/custom/form/checkbox.tsx +0 -53
  23. package/src/components/ui/custom/form/color.tsx +0 -140
  24. package/src/components/ui/custom/form/combobox.tsx +0 -259
  25. package/src/components/ui/custom/form/cpf-cnpj.tsx +0 -85
  26. package/src/components/ui/custom/form/currency.tsx +0 -51
  27. package/src/components/ui/custom/form/date-range.tsx +0 -110
  28. package/src/components/ui/custom/form/date.tsx +0 -109
  29. package/src/components/ui/custom/form/decimal.tsx +0 -50
  30. package/src/components/ui/custom/form/file.tsx +0 -65
  31. package/src/components/ui/custom/form/form-help-text.tsx +0 -20
  32. package/src/components/ui/custom/form/form-label.tsx +0 -24
  33. package/src/components/ui/custom/form/form-message.tsx +0 -10
  34. package/src/components/ui/custom/form/ghost.tsx +0 -28
  35. package/src/components/ui/custom/form/input.tsx +0 -69
  36. package/src/components/ui/custom/form/mask.tsx +0 -78
  37. package/src/components/ui/custom/form/multi-select.tsx +0 -209
  38. package/src/components/ui/custom/form/password.tsx +0 -70
  39. package/src/components/ui/custom/form/percent.tsx +0 -52
  40. package/src/components/ui/custom/form/phone.tsx +0 -79
  41. package/src/components/ui/custom/form/radio-group.tsx +0 -94
  42. package/src/components/ui/custom/form/select.tsx +0 -62
  43. package/src/components/ui/custom/form/step-new-form.tsx +0 -49
  44. package/src/components/ui/custom/form/switch.tsx +0 -51
  45. package/src/components/ui/custom/form/text.tsx +0 -71
  46. package/src/components/ui/custom/form/textarea.tsx +0 -71
  47. package/src/components/ui/custom/form/utils.ts +0 -100
  48. package/src/components/ui/custom/header.tsx +0 -128
  49. package/src/components/ui/custom/label.tsx +0 -79
  50. package/src/components/ui/custom/not-found.tsx +0 -30
  51. package/src/components/ui/custom/sidebar/module-switcher.tsx +0 -58
  52. package/src/components/ui/custom/sidebar/nav-footer.tsx +0 -35
  53. package/src/components/ui/custom/sidebar/nav-main.tsx +0 -64
  54. package/src/components/ui/custom/sidebar/nav-submenu-collapsible.tsx +0 -60
  55. package/src/components/ui/custom/sidebar/nav-submenu-dropdown.tsx +0 -56
  56. package/src/components/ui/custom/sidebar/nav-user.tsx +0 -77
  57. package/src/components/ui/custom/sidebar/sidebar-button.tsx +0 -30
  58. package/src/components/ui/custom/sidebar/sidebar-item-two-lines.tsx +0 -25
  59. package/src/components/ui/custom/sidebar/sidebar-item.tsx +0 -19
  60. package/src/components/ui/custom/sidebar/types/sidebar.ts +0 -31
  61. package/src/components/ui/custom/table/data-table-export.tsx +0 -126
  62. package/src/components/ui/custom/table/data-table-footer.tsx +0 -148
  63. package/src/components/ui/custom/table/data-table-header.tsx +0 -58
  64. package/src/components/ui/custom/table/data-table-rows.tsx +0 -94
  65. package/src/components/ui/custom/table/data-table.tsx +0 -285
  66. package/src/components/ui/custom/table/types/data-table.ts +0 -31
  67. package/src/components/ui/custom/theme-provider.tsx +0 -121
  68. package/src/components/ui/dateRangePicker.tsx +0 -63
  69. package/src/components/ui/dialog.tsx +0 -84
  70. package/src/components/ui/drawer.tsx +0 -116
  71. package/src/components/ui/dropdown-menu.tsx +0 -173
  72. package/src/components/ui/form.tsx +0 -114
  73. package/src/components/ui/hover-card.tsx +0 -27
  74. package/src/components/ui/input.tsx +0 -265
  75. package/src/components/ui/label.tsx +0 -15
  76. package/src/components/ui/masks.ts +0 -35
  77. package/src/components/ui/pagination.tsx +0 -78
  78. package/src/components/ui/popover.tsx +0 -32
  79. package/src/components/ui/progress.tsx +0 -22
  80. package/src/components/ui/radio-group.tsx +0 -36
  81. package/src/components/ui/scroll-area.tsx +0 -46
  82. package/src/components/ui/select.tsx +0 -130
  83. package/src/components/ui/separator.tsx +0 -29
  84. package/src/components/ui/sheet.tsx +0 -90
  85. package/src/components/ui/sidebar.tsx +0 -598
  86. package/src/components/ui/skeleton.tsx +0 -15
  87. package/src/components/ui/slider.tsx +0 -18
  88. package/src/components/ui/switch.tsx +0 -26
  89. package/src/components/ui/table.tsx +0 -53
  90. package/src/components/ui/tabs.tsx +0 -47
  91. package/src/components/ui/textarea.tsx +0 -27
  92. package/src/components/ui/toast.tsx +0 -88
  93. package/src/components/ui/toaster.tsx +0 -49
  94. package/src/components/ui/tooltip.tsx +0 -31
  95. package/src/components/ui/use-calendar.tsx +0 -61
  96. package/src/components/ui/use-toast.ts +0 -186
  97. package/src/hooks/use-mobile.tsx +0 -19
  98. package/src/index.ts +0 -299
  99. package/src/lib/help/date-utils.ts +0 -41
  100. package/src/lib/help/format.ts +0 -171
  101. package/src/lib/help/theme.ts +0 -346
  102. package/src/lib/help/uuid.ts +0 -4
  103. package/src/lib/utils.ts +0 -6
  104. package/src/styles/globals.css +0 -59
@@ -1,128 +0,0 @@
1
- import { ReactNode, useEffect, useRef } from 'react';
2
- import { useNavigate } from 'react-router-dom';
3
- import LoadingBar, { LoadingBarRef } from 'react-top-loading-bar';
4
- import { getTailwindColorShades, TailwindColorName } from '../../../lib/help/theme';
5
- import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '../breadcrumb';
6
- import { SidebarTrigger } from '../sidebar';
7
- import { Module, SidebarPage } from './sidebar/types/sidebar';
8
- import { DEFAULT_THEME_DATA, useTheme } from './theme-provider';
9
-
10
- const Header = ({
11
- splittedPath,
12
- modules,
13
- pages,
14
- isLoading,
15
- combobox,
16
- }: { splittedPath: string[]; modules: Module[]; pages: SidebarPage[]; isLoading: boolean; combobox: ReactNode }) => {
17
- const { portalDefinitions } = useTheme();
18
- const navigate = useNavigate();
19
- const refProgressLoading = useRef<LoadingBarRef>(null);
20
- const lastPage = splittedPath[splittedPath.length - 1];
21
-
22
- useEffect(() => {
23
- isLoading ? refProgressLoading.current?.start() : refProgressLoading.current?.complete();
24
- }, [isLoading]);
25
-
26
- const setRouter = (path: string) => {
27
- navigate(path);
28
- };
29
-
30
- const getPath = (index: number) => {
31
- let path = '';
32
-
33
- for (let i = 0; i <= index; i++) {
34
- path += `/${splittedPath[i]}`;
35
- }
36
-
37
- return path;
38
- };
39
-
40
- const getLinkSidebar = (index: number) => {
41
- return pages.find((item) => item.path === getPath(index));
42
- };
43
-
44
- const getSubMenuItem = (index: number) => {
45
- return pages.flatMap((item) => item.subMenuItems || []).find((sub) => sub.path === getPath(index));
46
- };
47
-
48
- const getModule = (page: string) => {
49
- const module = modules.find((mod) => mod.value === page);
50
- if (!module) {
51
- return page;
52
- }
53
-
54
- return module?.title;
55
- };
56
-
57
- const getTitle = (index: number) => {
58
- const linkSidebar = getLinkSidebar(index);
59
- const subMenuItem = getSubMenuItem(index);
60
-
61
- if (subMenuItem) {
62
- return subMenuItem.label;
63
- }
64
-
65
- return linkSidebar?.title;
66
- };
67
-
68
- const renderBreadcrumbPage = (index: number) => {
69
- return <BreadcrumbPage>{getTitle(index)}</BreadcrumbPage>;
70
- };
71
-
72
- const renderBreadcrumbLink = (page: string, index: number) => {
73
- const linkSidebar = getLinkSidebar(index);
74
-
75
- return linkSidebar?.subMenuType ? (
76
- renderBreadcrumbPage(index)
77
- ) : (
78
- <BreadcrumbLink onClick={() => setRouter(getPath(index))} className='cursor-pointer'>
79
- {index === 0 ? getModule(page) : getTitle(index)}
80
- </BreadcrumbLink>
81
- );
82
- };
83
-
84
- const renderBreadcrumbItens = () => {
85
- const breadcrumbItems: JSX.Element[] = [];
86
-
87
- splittedPath.map((page, index) => {
88
- breadcrumbItems.push(
89
- <BreadcrumbItem key={`breadcrumb-item-${index}`}>
90
- {page === lastPage ? renderBreadcrumbPage(index) : renderBreadcrumbLink(page, index)}
91
- </BreadcrumbItem>,
92
- );
93
- if (page !== lastPage) {
94
- breadcrumbItems.push(<BreadcrumbSeparator key={`breadcrumb-separator-${index}`} className='mt-[1px]' />);
95
- }
96
- });
97
-
98
- return breadcrumbItems;
99
- };
100
-
101
- const getColorLoadingBar = () => {
102
- const colorShades = getTailwindColorShades();
103
- const tailwindColor = portalDefinitions?.mvnoPrimaryColor || DEFAULT_THEME_DATA.mvnoPrimaryColor;
104
- const isValidColor = (color: string): color is TailwindColorName => color in colorShades;
105
- const colorPallete = isValidColor(tailwindColor) ? colorShades[tailwindColor] : colorShades.violet;
106
- return colorPallete[900];
107
- };
108
-
109
- return (
110
- <header className='flex flex-col justify-between items-center w-full'>
111
- <div className='flex justify-between items-center py-3 px-5 w-full'>
112
- <div className='flex items-center gap-x-2 h-[40px]'>
113
- <SidebarTrigger className='p-5' />
114
- <div className='p-2'>
115
- <Breadcrumb>
116
- <BreadcrumbList>{renderBreadcrumbItens()}</BreadcrumbList>
117
- </Breadcrumb>
118
- </div>
119
- </div>
120
-
121
- <div className='flex items-center'>{combobox}</div>
122
- </div>
123
- {<LoadingBar ref={refProgressLoading} color={getColorLoadingBar()} height={7} />}
124
- </header>
125
- );
126
- };
127
-
128
- export default Header;
@@ -1,79 +0,0 @@
1
- import { Copy } from 'lucide-react';
2
- import React from 'react';
3
- import { cn } from '../../../lib/utils';
4
- import { Button } from '../button';
5
- import { Skeleton } from '../skeleton';
6
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../tooltip';
7
- import { toast } from '../use-toast';
8
-
9
- interface LabelWithTitleProps {
10
- title: string;
11
- value: string;
12
- value2?: string;
13
- required?: boolean;
14
- showCopyIcon?: boolean;
15
- className?: string;
16
- isLoading?: boolean;
17
- }
18
-
19
- const LabelWithTitle: React.FC<LabelWithTitleProps> = ({ title, value, value2, required, showCopyIcon = false, className, isLoading }) => {
20
- const handleCopy = () => {
21
- if (showCopyIcon && value) {
22
- navigator.clipboard.writeText(`${value}${value2 ?? ''}`);
23
- toast({
24
- title: `"${value}${value2 ?? ''}" foi copiado para a área de transferência.`,
25
- variant: 'success',
26
- });
27
- }
28
- };
29
-
30
- return (
31
- <div className={cn('flex group', className)}>
32
- <div
33
- className={cn(
34
- 'flex flex-col text-sm w-full',
35
- showCopyIcon ? 'p-1 rounded-md transition-colors group-hover:bg-sidebar-accent' : 'p-1',
36
- )}
37
- >
38
- <div className='relative'>
39
- <div className='flex items-center text-sm font-medium gap-0.5'>
40
- <label className='text-default truncate'>{title}</label>
41
- {required && <div className='text-red-500 truncate'>*</div>}
42
- </div>
43
- <div className='grid flex-1 items-center pt-1'>
44
- {isLoading ? <Skeleton className='h-5 w-full rounded-lg' /> : <div className='text-zinc-500 truncate'>{value}</div>}
45
- </div>
46
- {value2 && (
47
- <div className='grid flex-1 items-center pt-1'>
48
- {isLoading ? <Skeleton className='h-5 w-full rounded-lg' /> : <div className='text-zinc-500 truncate'>{value2}</div>}
49
- </div>
50
- )}
51
- <div
52
- className={cn(
53
- 'pr-1 absolute top-1/2 right-0 -translate-y-1/2 opacity-0 transition-opacity',
54
- showCopyIcon && 'group-hover:opacity-100',
55
- )}
56
- >
57
- <TooltipProvider>
58
- <Tooltip>
59
- <TooltipTrigger asChild>
60
- <Button
61
- variant='ghost'
62
- type='button'
63
- className={cn('p-1 h-8', !showCopyIcon && 'cursor-default')}
64
- onClick={handleCopy}
65
- >
66
- <Copy size={16} />
67
- </Button>
68
- </TooltipTrigger>
69
- <TooltipContent>Copiar</TooltipContent>
70
- </Tooltip>
71
- </TooltipProvider>
72
- </div>
73
- </div>
74
- </div>
75
- </div>
76
- );
77
- };
78
-
79
- export default LabelWithTitle;
@@ -1,30 +0,0 @@
1
- import { BarChart2 } from 'lucide-react';
2
- import { Button } from '../button';
3
-
4
- const NotFound = () => {
5
- return (
6
- <div className="flex flex-col items-center justify-center h-screen bg-[url('/imgs/404.png')] bg-cover bg-no-repeat bg-center">
7
- <div className='flex flex-col items-center justify-center gap-8 w-[424px]'>
8
- <div className='flex flex-col items-center w-full'>
9
- <div className='text-5xl font-extrabold'>404</div>
10
- <div className='text-3xl font-semibold'>Página Indisponível</div>
11
- </div>
12
- <div className='flex text-center text-xl font-semibold text-zinc-500'>
13
- A página que você está tentando acessar se encontra indisponível no momento, tente novamente mais tarde
14
- </div>
15
- <div className='flex justify-center w-full'>
16
- <Button
17
- onClick={() => {
18
- window.location.href = '/';
19
- }}
20
- className='[&_svg]:size-5'
21
- >
22
- <BarChart2 />
23
- Voltar Para Inicial
24
- </Button>
25
- </div>
26
- </div>
27
- </div>
28
- );
29
- };
30
- export default NotFound;
@@ -1,58 +0,0 @@
1
- import { Check, ChevronsUpDown } from 'lucide-react';
2
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../../dropdown-menu';
3
- import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from '../../sidebar';
4
- import SidebarItemTwoLines from './sidebar-item-two-lines';
5
- import { Module } from './types/sidebar';
6
-
7
- interface ModuleSwitcherProps {
8
- modules: Module[];
9
- activeModule: Module | undefined;
10
- onModuleChange: (module: Module) => void;
11
- }
12
-
13
- const ModuleSwitcher = ({
14
- modules,
15
- activeModule,
16
- onModuleChange,
17
- }: ModuleSwitcherProps) => {
18
- const { isMobile } = useSidebar();
19
-
20
- return (
21
- <SidebarMenu>
22
- <SidebarMenuItem>
23
- <DropdownMenu>
24
- <DropdownMenuTrigger asChild>
25
- <SidebarMenuButton size='lg' className='data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground'>
26
- <SidebarItemTwoLines
27
- item={{
28
- iconLeft: (
29
- <div className='flex p-[7.6px] items-center rounded-md bg-background-primary'>{activeModule?.icon}</div>
30
- ),
31
- title: activeModule?.title ?? '',
32
- subTitle: activeModule?.subTitle ?? '',
33
- iconRight: <ChevronsUpDown size={16} />,
34
- }}
35
- />
36
- </SidebarMenuButton>
37
- </DropdownMenuTrigger>
38
- <DropdownMenuContent className='w-[250px] rounded-lg' align='start' side={isMobile ? 'bottom' : 'right'} sideOffset={4}>
39
- {modules.map((module) => (
40
- <DropdownMenuItem key={`module-switcher-${module.value}`} onClick={() => onModuleChange?.(module)} className='gap-2 p-2'>
41
- <SidebarItemTwoLines
42
- item={{
43
- iconLeft: <div className='flex p-[7.6px] items-center rounded-md bg-background-primary'>{module.icon}</div>,
44
- title: module.title,
45
- subTitle: module.subTitle,
46
- iconRight: activeModule?.value === module.value ? <Check size={16} /> : null,
47
- }}
48
- />
49
- </DropdownMenuItem>
50
- ))}
51
- </DropdownMenuContent>
52
- </DropdownMenu>
53
- </SidebarMenuItem>
54
- </SidebarMenu>
55
- );
56
- };
57
-
58
- export default ModuleSwitcher;
@@ -1,35 +0,0 @@
1
- import { useLocation, useNavigate } from 'react-router-dom';
2
- import { SidebarGroup, SidebarGroupContent, SidebarMenu } from '../../sidebar';
3
- import SidebarItem from './sidebar-item';
4
- import { SidebarPage } from './types/sidebar';
5
-
6
- interface NavFooterProps {
7
- pages: SidebarPage[];
8
- }
9
-
10
- const NavFooter = ({pages}: NavFooterProps) => {
11
- const navigate = useNavigate();
12
- const location = useLocation();
13
- const selectedRoutePath = location.pathname;
14
-
15
- return (
16
- <SidebarGroup className='p-0'>
17
- <SidebarGroupContent>
18
- <SidebarMenu>
19
- {pages.map((item) => {
20
- return (
21
- <SidebarItem
22
- key={`sidebar-menu-main-${item.path}`}
23
- item={item}
24
- selectedRoute={selectedRoutePath}
25
- onClick={() => navigate(item.path)}
26
- />
27
- );
28
- })}
29
- </SidebarMenu>
30
- </SidebarGroupContent>
31
- </SidebarGroup>
32
- );
33
- };
34
-
35
- export default NavFooter;
@@ -1,64 +0,0 @@
1
- import { useIsMobile } from '@/hooks/use-mobile';
2
- import { useLocation, useNavigate } from 'react-router-dom';
3
- import { SidebarGroup, SidebarGroupContent, SidebarMenu } from '../../sidebar';
4
- import NavSubmenuCollapsible from './nav-submenu-collapsible';
5
- import NavSubmenuDropdown from './nav-submenu-dropdown';
6
- import SidebarItem from './sidebar-item';
7
- import { SidebarPage, SidebarSubmenuType } from './types/sidebar';
8
-
9
- interface NavMainProps {
10
- pages: SidebarPage[];
11
- }
12
-
13
- const NavMain = ({pages}: NavMainProps) => {
14
- const navigate = useNavigate();
15
- const location = useLocation();
16
- const isMobile = useIsMobile();
17
- const selectedRoutePath = location.pathname;
18
-
19
- return (
20
- <SidebarGroup>
21
- <SidebarGroupContent>
22
- <SidebarMenu>
23
- {pages.map((item) => {
24
- if (item.subMenuType) {
25
- if (item.subMenuType === SidebarSubmenuType.COLLAPSIBLE || isMobile) {
26
- return (
27
- <NavSubmenuCollapsible
28
- key={`sidebar-submenu-collapsible-${item.path}`}
29
- item={item}
30
- selectedRoute={selectedRoutePath}
31
- onClick={(path) => navigate(path)}
32
- />
33
- );
34
- }
35
-
36
- // Deprecated: Use COLLAPSIBLE instead
37
- if (item.subMenuType === SidebarSubmenuType.DROPDOWN) {
38
- return (
39
- <NavSubmenuDropdown
40
- key={`sidebar-submenu-dropdown-${item.path}`}
41
- item={item}
42
- selectedRoute={selectedRoutePath}
43
- onClick={(path) => navigate(path)}
44
- cols={3}
45
- />
46
- );
47
- }
48
- }
49
- return (
50
- <SidebarItem
51
- key={`sidebar-menu-main-${item.path}`}
52
- item={item}
53
- selectedRoute={selectedRoutePath}
54
- onClick={() => navigate(item.path)}
55
- />
56
- );
57
- })}
58
- </SidebarMenu>
59
- </SidebarGroupContent>
60
- </SidebarGroup>
61
- );
62
- };
63
-
64
- export default NavMain;
@@ -1,60 +0,0 @@
1
- import { ChevronRight } from 'lucide-react';
2
- import { cn } from '../../../../lib/utils';
3
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../../collapsible';
4
- import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, useSidebar } from '../../sidebar';
5
- import { SidebarPage } from './types/sidebar';
6
-
7
- interface NavSubmenuCollapsibleProps {
8
- item: SidebarPage;
9
- selectedRoute: string | null;
10
- onClick: (path: string) => void;
11
- }
12
-
13
- const NavSubmenuCollapsible = ({ item, selectedRoute, onClick }: NavSubmenuCollapsibleProps) => {
14
- const { open, toggleSidebar } = useSidebar();
15
-
16
- const isOpen = (): boolean => {
17
- return selectedRoute?.includes(item.path) ?? false;
18
- };
19
-
20
- const handleToggleSidebar = () => {
21
- if (!open) toggleSidebar();
22
- };
23
-
24
- return (
25
- <SidebarMenu>
26
- <Collapsible key={item.title} asChild defaultOpen={isOpen()}>
27
- <SidebarMenuItem>
28
- <CollapsibleTrigger asChild className='group/collapsible'>
29
- <SidebarMenuButton tooltip={item.title} className='px-2 py-5 gap-3' onClick={() => handleToggleSidebar()}>
30
- {item.icon}
31
- <span>{item.title}</span>
32
- <ChevronRight className='ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90' />
33
- </SidebarMenuButton>
34
- </CollapsibleTrigger>
35
- <CollapsibleContent>
36
- <SidebarMenuSub>
37
- {item.subMenuItems
38
- ?.map((subItem) => (
39
- <SidebarMenuSubItem key={subItem.label}>
40
- <SidebarMenuSubButton asChild onClick={() => onClick(subItem.path)} aria-disabled={subItem.disabled}>
41
- <div
42
- className={cn(
43
- 'cursor-pointer px-2 py-1 items-center self-stretch',
44
- selectedRoute === subItem.path ? 'bg-sidebar-accent' : '',
45
- )}
46
- >
47
- <span>{subItem.label}</span>
48
- </div>
49
- </SidebarMenuSubButton>
50
- </SidebarMenuSubItem>
51
- ))}
52
- </SidebarMenuSub>
53
- </CollapsibleContent>
54
- </SidebarMenuItem>
55
- </Collapsible>
56
- </SidebarMenu>
57
- );
58
- };
59
-
60
- export default NavSubmenuCollapsible;
@@ -1,56 +0,0 @@
1
- import { ChevronRight } from 'lucide-react';
2
- import { cn } from '../../../../lib/utils';
3
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../../dropdown-menu';
4
- import { SidebarMenuButton, SidebarMenuItem } from '../../sidebar';
5
- import { SidebarPage } from './types/sidebar';
6
-
7
- interface NavSubmenuDropdownProps {
8
- cols?: number;
9
- item: SidebarPage;
10
- selectedRoute: string | null;
11
- onClick: (path: string) => void;
12
- }
13
-
14
- const NavSubmenuDropdown = ({ cols, item, selectedRoute, onClick }: NavSubmenuDropdownProps) => {
15
- return (
16
- <SidebarMenuItem>
17
- <DropdownMenu>
18
- <DropdownMenuTrigger asChild>
19
- <SidebarMenuButton
20
- asChild
21
- className={cn(
22
- 'data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground hover:bg-sidebar-accent px-2 py-5 gap-3 cursor-pointer',
23
- selectedRoute?.includes(item.path) ? 'bg-sidebar-accent' : '',
24
- )}
25
- tooltip={item.title}
26
- >
27
- <div>
28
- {item.icon}
29
- <span>{item.title}</span>
30
- {<ChevronRight className='ml-auto' />}
31
- </div>
32
- </SidebarMenuButton>
33
- </DropdownMenuTrigger>
34
- <DropdownMenuContent className={`grid grid-cols-${cols ?? '1'} gap-4 p-4`} align='start' side='right' sideOffset={4}>
35
- {item.subMenuItems
36
- ?.map((subItem, index) => (
37
- <DropdownMenuItem
38
- key={`${index}`}
39
- className={cn(
40
- 'flex flex-col items-start text-left max-w-[220px] gap-1 cursor-pointer',
41
- selectedRoute === subItem.path ? 'bg-sidebar-accent' : '',
42
- )}
43
- onClick={() => onClick(subItem.path)}
44
- disabled={subItem.disabled}
45
- >
46
- <div className='text-sm font-semibold'>{subItem.label}</div>
47
- <div className='text-sm text-muted-foreground'>{subItem.description}</div>
48
- </DropdownMenuItem>
49
- ))}
50
- </DropdownMenuContent>
51
- </DropdownMenu>
52
- </SidebarMenuItem>
53
- );
54
- };
55
-
56
- export default NavSubmenuDropdown;
@@ -1,77 +0,0 @@
1
- import { LoaderCircle, LogOut } from 'lucide-react';
2
- import { useState } from 'react';
3
- import { Avatar, AvatarFallback, AvatarImage } from '../../avatar';
4
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger } from '../../dropdown-menu';
5
- import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from '../../sidebar';
6
- import SidebarItemTwoLines from './sidebar-item-two-lines';
7
-
8
- interface NavUserProps {
9
- userName: string;
10
- userEmail: string;
11
- userInitials: string;
12
- callbackLogout: () => void;
13
- }
14
-
15
- const NavUser = ({userName, userEmail, userInitials, callbackLogout}: NavUserProps) => {
16
- const [isLoggingOut, setIsLoggingOut] = useState(false);
17
- const { isMobile } = useSidebar();
18
-
19
- const handleLogout = () => {
20
- setIsLoggingOut(true);
21
- setTimeout(() => {
22
- callbackLogout();
23
- }, 1000);
24
- };
25
-
26
- return (
27
- <SidebarMenu>
28
- <SidebarMenuItem>
29
- <DropdownMenu>
30
- <DropdownMenuTrigger asChild>
31
- <SidebarMenuButton size='lg' className='data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground'>
32
- <SidebarItemTwoLines
33
- item={{
34
- iconLeft: (
35
- <Avatar className='h-[31px] w-[31px] rounded-md'>
36
- <AvatarImage src={userInitials} alt={userName} />
37
- <AvatarFallback className='rounded-md bg-background-primary text-white'>{userInitials}</AvatarFallback>
38
- </Avatar>
39
- ),
40
- title: isLoggingOut ? 'Saindo...' : userName,
41
- subTitle: isLoggingOut ? '' : userEmail,
42
- iconRight: isLoggingOut ? (
43
- <LoaderCircle size={16} className='text-sidebar-foreground animate-spin mr-2' />
44
- ) : (
45
- <LogOut size={16} className='text-sidebar-foreground' />
46
- ),
47
- }}
48
- />
49
- </SidebarMenuButton>
50
- </DropdownMenuTrigger>
51
- <DropdownMenuContent className='w-[250px] rounded-lg' side={isMobile ? 'bottom' : 'right'} align='end' sideOffset={4}>
52
- <DropdownMenuLabel className='p-0 font-normal'>
53
- <div className='flex items-center gap-2 px-1 py-1.5 text-left text-sm'>
54
- <Avatar className='h-8 w-8 rounded-lg'>
55
- <AvatarImage src={userInitials} alt={userName} />
56
- <AvatarFallback className='rounded-lg bg-background-primary text-white'>{userInitials}</AvatarFallback>
57
- </Avatar>
58
- <div className='grid flex-1 text-left text-sm leading-tight'>
59
- <span className='truncate font-semibold'>{userName}</span>
60
- <span className='truncate text-xs'>{userEmail}</span>
61
- </div>
62
- </div>
63
- </DropdownMenuLabel>
64
- <DropdownMenuItem className='p-0 font-normal cursor-pointer' onClick={() => handleLogout()}>
65
- <div className='flex items-center gap-2 px-1 py-1.5 text-left text-sm'>
66
- <div className='flex w-8 h-8 p-2 items-center rounded-md'>{<LogOut size={16} />}</div>
67
- Log out
68
- </div>
69
- </DropdownMenuItem>
70
- </DropdownMenuContent>
71
- </DropdownMenu>
72
- </SidebarMenuItem>
73
- </SidebarMenu>
74
- );
75
- };
76
-
77
- export default NavUser;
@@ -1,30 +0,0 @@
1
- import { cn } from '../../../../lib/utils';
2
- import { SidebarMenuButton } from '../../sidebar';
3
- import { Module, SidebarPage } from './types/sidebar';
4
-
5
- interface SidebarItemProps {
6
- item: SidebarPage;
7
- selectedRoute: string | null;
8
- onClick?: (module: Module | null, path: string) => void;
9
- }
10
-
11
- const SidebarButton = ({ item, selectedRoute, onClick }: SidebarItemProps) => {
12
- return (
13
- <SidebarMenuButton
14
- asChild
15
- className={cn(
16
- 'data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground hover:bg-sidebar-accent px-2 py-5 gap-3 cursor-pointer',
17
- selectedRoute?.includes(item.path) ? 'bg-sidebar-accent' : '',
18
- )}
19
- tooltip={item.title}
20
- onClick={() => onClick?.(item.module ?? null, item.path)}
21
- >
22
- <div>
23
- <div className='[&_svg]:size-4 text-sidebar-foreground'>{item.icon}</div>
24
- <span>{item.title}</span>
25
- </div>
26
- </SidebarMenuButton>
27
- );
28
- };
29
-
30
- export default SidebarButton;
@@ -1,25 +0,0 @@
1
- import * as React from 'react';
2
-
3
- interface SidebarItemTwoLinesProps {
4
- item: {
5
- iconLeft: React.ReactNode;
6
- title: string;
7
- subTitle: string;
8
- iconRight?: React.ReactNode | null;
9
- };
10
- }
11
-
12
- const SidebarItemTwoLines = ({ item }: SidebarItemTwoLinesProps) => {
13
- return (
14
- <>
15
- <div className='[&_svg]:size-4 text-white'>{item.iconLeft}</div>
16
- <div className='grid flex-1 text-left text-sm leading-tight'>
17
- <span className='truncate font-semibold'>{item.title}</span>
18
- <span className='truncate text-xs text-foreground'>{item.subTitle}</span>
19
- </div>
20
- {item.iconRight}
21
- </>
22
- );
23
- };
24
-
25
- export default SidebarItemTwoLines;
@@ -1,19 +0,0 @@
1
- import { SidebarMenuItem } from '../../sidebar';
2
- import SidebarButton from './sidebar-button';
3
- import { Module, SidebarPage } from './types/sidebar';
4
-
5
- interface SidebarItemProps {
6
- item: SidebarPage;
7
- selectedRoute: string | null;
8
- onClick?: (module: Module | null, path: string) => void;
9
- }
10
-
11
- const SidebarItem = ({ item, selectedRoute, onClick }: SidebarItemProps) => {
12
- return (
13
- <SidebarMenuItem>
14
- <SidebarButton item={item} selectedRoute={selectedRoute} onClick={onClick} />
15
- </SidebarMenuItem>
16
- );
17
- };
18
-
19
- export default SidebarItem;