@cupcodev/ui 1.2.3 → 1.2.51

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.cjs CHANGED
@@ -2675,9 +2675,54 @@ var NavbarCupcode = ({
2675
2675
  className
2676
2676
  }) => {
2677
2677
  const [isOpen, setIsOpen] = React10.useState(false);
2678
+ const navRef = React10.useRef(null);
2679
+ const mobileMenuId = React10.useId();
2680
+ React10.useEffect(() => {
2681
+ if (!isOpen) return;
2682
+ const handlePointerDown = (event) => {
2683
+ var _a65;
2684
+ const target = event.target;
2685
+ if (!(target instanceof Node)) return;
2686
+ if (!((_a65 = navRef.current) == null ? void 0 : _a65.contains(target))) {
2687
+ setIsOpen(false);
2688
+ }
2689
+ };
2690
+ const handleEscape = (event) => {
2691
+ if (event.key === "Escape") {
2692
+ setIsOpen(false);
2693
+ }
2694
+ };
2695
+ document.addEventListener("pointerdown", handlePointerDown);
2696
+ document.addEventListener("keydown", handleEscape);
2697
+ return () => {
2698
+ document.removeEventListener("pointerdown", handlePointerDown);
2699
+ document.removeEventListener("keydown", handleEscape);
2700
+ };
2701
+ }, [isOpen]);
2702
+ React10.useEffect(() => {
2703
+ if (!isOpen) return;
2704
+ const { style } = document.body;
2705
+ const previousOverflow = style.overflow;
2706
+ style.overflow = "hidden";
2707
+ return () => {
2708
+ style.overflow = previousOverflow;
2709
+ };
2710
+ }, [isOpen]);
2711
+ React10.useEffect(() => {
2712
+ const handleResize = () => {
2713
+ if (window.innerWidth >= 768) {
2714
+ setIsOpen(false);
2715
+ }
2716
+ };
2717
+ window.addEventListener("resize", handleResize);
2718
+ return () => {
2719
+ window.removeEventListener("resize", handleResize);
2720
+ };
2721
+ }, []);
2678
2722
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2679
2723
  "nav",
2680
2724
  {
2725
+ ref: navRef,
2681
2726
  className: cn(
2682
2727
  "fixed top-0 left-0 right-0 z-[200] pointer-events-auto",
2683
2728
  "glass border-b border-border",
@@ -2736,38 +2781,49 @@ var NavbarCupcode = ({
2736
2781
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2737
2782
  "button",
2738
2783
  {
2784
+ type: "button",
2739
2785
  onClick: () => setIsOpen(!isOpen),
2740
- className: "md:hidden p-2 rounded-lg hover:bg-primary/10 transition-colors",
2741
- children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.X, { className: "h-6 w-6 text-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.Menu, { className: "h-6 w-6 text-foreground" })
2786
+ "aria-controls": mobileMenuId,
2787
+ "aria-expanded": isOpen,
2788
+ "aria-label": isOpen ? "Fechar menu de navega\xE7\xE3o" : "Abrir menu de navega\xE7\xE3o",
2789
+ className: "md:hidden inline-flex h-10 w-10 items-center justify-center rounded-lg transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
2790
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react5.Menu, { className: cn("h-6 w-6 text-foreground", isOpen && "text-primary") })
2742
2791
  }
2743
2792
  )
2744
2793
  ] }),
2745
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "md:hidden py-4 space-y-3 animate-slide-up", children: [
2746
- items.map((item, index) => {
2747
- const key = `${item.label}-${index}`;
2748
- const isActive = item.isActive;
2749
- const classes = cn(
2750
- "flex items-center gap-2 px-4 py-2 text-sm font-semibold text-foreground hover:bg-primary/10 rounded-lg transition-colors",
2751
- isActive && "text-primary"
2752
- );
2753
- const handleClick = (event) => {
2754
- var _a65;
2755
- (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2756
- setIsOpen(false);
2757
- };
2758
- if (item.href.startsWith("#")) {
2759
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("a", { href: item.href, className: classes, onClick: handleClick, children: [
2760
- item.icon && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: item.icon }),
2761
- item.label
2762
- ] }, key);
2763
- }
2764
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("a", { href: item.href, className: classes, onClick: handleClick, children: [
2765
- item.icon && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: item.icon }),
2766
- item.label
2767
- ] }, key);
2768
- }),
2769
- actions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "px-4 pt-2", children: actions })
2770
- ] })
2794
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2795
+ "div",
2796
+ {
2797
+ id: mobileMenuId,
2798
+ className: "md:hidden max-h-[calc(100dvh-4rem)] space-y-3 overflow-y-auto border-t border-border/60 py-4 animate-slide-up",
2799
+ children: [
2800
+ items.map((item, index) => {
2801
+ const key = `${item.label}-${index}`;
2802
+ const isActive = item.isActive;
2803
+ const classes = cn(
2804
+ "flex min-h-11 items-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold text-foreground transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
2805
+ isActive && "text-primary"
2806
+ );
2807
+ const handleClick = (event) => {
2808
+ var _a65;
2809
+ (_a65 = item.onClick) == null ? void 0 : _a65.call(item, event);
2810
+ setIsOpen(false);
2811
+ };
2812
+ if (item.href.startsWith("#")) {
2813
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("a", { href: item.href, className: classes, onClick: handleClick, children: [
2814
+ item.icon && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: item.icon }),
2815
+ item.label
2816
+ ] }, key);
2817
+ }
2818
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("a", { href: item.href, className: classes, onClick: handleClick, children: [
2819
+ item.icon && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: item.icon }),
2820
+ item.label
2821
+ ] }, key);
2822
+ }),
2823
+ actions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "px-4 pb-[max(env(safe-area-inset-bottom),0.5rem)] pt-2", children: actions })
2824
+ ]
2825
+ }
2826
+ )
2771
2827
  ] })
2772
2828
  }
2773
2829
  );
@@ -10118,7 +10174,7 @@ var UserMenuCupcode = ({
10118
10174
  type: "button",
10119
10175
  onClick: () => openChatPanel(),
10120
10176
  className: cn(
10121
- "relative z-0 inline-flex h-9 min-w-[2.55rem] origin-right items-center justify-center rounded-[12px] border border-border/70 bg-background/80 px-2.5 text-foreground shadow-[0_10px_22px_-18px_rgba(0,0,0,0.75)] transition-[transform,opacity] duration-[260ms] will-change-transform",
10177
+ "relative z-0 inline-flex h-9 min-w-[2.55rem] origin-right items-center justify-center rounded-[12px] border border-border/70 bg-background/80 px-2.5 text-foreground shadow-[0_10px_22px_-18px_rgba(0,0,0,0.75)] transition-[transform,opacity] [transition-duration:260ms] will-change-transform",
10122
10178
  prefersReducedMotion ? isChatIndicatorVisible ? "opacity-100" : "opacity-0" : isChatIndicatorVisible ? "translate-x-0 opacity-100" : "translate-x-[10px] opacity-0"
10123
10179
  ),
10124
10180
  style: {
@@ -10131,7 +10187,7 @@ var UserMenuCupcode = ({
10131
10187
  "span",
10132
10188
  {
10133
10189
  className: cn(
10134
- "relative inline-flex transition-[transform,opacity] duration-[220ms]",
10190
+ "relative inline-flex transition-[transform,opacity] [transition-duration:220ms]",
10135
10191
  prefersReducedMotion ? isChatIndicatorVisible ? "scale-100 opacity-100" : "scale-100 opacity-0" : isChatIndicatorVisible ? isChatIndicatorIntroAnimating ? "scale-[1.08] opacity-100" : "scale-100 opacity-100" : "scale-[0.84] opacity-0"
10136
10192
  ),
10137
10193
  style: {
@@ -10144,7 +10200,7 @@ var UserMenuCupcode = ({
10144
10200
  "span",
10145
10201
  {
10146
10202
  className: cn(
10147
- "absolute -right-1 -top-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full border border-background bg-destructive px-1 text-[9px] font-bold text-destructive-foreground transition-[transform,opacity] duration-[180ms]",
10203
+ "absolute -right-1 -top-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full border border-background bg-destructive px-1 text-[9px] font-bold text-destructive-foreground transition-[transform,opacity] [transition-duration:180ms]",
10148
10204
  prefersReducedMotion ? isChatIndicatorVisible ? "scale-100 opacity-100" : "scale-100 opacity-0" : isChatIndicatorVisible ? isChatBadgePulsing ? "scale-[1.14] opacity-100" : "scale-100 opacity-100" : "scale-[0.72] opacity-0"
10149
10205
  ),
10150
10206
  style: {
@@ -22773,7 +22829,7 @@ var MainNavbar = ({
22773
22829
  ctaHref = "/login",
22774
22830
  pathname,
22775
22831
  onNavigate,
22776
- authStatus = "unauthenticated",
22832
+ authStatus,
22777
22833
  authUser,
22778
22834
  presenceStatus,
22779
22835
  onPresenceStatusChange,
@@ -22824,7 +22880,14 @@ var MainNavbar = ({
22824
22880
  }, []);
22825
22881
  const resolvedProfileAvatarUrl = (_b5 = (_a65 = resolveChatAvatarUrl(persistedProfileAvatarValue)) != null ? _a65 : authUser == null ? void 0 : authUser.picture) != null ? _b5 : void 0;
22826
22882
  const effectiveCurrentUserId = resolvedSenderId != null ? resolvedSenderId : currentUserId;
22827
- const isAuthenticated = authStatus === "authenticated";
22883
+ const resolvedAuthStatus = (0, import_react19.useMemo)(() => {
22884
+ if (authStatus) return authStatus;
22885
+ if ((authUser == null ? void 0 : authUser.sub) || (authUser == null ? void 0 : authUser.email)) {
22886
+ return "authenticated";
22887
+ }
22888
+ return "unauthenticated";
22889
+ }, [authStatus, authUser == null ? void 0 : authUser.email, authUser == null ? void 0 : authUser.sub]);
22890
+ const isAuthenticated = resolvedAuthStatus === "authenticated";
22828
22891
  (0, import_react19.useEffect)(() => {
22829
22892
  if (!isAuthenticated) {
22830
22893
  setResolvedSenderId(null);
@@ -24185,8 +24248,8 @@ var MainNavbar = ({
24185
24248
  actions: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
24186
24249
  UserMenuCupcode,
24187
24250
  {
24188
- isAuthenticated: authStatus === "authenticated",
24189
- isLoading: authStatus === "loading",
24251
+ isAuthenticated: resolvedAuthStatus === "authenticated",
24252
+ isLoading: resolvedAuthStatus === "loading",
24190
24253
  loginLabel: ctaLabel,
24191
24254
  displayName: authUser == null ? void 0 : authUser.name,
24192
24255
  username: (_c = authUser == null ? void 0 : authUser.preferredUsername) != null ? _c : authUser == null ? void 0 : authUser.nickname,
@@ -26363,14 +26426,31 @@ var sheetVariants = (0, import_class_variance_authority6.cva)(
26363
26426
  }
26364
26427
  );
26365
26428
  var SheetContent = React56.forwardRef(
26366
- ({ side = "right", className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(SheetPortal, { children: [
26429
+ ({
26430
+ side = "right",
26431
+ className,
26432
+ children,
26433
+ showCloseButton = false,
26434
+ closeButtonClassName,
26435
+ closeButtonLabel = "Close",
26436
+ ...props
26437
+ }, ref) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(SheetPortal, { children: [
26367
26438
  /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(SheetOverlay, {}),
26368
26439
  /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(SheetPrimitive.Content, { ref, className: cn(sheetVariants({ side }), className), ...props, children: [
26369
26440
  children,
26370
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(SheetPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none", children: [
26371
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_lucide_react28.X, { className: "h-4 w-4" }),
26372
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "sr-only", children: "Close" })
26373
- ] })
26441
+ showCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
26442
+ SheetPrimitive.Close,
26443
+ {
26444
+ className: cn(
26445
+ "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",
26446
+ closeButtonClassName
26447
+ ),
26448
+ children: [
26449
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_lucide_react28.X, { className: "h-4 w-4" }),
26450
+ /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "sr-only", children: closeButtonLabel })
26451
+ ]
26452
+ }
26453
+ ) : null
26374
26454
  ] })
26375
26455
  ] })
26376
26456
  );
@@ -26501,7 +26581,7 @@ var Sidebar = React58.forwardRef(({ side = "left", variant = "sidebar", collapsi
26501
26581
  {
26502
26582
  "data-sidebar": "sidebar",
26503
26583
  "data-mobile": "true",
26504
- className: "w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
26584
+ className: "w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground",
26505
26585
  style: {
26506
26586
  "--sidebar-width": SIDEBAR_WIDTH_MOBILE
26507
26587
  },
package/dist/index.d.cts CHANGED
@@ -1308,6 +1308,9 @@ declare const sheetVariants: (props?: ({
1308
1308
  side?: "top" | "right" | "bottom" | "left" | null | undefined;
1309
1309
  } & class_variance_authority_types.ClassProp) | undefined) => string;
1310
1310
  interface SheetContentProps extends React$1.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof sheetVariants> {
1311
+ showCloseButton?: boolean;
1312
+ closeButtonClassName?: string;
1313
+ closeButtonLabel?: string;
1311
1314
  }
1312
1315
  declare const SheetContent: React$1.ForwardRefExoticComponent<SheetContentProps & React$1.RefAttributes<HTMLDivElement>>;
1313
1316
  declare const SheetHeader: {
package/dist/index.d.ts CHANGED
@@ -1308,6 +1308,9 @@ declare const sheetVariants: (props?: ({
1308
1308
  side?: "top" | "right" | "bottom" | "left" | null | undefined;
1309
1309
  } & class_variance_authority_types.ClassProp) | undefined) => string;
1310
1310
  interface SheetContentProps extends React$1.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof sheetVariants> {
1311
+ showCloseButton?: boolean;
1312
+ closeButtonClassName?: string;
1313
+ closeButtonLabel?: string;
1311
1314
  }
1312
1315
  declare const SheetContent: React$1.ForwardRefExoticComponent<SheetContentProps & React$1.RefAttributes<HTMLDivElement>>;
1313
1316
  declare const SheetHeader: {