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.
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/ui/accordion.tsx +0 -48
- package/src/components/ui/alert-dialog.tsx +0 -138
- package/src/components/ui/alert.tsx +0 -36
- package/src/components/ui/avatar.tsx +0 -48
- package/src/components/ui/badge.tsx +0 -35
- package/src/components/ui/breadcrumb.tsx +0 -115
- package/src/components/ui/button.tsx +0 -43
- package/src/components/ui/calendar.tsx +0 -142
- package/src/components/ui/card.tsx +0 -35
- package/src/components/ui/carousel.tsx +0 -257
- package/src/components/ui/chart.tsx +0 -363
- package/src/components/ui/checkbox.tsx +0 -26
- package/src/components/ui/collapsible.tsx +0 -9
- package/src/components/ui/command.tsx +0 -145
- package/src/components/ui/context-menu.tsx +0 -198
- package/src/components/ui/custom/date-picker.tsx +0 -97
- package/src/components/ui/custom/form/checkbox.tsx +0 -53
- package/src/components/ui/custom/form/color.tsx +0 -140
- package/src/components/ui/custom/form/combobox.tsx +0 -259
- package/src/components/ui/custom/form/cpf-cnpj.tsx +0 -85
- package/src/components/ui/custom/form/currency.tsx +0 -51
- package/src/components/ui/custom/form/date-range.tsx +0 -110
- package/src/components/ui/custom/form/date.tsx +0 -109
- package/src/components/ui/custom/form/decimal.tsx +0 -50
- package/src/components/ui/custom/form/file.tsx +0 -65
- package/src/components/ui/custom/form/form-help-text.tsx +0 -20
- package/src/components/ui/custom/form/form-label.tsx +0 -24
- package/src/components/ui/custom/form/form-message.tsx +0 -10
- package/src/components/ui/custom/form/ghost.tsx +0 -28
- package/src/components/ui/custom/form/input.tsx +0 -69
- package/src/components/ui/custom/form/mask.tsx +0 -78
- package/src/components/ui/custom/form/multi-select.tsx +0 -209
- package/src/components/ui/custom/form/password.tsx +0 -70
- package/src/components/ui/custom/form/percent.tsx +0 -52
- package/src/components/ui/custom/form/phone.tsx +0 -79
- package/src/components/ui/custom/form/radio-group.tsx +0 -94
- package/src/components/ui/custom/form/select.tsx +0 -62
- package/src/components/ui/custom/form/step-new-form.tsx +0 -49
- package/src/components/ui/custom/form/switch.tsx +0 -51
- package/src/components/ui/custom/form/text.tsx +0 -71
- package/src/components/ui/custom/form/textarea.tsx +0 -71
- package/src/components/ui/custom/form/utils.ts +0 -100
- package/src/components/ui/custom/header.tsx +0 -128
- package/src/components/ui/custom/label.tsx +0 -79
- package/src/components/ui/custom/not-found.tsx +0 -30
- package/src/components/ui/custom/sidebar/module-switcher.tsx +0 -58
- package/src/components/ui/custom/sidebar/nav-footer.tsx +0 -35
- package/src/components/ui/custom/sidebar/nav-main.tsx +0 -64
- package/src/components/ui/custom/sidebar/nav-submenu-collapsible.tsx +0 -60
- package/src/components/ui/custom/sidebar/nav-submenu-dropdown.tsx +0 -56
- package/src/components/ui/custom/sidebar/nav-user.tsx +0 -77
- package/src/components/ui/custom/sidebar/sidebar-button.tsx +0 -30
- package/src/components/ui/custom/sidebar/sidebar-item-two-lines.tsx +0 -25
- package/src/components/ui/custom/sidebar/sidebar-item.tsx +0 -19
- package/src/components/ui/custom/sidebar/types/sidebar.ts +0 -31
- package/src/components/ui/custom/table/data-table-export.tsx +0 -126
- package/src/components/ui/custom/table/data-table-footer.tsx +0 -148
- package/src/components/ui/custom/table/data-table-header.tsx +0 -58
- package/src/components/ui/custom/table/data-table-rows.tsx +0 -94
- package/src/components/ui/custom/table/data-table.tsx +0 -285
- package/src/components/ui/custom/table/types/data-table.ts +0 -31
- package/src/components/ui/custom/theme-provider.tsx +0 -121
- package/src/components/ui/dateRangePicker.tsx +0 -63
- package/src/components/ui/dialog.tsx +0 -84
- package/src/components/ui/drawer.tsx +0 -116
- package/src/components/ui/dropdown-menu.tsx +0 -173
- package/src/components/ui/form.tsx +0 -114
- package/src/components/ui/hover-card.tsx +0 -27
- package/src/components/ui/input.tsx +0 -265
- package/src/components/ui/label.tsx +0 -15
- package/src/components/ui/masks.ts +0 -35
- package/src/components/ui/pagination.tsx +0 -78
- package/src/components/ui/popover.tsx +0 -32
- package/src/components/ui/progress.tsx +0 -22
- package/src/components/ui/radio-group.tsx +0 -36
- package/src/components/ui/scroll-area.tsx +0 -46
- package/src/components/ui/select.tsx +0 -130
- package/src/components/ui/separator.tsx +0 -29
- package/src/components/ui/sheet.tsx +0 -90
- package/src/components/ui/sidebar.tsx +0 -598
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/slider.tsx +0 -18
- package/src/components/ui/switch.tsx +0 -26
- package/src/components/ui/table.tsx +0 -53
- package/src/components/ui/tabs.tsx +0 -47
- package/src/components/ui/textarea.tsx +0 -27
- package/src/components/ui/toast.tsx +0 -88
- package/src/components/ui/toaster.tsx +0 -49
- package/src/components/ui/tooltip.tsx +0 -31
- package/src/components/ui/use-calendar.tsx +0 -61
- package/src/components/ui/use-toast.ts +0 -186
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/index.ts +0 -299
- package/src/lib/help/date-utils.ts +0 -41
- package/src/lib/help/format.ts +0 -171
- package/src/lib/help/theme.ts +0 -346
- package/src/lib/help/uuid.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -59
package/src/index.ts
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// CORE UI COMPONENTS
|
|
3
|
-
// =============================================================================
|
|
4
|
-
|
|
5
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from './components/ui/accordion';
|
|
6
|
-
export { Alert, AlertDescription, AlertTitle } from './components/ui/alert';
|
|
7
|
-
export {
|
|
8
|
-
AlertDialog,
|
|
9
|
-
AlertDialogAction,
|
|
10
|
-
AlertDialogCancel,
|
|
11
|
-
AlertDialogContent,
|
|
12
|
-
AlertDialogDescription,
|
|
13
|
-
AlertDialogFooter,
|
|
14
|
-
AlertDialogHeader,
|
|
15
|
-
AlertDialogTitle,
|
|
16
|
-
AlertDialogTrigger
|
|
17
|
-
} from './components/ui/alert-dialog';
|
|
18
|
-
export { Avatar, AvatarFallback, AvatarImage } from './components/ui/avatar';
|
|
19
|
-
export { Badge, badgeVariants } from './components/ui/badge';
|
|
20
|
-
export {
|
|
21
|
-
Breadcrumb,
|
|
22
|
-
BreadcrumbEllipsis,
|
|
23
|
-
BreadcrumbItem,
|
|
24
|
-
BreadcrumbLink,
|
|
25
|
-
BreadcrumbList,
|
|
26
|
-
BreadcrumbPage,
|
|
27
|
-
BreadcrumbSeparator
|
|
28
|
-
} from './components/ui/breadcrumb';
|
|
29
|
-
export { Button, buttonVariants } from './components/ui/button';
|
|
30
|
-
export type { ButtonProps } from './components/ui/button';
|
|
31
|
-
export { Calendar } from './components/ui/calendar';
|
|
32
|
-
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/ui/card';
|
|
33
|
-
export { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from './components/ui/carousel';
|
|
34
|
-
export type { CarouselApi } from './components/ui/carousel';
|
|
35
|
-
export { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from './components/ui/chart';
|
|
36
|
-
export { Checkbox } from './components/ui/checkbox';
|
|
37
|
-
export { Collapsible, CollapsibleContent, CollapsibleTrigger } from './components/ui/collapsible';
|
|
38
|
-
export {
|
|
39
|
-
Command,
|
|
40
|
-
CommandDialog,
|
|
41
|
-
CommandEmpty,
|
|
42
|
-
CommandGroup,
|
|
43
|
-
CommandInput,
|
|
44
|
-
CommandItem,
|
|
45
|
-
CommandList,
|
|
46
|
-
CommandSeparator,
|
|
47
|
-
CommandShortcut
|
|
48
|
-
} from './components/ui/command';
|
|
49
|
-
export {
|
|
50
|
-
ContextMenu,
|
|
51
|
-
ContextMenuCheckboxItem,
|
|
52
|
-
ContextMenuContent,
|
|
53
|
-
ContextMenuGroup,
|
|
54
|
-
ContextMenuItem,
|
|
55
|
-
ContextMenuLabel,
|
|
56
|
-
ContextMenuPortal,
|
|
57
|
-
ContextMenuRadioGroup,
|
|
58
|
-
ContextMenuRadioItem,
|
|
59
|
-
ContextMenuSeparator,
|
|
60
|
-
ContextMenuShortcut,
|
|
61
|
-
ContextMenuSub,
|
|
62
|
-
ContextMenuSubContent,
|
|
63
|
-
ContextMenuSubTrigger,
|
|
64
|
-
ContextMenuTrigger
|
|
65
|
-
} from './components/ui/context-menu';
|
|
66
|
-
export { DatePickerWithRange as DateRangePicker } from './components/ui/dateRangePicker';
|
|
67
|
-
export {
|
|
68
|
-
Dialog,
|
|
69
|
-
DialogClose,
|
|
70
|
-
DialogContent,
|
|
71
|
-
DialogDescription,
|
|
72
|
-
DialogFooter,
|
|
73
|
-
DialogHeader,
|
|
74
|
-
DialogOverlay,
|
|
75
|
-
DialogPortal,
|
|
76
|
-
DialogTitle,
|
|
77
|
-
DialogTrigger
|
|
78
|
-
} from './components/ui/dialog';
|
|
79
|
-
export {
|
|
80
|
-
Drawer,
|
|
81
|
-
DrawerClose,
|
|
82
|
-
DrawerContent,
|
|
83
|
-
DrawerDescription,
|
|
84
|
-
DrawerFooter,
|
|
85
|
-
DrawerHeader,
|
|
86
|
-
DrawerOverlay,
|
|
87
|
-
DrawerPortal,
|
|
88
|
-
DrawerTitle,
|
|
89
|
-
DrawerTrigger
|
|
90
|
-
} from './components/ui/drawer';
|
|
91
|
-
export {
|
|
92
|
-
DropdownMenu,
|
|
93
|
-
DropdownMenuCheckboxItem,
|
|
94
|
-
DropdownMenuContent,
|
|
95
|
-
DropdownMenuGroup,
|
|
96
|
-
DropdownMenuItem,
|
|
97
|
-
DropdownMenuLabel,
|
|
98
|
-
DropdownMenuPortal,
|
|
99
|
-
DropdownMenuRadioGroup,
|
|
100
|
-
DropdownMenuRadioItem,
|
|
101
|
-
DropdownMenuSeparator,
|
|
102
|
-
DropdownMenuShortcut,
|
|
103
|
-
DropdownMenuSub,
|
|
104
|
-
DropdownMenuSubContent,
|
|
105
|
-
DropdownMenuSubTrigger,
|
|
106
|
-
DropdownMenuTrigger
|
|
107
|
-
} from './components/ui/dropdown-menu';
|
|
108
|
-
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField } from './components/ui/form';
|
|
109
|
-
export { HoverCard, HoverCardContent, HoverCardTrigger } from './components/ui/hover-card';
|
|
110
|
-
export { Input } from './components/ui/input';
|
|
111
|
-
export { Label } from './components/ui/label';
|
|
112
|
-
export { modifyCpfCnpj, modifyPhone } from './components/ui/masks';
|
|
113
|
-
export {
|
|
114
|
-
Pagination,
|
|
115
|
-
PaginationContent,
|
|
116
|
-
PaginationEllipsis,
|
|
117
|
-
PaginationItem,
|
|
118
|
-
PaginationLink,
|
|
119
|
-
PaginationNext,
|
|
120
|
-
PaginationPrevious
|
|
121
|
-
} from './components/ui/pagination';
|
|
122
|
-
export { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover';
|
|
123
|
-
export { Progress } from './components/ui/progress';
|
|
124
|
-
export { RadioGroup, RadioGroupItem } from './components/ui/radio-group';
|
|
125
|
-
export { ScrollArea, ScrollBar } from './components/ui/scroll-area';
|
|
126
|
-
export {
|
|
127
|
-
Select,
|
|
128
|
-
SelectContent,
|
|
129
|
-
SelectGroup,
|
|
130
|
-
SelectItem,
|
|
131
|
-
SelectLabel,
|
|
132
|
-
SelectScrollDownButton,
|
|
133
|
-
SelectScrollUpButton,
|
|
134
|
-
SelectSeparator,
|
|
135
|
-
SelectTrigger,
|
|
136
|
-
SelectValue
|
|
137
|
-
} from './components/ui/select';
|
|
138
|
-
export { Separator } from './components/ui/separator';
|
|
139
|
-
export {
|
|
140
|
-
Sheet,
|
|
141
|
-
SheetClose,
|
|
142
|
-
SheetContent,
|
|
143
|
-
SheetDescription,
|
|
144
|
-
SheetFooter,
|
|
145
|
-
SheetHeader,
|
|
146
|
-
SheetOverlay,
|
|
147
|
-
SheetPortal,
|
|
148
|
-
SheetTitle,
|
|
149
|
-
SheetTrigger
|
|
150
|
-
} from './components/ui/sheet';
|
|
151
|
-
export {
|
|
152
|
-
Sidebar,
|
|
153
|
-
SidebarContent,
|
|
154
|
-
SidebarFooter,
|
|
155
|
-
SidebarGroup,
|
|
156
|
-
SidebarGroupAction,
|
|
157
|
-
SidebarGroupContent,
|
|
158
|
-
SidebarGroupLabel,
|
|
159
|
-
SidebarHeader,
|
|
160
|
-
SidebarInput,
|
|
161
|
-
SidebarInset,
|
|
162
|
-
SidebarMenu,
|
|
163
|
-
SidebarMenuAction,
|
|
164
|
-
SidebarMenuBadge,
|
|
165
|
-
SidebarMenuButton,
|
|
166
|
-
SidebarMenuItem,
|
|
167
|
-
SidebarMenuSkeleton,
|
|
168
|
-
SidebarMenuSub,
|
|
169
|
-
SidebarMenuSubButton,
|
|
170
|
-
SidebarMenuSubItem,
|
|
171
|
-
SidebarProvider,
|
|
172
|
-
SidebarRail,
|
|
173
|
-
SidebarSeparator,
|
|
174
|
-
SidebarTrigger,
|
|
175
|
-
useSidebar
|
|
176
|
-
} from './components/ui/sidebar';
|
|
177
|
-
export { Skeleton } from './components/ui/skeleton';
|
|
178
|
-
export { Slider } from './components/ui/slider';
|
|
179
|
-
export { Switch } from './components/ui/switch';
|
|
180
|
-
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './components/ui/table';
|
|
181
|
-
export { Tabs, TabsContent, TabsList, TabsTrigger } from './components/ui/tabs';
|
|
182
|
-
export { Textarea } from './components/ui/textarea';
|
|
183
|
-
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from './components/ui/toast';
|
|
184
|
-
export { Toaster } from './components/ui/toaster';
|
|
185
|
-
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/ui/tooltip';
|
|
186
|
-
export { default as UseCalendar } from './components/ui/use-calendar';
|
|
187
|
-
|
|
188
|
-
// =============================================================================
|
|
189
|
-
// CUSTOM COMPONENTS
|
|
190
|
-
// =============================================================================
|
|
191
|
-
|
|
192
|
-
// Custom Date Picker
|
|
193
|
-
export type { CalendarProps } from './components/ui/custom/date-picker';
|
|
194
|
-
|
|
195
|
-
// Custom Theme Provider
|
|
196
|
-
export { DEFAULT_THEME_DATA, ThemeProvider, useTheme } from './components/ui/custom/theme-provider';
|
|
197
|
-
|
|
198
|
-
// Custom Form Components
|
|
199
|
-
export { FormInputCpfCnpj } from './components/ui/custom/form/cpf-cnpj';
|
|
200
|
-
export { FormInputCurrency } from './components/ui/custom/form/currency';
|
|
201
|
-
export { FormInputDate } from './components/ui/custom/form/date';
|
|
202
|
-
export { FormDataRange } from './components/ui/custom/form/date-range';
|
|
203
|
-
export { FormInputDecimal } from './components/ui/custom/form/decimal';
|
|
204
|
-
export { FormInputFile } from './components/ui/custom/form/file';
|
|
205
|
-
export { FormInputGhost } from './components/ui/custom/form/ghost';
|
|
206
|
-
export { FormInput } from './components/ui/custom/form/input';
|
|
207
|
-
export { FormInputMask } from './components/ui/custom/form/mask';
|
|
208
|
-
export { MultiSelect, type MultiSelectOption } from './components/ui/custom/form/multi-select';
|
|
209
|
-
export { FormInputPassWord } from './components/ui/custom/form/password';
|
|
210
|
-
export { FormInputPercent } from './components/ui/custom/form/percent';
|
|
211
|
-
export { FormInputPhone } from './components/ui/custom/form/phone';
|
|
212
|
-
export { FormRadioGroup, type RadioOption } from './components/ui/custom/form/radio-group';
|
|
213
|
-
export { FormSelect, type SelectOption } from './components/ui/custom/form/select';
|
|
214
|
-
export { FormInputSwitch } from './components/ui/custom/form/switch';
|
|
215
|
-
export { FormInputText } from './components/ui/custom/form/text';
|
|
216
|
-
export { FormTextarea } from './components/ui/custom/form/textarea';
|
|
217
|
-
|
|
218
|
-
// Form Helpers
|
|
219
|
-
export { formHelpText } from './components/ui/custom/form/form-help-text';
|
|
220
|
-
export { formLabel, formLabelAndSubLabel } from './components/ui/custom/form/form-label';
|
|
221
|
-
export { formMessage } from './components/ui/custom/form/form-message';
|
|
222
|
-
|
|
223
|
-
// Custom Table Components
|
|
224
|
-
export {
|
|
225
|
-
DataTable,
|
|
226
|
-
type DataTableProps,
|
|
227
|
-
type OriginalDataTableData
|
|
228
|
-
} from './components/ui/custom/table/data-table';
|
|
229
|
-
export { DataTableExport } from './components/ui/custom/table/data-table-export';
|
|
230
|
-
export { DataTableFooter } from './components/ui/custom/table/data-table-footer';
|
|
231
|
-
export { DataTableHeader } from './components/ui/custom/table/data-table-header';
|
|
232
|
-
export { DataTableRows } from './components/ui/custom/table/data-table-rows';
|
|
233
|
-
|
|
234
|
-
// Table Types
|
|
235
|
-
export type {
|
|
236
|
-
ActionRow, ActionTable, ExportDataTable,
|
|
237
|
-
FiltersActions
|
|
238
|
-
} from './components/ui/custom/table/types/data-table';
|
|
239
|
-
|
|
240
|
-
// Custom Sidebar Components
|
|
241
|
-
export { default as ModuleSwitcher } from './components/ui/custom/sidebar/module-switcher';
|
|
242
|
-
export { default as NavFooter } from './components/ui/custom/sidebar/nav-footer';
|
|
243
|
-
export { default as NavMain } from './components/ui/custom/sidebar/nav-main';
|
|
244
|
-
export { default as NavSubmenuCollapsible } from './components/ui/custom/sidebar/nav-submenu-collapsible';
|
|
245
|
-
export { default as NavSubmenuDropdown } from './components/ui/custom/sidebar/nav-submenu-dropdown';
|
|
246
|
-
export { default as NavUser } from './components/ui/custom/sidebar/nav-user';
|
|
247
|
-
export { default as SidebarButton } from './components/ui/custom/sidebar/sidebar-button';
|
|
248
|
-
export { default as SidebarItem } from './components/ui/custom/sidebar/sidebar-item';
|
|
249
|
-
export { default as SidebarItemTwoLines } from './components/ui/custom/sidebar/sidebar-item-two-lines';
|
|
250
|
-
|
|
251
|
-
// Other Custom Components
|
|
252
|
-
export { default as Header } from './components/ui/custom/header';
|
|
253
|
-
export { default as LabelWithTitle } from './components/ui/custom/label';
|
|
254
|
-
export { default as NotFound } from './components/ui/custom/not-found';
|
|
255
|
-
|
|
256
|
-
// Sidebar Types
|
|
257
|
-
export {
|
|
258
|
-
SidebarSubmenuType,
|
|
259
|
-
type Module,
|
|
260
|
-
type SidebarPage
|
|
261
|
-
} from './components/ui/custom/sidebar/types/sidebar';
|
|
262
|
-
|
|
263
|
-
// =============================================================================
|
|
264
|
-
// HOOKS & UTILITIES
|
|
265
|
-
// =============================================================================
|
|
266
|
-
|
|
267
|
-
// Toast Hook
|
|
268
|
-
export { toast, useToast } from './components/ui/use-toast';
|
|
269
|
-
|
|
270
|
-
// Utility Functions
|
|
271
|
-
export { cn } from './lib/utils';
|
|
272
|
-
|
|
273
|
-
// Theme Utilities
|
|
274
|
-
export {
|
|
275
|
-
getTailwindColorShades,
|
|
276
|
-
replaceThemeTailwindColors,
|
|
277
|
-
type TailwindColorName
|
|
278
|
-
} from './lib/help/theme';
|
|
279
|
-
|
|
280
|
-
// Format Utilities
|
|
281
|
-
export {
|
|
282
|
-
convertBytesToMB, convertDaysToMonth, convertGbToMb, convertMbToGb, convertMonthToDays, convertSecondsToMinutes, formatCpfCnpj,
|
|
283
|
-
formatDate, formatDateCalendar, formatDateTime, formatDecimal, formatNumber, formatPhone, roundNumber, stringDateToDate, stringToNumber
|
|
284
|
-
} from './lib/help/format';
|
|
285
|
-
|
|
286
|
-
// Date Utilities
|
|
287
|
-
export {
|
|
288
|
-
addDaysToToday, aYearAgo, getFirstDayOf90DaysAgo, getFirstDayOfCurrentMonth, invertDate, stringToDate
|
|
289
|
-
} from './lib/help/date-utils';
|
|
290
|
-
|
|
291
|
-
// UUID Utilities
|
|
292
|
-
export { isUUIDv4 } from './lib/help/uuid';
|
|
293
|
-
|
|
294
|
-
// =============================================================================
|
|
295
|
-
// STYLES
|
|
296
|
-
// =============================================================================
|
|
297
|
-
|
|
298
|
-
import './styles/globals.css';
|
|
299
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const getFirstDayOfCurrentMonth = (): Date => {
|
|
2
|
-
const now = new Date();
|
|
3
|
-
return new Date(now.getFullYear(), now.getMonth(), 1);
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export const getFirstDayOf90DaysAgo = (): Date => {
|
|
7
|
-
const now = new Date();
|
|
8
|
-
return new Date(now.getFullYear(), now.getMonth() - 3, 1);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const stringToDate = (dateString: string, separator: string = '/'): Date | undefined => {
|
|
12
|
-
if (!dateString) return undefined;
|
|
13
|
-
|
|
14
|
-
const dateParts = dateString.split(separator);
|
|
15
|
-
if (dateParts.length !== 3) return undefined;
|
|
16
|
-
|
|
17
|
-
const day = parseInt(dateParts[0], 10);
|
|
18
|
-
const month = parseInt(dateParts[1], 10) - 1; // Months are zero-based in JavaScript
|
|
19
|
-
const year = parseInt(dateParts[2], 10);
|
|
20
|
-
|
|
21
|
-
return new Date(year, month, day);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const aYearAgo = (): Date => {
|
|
25
|
-
const aYearAgo = new Date();
|
|
26
|
-
aYearAgo.setFullYear(aYearAgo.getFullYear() - 1);
|
|
27
|
-
|
|
28
|
-
return aYearAgo;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const invertDate = (date: string, separator: string = '/'): string => {
|
|
32
|
-
if (!date) return '';
|
|
33
|
-
|
|
34
|
-
return date.split(separator).reverse().join('-');
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const addDaysToToday = (days: number): Date => {
|
|
38
|
-
const date = new Date();
|
|
39
|
-
date.setDate(date.getDate() + days);
|
|
40
|
-
return date;
|
|
41
|
-
};
|
package/src/lib/help/format.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { maskCpfCnpj, maskPhone } from "@/components/ui/masks";
|
|
2
|
-
import { format } from '@react-input/mask';
|
|
3
|
-
|
|
4
|
-
// PHONE
|
|
5
|
-
export function formatPhone(telefone: string, removerCountryCode = true) {
|
|
6
|
-
if (!telefone) return '';
|
|
7
|
-
|
|
8
|
-
let numberPhone = telefone.replace(/\D/g, '');
|
|
9
|
-
|
|
10
|
-
// Remover código do país apenas se ele começar com '55'
|
|
11
|
-
if (removerCountryCode && numberPhone.startsWith('55')) {
|
|
12
|
-
numberPhone = numberPhone.substring(2);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return format(numberPhone, maskPhone(numberPhone));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// CPF/CNPJ
|
|
19
|
-
export function formatCpfCnpj(cpfCnpj?: string): string {
|
|
20
|
-
if (!cpfCnpj) return '';
|
|
21
|
-
|
|
22
|
-
const numberCpfCnpj = cpfCnpj.replace(/\D/g, '');
|
|
23
|
-
|
|
24
|
-
return format(numberCpfCnpj, maskCpfCnpj(numberCpfCnpj));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// DATE
|
|
28
|
-
function getDay(date: Date) {
|
|
29
|
-
return date.getDate().toString().padStart(2, '0');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getMonth(date: Date) {
|
|
33
|
-
return (date.getMonth() + 1).toString().padStart(2, '0');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getYear(date: Date) {
|
|
37
|
-
return date.getFullYear().toString();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const formatDate = (date: string | Date | undefined, separator: string = '/') => {
|
|
41
|
-
if (!date) return '';
|
|
42
|
-
|
|
43
|
-
const d = new Date(date);
|
|
44
|
-
|
|
45
|
-
return d.toLocaleDateString('pt-BR');
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const formatDateTime = (date: Date | undefined, returnSeconds: boolean = false): string => {
|
|
49
|
-
if (!date) return '';
|
|
50
|
-
|
|
51
|
-
const hours = date.getHours().toString().padStart(2, '0');
|
|
52
|
-
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
53
|
-
const seconds = returnSeconds ? `:${date.getSeconds().toString().padStart(2, '0')}` : '';
|
|
54
|
-
|
|
55
|
-
return `${formatDate(date)} ${hours}:${minutes}${seconds}`;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export function formatDateCalendar(date: Date | undefined): string {
|
|
59
|
-
if (!date) return '';
|
|
60
|
-
|
|
61
|
-
const day = getDay(date);
|
|
62
|
-
const month = getMonth(date);
|
|
63
|
-
const year = getYear(date);
|
|
64
|
-
|
|
65
|
-
return `${year}-${month}-${day}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function stringDateToDate(date: string | undefined, separator: string = '/'): Date | undefined {
|
|
69
|
-
if (!date) return undefined;
|
|
70
|
-
|
|
71
|
-
const [day, month, year] = date.split(separator).map(Number);
|
|
72
|
-
|
|
73
|
-
// new Date(ano, mês-1, dia) interpreta a data no fuso horário local
|
|
74
|
-
return new Date(year, month - 1, day);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// NUMBER
|
|
78
|
-
export const roundNumber = (value: number, fractionDigits: number = 2): number => {
|
|
79
|
-
return Number(value.toFixed(fractionDigits));
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const stringToNumber = (value: string | undefined): number => {
|
|
83
|
-
if (!value) return 0;
|
|
84
|
-
|
|
85
|
-
const numericValue = value
|
|
86
|
-
.replace(/[^\d,-]/g, '')
|
|
87
|
-
.replace(/\./g, '')
|
|
88
|
-
.replace(',', '.');
|
|
89
|
-
return Number.parseFloat(numericValue);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const convertMbToGb = (value: number) => {
|
|
93
|
-
return value > 0 ? roundNumber(value / 1024) : 0;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const convertGbToMb = (value: number) => {
|
|
97
|
-
return value > 0 ? roundNumber(value * 1024) : 0;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const convertSecondsToMinutes = (value: number): number => {
|
|
101
|
-
return value > 0 ? roundNumber(value / 60) : 0;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const convertBytesToMB = (bytes: number): number => {
|
|
105
|
-
if (!bytes || Number.isNaN(bytes)) return 0;
|
|
106
|
-
return roundNumber(bytes / (1024 * 1024));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const convertMonthToDays = (months: number): number => {
|
|
110
|
-
return months > 0 ? months * 30 : 0;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const convertDaysToMonth = (days: number): number => {
|
|
114
|
-
return days > 0 ? roundNumber(days / 30) : 0;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// NUMBER
|
|
118
|
-
export const formatNumber = (value: number) => {
|
|
119
|
-
return value.toLocaleString('pt-BR', {
|
|
120
|
-
style: 'decimal',
|
|
121
|
-
minimumFractionDigits: 0,
|
|
122
|
-
maximumFractionDigits: 0,
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// DECIMAL
|
|
127
|
-
export const formatDecimal = (value: number, decimalPlaces: number = 2) => {
|
|
128
|
-
return value.toLocaleString('pt-BR', {
|
|
129
|
-
style: 'decimal',
|
|
130
|
-
minimumFractionDigits: decimalPlaces,
|
|
131
|
-
maximumFractionDigits: decimalPlaces,
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// PERCENT
|
|
136
|
-
export const formatPercent = (value: number, decimalPlaces: number = 2) => {
|
|
137
|
-
return `% ${formatDecimal(value, decimalPlaces)}`;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// CURRENCY
|
|
141
|
-
export const formatCurrency = (value: number, decimalPlaces: number = 2) => {
|
|
142
|
-
return value.toLocaleString('pt-BR', {
|
|
143
|
-
style: 'currency',
|
|
144
|
-
currency: 'BRL',
|
|
145
|
-
minimumFractionDigits: decimalPlaces,
|
|
146
|
-
maximumFractionDigits: decimalPlaces,
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const isInvalidCurrencyValue = (rawValue: string | undefined): boolean => {
|
|
151
|
-
if (!rawValue || rawValue.trim() === '') return true;
|
|
152
|
-
|
|
153
|
-
const numericValue = stringToNumber(rawValue);
|
|
154
|
-
|
|
155
|
-
return Number.isNaN(numericValue) || numericValue <= 0;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// OTHERS
|
|
159
|
-
export function formatMsisdn(value: string = ''): string {
|
|
160
|
-
const msisdn = value.replace(/\D/g, '');
|
|
161
|
-
return `(${msisdn.slice(2, 4)}) ${msisdn.slice(4, 9)}-${msisdn.slice(9)}`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function formatCEP(cep?: string) {
|
|
165
|
-
if (!cep) return '';
|
|
166
|
-
|
|
167
|
-
return cep
|
|
168
|
-
.replace(/\D/g, '')
|
|
169
|
-
.replace(/(\d{5})(\d)/, '$1-$2')
|
|
170
|
-
.replace(/(-\d{3})\d+?$/, '$1');
|
|
171
|
-
}
|