eai-frontend-components 2.0.5 → 2.0.6

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 (100) hide show
  1. package/package.json +3 -3
  2. package/src/components/ui/accordion.tsx +0 -48
  3. package/src/components/ui/alert-dialog.tsx +0 -138
  4. package/src/components/ui/alert.tsx +0 -36
  5. package/src/components/ui/avatar.tsx +0 -48
  6. package/src/components/ui/badge.tsx +0 -35
  7. package/src/components/ui/breadcrumb.tsx +0 -115
  8. package/src/components/ui/button.tsx +0 -43
  9. package/src/components/ui/calendar.tsx +0 -142
  10. package/src/components/ui/card.tsx +0 -35
  11. package/src/components/ui/carousel.tsx +0 -257
  12. package/src/components/ui/chart.tsx +0 -363
  13. package/src/components/ui/checkbox.tsx +0 -26
  14. package/src/components/ui/collapsible.tsx +0 -9
  15. package/src/components/ui/command.tsx +0 -145
  16. package/src/components/ui/context-menu.tsx +0 -198
  17. package/src/components/ui/custom/date-picker.tsx +0 -97
  18. package/src/components/ui/custom/form/checkbox.tsx +0 -53
  19. package/src/components/ui/custom/form/color.tsx +0 -140
  20. package/src/components/ui/custom/form/combobox.tsx +0 -259
  21. package/src/components/ui/custom/form/cpf-cnpj.tsx +0 -85
  22. package/src/components/ui/custom/form/currency.tsx +0 -51
  23. package/src/components/ui/custom/form/date-range.tsx +0 -110
  24. package/src/components/ui/custom/form/date.tsx +0 -109
  25. package/src/components/ui/custom/form/decimal.tsx +0 -50
  26. package/src/components/ui/custom/form/file.tsx +0 -65
  27. package/src/components/ui/custom/form/form-help-text.tsx +0 -20
  28. package/src/components/ui/custom/form/form-label.tsx +0 -24
  29. package/src/components/ui/custom/form/form-message.tsx +0 -10
  30. package/src/components/ui/custom/form/ghost.tsx +0 -28
  31. package/src/components/ui/custom/form/input.tsx +0 -69
  32. package/src/components/ui/custom/form/mask.tsx +0 -78
  33. package/src/components/ui/custom/form/multi-select.tsx +0 -209
  34. package/src/components/ui/custom/form/password.tsx +0 -70
  35. package/src/components/ui/custom/form/percent.tsx +0 -52
  36. package/src/components/ui/custom/form/phone.tsx +0 -79
  37. package/src/components/ui/custom/form/radio-group.tsx +0 -94
  38. package/src/components/ui/custom/form/select.tsx +0 -62
  39. package/src/components/ui/custom/form/step-new-form.tsx +0 -49
  40. package/src/components/ui/custom/form/switch.tsx +0 -51
  41. package/src/components/ui/custom/form/text.tsx +0 -71
  42. package/src/components/ui/custom/form/textarea.tsx +0 -71
  43. package/src/components/ui/custom/form/utils.ts +0 -100
  44. package/src/components/ui/custom/header.tsx +0 -128
  45. package/src/components/ui/custom/label.tsx +0 -79
  46. package/src/components/ui/custom/not-found.tsx +0 -30
  47. package/src/components/ui/custom/sidebar/module-switcher.tsx +0 -58
  48. package/src/components/ui/custom/sidebar/nav-footer.tsx +0 -35
  49. package/src/components/ui/custom/sidebar/nav-main.tsx +0 -64
  50. package/src/components/ui/custom/sidebar/nav-submenu-collapsible.tsx +0 -60
  51. package/src/components/ui/custom/sidebar/nav-submenu-dropdown.tsx +0 -56
  52. package/src/components/ui/custom/sidebar/nav-user.tsx +0 -77
  53. package/src/components/ui/custom/sidebar/sidebar-button.tsx +0 -30
  54. package/src/components/ui/custom/sidebar/sidebar-item-two-lines.tsx +0 -25
  55. package/src/components/ui/custom/sidebar/sidebar-item.tsx +0 -19
  56. package/src/components/ui/custom/sidebar/types/sidebar.ts +0 -31
  57. package/src/components/ui/custom/table/data-table-export.tsx +0 -126
  58. package/src/components/ui/custom/table/data-table-footer.tsx +0 -148
  59. package/src/components/ui/custom/table/data-table-header.tsx +0 -58
  60. package/src/components/ui/custom/table/data-table-rows.tsx +0 -94
  61. package/src/components/ui/custom/table/data-table.tsx +0 -285
  62. package/src/components/ui/custom/table/types/data-table.ts +0 -31
  63. package/src/components/ui/custom/theme-provider.tsx +0 -121
  64. package/src/components/ui/dateRangePicker.tsx +0 -63
  65. package/src/components/ui/dialog.tsx +0 -84
  66. package/src/components/ui/drawer.tsx +0 -116
  67. package/src/components/ui/dropdown-menu.tsx +0 -173
  68. package/src/components/ui/form.tsx +0 -114
  69. package/src/components/ui/hover-card.tsx +0 -27
  70. package/src/components/ui/input.tsx +0 -265
  71. package/src/components/ui/label.tsx +0 -15
  72. package/src/components/ui/masks.ts +0 -35
  73. package/src/components/ui/pagination.tsx +0 -78
  74. package/src/components/ui/popover.tsx +0 -32
  75. package/src/components/ui/progress.tsx +0 -22
  76. package/src/components/ui/radio-group.tsx +0 -36
  77. package/src/components/ui/scroll-area.tsx +0 -46
  78. package/src/components/ui/select.tsx +0 -130
  79. package/src/components/ui/separator.tsx +0 -29
  80. package/src/components/ui/sheet.tsx +0 -90
  81. package/src/components/ui/sidebar.tsx +0 -598
  82. package/src/components/ui/skeleton.tsx +0 -15
  83. package/src/components/ui/slider.tsx +0 -18
  84. package/src/components/ui/switch.tsx +0 -26
  85. package/src/components/ui/table.tsx +0 -53
  86. package/src/components/ui/tabs.tsx +0 -47
  87. package/src/components/ui/textarea.tsx +0 -27
  88. package/src/components/ui/toast.tsx +0 -88
  89. package/src/components/ui/toaster.tsx +0 -49
  90. package/src/components/ui/tooltip.tsx +0 -31
  91. package/src/components/ui/use-calendar.tsx +0 -61
  92. package/src/components/ui/use-toast.ts +0 -186
  93. package/src/hooks/use-mobile.tsx +0 -19
  94. package/src/index.ts +0 -299
  95. package/src/lib/help/date-utils.ts +0 -41
  96. package/src/lib/help/format.ts +0 -171
  97. package/src/lib/help/theme.ts +0 -346
  98. package/src/lib/help/uuid.ts +0 -4
  99. package/src/lib/utils.ts +0 -6
  100. package/src/styles/globals.css +0 -59
@@ -1,31 +0,0 @@
1
- export const SidebarSubmenuType = {
2
- COLLAPSIBLE: 'collapsible',
3
- // Deprecated: Use COLLAPSIBLE instead
4
- DROPDOWN: 'dropdown',
5
- } as const;
6
- export type SidebarSubmenuType = (typeof SidebarSubmenuType)[keyof typeof SidebarSubmenuType];
7
-
8
- export interface Module {
9
- value: string;
10
- path: string;
11
- title: string;
12
- icon: React.ReactNode;
13
- subTitle: string;
14
- }
15
-
16
- export interface SidebarPage {
17
- module: Module;
18
- path: string;
19
- icon?: React.ReactNode;
20
- title: string;
21
- hideSidebar: boolean;
22
- displayOnlyresellerIsAdm?: boolean;
23
- subMenuType?: SidebarSubmenuType;
24
- subMenuItems?: {
25
- label: string;
26
- description?: string;
27
- path: string;
28
- displayOnlyresellerIsAdm?: boolean;
29
- disabled?: boolean;
30
- }[];
31
- }
@@ -1,126 +0,0 @@
1
- import { zodResolver } from '@hookform/resolvers/zod';
2
- import { FieldErrors, useForm } from 'react-hook-form';
3
- import { z } from 'zod';
4
- import { Button } from '../../button';
5
- import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../../dialog';
6
- import { Form } from '../../form';
7
- import { toast } from '../../use-toast';
8
- import { FormRadioGroup } from '../form/radio-group';
9
- import { ExportDataTable } from './types/data-table';
10
-
11
- interface DataTableExportProps {
12
- exportData?: ExportDataTable;
13
- totalRows: number;
14
- }
15
-
16
- export function DataTableExport({ exportData, totalRows }: DataTableExportProps) {
17
- const exportXlSX = () => {
18
- if (!exportData) return;
19
-
20
- if (totalRows === 0) {
21
- toast({
22
- title: 'Não há dados para exportar.',
23
- variant: 'destructive',
24
- });
25
- return {};
26
- }
27
- const params = new URLSearchParams(exportData.params).toString();
28
- window.open(`${exportData.url}?${params}`, '_blank');
29
- };
30
-
31
- const renderExport = () => {
32
- if (!exportData) return null;
33
-
34
- if (exportData.type === 'xlsx') {
35
- return (
36
- <Button variant='secondary' onClick={exportXlSX}>
37
- Exportar
38
- </Button>
39
- );
40
- }
41
-
42
- if (exportData.type === 'dialog') {
43
- const ExportDataSchema = z.object({
44
- model: z.string(),
45
- format: z.string(),
46
- });
47
-
48
- const form = useForm<z.infer<typeof ExportDataSchema>>({
49
- mode: 'onTouched',
50
- resolver: zodResolver(ExportDataSchema),
51
- });
52
-
53
- const { control, trigger, handleSubmit } = form;
54
-
55
- const onSubmit = async (values: z.infer<typeof ExportDataSchema>) => {
56
- await trigger();
57
-
58
- toast({
59
- title: 'Em desenvolvimento.',
60
- variant: 'destructive',
61
- });
62
- };
63
-
64
- const onError = async (errors: FieldErrors<z.infer<typeof ExportDataSchema>>) => {
65
- toast({
66
- title: 'Erro ao salvar',
67
- description: 'Verifique os campos obrigatórios',
68
- variant: 'destructive',
69
- });
70
- };
71
-
72
- return (
73
- <Form {...(form as any)} onSubmit={handleSubmit(onSubmit, onError)}>
74
- <Dialog>
75
- <DialogTrigger asChild>
76
- <Button variant='secondary'>Exportar</Button>
77
- </DialogTrigger>
78
- <DialogContent hideClose className='fixed p-6 rounded-lg w-[451px]'>
79
- <DialogHeader>
80
- <DialogTitle>Exportar</DialogTitle>
81
- <DialogDescription />
82
- </DialogHeader>
83
- <div className='flex flex-col gap-6'>
84
- <FormRadioGroup
85
- control={control}
86
- name='model'
87
- label='Selecione o modelo de visualização'
88
- options={[
89
- { value: '0', label: 'Resumido' },
90
- { value: '1', label: 'Detalhado' },
91
- ]}
92
- className='text-sm font-normal'
93
- classNameOptions='flex flex-col gap-4 mt-4 text-sm font-normal'
94
- />
95
-
96
- <FormRadioGroup
97
- control={control}
98
- name='format'
99
- label='Selecione o formato desejado para exportação'
100
- options={[
101
- { value: '0', label: 'PDF' },
102
- { value: '1', label: 'XLSX' },
103
- ]}
104
- className='text-sm font-normal'
105
- classNameOptions='flex flex-col gap-4 mt-4 text-sm font-normal'
106
- />
107
- </div>
108
- <DialogFooter className='sm:justify-end gap-2'>
109
- <Button type='button' variant='secondary'>
110
- Fechar
111
- </Button>
112
- <Button type='button' variant='default' onClick={() => exportXlSX()}>
113
- Exportar
114
- </Button>
115
- </DialogFooter>
116
- </DialogContent>
117
- </Dialog>
118
- </Form>
119
- );
120
- }
121
-
122
- return null;
123
- };
124
-
125
- return exportData && renderExport();
126
- }
@@ -1,148 +0,0 @@
1
- import { PaginationState } from '@tanstack/react-table';
2
- import { Badge } from '../../badge';
3
- import {
4
- Pagination,
5
- PaginationContent,
6
- PaginationEllipsis,
7
- PaginationItem,
8
- PaginationLink,
9
- PaginationNext,
10
- PaginationPrevious,
11
- } from '../../pagination';
12
- import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../../select';
13
- import { DataTableExport } from './data-table-export';
14
- import { ExportDataTable } from './types/data-table';
15
-
16
- interface DataTableFooterProps<TData> {
17
- hidePagination?: boolean;
18
- disablePagination?: boolean;
19
- isLoading?: boolean;
20
- totalRows: number;
21
- totalPages: number;
22
- currentPage: number;
23
- pagination: PaginationState;
24
- handlePageSize: (value: number) => void;
25
- handlePage: (value: number) => void;
26
- previousPage: {
27
- action: () => void;
28
- disabled: boolean;
29
- };
30
- nextPage: {
31
- action: () => void;
32
- disabled: boolean;
33
- };
34
- exportData?: ExportDataTable;
35
- }
36
-
37
- export function DataTableFooter<TData>({
38
- isLoading,
39
- totalRows,
40
- totalPages,
41
- currentPage,
42
- hidePagination,
43
- disablePagination,
44
- pagination,
45
- handlePageSize,
46
- handlePage,
47
- previousPage,
48
- nextPage,
49
- exportData,
50
- }: DataTableFooterProps<TData>) {
51
- const renderPaginationPages = () => {
52
- const paginationItems: JSX.Element[] = [];
53
-
54
- const createPaginationItem = (pageIndex: number) => (
55
- <PaginationItem key={pageIndex}>
56
- <PaginationLink onClick={() => handlePage(pageIndex)} isActive={currentPage === pageIndex}>
57
- {pageIndex + 1}
58
- </PaginationLink>
59
- </PaginationItem>
60
- );
61
-
62
- // Add first page
63
- paginationItems.push(createPaginationItem(0));
64
-
65
- // Add ellipsis if needed
66
- if (currentPage > 2) {
67
- paginationItems.push(<PaginationEllipsis key='start-ellipsis' />);
68
- }
69
-
70
- // Add pages before current page
71
- for (let i = Math.max(1, currentPage - 1); i < currentPage; i++) {
72
- paginationItems.push(createPaginationItem(i));
73
- }
74
-
75
- // Add current page
76
- if (currentPage !== 0 && currentPage !== totalPages - 1) {
77
- paginationItems.push(createPaginationItem(currentPage));
78
- }
79
-
80
- // Add pages after current page
81
- for (let i = currentPage + 1; i <= Math.min(totalPages - 2, currentPage + 1); i++) {
82
- paginationItems.push(createPaginationItem(i));
83
- }
84
-
85
- // Add ellipsis if needed
86
- if (currentPage < totalPages - 3) {
87
- paginationItems.push(<PaginationEllipsis key='end-ellipsis' />);
88
- }
89
-
90
- // Add last page
91
- if (totalPages > 1) {
92
- paginationItems.push(createPaginationItem(totalPages - 1));
93
- }
94
-
95
- return paginationItems;
96
- };
97
-
98
- return (
99
- !hidePagination && (
100
- <footer className='flex items-center justify-between h-[64px]'>
101
- <div className='flex flex-row items-center gap-6'>
102
- <div className='flex flex-row items-center gap-2'>
103
- Linhas por página
104
- <Select
105
- value={pagination.pageSize.toString()}
106
- onValueChange={(value) => handlePageSize(Number(value))}
107
- disabled={isLoading || disablePagination}
108
- >
109
- <SelectTrigger className='w-20'>
110
- <SelectValue placeholder='' className='text-slate-800 font-medium' />
111
- </SelectTrigger>
112
- <SelectContent>
113
- <SelectGroup>
114
- <SelectItem value='25'>25</SelectItem>
115
- <SelectItem value='50'>50</SelectItem>
116
- <SelectItem value='100'>100</SelectItem>
117
- </SelectGroup>
118
- </SelectContent>
119
- </Select>
120
- </div>
121
-
122
- <DataTableExport exportData={exportData} totalRows={totalPages} />
123
- </div>
124
-
125
- <div className='flex items-center gap-4'>
126
- <div>
127
- {!isLoading && (
128
- <Badge variant='secondary'>{totalRows === 0 ? 'Nenhum item' : totalRows === 1 ? '1 item' : `${totalRows} itens`}</Badge>
129
- )}
130
- </div>
131
- <div>
132
- <Pagination>
133
- <PaginationContent>
134
- <PaginationItem>
135
- <PaginationPrevious onClick={() => previousPage.action()} disabled={previousPage.disabled || disablePagination} />
136
- </PaginationItem>
137
- {renderPaginationPages()}
138
- <PaginationItem>
139
- <PaginationNext onClick={() => nextPage.action()} disabled={nextPage.disabled || disablePagination} />
140
- </PaginationItem>
141
- </PaginationContent>
142
- </Pagination>
143
- </div>
144
- </div>
145
- </footer>
146
- )
147
- );
148
- }
@@ -1,58 +0,0 @@
1
- import { Table, flexRender } from '@tanstack/react-table';
2
- import { ArrowUpDown, MoveDown, MoveUp } from 'lucide-react';
3
- import { cn } from '../../../../lib/utils';
4
- import { Button } from '../../button';
5
- import { Checkbox } from '../../checkbox';
6
- import { TableHead, TableHeader, TableRow } from '../../table';
7
-
8
- interface DataTableHeaderProps<TData> {
9
- table: Table<TData>;
10
- canActionsRow?: boolean;
11
- enableMultiRowSelection?: boolean;
12
- }
13
-
14
- export function DataTableHeader<TData>({ table, canActionsRow, enableMultiRowSelection }: DataTableHeaderProps<TData>) {
15
- const headerGroups = table.getHeaderGroups();
16
- return (
17
- <TableHeader>
18
- {headerGroups.map((headerGroup) => (
19
- <TableRow key={headerGroup.id} className='bg-background dark:bg-datatable-accent rounded-t-md sticky top-0 z-10'>
20
- {enableMultiRowSelection && (
21
- <TableHead className='h-[65px] w-6'>
22
- <Checkbox
23
- checked={table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && 'indeterminate')}
24
- onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
25
- />
26
- </TableHead>
27
- )}
28
- {headerGroup.headers.map((header) => (
29
- <TableHead
30
- key={header.id}
31
- className={cn(
32
- 'h-[65px] whitespace-nowrap',
33
- header.column.id === 'id' ? 'sticky left-0 z-20' : '',
34
- header.column.columnDef.enableSorting ? 'pl-2' : '',
35
- )}
36
- >
37
- {header.column.columnDef.enableSorting ? (
38
- <Button variant='ghost' onClick={() => header.column.toggleSorting(header.column.getIsSorted() === 'asc')}>
39
- {flexRender(header.column.columnDef.header, header.getContext())}
40
- {header.column.getIsSorted() === 'asc' ? (
41
- <MoveUp className='ml-2 h-4 w-4' />
42
- ) : header.column.getIsSorted() === 'desc' ? (
43
- <MoveDown className='ml-2 h-4 w-4' />
44
- ) : (
45
- <ArrowUpDown className='ml-2 h-4 w-4' />
46
- )}
47
- </Button>
48
- ) : (
49
- flexRender(header.column.columnDef.header, header.getContext())
50
- )}
51
- </TableHead>
52
- ))}
53
- {canActionsRow && <TableHead />}
54
- </TableRow>
55
- ))}
56
- </TableHeader>
57
- );
58
- }
@@ -1,94 +0,0 @@
1
- import { ColumnDef, Table, flexRender } from '@tanstack/react-table';
2
- import { cn } from '../../../../lib/utils';
3
- import { Button } from '../../button';
4
- import { Checkbox } from '../../checkbox';
5
- import { Skeleton } from '../../skeleton';
6
- import { TableCell, TableRow } from '../../table';
7
- import { ActionRow } from './types/data-table';
8
-
9
- interface DataTableRowsProps<TData> {
10
- table: Table<TData>;
11
- columns: ColumnDef<TData>[];
12
- isLoading?: boolean;
13
- actionsRow?: ActionRow[];
14
- textNoRecords?: string;
15
- enableMultiRowSelection?: boolean;
16
- }
17
-
18
- export function DataTableRows<TData>({ table, isLoading, columns, actionsRow, textNoRecords, enableMultiRowSelection }: DataTableRowsProps<TData>) {
19
- const rows = table.getRowModel().rows;
20
-
21
- const renderLoadingRows = () => {
22
- const rows: JSX.Element[] = [];
23
-
24
- for (let i = 0; i < 10; i++) {
25
- rows.push(
26
- <TableRow key={`loading-row-${i}`}>
27
- {enableMultiRowSelection && (
28
- <TableCell className='py-2'>
29
- <Skeleton className='h-10 w-full' />
30
- </TableCell>
31
- )}
32
- {columns.map((column) => (
33
- <TableCell key={column.id} className='py-2'>
34
- <Skeleton className='h-10 w-full' />
35
- </TableCell>
36
- ))}
37
- </TableRow>,
38
- );
39
- }
40
-
41
- return rows;
42
- };
43
-
44
- const renderRows = () => {
45
- return rows.map((row) => (
46
- <TableRow key={row.id} data-state={row.getIsSelected() && 'selected'} className='group'>
47
- {enableMultiRowSelection && (
48
- <TableCell className='py-4'>
49
- <Checkbox checked={row.getIsSelected()} onCheckedChange={(value) => row.toggleSelected(!!value)} aria-label='Select row' />
50
- </TableCell>
51
- )}
52
- {row.getVisibleCells().map((cell) => (
53
- <TableCell key={cell.id} className='py-4'>
54
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
55
- </TableCell>
56
- ))}
57
- {actionsRow && (
58
- <TableCell
59
- className='opacity-0 group-hover:opacity-100 hover:opacity-100 relative overflow-visible w-[0px]'
60
- key={`buttons-${row.id}`}
61
- >
62
- <div className='absolute transition-colors group-hover:bg-datatable-accent overflow-visible right-5 -translate-y-1/2 flex space-x-4'>
63
- {actionsRow.map((action, index) => (
64
- <Button
65
- key={`action-row-${index}`}
66
- variant={(action.variant as 'link' | 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost') || 'default'}
67
- className={cn('bg-datatable-accent', action.className?.(row.original) || '')}
68
- onClick={() => action.onClick?.(row.original)}
69
- disabled={action.disabled?.(row.original) || false}
70
- >
71
- {action.icon}
72
- {action.label}
73
- </Button>
74
- ))}
75
- </div>
76
- </TableCell>
77
- )}
78
- </TableRow>
79
- ));
80
- };
81
-
82
- const renderEmptyRows = () => {
83
- const colSpan = columns.length + (actionsRow ? 1 : 0);
84
- return (
85
- <TableRow>
86
- <TableCell colSpan={colSpan} className='text-center h-[53px]'>
87
- {textNoRecords ? textNoRecords : 'Sem resultados.'}
88
- </TableCell>
89
- </TableRow>
90
- );
91
- };
92
-
93
- return isLoading ? renderLoadingRows() : rows.length ? renderRows() : renderEmptyRows();
94
- }