@dimaan/ui 0.0.29 → 0.0.30

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
@@ -372,7 +372,7 @@ function DashboardMain({ className, children, ...props }) {
372
372
  // stretching the whole layout past 100%.
373
373
  "flex min-h-screen min-w-0 flex-1 flex-col transition-[margin] duration-200 ease-out",
374
374
  // On desktop, push the main column past the fixed sidebar using logical margin.
375
- collapsed ? "lg:ms-[var(--sidebar-width-collapsed)]" : "lg:ms-[var(--sidebar-width)]",
375
+ collapsed ? "lg:ms-0" : "lg:ms-(--sidebar-width)",
376
376
  className
377
377
  ),
378
378
  ...props,
@@ -541,14 +541,16 @@ function Sidebar({ className, children, ...props }) {
541
541
  "fixed inset-y-0 start-0 z-40 flex flex-col",
542
542
  // Surface
543
543
  "bg-sidebar text-sidebar-foreground border-e border-sidebar-border",
544
- // Sizing — width animates between full and collapsed
545
- collapsed ? "w-[var(--sidebar-width-collapsed)]" : "w-[var(--sidebar-width)]",
544
+ // Sizing — always full width; collapse hides it off-canvas (below).
545
+ "w-[var(--sidebar-width)]",
546
546
  // Motion
547
- "transition-[transform,width] duration-200 ease-out",
548
- // Mobile slide: hidden by default, visible when mobileOpen.
549
- // Logical translate via rtl variant so it slides off the inline-start edge
550
- // in both LTR and RTL.
551
- mobileOpen ? "translate-x-0" : "-translate-x-full rtl:translate-x-full lg:translate-x-0 lg:rtl:translate-x-0",
547
+ "transition-transform duration-200 ease-out",
548
+ // Mobile: slide in/out via mobileOpen. Logical translate (rtl variant)
549
+ // so it slides off the inline-start edge in both LTR and RTL.
550
+ mobileOpen ? "translate-x-0" : "-translate-x-full rtl:translate-x-full",
551
+ // Desktop: collapse fully hides the sidebar off-canvas; the header
552
+ // trigger slides it back in and the main content reclaims the width.
553
+ collapsed ? "lg:-translate-x-full lg:rtl:translate-x-full" : "lg:translate-x-0 lg:rtl:translate-x-0",
552
554
  className
553
555
  ),
554
556
  ...props,
@@ -571,18 +573,8 @@ function SidebarFooter({ className, children, ...props }) {
571
573
  );
572
574
  }
573
575
  function SidebarGroup({ label, className, children, ...props }) {
574
- const { collapsed } = useDashboardLayout();
575
576
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1 py-2", className), ...props, children: [
576
- label ? /* @__PURE__ */ jsxRuntime.jsx(
577
- "div",
578
- {
579
- className: cn(
580
- "px-3 pb-1 text-xs font-medium uppercase tracking-wider text-muted-foreground transition-opacity",
581
- collapsed && "pointer-events-none h-0 overflow-hidden opacity-0"
582
- ),
583
- children: label
584
- }
585
- ) : null,
577
+ label ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 pb-1 text-xs font-medium uppercase tracking-wider text-muted-foreground", children: label }) : null,
586
578
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children })
587
579
  ] });
588
580
  }
@@ -616,7 +608,6 @@ function SidebarNavGroup({
616
608
  onClick,
617
609
  ...props
618
610
  }) {
619
- const { collapsed } = useDashboardLayout();
620
611
  const submenuId = react.useId();
621
612
  const [internalOpen, setInternalOpen] = react.useState(defaultOpen);
622
613
  const isControlled = openProp !== void 0;
@@ -643,27 +634,23 @@ function SidebarNavGroup({
643
634
  const isActive = active || hasActiveChild;
644
635
  const prevHasActiveChild = react.useRef(false);
645
636
  react.useEffect(() => {
646
- if (hasActiveChild && !prevHasActiveChild.current && !collapsed) {
637
+ if (hasActiveChild && !prevHasActiveChild.current) {
647
638
  setOpen(true);
648
639
  }
649
640
  prevHasActiveChild.current = hasActiveChild;
650
- }, [hasActiveChild, collapsed, setOpen]);
651
- react.useEffect(() => {
652
- if (collapsed && open) setOpen(false);
653
- }, [collapsed, open, setOpen]);
654
- const titleAttr = collapsed && typeof label === "string" ? label : props.title ?? void 0;
655
- const showChildren = !collapsed;
641
+ }, [hasActiveChild, setOpen]);
642
+ const titleAttr = props.title ?? void 0;
656
643
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 flex-col", children: [
657
644
  /* @__PURE__ */ jsxRuntime.jsxs(
658
645
  "button",
659
646
  {
660
647
  type: "button",
661
- "aria-expanded": showChildren ? open : void 0,
662
- "aria-controls": showChildren ? submenuId : void 0,
648
+ "aria-expanded": open,
649
+ "aria-controls": submenuId,
663
650
  "data-active": isActive ? "true" : void 0,
664
651
  title: titleAttr,
665
652
  onClick: (e) => {
666
- if (showChildren) setOpen(!open);
653
+ setOpen(!open);
667
654
  onClick?.(e);
668
655
  },
669
656
  className: cn(
@@ -671,7 +658,6 @@ function SidebarNavGroup({
671
658
  "text-sidebar-foreground/80 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
672
659
  "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar",
673
660
  isActive && "bg-sidebar-accent text-sidebar-accent-foreground",
674
- collapsed && "justify-center px-0",
675
661
  className
676
662
  ),
677
663
  ...props,
@@ -684,18 +670,9 @@ function SidebarNavGroup({
684
670
  }
685
671
  ) : null,
686
672
  icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "flex size-5 shrink-0 items-center justify-center", children: icon }) : null,
687
- /* @__PURE__ */ jsxRuntime.jsx(
688
- "span",
689
- {
690
- className: cn(
691
- "flex-1 truncate text-start transition-[opacity,width]",
692
- collapsed && "pointer-events-none w-0 opacity-0"
693
- ),
694
- children: label
695
- }
696
- ),
697
- endSlot && !collapsed ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-center", children: endSlot }) : null,
698
- showChildren ? /* @__PURE__ */ jsxRuntime.jsx(ChevronCaret, { open }) : null
673
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate text-start", children: label }),
674
+ endSlot ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-center", children: endSlot }) : null,
675
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronCaret, { open })
699
676
  ]
700
677
  }
701
678
  ),
@@ -703,10 +680,10 @@ function SidebarNavGroup({
703
680
  "div",
704
681
  {
705
682
  id: submenuId,
706
- hidden: !showChildren || !open,
683
+ hidden: !open,
707
684
  className: cn(
708
685
  "grid transition-[grid-template-rows] duration-200 ease-out",
709
- showChildren && open ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
686
+ open ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
710
687
  ),
711
688
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5 ps-7 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(SidebarNavGroupContext.Provider, { value: contextValue, children }) }) })
712
689
  }
@@ -737,7 +714,6 @@ function SidebarNavItem({
737
714
  end,
738
715
  ...props
739
716
  }) {
740
- const { collapsed } = useDashboardLayout();
741
717
  const resolved = reactRouterDom.useResolvedPath(to);
742
718
  const group = react.useContext(SidebarNavGroupContext);
743
719
  const itemId = react.useId();
@@ -749,13 +725,12 @@ function SidebarNavItem({
749
725
  return () => group.reportActive(itemId, false);
750
726
  }, [group, itemId, isActive]);
751
727
  const labelContent = label ?? children;
752
- const titleAttr = collapsed && typeof labelContent === "string" ? labelContent : props.title;
728
+ const titleAttr = props.title;
753
729
  const getClassName = (active) => cn(
754
730
  "group relative flex h-9 shrink-0 items-center gap-3 rounded-md px-3 text-sm font-medium outline-none transition-colors",
755
731
  "text-sidebar-foreground/80 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
756
732
  "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-sidebar",
757
733
  active && "bg-sidebar-accent text-sidebar-accent-foreground",
758
- collapsed && "justify-center px-0",
759
734
  className
760
735
  );
761
736
  const innerContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -767,17 +742,8 @@ function SidebarNavItem({
767
742
  }
768
743
  ) : null,
769
744
  icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "flex size-5 shrink-0 items-center justify-center", children: icon }) : null,
770
- /* @__PURE__ */ jsxRuntime.jsx(
771
- "span",
772
- {
773
- className: cn(
774
- "flex-1 truncate text-start transition-[opacity,width]",
775
- collapsed && "pointer-events-none w-0 opacity-0"
776
- ),
777
- children: labelContent
778
- }
779
- ),
780
- endSlot && !collapsed ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ms-auto flex shrink-0 items-center", children: endSlot }) : null
745
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate text-start", children: labelContent }),
746
+ endSlot ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ms-auto flex shrink-0 items-center", children: endSlot }) : null
781
747
  ] });
782
748
  if (render) {
783
749
  return render({