@greatapps/greatauth-ui 0.3.13 → 0.3.15

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
@@ -38,6 +38,8 @@ interface MenuItem {
38
38
  href: string;
39
39
  children?: MenuItem[];
40
40
  onClick?: () => void;
41
+ isActive?: boolean;
42
+ badge?: string | number;
41
43
  }
42
44
  interface HeaderConfig {
43
45
  defaultBreadcrumb?: string;
package/dist/index.js CHANGED
@@ -362,7 +362,7 @@ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
362
362
  var SIDEBAR_STORAGE_KEY = "sidebar_state";
363
363
  var SIDEBAR_WIDTH = "16rem";
364
364
  var SIDEBAR_WIDTH_MOBILE = "18rem";
365
- var SIDEBAR_WIDTH_ICON = "3rem";
365
+ var SIDEBAR_WIDTH_ICON = "3.5rem";
366
366
  var SIDEBAR_KEYBOARD_SHORTCUT = "b";
367
367
  var SidebarContext = React.createContext(null);
368
368
  function useSidebar() {
@@ -572,6 +572,30 @@ function SidebarTrigger({
572
572
  }
573
573
  );
574
574
  }
575
+ function SidebarRail({ className, ...props }) {
576
+ const { toggleSidebar } = useSidebar();
577
+ return /* @__PURE__ */ jsx7(
578
+ "button",
579
+ {
580
+ "data-sidebar": "rail",
581
+ "data-slot": "sidebar-rail",
582
+ "aria-label": "Toggle Sidebar",
583
+ tabIndex: -1,
584
+ onClick: toggleSidebar,
585
+ title: "Toggle Sidebar",
586
+ className: cn(
587
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
588
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
589
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
590
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
591
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
592
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
593
+ className
594
+ ),
595
+ ...props
596
+ }
597
+ );
598
+ }
575
599
  function SidebarInset({ className, ...props }) {
576
600
  return /* @__PURE__ */ jsx7(
577
601
  "main",
@@ -757,7 +781,7 @@ function SidebarMenuButton({
757
781
  // src/components/app-sidebar.tsx
758
782
  import { usePathname, useRouter } from "next/navigation";
759
783
  import Link from "next/link";
760
- import { ChevronUp, ChevronRight as ChevronRight2, LogOut } from "lucide-react";
784
+ import { ChevronsUpDown, ChevronRight as ChevronRight2, LogOut } from "lucide-react";
761
785
 
762
786
  // src/components/ui/collapsible.tsx
763
787
  import { Collapsible as CollapsiblePrimitive } from "radix-ui";
@@ -779,12 +803,17 @@ function CollapsibleTrigger({
779
803
  );
780
804
  }
781
805
  function CollapsibleContent({
806
+ className,
782
807
  ...props
783
808
  }) {
784
809
  return /* @__PURE__ */ jsx8(
785
810
  CollapsiblePrimitive.CollapsibleContent,
786
811
  {
787
812
  "data-slot": "collapsible-content",
813
+ className: cn(
814
+ "overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",
815
+ className
816
+ ),
788
817
  ...props
789
818
  }
790
819
  );
@@ -981,23 +1010,35 @@ function getUserInitials(name, email) {
981
1010
  return parts[0][0].toUpperCase();
982
1011
  }
983
1012
  function SimpleMenuItem({ item, pathname }) {
984
- const isActive = pathname.startsWith(item.href);
1013
+ const isActive = item.isActive ?? pathname.startsWith(item.href);
985
1014
  const Icon = item.icon;
986
- return /* @__PURE__ */ jsx12(SidebarMenuItem, { children: /* @__PURE__ */ jsx12(SidebarMenuButton, { asChild: true, isActive, tooltip: item.label, children: /* @__PURE__ */ jsxs5(Link, { href: item.href, onClick: item.onClick, children: [
1015
+ return /* @__PURE__ */ jsx12(SidebarMenuItem, { children: /* @__PURE__ */ jsx12(SidebarMenuButton, { asChild: true, isActive, tooltip: item.label, children: /* @__PURE__ */ jsxs5(Link, { href: item.href, onClick: item.onClick, "aria-current": isActive ? "page" : void 0, children: [
987
1016
  /* @__PURE__ */ jsx12(Icon, { className: "size-4" }),
988
- /* @__PURE__ */ jsx12("span", { children: item.label })
1017
+ /* @__PURE__ */ jsx12("span", { children: item.label }),
1018
+ item.badge != null && /* @__PURE__ */ jsx12("span", { className: "ml-auto flex h-5 min-w-5 items-center justify-center rounded-full bg-primary/10 px-1.5 text-[10px] font-semibold text-primary tabular-nums", children: item.badge })
989
1019
  ] }) }) });
990
1020
  }
991
1021
  function CollapsibleMenuItem({ item, pathname }) {
992
1022
  const Icon = item.icon;
993
- const isChildActive = item.children?.some((child) => pathname.startsWith(child.href)) ?? false;
994
- return /* @__PURE__ */ jsx12(Collapsible, { defaultOpen: isChildActive, className: "group/collapsible", children: /* @__PURE__ */ jsxs5(SidebarMenuItem, { children: [
995
- /* @__PURE__ */ jsx12(CollapsibleTrigger, { asChild: true, children: /* @__PURE__ */ jsxs5(SidebarMenuButton, { tooltip: item.label, children: [
1023
+ const isParentActive = pathname.startsWith(item.href);
1024
+ const isChildActive = item.children?.some(
1025
+ (child) => child.isActive !== void 0 ? child.isActive : pathname.startsWith(child.href)
1026
+ ) ?? false;
1027
+ return /* @__PURE__ */ jsx12(Collapsible, { defaultOpen: isParentActive || isChildActive, className: "group/collapsible", children: /* @__PURE__ */ jsxs5(SidebarMenuItem, { children: [
1028
+ /* @__PURE__ */ jsx12(SidebarMenuButton, { asChild: true, isActive: isParentActive, tooltip: item.label, children: /* @__PURE__ */ jsxs5(Link, { href: item.href, onClick: item.onClick, children: [
996
1029
  /* @__PURE__ */ jsx12(Icon, { className: "size-4" }),
997
- /* @__PURE__ */ jsx12("span", { children: item.label }),
998
- /* @__PURE__ */ jsx12(ChevronRight2, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1030
+ /* @__PURE__ */ jsx12("span", { children: item.label })
999
1031
  ] }) }),
1000
- /* @__PURE__ */ jsx12(CollapsibleContent, { children: /* @__PURE__ */ jsx12(SidebarMenu, { className: "ml-4 border-l pl-2", children: item.children?.map((child) => /* @__PURE__ */ jsx12(SimpleMenuItem, { item: child, pathname }, child.href)) }) })
1032
+ /* @__PURE__ */ jsx12(CollapsibleTrigger, { asChild: true, children: /* @__PURE__ */ jsx12(
1033
+ "button",
1034
+ {
1035
+ "data-sidebar": "menu-action",
1036
+ className: "absolute right-1 top-1.5 flex h-5 w-5 items-center justify-center rounded-md text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground outline-hidden focus-visible:ring-2 ring-sidebar-ring transition-colors group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden",
1037
+ "aria-label": "Expandir submenu",
1038
+ children: /* @__PURE__ */ jsx12(ChevronRight2, { className: "size-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1039
+ }
1040
+ ) }),
1041
+ /* @__PURE__ */ jsx12(CollapsibleContent, { children: /* @__PURE__ */ jsx12(SidebarMenu, { className: "ml-4 border-l pl-2", children: item.children?.map((child) => /* @__PURE__ */ jsx12(SimpleMenuItem, { item: child, pathname }, child.href + child.label)) }) })
1001
1042
  ] }) });
1002
1043
  }
1003
1044
  function AppSidebar({ config }) {
@@ -1034,7 +1075,7 @@ function AppSidebar({ config }) {
1034
1075
  /* @__PURE__ */ jsx12("span", { className: "truncate font-semibold", children: userName }),
1035
1076
  /* @__PURE__ */ jsx12("span", { className: "truncate text-xs text-muted-foreground", children: userEmail })
1036
1077
  ] }),
1037
- /* @__PURE__ */ jsx12(ChevronUp, { className: "ml-auto size-4 group-data-[collapsible=icon]:hidden" })
1078
+ /* @__PURE__ */ jsx12(ChevronsUpDown, { className: "ml-auto size-4 group-data-[collapsible=icon]:hidden" })
1038
1079
  ] }) }),
1039
1080
  /* @__PURE__ */ jsxs5(
1040
1081
  DropdownMenuContent,
@@ -1057,7 +1098,8 @@ function AppSidebar({ config }) {
1057
1098
  ]
1058
1099
  }
1059
1100
  )
1060
- ] }) }) }) })
1101
+ ] }) }) }) }),
1102
+ /* @__PURE__ */ jsx12(SidebarRail, {})
1061
1103
  ] });
1062
1104
  }
1063
1105
 
@@ -1990,7 +2032,7 @@ import { useEffect as useEffect3, useState as useState5 } from "react";
1990
2032
 
1991
2033
  // src/components/ui/select.tsx
1992
2034
  import { Select as SelectPrimitive } from "radix-ui";
1993
- import { ChevronsUpDown, Check as Check2, ChevronUp as ChevronUp2, ChevronDown } from "lucide-react";
2035
+ import { ChevronsUpDown as ChevronsUpDown2, Check as Check2, ChevronUp, ChevronDown } from "lucide-react";
1994
2036
  import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
1995
2037
  function Select({
1996
2038
  ...props
@@ -2020,7 +2062,7 @@ function SelectTrigger({
2020
2062
  ...props,
2021
2063
  children: [
2022
2064
  children,
2023
- /* @__PURE__ */ jsx23(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx23(ChevronsUpDown, { className: "text-muted-foreground size-4 pointer-events-none" }) })
2065
+ /* @__PURE__ */ jsx23(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx23(ChevronsUpDown2, { className: "text-muted-foreground size-4 pointer-events-none" }) })
2024
2066
  ]
2025
2067
  }
2026
2068
  );
@@ -2090,7 +2132,7 @@ function SelectScrollUpButton({
2090
2132
  "data-slot": "select-scroll-up-button",
2091
2133
  className: cn("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4", className),
2092
2134
  ...props,
2093
- children: /* @__PURE__ */ jsx23(ChevronUp2, {})
2135
+ children: /* @__PURE__ */ jsx23(ChevronUp, {})
2094
2136
  }
2095
2137
  );
2096
2138
  }