eai-frontend-components 2.0.83 → 2.0.85

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.d.ts CHANGED
@@ -80,7 +80,7 @@ declare const AvatarImage: React$1.ForwardRefExoticComponent<Omit<AvatarPrimitiv
80
80
  declare const AvatarFallback: React$1.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React$1.RefAttributes<HTMLSpanElement>, "ref"> & React$1.RefAttributes<HTMLSpanElement>>;
81
81
 
82
82
  declare const badgeVariants: (props?: ({
83
- variant?: "default" | "secondary" | "surface" | "destructive" | "outline" | "green" | "red" | "gray" | "blue" | "orange" | "yellow" | null | undefined;
83
+ variant?: "default" | "secondary" | "destructive" | "outline" | "surface" | "green" | "red" | "gray" | "blue" | "orange" | "yellow" | null | undefined;
84
84
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
85
85
  interface BadgeProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
86
86
  }
@@ -105,7 +105,7 @@ declare const BreadcrumbEllipsis: {
105
105
  };
106
106
 
107
107
  declare const buttonVariants: (props?: ({
108
- variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "primary" | "ghost" | null | undefined;
108
+ variant?: "link" | "default" | "primary" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
109
109
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
110
110
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
111
111
  interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -1113,13 +1113,32 @@ interface OrgChartNodeData {
1113
1113
  children?: OrgChartNodeData[];
1114
1114
  data?: Record<string, unknown>;
1115
1115
  }
1116
+ interface NodeCardProps {
1117
+ node: OrgChartNodeData;
1118
+ onNodeClick?: (node: OrgChartNodeData) => void;
1119
+ isExpanded: boolean;
1120
+ hasChildren: boolean;
1121
+ onToggle: () => void;
1122
+ }
1123
+ type ActionOrgChart = {
1124
+ label: string;
1125
+ icon?: JSX.Element;
1126
+ variant?: string;
1127
+ onClick?: () => void;
1128
+ className?: string;
1129
+ disabled?: boolean;
1130
+ };
1116
1131
  interface OrgChartProps {
1132
+ defaultSearch?: string;
1133
+ setSearch?: (value?: string) => void;
1134
+ actions?: ActionOrgChart[];
1117
1135
  data: OrgChartNodeData;
1118
1136
  onNodeClick?: (node: OrgChartNodeData) => void;
1119
1137
  defaultExpanded?: boolean;
1120
1138
  className?: string;
1139
+ renderNode?: (props: NodeCardProps) => ReactNode;
1121
1140
  }
1122
- declare function OrgChart({ data, onNodeClick, defaultExpanded, className }: OrgChartProps): react_jsx_runtime.JSX.Element;
1141
+ declare function OrgChart({ defaultSearch, setSearch, actions, data, onNodeClick, defaultExpanded, className, renderNode }: OrgChartProps): react_jsx_runtime.JSX.Element;
1123
1142
 
1124
1143
  type ResponsiveDialogAction = {
1125
1144
  label: string;
@@ -1800,4 +1819,4 @@ declare function isUUIDv4(str: string): boolean;
1800
1819
  declare function cn(...inputs: ClassValue[]): string;
1801
1820
 
1802
1821
  export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DEFAULT_THEME_DATA, DataTable, DataTableExport, DataTableFooter, DataTableHeader, DataTableRows, DatePickerWithRange as DateRangePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormCombobox, FormControl, FormDataRange, FormDescription, FormField, FormInput, FormInputCheckbox, FormInputColor, FormInputCpfCnpj, FormInputCurrency, FormInputDate, FormInputDecimal, FormInputFile, FormInputGhost, FormInputMask, FormInputPassWord, FormInputPercent, FormInputPhone, FormInputSwitch, FormInputText, FormItem, FormLabel, FormMessage, FormRadioGroup, FormSelect, FormTextarea, Header, HoverCard, HoverCardContent, HoverCardTrigger, Input, Label, LabelWithTitle, ModuleSwitcher, MultiSelect, NavFooter, NavMain, NavSubmenuCollapsible, NavSubmenuDropdown, NavUser, NotFound, OrgChart, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ResponsiveDialog, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarButton, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarItem, SidebarItemTwoLines, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarSubmenuType, SidebarTrigger, Skeleton, Slider, StepNewForm, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toast$1 as Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UseCalendar, aYearAgo, addDaysToToday, badgeVariants, buttonVariants, cn, convertBytesToMB, convertDaysToMonth, convertGbToMb, convertInternetToDisplay, convertMbToGb, convertMonthToDays, convertSecondsToMinutes, formHelpText, formLabel, formLabelAndSubLabel, formMessage, formatCEP, formatCpfCnpj, formatCurrency, formatDate, formatDateCalendar, formatDateTime, formatDecimal, formatMsisdn, formatNumber, formatPercent, formatPhone, getFirstDayOf90DaysAgo, getFirstDayOfCurrentMonth, getTailwindColorShades, invertDate, isDateRangeValid, isInvalidCurrencyValue, isUUIDv4, isValidDate, maskCpfCnpj, maskPhone, modifyCpfCnpj, modifyPhone, removeMaskNumber, replaceThemeTailwindColors, roundNumber, stringDateToDate, stringToDate, stringToNumber, toast, useDownload, useFormField, useSidebar, useTheme, useToast };
1803
- export type { ActionRow, ActionTable, ButtonProps, CalendarProps, CarouselApi, ChartConfig, ComboboxOption, DataTableProps, ExportDataTable, FiltersActions, MaskModifyFunction, Module, MultiSelectOption, OrgChartNodeBadge, OrgChartNodeData, OrgChartProps, OriginalDataTableData, PropsStepNewForm, RadioOption, ResponsiveDialogAction, ResponsiveDialogRef, SelectOption, SidebarPage, TailwindColorName };
1822
+ export type { ActionOrgChart, ActionRow, ActionTable, ButtonProps, CalendarProps, CarouselApi, ChartConfig, ComboboxOption, DataTableProps, ExportDataTable, FiltersActions, MaskModifyFunction, Module, MultiSelectOption, OrgChartNodeBadge, OrgChartNodeData, OrgChartProps, OriginalDataTableData, PropsStepNewForm, RadioOption, ResponsiveDialogAction, ResponsiveDialogRef, SelectOption, SidebarPage, TailwindColorName };
package/dist/index.esm.js CHANGED
@@ -10144,19 +10144,38 @@ function NodeCard({ node, onNodeClick, isExpanded, hasChildren, onToggle }) {
10144
10144
  onToggle();
10145
10145
  }, children: isExpanded ? jsx(ChevronUp, { className: 'h-3 w-3' }) : jsx(ChevronDown, { className: 'h-3 w-3' }) }) }))] }) }));
10146
10146
  }
10147
- function OrgChartTreeNode({ node, onNodeClick, defaultExpanded }) {
10147
+ function OrgChartTreeNode({ node, onNodeClick, defaultExpanded, renderNode }) {
10148
10148
  const [isExpanded, setIsExpanded] = useState(defaultExpanded);
10149
10149
  const children = node.children ?? [];
10150
10150
  const hasChildren = children.length > 0;
10151
- return (jsxs("div", { className: 'flex flex-col items-center', children: [jsx(NodeCard, { node: node, onNodeClick: onNodeClick, isExpanded: isExpanded, hasChildren: hasChildren, onToggle: () => setIsExpanded((prev) => !prev) }), hasChildren && isExpanded && (jsxs(Fragment, { children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx("div", { className: 'flex items-start', children: children.map((child, i) => {
10151
+ const cardProps = {
10152
+ node,
10153
+ onNodeClick,
10154
+ isExpanded,
10155
+ hasChildren,
10156
+ onToggle: () => setIsExpanded((prev) => !prev),
10157
+ };
10158
+ return (jsxs("div", { className: 'flex flex-col items-center', children: [renderNode ? renderNode(cardProps) : jsx(NodeCard, { ...cardProps }), hasChildren && isExpanded && (jsxs(Fragment, { children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx("div", { className: 'flex items-start', children: children.map((child, i) => {
10152
10159
  const isOnly = children.length === 1;
10153
10160
  const isFirst = i === 0;
10154
10161
  const isLast = i === children.length - 1;
10155
- return (jsxs("div", { className: cn('relative flex flex-col items-center px-4', !isOnly && "after:absolute after:top-0 after:h-px after:bg-border after:content-['']", !isOnly && isFirst && 'after:-right-4 after:left-1/2', !isOnly && isLast && 'after:-left-4 after:right-1/2', !isOnly && !isFirst && !isLast && 'after:-left-4 after:-right-4'), children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded })] }, child.id));
10162
+ return (jsxs("div", { className: cn('relative flex flex-col items-center px-4', !isOnly && "after:absolute after:top-0 after:h-px after:bg-border after:content-['']", !isOnly && isFirst && 'after:-right-4 after:left-1/2', !isOnly && isLast && 'after:-left-4 after:right-1/2', !isOnly && !isFirst && !isLast && 'after:-left-4 after:-right-4'), children: [jsx("div", { className: 'h-4 w-px bg-border' }), jsx(OrgChartTreeNode, { node: child, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode })] }, child.id));
10156
10163
  }) })] }))] }));
10157
10164
  }
10158
- function OrgChart({ data, onNodeClick, defaultExpanded = true, className }) {
10159
- return (jsx("div", { className: cn('w-full overflow-x-auto', className), children: jsx("div", { className: 'flex justify-center px-4 py-6', children: jsx(OrgChartTreeNode, { node: data, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded }) }) }));
10165
+ function OrgChart({ defaultSearch, setSearch, actions, data, onNodeClick, defaultExpanded = true, className, renderNode }) {
10166
+ const debounceTimeout = useRef(null);
10167
+ const handleSearchChange = (event) => {
10168
+ const value = event.currentTarget.value;
10169
+ if (debounceTimeout.current) {
10170
+ clearTimeout(debounceTimeout.current);
10171
+ }
10172
+ debounceTimeout.current = setTimeout(() => {
10173
+ setSearch?.(value);
10174
+ }, 300);
10175
+ };
10176
+ return (jsxs("div", { className: 'flex h-full flex-col gap-4 overflow-x-auto', children: [jsxs("div", { className: 'flex items-center gap-x-4', children: [jsx("div", { className: 'flex gap-x-4', children: jsxs("div", { className: 'flex bg-background items-center border border-slate-300 rounded-sm w-[350px] overflow-hidden focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 group', children: [jsx("div", { className: 'pl-3.5 transform transition-transform duration-300 group-hover:-translate-x-1', children: jsx(Search, { size: 18, className: 'w-5 h-5 stroke-zinc-500 dark:stroke-default' }) }), jsx("input", { placeholder: 'Buscar', defaultValue: defaultSearch, onChange: (event) => {
10177
+ handleSearchChange(event);
10178
+ }, className: 'w-full bg-background text-default border-none focus:ring-0 focus:outline-none px-3 py-2 transform transition-transform duration-300 group-hover:-translate-x-1 ' })] }) }), jsx("div", { className: 'flex space-x-4 content-end', children: actions?.map((action, index) => (jsx("div", { children: jsxs(Button, { type: 'button', onClick: () => action.onClick?.(), className: cn(action.className), variant: action.variant || 'default', disabled: action.disabled, children: [jsx("div", { className: '[&_svg]:size-5', children: action.icon }), action.label] }) }, `action-table-${index}`))) })] }), jsx(Card, { className: 'flex-1 overflow-hidden', children: jsx(CardContent, { className: 'h-full p-0', children: jsx("div", { className: cn('w-full overflow-x-auto', className), children: jsx("div", { className: 'flex justify-center px-4 py-6', children: jsx(OrgChartTreeNode, { node: data, onNodeClick: onNodeClick, defaultExpanded: defaultExpanded, renderNode: renderNode }) }) }) }) })] }));
10160
10179
  }
10161
10180
 
10162
10181
  function useMediaQuery(queryInput) {