@platned/ui 0.9.4 → 0.9.6

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/sidebar.cjs CHANGED
@@ -36,9 +36,8 @@ __export(sidebar_exports, {
36
36
  SidebarUserCard: () => SidebarUserCard
37
37
  });
38
38
  module.exports = __toCommonJS(sidebar_exports);
39
- var import_react10 = require("react");
39
+ var import_react16 = require("react");
40
40
  var import_react_router_dom2 = require("react-router-dom");
41
- var import_lucide_react3 = require("lucide-react");
42
41
 
43
42
  // src/lib/cn.ts
44
43
  var import_clsx = require("clsx");
@@ -349,16 +348,46 @@ var OVERLAY_ITEM_SIZE = {
349
348
  md: "px-2.5 py-2 text-body-sm",
350
349
  sm: "px-2 py-1.5 text-body-tiny"
351
350
  };
351
+ function overlayItemTone(tone, disabled) {
352
+ if (disabled) return "cursor-not-allowed text-disabled";
353
+ return tone === "danger" ? "text-danger hover:bg-danger-tertiary focus:bg-danger-tertiary" : "text-default hover:bg-default-secondary focus:bg-default-secondary";
354
+ }
352
355
  var OVERLAY_HEADING = "px-2.5 py-1.5 text-body-tiny font-semibold uppercase tracking-wide text-default-tertiary";
353
356
  var OVERLAY_SEPARATOR = "-mx-1 my-1 h-px bg-divider";
354
357
 
355
- // src/components/overlays/portal.tsx
358
+ // src/components/overlays/overlay.ts
359
+ var import_react6 = require("react");
360
+ var import_tabbable = require("tabbable");
361
+
362
+ // src/components/overlays/overlay-stack.ts
356
363
  var import_react5 = require("react");
364
+ var layers = [];
365
+ var deferredEscapes = /* @__PURE__ */ new WeakSet();
366
+ function deferEscapeToInnerPopup(event) {
367
+ const target = event.target;
368
+ const fromOpenCombobox = target instanceof Element && target.closest('[role="combobox"][aria-expanded="true"]') !== null;
369
+ if (layers.length === 0 && !fromOpenCombobox) return false;
370
+ deferredEscapes.add(event);
371
+ event.preventDefault();
372
+ return true;
373
+ }
374
+
375
+ // src/components/overlays/overlay.ts
376
+ var OVERLAY_SCRIM = "bg-overlay";
377
+
378
+ // src/components/overlays/portal.tsx
379
+ var import_react7 = require("react");
357
380
  var import_react_dom = require("react-dom");
358
381
  var import_jsx_runtime4 = require("react/jsx-runtime");
359
- var PortalContainerContext = (0, import_react5.createContext)(null);
382
+ var PortalContainerContext = (0, import_react7.createContext)(null);
383
+ function PortalContainerProvider({
384
+ container,
385
+ children
386
+ }) {
387
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PortalContainerContext.Provider, { value: container, children });
388
+ }
360
389
  function usePortalContainer() {
361
- return (0, import_react5.useContext)(PortalContainerContext);
390
+ return (0, import_react7.useContext)(PortalContainerContext);
362
391
  }
363
392
 
364
393
  // src/lib/compose-event-handlers.ts
@@ -369,8 +398,14 @@ function composeEventHandlers(theirs, ours) {
369
398
  };
370
399
  }
371
400
 
401
+ // src/components/overlays/toaster-guard.ts
402
+ var TOASTER_ATTRIBUTE = "data-platned-toaster";
403
+ function isInsideToaster(target) {
404
+ return target instanceof Element && target.closest(`[${TOASTER_ATTRIBUTE}]`) !== null;
405
+ }
406
+
372
407
  // src/components/overlays/tooltip.tsx
373
- var import_react6 = require("react");
408
+ var import_react8 = require("react");
374
409
  var import_radix_ui = require("radix-ui");
375
410
  var import_jsx_runtime5 = require("react/jsx-runtime");
376
411
  function Tooltip({
@@ -387,7 +422,7 @@ function Tooltip({
387
422
  className
388
423
  }) {
389
424
  const container = usePortalContainer();
390
- const labelId = (0, import_react6.useId)();
425
+ const labelId = (0, import_react8.useId)();
391
426
  const labelled = association === "labelledby";
392
427
  const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
393
428
  title && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold", children: title }),
@@ -426,7 +461,7 @@ function Tooltip({
426
461
  }
427
462
 
428
463
  // src/components/overlays/menu-core.tsx
429
- var import_react7 = require("react");
464
+ var import_react9 = require("react");
430
465
  var import_clsx7 = __toESM(require("clsx"), 1);
431
466
  var import_lucide_react = require("lucide-react");
432
467
  var import_jsx_runtime6 = require("react/jsx-runtime");
@@ -469,8 +504,8 @@ function visibleMenuItems(items) {
469
504
  });
470
505
  }
471
506
  function createMenuParts(P) {
472
- const Item = (0, import_react7.forwardRef)(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
473
- const descriptionId = (0, import_react7.useId)();
507
+ const Item = (0, import_react9.forwardRef)(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
508
+ const descriptionId = (0, import_react9.useId)();
474
509
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
475
510
  P.Item,
476
511
  {
@@ -493,7 +528,7 @@ function createMenuParts(P) {
493
528
  }
494
529
  );
495
530
  });
496
- const CheckboxItem = (0, import_react7.forwardRef)(function MenuCheckboxItem({ children, checked, onCheckedChange, disabled = false, tone = "default", shortcut, textValue, className, ...rest }, ref) {
531
+ const CheckboxItem = (0, import_react9.forwardRef)(function MenuCheckboxItem({ children, checked, onCheckedChange, disabled = false, tone = "default", shortcut, textValue, className, ...rest }, ref) {
497
532
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
498
533
  P.CheckboxItem,
499
534
  {
@@ -517,7 +552,7 @@ function createMenuParts(P) {
517
552
  function RadioGroup({ children, value, onValueChange }) {
518
553
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.RadioGroup, { value, onValueChange, children });
519
554
  }
520
- const RadioItem = (0, import_react7.forwardRef)(function MenuRadioItem({ children, value, disabled = false, tone = "default", textValue, className, ...rest }, ref) {
555
+ const RadioItem = (0, import_react9.forwardRef)(function MenuRadioItem({ children, value, disabled = false, tone = "default", textValue, className, ...rest }, ref) {
521
556
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
522
557
  P.RadioItem,
523
558
  {
@@ -535,26 +570,26 @@ function createMenuParts(P) {
535
570
  }
536
571
  );
537
572
  });
538
- const Group = (0, import_react7.forwardRef)(function MenuGroup({ children, label, className, ...rest }, ref) {
539
- const labelId = (0, import_react7.useId)();
573
+ const Group = (0, import_react9.forwardRef)(function MenuGroup({ children, label, className, ...rest }, ref) {
574
+ const labelId = (0, import_react9.useId)();
540
575
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(P.Group, { ref, "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
541
576
  label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: labelId, className: OVERLAY_HEADING, children: label }),
542
577
  children
543
578
  ] });
544
579
  });
545
- const Label = (0, import_react7.forwardRef)(function MenuLabel({ className, ...rest }, ref) {
580
+ const Label = (0, import_react9.forwardRef)(function MenuLabel({ className, ...rest }, ref) {
546
581
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Label, { ref, className: cn(OVERLAY_HEADING, className), ...rest });
547
582
  });
548
- const Separator = (0, import_react7.forwardRef)(function MenuSeparator({ className, ...rest }, ref) {
583
+ const Separator = (0, import_react9.forwardRef)(function MenuSeparator({ className, ...rest }, ref) {
549
584
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Separator, { ref, className: cn(OVERLAY_SEPARATOR, className), ...rest });
550
585
  });
551
- const Shortcut = (0, import_react7.forwardRef)(function MenuShortcut({ className, ...rest }, ref) {
586
+ const Shortcut = (0, import_react9.forwardRef)(function MenuShortcut({ className, ...rest }, ref) {
552
587
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { ref, className: cn("ml-auto pl-4 text-body-tiny text-default-tertiary", className), ...rest });
553
588
  });
554
589
  function Sub({ children, open, defaultOpen, onOpenChange }) {
555
590
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Sub, { open, defaultOpen, onOpenChange, children });
556
591
  }
557
- const SubTrigger = (0, import_react7.forwardRef)(function MenuSubTrigger({ children, icon, disabled = false, textValue, className, ...rest }, ref) {
592
+ const SubTrigger = (0, import_react9.forwardRef)(function MenuSubTrigger({ children, icon, disabled = false, textValue, className, ...rest }, ref) {
558
593
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
559
594
  P.SubTrigger,
560
595
  {
@@ -577,7 +612,7 @@ function createMenuParts(P) {
577
612
  }
578
613
  );
579
614
  });
580
- const SubContent = (0, import_react7.forwardRef)(function MenuSubContent({ className, onClick, onKeyDown, ...rest }, ref) {
615
+ const SubContent = (0, import_react9.forwardRef)(function MenuSubContent({ className, onClick, onKeyDown, ...rest }, ref) {
581
616
  const container = usePortalContainer();
582
617
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(P.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
583
618
  P.SubContent,
@@ -630,7 +665,7 @@ function createMenuParts(P) {
630
665
  case "separator":
631
666
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Separator, {}, item.id);
632
667
  case "custom":
633
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: item.render() }, item.id);
668
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react9.Fragment, { children: item.render() }, item.id);
634
669
  default:
635
670
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
636
671
  Item,
@@ -664,8 +699,13 @@ function createMenuParts(P) {
664
699
  };
665
700
  }
666
701
 
702
+ // src/components/overlays/drawer.tsx
703
+ var import_react11 = require("react");
704
+ var import_radix_ui2 = require("radix-ui");
705
+ var import_lucide_react2 = require("lucide-react");
706
+
667
707
  // src/components/cards/scroll-area.tsx
668
- var import_react8 = require("react");
708
+ var import_react10 = require("react");
669
709
  var import_clsx8 = __toESM(require("clsx"), 1);
670
710
  var import_jsx_runtime7 = require("react/jsx-runtime");
671
711
  var OVERFLOW = {
@@ -673,10 +713,10 @@ var OVERFLOW = {
673
713
  horizontal: "overflow-x-auto overflow-y-hidden",
674
714
  both: "overflow-auto"
675
715
  };
676
- var ScrollArea = (0, import_react8.forwardRef)(function ScrollArea2({ children, axis = "vertical", label, className, ...rest }, ref) {
677
- const localRef = (0, import_react8.useRef)(null);
678
- const [overflows, setOverflows] = (0, import_react8.useState)(false);
679
- (0, import_react8.useEffect)(() => {
716
+ var ScrollArea = (0, import_react10.forwardRef)(function ScrollArea2({ children, axis = "vertical", label, className, ...rest }, ref) {
717
+ const localRef = (0, import_react10.useRef)(null);
718
+ const [overflows, setOverflows] = (0, import_react10.useState)(false);
719
+ (0, import_react10.useEffect)(() => {
680
720
  const node = localRef.current;
681
721
  if (!node) return;
682
722
  const measure = () => {
@@ -713,14 +753,215 @@ var ScrollArea = (0, import_react8.forwardRef)(function ScrollArea2({ children,
713
753
  );
714
754
  });
715
755
 
716
- // src/components/overlays/dropdown-menu.tsx
717
- var import_react9 = require("react");
718
- var import_radix_ui2 = require("radix-ui");
719
- var import_lucide_react2 = require("lucide-react");
756
+ // src/components/overlays/drawer.tsx
720
757
  var import_jsx_runtime8 = require("react/jsx-runtime");
721
- var DropdownMenuStateContext = (0, import_react9.createContext)(null);
758
+ var DrawerNaming = (0, import_react11.createContext)(null);
759
+ var Drawer = (0, import_react11.forwardRef)(function Drawer2({
760
+ open,
761
+ defaultOpen,
762
+ onOpenChange,
763
+ header,
764
+ children,
765
+ footer,
766
+ footerAlign = "end",
767
+ width = "w-[440px] max-w-[90vw]",
768
+ side = "right",
769
+ label,
770
+ className,
771
+ onEscapeKeyDown,
772
+ onInteractOutside,
773
+ initialFocus,
774
+ container
775
+ }, ref) {
776
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_radix_ui2.Dialog.Root, { open, defaultOpen, onOpenChange, children: [
777
+ extractTrigger(children),
778
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Portal, { container: container ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
779
+ DrawerPanel,
780
+ {
781
+ ref,
782
+ side,
783
+ width,
784
+ label,
785
+ className,
786
+ onEscapeKeyDown,
787
+ onInteractOutside,
788
+ initialFocus,
789
+ children: header !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
790
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerHeader, { children: header }),
791
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerBody, { label, children: withoutTrigger(children) }),
792
+ footer && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DrawerFooter, { align: footerAlign, children: footer })
793
+ ] }) : withoutTrigger(children)
794
+ }
795
+ ) })
796
+ ] });
797
+ });
798
+ var DrawerPanel = (0, import_react11.forwardRef)(function DrawerPanel2({ side = "right", width, label, className, onEscapeKeyDown, onInteractOutside, initialFocus, children }, ref) {
799
+ const [hasTitle, setHasTitle] = (0, import_react11.useState)(false);
800
+ const [hasDescription, setHasDescription] = (0, import_react11.useState)(false);
801
+ const [panelNode, setPanelNode] = (0, import_react11.useState)(null);
802
+ const [returnFocusTo] = (0, import_react11.useState)(
803
+ () => typeof document === "undefined" ? null : document.activeElement
804
+ );
805
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
806
+ import_radix_ui2.Dialog.Overlay,
807
+ {
808
+ className: cn(
809
+ "fixed inset-0 z-modal flex",
810
+ side === "right" ? "justify-end" : "justify-start",
811
+ OVERLAY_SCRIM
812
+ ),
813
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
814
+ import_radix_ui2.Dialog.Content,
815
+ {
816
+ asChild: true,
817
+ ...hasDescription ? {} : { "aria-describedby": void 0 },
818
+ onOpenAutoFocus: (event) => {
819
+ const target = initialFocus?.current;
820
+ if (target) {
821
+ event.preventDefault();
822
+ target.focus();
823
+ }
824
+ },
825
+ onCloseAutoFocus: (event) => {
826
+ if (returnFocusTo?.isConnected && returnFocusTo !== document.body) {
827
+ event.preventDefault();
828
+ returnFocusTo.focus();
829
+ }
830
+ },
831
+ onEscapeKeyDown: (event) => {
832
+ if (!deferEscapeToInnerPopup(event)) onEscapeKeyDown?.(event);
833
+ },
834
+ onPointerDownOutside: (event) => {
835
+ if (isInsideToaster(event.target)) {
836
+ event.preventDefault();
837
+ return;
838
+ }
839
+ const original = event.detail.originalEvent;
840
+ onInteractOutside?.(original);
841
+ if (original.defaultPrevented) event.preventDefault();
842
+ },
843
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
844
+ "div",
845
+ {
846
+ ref: composeRefs(ref, setPanelNode),
847
+ "data-side": side,
848
+ className: cn(
849
+ "relative flex h-full flex-col bg-default shadow-500 focus:outline-none",
850
+ width,
851
+ className
852
+ ),
853
+ children: [
854
+ !hasTitle && label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Title, { className: "sr-only", children: label }),
855
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
856
+ DrawerNaming.Provider,
857
+ {
858
+ value: { registerTitle: setHasTitle, registerDescription: setHasDescription },
859
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PortalContainerProvider, { container: panelNode, children })
860
+ }
861
+ )
862
+ ]
863
+ }
864
+ )
865
+ }
866
+ )
867
+ }
868
+ );
869
+ });
870
+ var DrawerTrigger = (0, import_react11.forwardRef)(
871
+ function DrawerTrigger2(props, ref) {
872
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Trigger, { ref, ...props });
873
+ }
874
+ );
875
+ DrawerTrigger.__drawerTrigger = true;
876
+ var DrawerClose = (0, import_react11.forwardRef)(
877
+ function DrawerClose2(props, ref) {
878
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Close, { ref, ...props });
879
+ }
880
+ );
881
+ function isTrigger(node) {
882
+ return typeof node === "object" && node !== null && "type" in node && node.type?.__drawerTrigger === true;
883
+ }
884
+ function extractTrigger(children) {
885
+ return Array.isArray(children) ? children.filter(isTrigger) : isTrigger(children) ? children : null;
886
+ }
887
+ function withoutTrigger(children) {
888
+ return Array.isArray(children) ? children.filter((child) => !isTrigger(child)) : isTrigger(children) ? null : children;
889
+ }
890
+ var DrawerHeader = (0, import_react11.forwardRef)(function DrawerHeader2({ children, showClose = true, className, ...rest }, ref) {
891
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
892
+ "div",
893
+ {
894
+ ref,
895
+ className: cn("flex items-start justify-between gap-3 border-b border-default p-6", className),
896
+ ...rest,
897
+ children: [
898
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "min-w-0", children }),
899
+ showClose && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconButton, { variant: "subtle", size: "sm", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.XIcon, { size: 18, "aria-hidden": true }) }) })
900
+ ]
901
+ }
902
+ );
903
+ });
904
+ var DrawerTitle = (0, import_react11.forwardRef)(function DrawerTitle2({ className, children, ...rest }, ref) {
905
+ const naming = (0, import_react11.useContext)(DrawerNaming);
906
+ (0, import_react11.useEffect)(() => {
907
+ naming?.registerTitle(true);
908
+ return () => naming?.registerTitle(false);
909
+ }, [naming]);
910
+ const classes = cn("text-heading-sm font-semibold text-default", className);
911
+ if (!naming) {
912
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { ref, className: classes, ...rest, children });
913
+ }
914
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Title, { ref, className: classes, ...rest, children });
915
+ });
916
+ var DrawerDescription = (0, import_react11.forwardRef)(
917
+ function DrawerDescription2({ className, ...rest }, ref) {
918
+ const naming = (0, import_react11.useContext)(DrawerNaming);
919
+ (0, import_react11.useEffect)(() => {
920
+ naming?.registerDescription(true);
921
+ return () => naming?.registerDescription(false);
922
+ }, [naming]);
923
+ const classes = cn("mt-0.5 text-body-xs text-default-secondary", className);
924
+ if (!naming) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { ref, className: classes, ...rest });
925
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.Dialog.Description, { ref, className: classes, ...rest });
926
+ }
927
+ );
928
+ var DrawerBody = (0, import_react11.forwardRef)(function DrawerBody2({ children, label, className, ...rest }, ref) {
929
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
930
+ ScrollArea,
931
+ {
932
+ ref,
933
+ axis: "vertical",
934
+ label: label ? `${label} content` : "Content",
935
+ className: "min-h-0 flex-1",
936
+ ...rest,
937
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn("space-y-6 p-6", className), children })
938
+ }
939
+ );
940
+ });
941
+ var DrawerFooter = (0, import_react11.forwardRef)(function DrawerFooter2({ align = "end", className, ...rest }, ref) {
942
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
943
+ "div",
944
+ {
945
+ ref,
946
+ "data-align": align,
947
+ className: cn(
948
+ "flex items-center gap-2 border-t border-default px-6 py-4",
949
+ align === "between" ? "justify-between" : "justify-end",
950
+ className
951
+ ),
952
+ ...rest
953
+ }
954
+ );
955
+ });
956
+
957
+ // src/components/overlays/dropdown-menu.tsx
958
+ var import_react12 = require("react");
959
+ var import_radix_ui3 = require("radix-ui");
960
+ var import_lucide_react3 = require("lucide-react");
961
+ var import_jsx_runtime9 = require("react/jsx-runtime");
962
+ var DropdownMenuStateContext = (0, import_react12.createContext)(null);
722
963
  function useDropdownMenuState(part) {
723
- const value = (0, import_react9.useContext)(DropdownMenuStateContext);
964
+ const value = (0, import_react12.useContext)(DropdownMenuStateContext);
724
965
  if (!value) throw new Error(`<${part}> must be used inside <DropdownMenu>`);
725
966
  return value;
726
967
  }
@@ -741,14 +982,14 @@ function DropdownMenu({
741
982
  defaultValue: defaultOpen,
742
983
  onChange: onOpenChange
743
984
  });
744
- const pendingEdge = (0, import_react9.useRef)("start");
745
- const state = (0, import_react9.useMemo)(() => ({ setOpen, pendingEdge }), [setOpen]);
746
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
747
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
748
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuContent, { side, align, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuItems, { items }) })
985
+ const pendingEdge = (0, import_react12.useRef)("start");
986
+ const state = (0, import_react12.useMemo)(() => ({ setOpen, pendingEdge }), [setOpen]);
987
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
988
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
989
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuContent, { side, align, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenuItems, { items }) })
749
990
  ] }) : children }) });
750
991
  }
751
- var DropdownMenuTrigger = (0, import_react9.forwardRef)(
992
+ var DropdownMenuTrigger = (0, import_react12.forwardRef)(
752
993
  function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
753
994
  const state = useDropdownMenuState("DropdownMenuTrigger");
754
995
  const handlers = {
@@ -776,12 +1017,12 @@ var DropdownMenuTrigger = (0, import_react9.forwardRef)(
776
1017
  }
777
1018
  };
778
1019
  if (asChild) {
779
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children });
1020
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children });
780
1021
  }
781
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconButton, { variant: "neutral", size: "sm", "aria-label": label, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react2.EllipsisIcon, { className: "size-4", "aria-hidden": true }) }) });
1022
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Trigger, { ref, asChild: true, ...rest, ...handlers, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(IconButton, { variant: "neutral", size: "sm", "aria-label": label, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.EllipsisIcon, { className: "size-4", "aria-hidden": true }) }) });
782
1023
  }
783
1024
  );
784
- var DropdownMenuContent = (0, import_react9.forwardRef)(
1025
+ var DropdownMenuContent = (0, import_react12.forwardRef)(
785
1026
  function DropdownMenuContent2({
786
1027
  children,
787
1028
  side = "bottom",
@@ -797,8 +1038,8 @@ var DropdownMenuContent = (0, import_react9.forwardRef)(
797
1038
  }, ref) {
798
1039
  const state = useDropdownMenuState("DropdownMenuContent");
799
1040
  const inherited = usePortalContainer();
800
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_radix_ui2.DropdownMenu.Portal, { container: container ?? inherited ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
801
- import_radix_ui2.DropdownMenu.Content,
1041
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_radix_ui3.DropdownMenu.Portal, { container: container ?? inherited ?? void 0, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1042
+ import_radix_ui3.DropdownMenu.Content,
802
1043
  {
803
1044
  ref,
804
1045
  side,
@@ -830,7 +1071,7 @@ var DropdownMenuContent = (0, import_react9.forwardRef)(
830
1071
  ) });
831
1072
  }
832
1073
  );
833
- var parts = createMenuParts(import_radix_ui2.DropdownMenu);
1074
+ var parts = createMenuParts(import_radix_ui3.DropdownMenu);
834
1075
  var DropdownMenuItems = parts.Items;
835
1076
  var DropdownMenuItem = parts.Item;
836
1077
  var DropdownMenuCheckboxItem = parts.CheckboxItem;
@@ -845,8 +1086,10 @@ var DropdownMenuSubTrigger = parts.SubTrigger;
845
1086
  var DropdownMenuSubContent = parts.SubContent;
846
1087
 
847
1088
  // src/components/chrome/nav-item.tsx
1089
+ var import_react13 = require("react");
848
1090
  var import_clsx9 = __toESM(require("clsx"), 1);
849
- var import_jsx_runtime9 = require("react/jsx-runtime");
1091
+ var import_lucide_react4 = require("lucide-react");
1092
+ var import_jsx_runtime10 = require("react/jsx-runtime");
850
1093
  var SIZE = {
851
1094
  sm: { box: "h-9 gap-2 rounded-lg px-3 py-1.5", label: "text-body-xs", square: "w-9" },
852
1095
  md: { box: "h-11 gap-3 rounded-xl px-3.5 py-2.5", label: "text-body-sm", square: "w-11" }
@@ -881,7 +1124,32 @@ var VARIANT = {
881
1124
  inactive: (0, import_clsx9.default)("text-default-secondary", STATE.hover)
882
1125
  }
883
1126
  };
884
- function NavItem({
1127
+ var DENSITY = {
1128
+ comfortable: {
1129
+ box: "h-11 gap-3 rounded-xl",
1130
+ pad: "px-3.5",
1131
+ square: "w-11",
1132
+ active: (0, import_clsx9.default)("border border-transparent", STATE.active),
1133
+ inactive: (0, import_clsx9.default)("border border-default bg-default text-default", STATE.hover),
1134
+ disabled: "data-[disabled]:hover:bg-default",
1135
+ // Straddles the card's corner, as in Figma.
1136
+ dot: "-right-px -top-px",
1137
+ railDot: "-right-px -top-px"
1138
+ },
1139
+ compact: {
1140
+ box: "h-10 gap-3 rounded-xl",
1141
+ pad: "px-3",
1142
+ square: "w-10",
1143
+ active: STATE.active,
1144
+ inactive: (0, import_clsx9.default)("text-default", STATE.hover),
1145
+ disabled: "data-[disabled]:hover:bg-transparent",
1146
+ // A plain row has no corner to sit on, so the expanded dot trails the label instead.
1147
+ dot: "right-2 top-1/2 -translate-y-1/2",
1148
+ railDot: "right-0 top-0"
1149
+ }
1150
+ };
1151
+ var DENSITY_DISABLED = "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled data-[disabled]:hover:text-disabled";
1152
+ var NavItem = (0, import_react13.forwardRef)(function NavItem2({
885
1153
  icon,
886
1154
  label,
887
1155
  isActive = false,
@@ -889,16 +1157,21 @@ function NavItem({
889
1157
  collapsed = false,
890
1158
  size = "md",
891
1159
  variant = "card",
1160
+ density,
1161
+ trailing,
892
1162
  asChild = false,
893
1163
  disabled = false,
894
1164
  children,
895
1165
  className,
896
1166
  onClick,
897
1167
  ...rest
898
- }) {
1168
+ }, ref) {
899
1169
  const s = SIZE[size];
900
1170
  const v = VARIANT[variant];
1171
+ const d = density ? DENSITY[density] : null;
901
1172
  const rootProps = {
1173
+ ref,
1174
+ "data-density": density,
902
1175
  // Only meaningful when `asChild` renders a real link — a decorative span with
903
1176
  // aria-current would be a lie.
904
1177
  "aria-current": asChild && isActive ? "page" : void 0,
@@ -919,12 +1192,25 @@ function NavItem({
919
1192
  // halo on the #F5F5F5 rail. The offset itself is load-bearing — in dark mode
920
1193
  // `ring-brand` and `bg-brand` are both #F1F7FD, so without it a focused *active* row
921
1194
  // would have no visible ring at its inner edge.
1195
+ // It is also Figma's focus state for both densities: 1px rail-coloured gap, 3px of brand
1196
+ // in all. Figma's compact focus variant draws a 0px shadow — no ring at all — which
1197
+ // would fail WCAG 2.4.7, so compact keeps this ring too.
922
1198
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary",
923
- s.box,
924
- // Expanded rows fill the nav; a collapsed one is a centred square, not a stretched row.
925
- collapsed ? (0, import_clsx9.default)("justify-center", s.square) : "w-full",
926
- isActive ? v.active : v.inactive,
927
- "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40 data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-default-secondary",
1199
+ d ? (0, import_clsx9.default)(
1200
+ // text-left: a parent row is a <button>, which centres its text by default.
1201
+ "group/nav-item text-left",
1202
+ d.box,
1203
+ collapsed ? (0, import_clsx9.default)("justify-center", d.square) : (0, import_clsx9.default)("w-full", d.pad),
1204
+ isActive ? d.active : d.inactive,
1205
+ DENSITY_DISABLED,
1206
+ d.disabled
1207
+ ) : (0, import_clsx9.default)(
1208
+ s.box,
1209
+ // Expanded rows fill the nav; a collapsed one is a centred square, not a stretched row.
1210
+ collapsed ? (0, import_clsx9.default)("justify-center", s.square) : "w-full",
1211
+ isActive ? v.active : v.inactive,
1212
+ "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40 data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-default-secondary"
1213
+ ),
928
1214
  className
929
1215
  ),
930
1216
  ...rest,
@@ -939,14 +1225,29 @@ function NavItem({
939
1225
  onClick?.(event);
940
1226
  }
941
1227
  };
942
- const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
943
- icon != null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "aria-hidden": true, className: "shrink-0 [&_svg]:size-4", children: icon }) : (
1228
+ const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1229
+ icon != null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1230
+ "span",
1231
+ {
1232
+ "aria-hidden": true,
1233
+ className: (0, import_clsx9.default)(
1234
+ "shrink-0",
1235
+ d ? (0, import_clsx9.default)(
1236
+ // Figma: a 20px glyph, icon-secondary at rest, brand under hover,
1237
+ // on-brand on the current row, disabled grey on a disabled one.
1238
+ "flex size-5 items-center justify-center [&_svg]:size-5",
1239
+ disabled ? "text-icon-disabled" : isActive ? "text-icon-brand-on-brand" : "text-icon-default-secondary group-hover/nav-item:text-icon-brand"
1240
+ ) : "[&_svg]:size-4"
1241
+ ),
1242
+ children: icon
1243
+ }
1244
+ ) : (
944
1245
  // Icons are optional, but the collapsed rail hides the label — so a row with neither
945
1246
  // renders as an empty box. Through 0.5.0 that is exactly what a nav without icons
946
1247
  // collapsed to, the docs site's own 36-row sidebar included. The monogram is
947
1248
  // decorative in the same way the icon is: the `sr-only` label below still names the
948
1249
  // row.
949
- collapsed && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1250
+ collapsed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
950
1251
  "span",
951
1252
  {
952
1253
  "aria-hidden": true,
@@ -955,105 +1256,329 @@ function NavItem({
955
1256
  }
956
1257
  )
957
1258
  ),
958
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1259
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
959
1260
  "span",
960
1261
  {
961
1262
  className: (0, import_clsx9.default)(
962
- "min-w-0 truncate font-regular leading-snug",
963
- s.label,
1263
+ "min-w-0 truncate font-regular",
1264
+ d ? "text-body" : (0, import_clsx9.default)("leading-snug", s.label),
964
1265
  collapsed ? "sr-only" : "flex-1"
965
1266
  ),
966
1267
  children: label
967
1268
  }
968
1269
  ),
969
- indicator && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1270
+ trailing != null && !collapsed && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": true, className: "flex shrink-0 items-center [&_svg]:size-4", children: trailing }),
1271
+ indicator && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
970
1272
  "span",
971
1273
  {
972
1274
  role: "status",
973
1275
  "aria-label": "Unread",
974
- className: "absolute -right-px -top-px size-2 rounded-full bg-danger"
1276
+ className: (0, import_clsx9.default)(
1277
+ "absolute size-2 rounded-full bg-danger",
1278
+ d ? collapsed ? d.railDot : d.dot : "-right-px -top-px"
1279
+ )
975
1280
  }
976
1281
  )
977
1282
  ] });
978
1283
  if (asChild) {
979
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
1284
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
980
1285
  }
981
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ...rootProps, children: content });
982
- }
983
-
984
- // src/sidebar/nav-tabs.tsx
985
- var import_react_router_dom = require("react-router-dom");
986
- var import_clsx10 = __toESM(require("clsx"), 1);
987
- var import_jsx_runtime10 = require("react/jsx-runtime");
988
- function NavTabs({ items, className }) {
989
- return (
990
- // The links inside are the tab stops.
1286
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...rootProps, children: content });
1287
+ });
1288
+ var SUB_HEIGHT = { comfortable: "h-11", compact: "h-10" };
1289
+ var NavSubItem = (0, import_react13.forwardRef)(function NavSubItem2({
1290
+ label,
1291
+ isActive = false,
1292
+ disabled = false,
1293
+ last = false,
1294
+ density = "comfortable",
1295
+ asChild = false,
1296
+ children,
1297
+ className,
1298
+ onClick,
1299
+ ...rest
1300
+ }, ref) {
1301
+ const rootProps = {
1302
+ ref,
1303
+ "aria-current": asChild && isActive ? "page" : void 0,
1304
+ "data-state": isActive ? "active" : void 0,
1305
+ "data-disabled": disabled || void 0,
1306
+ "aria-disabled": disabled || void 0,
1307
+ className: (0, import_clsx9.default)(
1308
+ "relative flex w-full items-center gap-3 rounded-md pl-4 pr-3 transition-colors",
1309
+ // Figma's focus variant is a 1px brand border on the hover tint. The transparent
1310
+ // border holds the 1px at rest so the label does not move when focus arrives.
1311
+ "border border-transparent focus-visible:border-brand focus-visible:bg-brand-secondary focus-visible:text-brand focus-visible:outline-none",
1312
+ SUB_HEIGHT[density],
1313
+ isActive ? "bg-brand text-brand-on-brand" : "text-default-secondary hover:bg-brand-secondary hover:text-brand",
1314
+ "data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled data-[disabled]:hover:bg-transparent data-[disabled]:hover:text-disabled",
1315
+ className
1316
+ ),
1317
+ ...rest,
1318
+ ...disabled ? { tabIndex: -1 } : {},
1319
+ onClick: (event) => {
1320
+ if (disabled) {
1321
+ event.preventDefault();
1322
+ return;
1323
+ }
1324
+ onClick?.(event);
1325
+ }
1326
+ };
1327
+ const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1328
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NestIndicator, { last }),
1329
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "min-w-0 flex-1 truncate text-body font-regular", children: label })
1330
+ ] });
1331
+ if (asChild) {
1332
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { wrapChildren: () => content, ...rootProps, children });
1333
+ }
1334
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { ...rootProps, children: content });
1335
+ });
1336
+ function NestIndicator({ last }) {
1337
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { "aria-hidden": true, className: "relative w-4 shrink-0 self-stretch", children: [
991
1338
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
992
- "div",
1339
+ "span",
993
1340
  {
994
- className: (0, import_clsx10.default)(
995
- "flex gap-6 overflow-x-auto border-b border-default",
996
- SCROLLBAR_CLASSES,
997
- className
1341
+ className: (0, import_clsx9.default)(
1342
+ "absolute left-1/2 top-0 w-px -translate-x-1/2 bg-[var(--prim-stone-400)]",
1343
+ last ? "h-1/2" : "h-full"
1344
+ )
1345
+ }
1346
+ ),
1347
+ last && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "absolute left-1/2 right-0 top-1/2 h-px bg-[var(--prim-stone-400)]" })
1348
+ ] });
1349
+ }
1350
+ var NavGroupHeader = (0, import_react13.forwardRef)(function NavGroupHeader2({ title, open, onOpenChange, controls, action, className, ...rest }, ref) {
1351
+ const collapsible = open !== void 0 && onOpenChange !== void 0;
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref, className: (0, import_clsx9.default)("flex items-center gap-2 pl-2.5", className), ...rest, children: [
1353
+ collapsible && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1354
+ "button",
1355
+ {
1356
+ type: "button",
1357
+ "aria-expanded": open,
1358
+ "aria-controls": controls,
1359
+ "aria-label": `${open ? "Collapse" : "Expand"} ${title}`,
1360
+ onClick: () => onOpenChange(!open),
1361
+ className: (0, import_clsx9.default)(
1362
+ "flex shrink-0 items-center justify-center rounded-full p-1 text-icon-default-secondary transition-colors",
1363
+ "hover:bg-brand-tertiary-hover hover:text-icon-brand",
1364
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default-secondary"
998
1365
  ),
999
- children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1000
- import_react_router_dom.NavLink,
1366
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1367
+ import_lucide_react4.ChevronDownIcon,
1001
1368
  {
1002
- to: tab.to,
1003
- end: tab.end,
1004
- className: ({ isActive }) => (0, import_clsx10.default)(
1005
- "shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors",
1006
- isActive ? "border-brand-emphasis font-semibold text-brand-emphasis" : "border-transparent font-medium text-default-secondary hover:text-default"
1007
- ),
1008
- children: tab.label
1009
- },
1010
- tab.to
1011
- ))
1369
+ "aria-hidden": true,
1370
+ className: (0, import_clsx9.default)(
1371
+ "size-4 transition-transform motion-reduce:transition-none",
1372
+ !open && "-rotate-90"
1373
+ )
1374
+ }
1375
+ )
1012
1376
  }
1013
- )
1377
+ ),
1378
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "min-w-0 flex-1 truncate text-body font-regular text-neutral-tertiary", children: title }),
1379
+ action != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex shrink-0 items-center", children: action })
1380
+ ] });
1381
+ });
1382
+
1383
+ // src/components/chrome/sidebar.tsx
1384
+ var import_react15 = require("react");
1385
+ var import_radix_ui4 = require("radix-ui");
1386
+ var import_lucide_react5 = require("lucide-react");
1387
+ var import_clsx10 = __toESM(require("clsx"), 1);
1388
+
1389
+ // src/lib/use-media-query.ts
1390
+ var import_react14 = require("react");
1391
+ function useMediaQuery(query) {
1392
+ const subscribe = (0, import_react14.useCallback)(
1393
+ (onChange) => {
1394
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => {
1395
+ };
1396
+ const list = window.matchMedia(query);
1397
+ list.addEventListener("change", onChange);
1398
+ return () => list.removeEventListener("change", onChange);
1399
+ },
1400
+ [query]
1014
1401
  );
1402
+ const getSnapshot = () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false;
1403
+ return (0, import_react14.useSyncExternalStore)(subscribe, getSnapshot, () => false);
1015
1404
  }
1016
1405
 
1017
- // src/sidebar/index.tsx
1406
+ // src/components/chrome/sidebar.tsx
1018
1407
  var import_jsx_runtime11 = require("react/jsx-runtime");
1019
- function AppSidebar({
1408
+ var MOBILE_QUERY = "(max-width: 767.98px)";
1409
+ var SidebarContext = (0, import_react15.createContext)(null);
1410
+ function useSidebar() {
1411
+ const value = (0, import_react15.useContext)(SidebarContext);
1412
+ if (!value) throw new Error("useSidebar must be used inside <SidebarProvider>");
1413
+ return value;
1414
+ }
1415
+ function readStored(key) {
1416
+ try {
1417
+ const value = window.localStorage.getItem(key);
1418
+ return value === "true" ? true : value === "false" ? false : null;
1419
+ } catch {
1420
+ return null;
1421
+ }
1422
+ }
1423
+ function writeStored(key, value) {
1424
+ try {
1425
+ window.localStorage.setItem(key, String(value));
1426
+ } catch {
1427
+ }
1428
+ }
1429
+ function SidebarProvider({
1430
+ children,
1431
+ collapsed: collapsedProp,
1432
+ defaultCollapsed = false,
1433
+ onCollapsedChange,
1434
+ storageKey,
1435
+ mobileOpen: mobileOpenProp,
1436
+ defaultMobileOpen = false,
1437
+ onMobileOpenChange
1438
+ }) {
1439
+ const [collapsed, setCollapsedState] = useControllableState({
1440
+ value: collapsedProp,
1441
+ defaultValue: defaultCollapsed,
1442
+ onChange: onCollapsedChange
1443
+ });
1444
+ const [mobileOpen, setMobileOpen] = useControllableState({
1445
+ value: mobileOpenProp,
1446
+ defaultValue: defaultMobileOpen,
1447
+ onChange: onMobileOpenChange
1448
+ });
1449
+ const isMobile = useMediaQuery(MOBILE_QUERY);
1450
+ (0, import_react15.useEffect)(() => {
1451
+ if (!storageKey) return;
1452
+ const stored = readStored(storageKey);
1453
+ if (stored !== null) setCollapsedState(stored);
1454
+ }, [storageKey, setCollapsedState]);
1455
+ const setCollapsed = (0, import_react15.useCallback)(
1456
+ (next) => {
1457
+ if (storageKey) writeStored(storageKey, next);
1458
+ setCollapsedState(next);
1459
+ },
1460
+ [storageKey, setCollapsedState]
1461
+ );
1462
+ const value = (0, import_react15.useMemo)(
1463
+ () => ({
1464
+ collapsed,
1465
+ setCollapsed,
1466
+ toggleCollapsed: () => setCollapsed(!collapsed),
1467
+ mobileOpen,
1468
+ setMobileOpen,
1469
+ isMobile
1470
+ }),
1471
+ [collapsed, setCollapsed, mobileOpen, setMobileOpen, isMobile]
1472
+ );
1473
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarContext.Provider, { value, children });
1474
+ }
1475
+ var DefaultLink = (0, import_react15.forwardRef)(function DefaultLink2({ children, ...rest }, ref) {
1476
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { ref, ...rest, children });
1477
+ });
1478
+ var Row = (0, import_react15.createContext)(null);
1479
+ function useRow() {
1480
+ const value = (0, import_react15.useContext)(Row);
1481
+ if (!value) throw new Error("Sidebar rows must be rendered by <Sidebar>");
1482
+ return value;
1483
+ }
1484
+ function Sidebar(props) {
1485
+ const outer = (0, import_react15.useContext)(SidebarContext);
1486
+ if (outer) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRoot, { ...props, context: outer, ownsState: false });
1487
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1488
+ SidebarProvider,
1489
+ {
1490
+ collapsed: props.collapsed,
1491
+ defaultCollapsed: props.defaultCollapsed,
1492
+ onCollapsedChange: props.onCollapsedChange,
1493
+ storageKey: props.storageKey,
1494
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarFromContext, { ...props })
1495
+ }
1496
+ );
1497
+ }
1498
+ function SidebarFromContext(props) {
1499
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRoot, { ...props, context: useSidebar(), ownsState: true });
1500
+ }
1501
+ function SidebarRoot({
1020
1502
  groups,
1021
1503
  footerNav,
1022
1504
  brand,
1023
1505
  footer,
1506
+ density: densityProp,
1024
1507
  collapsible = true,
1025
- collapsed: collapsedProp = false,
1508
+ collapsed: collapsedProp,
1509
+ onCollapsedChange,
1026
1510
  onToggle,
1027
- size = "md",
1028
- variant = "card",
1511
+ currentPath,
1512
+ currentHash,
1513
+ linkComponent = DefaultLink,
1514
+ onNavigate,
1515
+ label = "Primary",
1516
+ variant,
1029
1517
  width = "w-80",
1030
- collapsedWidth = "w-20",
1031
- className
1518
+ collapsedWidth,
1519
+ className,
1520
+ context,
1521
+ ownsState
1032
1522
  }) {
1033
- const collapsed = collapsible && collapsedProp;
1034
- const hashTargets = (0, import_react10.useMemo)(
1523
+ const density = densityProp ?? (variant === "plain" ? "compact" : "comfortable");
1524
+ const asideId = (0, import_react15.useId)();
1525
+ const { isMobile, setMobileOpen } = context;
1526
+ const collapsed = !isMobile && collapsible && (collapsedProp ?? context.collapsed);
1527
+ const showToggle = collapsible && !isMobile && (collapsedProp === void 0 || onToggle != null || onCollapsedChange != null);
1528
+ const toggle = () => {
1529
+ const next = !collapsed;
1530
+ onToggle?.();
1531
+ if (!ownsState) onCollapsedChange?.(next);
1532
+ context.setCollapsed(next);
1533
+ };
1534
+ const hashTargets = (0, import_react15.useMemo)(
1035
1535
  () => new Set(
1036
- [...groups.flatMap((group) => group.items), ...footerNav ?? []].map((item) => item.to).filter((to) => to.includes("#"))
1536
+ [...groups.flatMap((group) => group.items), ...footerNav ?? []].flatMap((item) => [item, ...item.children ?? []]).map((item) => item.to).filter((to) => to?.includes("#") ?? false)
1037
1537
  ),
1038
1538
  [groups, footerNav]
1039
1539
  );
1040
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HashTargets.Provider, { value: hashTargets, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1540
+ const row = (0, import_react15.useMemo)(
1541
+ () => ({
1542
+ density,
1543
+ collapsed,
1544
+ path: currentPath,
1545
+ hash: currentHash,
1546
+ hashTargets,
1547
+ Link: linkComponent,
1548
+ onNavigate: () => {
1549
+ if (isMobile) setMobileOpen(false);
1550
+ onNavigate?.();
1551
+ }
1552
+ }),
1553
+ [density, collapsed, currentPath, currentHash, hashTargets, linkComponent, isMobile, setMobileOpen, onNavigate]
1554
+ );
1555
+ const state = { collapsed, density };
1556
+ const comfortable = density === "comfortable";
1557
+ const panel = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1041
1558
  "aside",
1042
1559
  {
1560
+ id: asideId,
1561
+ "aria-label": label,
1562
+ "data-density": density,
1563
+ "data-collapsed": collapsed || void 0,
1043
1564
  className: cn(
1044
- "relative flex h-full shrink-0 flex-col py-2 transition-all duration-200 motion-reduce:transition-none",
1045
- "rounded-xl border-r border-default bg-default-secondary",
1046
- collapsed ? collapsedWidth : width,
1565
+ "relative flex h-full shrink-0 flex-col justify-between bg-default-secondary py-2",
1566
+ "transition-[width] duration-200 motion-reduce:transition-none",
1567
+ isMobile ? "w-full" : (0, import_clsx10.default)(
1568
+ "rounded-xl border-r border-default",
1569
+ collapsed ? collapsedWidth ?? (comfortable ? "w-20" : "w-[72px]") : width
1570
+ ),
1047
1571
  className
1048
1572
  ),
1049
1573
  children: [
1050
- collapsible && onToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1574
+ showToggle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1051
1575
  "button",
1052
1576
  {
1053
1577
  type: "button",
1054
1578
  "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
1055
1579
  "aria-expanded": !collapsed,
1056
- onClick: onToggle,
1580
+ "aria-controls": asideId,
1581
+ onClick: toggle,
1057
1582
  className: cn(
1058
1583
  "absolute -right-3 top-5 z-raised flex size-6 items-center justify-center rounded-full",
1059
1584
  "border border-default bg-default text-default-secondary",
@@ -1063,130 +1588,246 @@ function AppSidebar({
1063
1588
  "shadow-100 transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1064
1589
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default"
1065
1590
  ),
1066
- children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.ChevronRightIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.ChevronLeftIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true })
1591
+ children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.ChevronRightIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.ChevronLeftIcon, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true })
1067
1592
  }
1068
1593
  ),
1069
- brand && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1070
- "div",
1071
- {
1072
- className: cn(
1073
- "flex shrink-0 items-center overflow-hidden p-4",
1074
- collapsed ? "justify-center" : "gap-2.5"
1075
- ),
1076
- children: typeof brand === "function" ? brand({ collapsed }) : brand
1077
- }
1078
- ),
1079
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScrollArea, { axis: "vertical", label: "Sidebar navigation", className: "min-h-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "flex flex-col gap-4 px-4 pb-3 pt-2", children: groups.map((group, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1080
- SidebarGroup,
1081
- {
1082
- group,
1083
- showSeparator: groupIndex > 0,
1084
- collapsed,
1085
- size,
1086
- variant
1087
- },
1088
- group.title ?? `group-${groupIndex}`
1089
- )) }) }),
1090
- (footerNav?.length || footer) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex shrink-0 flex-col", children: [
1091
- footerNav && footerNav.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { className: "flex flex-col gap-3 px-4 pt-2", children: footerNav.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1092
- SidebarLink,
1594
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-h-0 flex-1 flex-col gap-1 pb-3", children: [
1595
+ brand && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1596
+ "div",
1597
+ {
1598
+ className: cn(
1599
+ "flex shrink-0 items-center overflow-hidden p-4",
1600
+ collapsed ? "justify-center" : "gap-2.5"
1601
+ ),
1602
+ children: typeof brand === "function" ? brand(state) : brand
1603
+ }
1604
+ ),
1605
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScrollArea, { axis: "vertical", label: "Sidebar navigation", className: "min-h-0 flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Row.Provider, { value: row, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("nav", { "aria-label": "Main", className: cn("flex flex-col px-4", comfortable ? "gap-4 pt-2" : "gap-2"), children: groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarGroupView, { group }, group.id ?? group.title ?? `group-${index}`)) }) }) })
1606
+ ] }),
1607
+ (Boolean(footerNav?.length) || footer != null) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex shrink-0 flex-col", children: [
1608
+ footerNav && footerNav.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Row.Provider, { value: row, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1609
+ "nav",
1093
1610
  {
1094
- item,
1095
- collapsed,
1096
- size,
1097
- variant
1098
- },
1099
- item.to
1100
- )) }),
1101
- footer
1611
+ "aria-label": "Secondary",
1612
+ className: cn("flex flex-col px-4 pt-2", comfortable && "gap-1", collapsed && "items-center"),
1613
+ children: footerNav.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRow, { item }, itemKey(item)))
1614
+ }
1615
+ ) }),
1616
+ typeof footer === "function" ? footer(state) : footer
1102
1617
  ] })
1103
1618
  ]
1104
1619
  }
1105
- ) });
1620
+ );
1621
+ if (isMobile) {
1622
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1623
+ Drawer,
1624
+ {
1625
+ side: "left",
1626
+ open: context.mobileOpen,
1627
+ onOpenChange: setMobileOpen,
1628
+ label,
1629
+ width: "w-80 max-w-[85vw]",
1630
+ className: "bg-default-secondary",
1631
+ children: panel
1632
+ }
1633
+ );
1634
+ }
1635
+ return panel;
1106
1636
  }
1107
- function SidebarGroup({
1108
- group,
1109
- showSeparator,
1110
- collapsed,
1111
- size,
1112
- variant
1113
- }) {
1637
+ function itemKey(item) {
1638
+ return item.id ?? item.to ?? item.href ?? item.label;
1639
+ }
1640
+ function SidebarGroupView({ group }) {
1641
+ const { density, collapsed } = useRow();
1642
+ const [open, setOpen] = (0, import_react15.useState)(group.defaultOpen ?? true);
1643
+ const regionId = (0, import_react15.useId)();
1644
+ const foldable = Boolean(group.collapsible && group.title) && !collapsed;
1645
+ const comfortable = density === "comfortable";
1114
1646
  return (
1115
- // 12px between rows, per the design — the rows read as separate pills rather than a
1116
- // stack. Through 0.5.0 this was `gap-1`, which packed them into a near-continuous block.
1117
- // The same gap spaces the separator and the heading, so neither needs a margin of its own.
1118
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-3", children: [
1119
- showSeparator && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarSeparator, {}),
1120
- group.title && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1121
- "p",
1647
+ // Figma "Menu Container": 8px above and below; 12px (comfortable) or 8px (compact)
1648
+ // between the heading and the rows; rows 4px apart when comfortable, touching when compact.
1649
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex flex-col py-2", comfortable ? "gap-3" : "gap-2"), children: [
1650
+ group.title && (collapsed ? (
1651
+ // No room in the rail, but still the only thing naming the run of icons below.
1652
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "sr-only", children: group.title })
1653
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1654
+ NavGroupHeader,
1122
1655
  {
1123
- className: cn(
1124
- "text-body-tiny font-semibold uppercase tracking-wider text-neutral-tertiary",
1125
- // Flush with the rows rather than inset a further 12px — the heading lines up
1126
- // with the left edge of the pills below it, not with their labels.
1127
- // `sr-only` is out of flow, so a collapsed group's heading costs no gap.
1128
- collapsed ? "sr-only" : "px-0"
1129
- ),
1130
- children: group.title
1656
+ title: group.title,
1657
+ action: group.action,
1658
+ ...foldable ? { open, onOpenChange: setOpen, controls: regionId } : {}
1131
1659
  }
1132
- ),
1133
- group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1134
- SidebarLink,
1135
- {
1136
- item,
1137
- collapsed,
1138
- size,
1139
- variant
1140
- },
1141
- item.to
1142
- ))
1660
+ )),
1661
+ (!foldable || open) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { id: regionId, className: cn("flex flex-col", comfortable && "gap-1", collapsed && "items-center"), children: group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarRow, { item }, itemKey(item))) })
1143
1662
  ] })
1144
1663
  );
1145
1664
  }
1146
- var HashTargets = (0, import_react10.createContext)(/* @__PURE__ */ new Set());
1147
- function useRowActive(item) {
1148
- const location = (0, import_react_router_dom2.useLocation)();
1149
- const hashTargets = (0, import_react10.useContext)(HashTargets);
1665
+ function isRowActive(item, row) {
1666
+ if (item.isActive !== void 0) return item.isActive;
1667
+ if (!item.to || row.path === void 0) return false;
1150
1668
  const [path, hash] = item.to.split("#");
1151
- const pathMatches = item.end ? location.pathname === path : location.pathname === path || location.pathname.startsWith(`${path.replace(/\/$/, "")}/`);
1669
+ const pathMatches = item.end ? row.path === path : row.path === path || row.path.startsWith(`${path.replace(/\/$/, "")}/`);
1152
1670
  if (!pathMatches) return false;
1153
- if (hash !== void 0) return location.hash === `#${hash}`;
1154
- return !hashTargets.has(`${location.pathname}${location.hash}`);
1671
+ if (hash !== void 0) return row.hash === `#${hash}`;
1672
+ return !row.hashTargets.has(`${row.path}${row.hash ?? ""}`);
1155
1673
  }
1156
- function SidebarLink({
1157
- item,
1158
- collapsed,
1159
- size,
1160
- variant
1161
- }) {
1162
- const active = useRowActive(item);
1163
- const link = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1164
- import_react_router_dom2.Link,
1165
- {
1166
- to: item.to,
1167
- "aria-current": active ? "page" : void 0,
1168
- "aria-disabled": item.disabled || void 0,
1169
- tabIndex: item.disabled ? -1 : void 0,
1170
- onClick: item.disabled ? (event) => event.preventDefault() : void 0,
1171
- className: cn("block w-full no-underline", collapsed && "flex justify-center"),
1172
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1173
- NavItem,
1174
- {
1175
- icon: item.icon,
1176
- label: item.label,
1177
- isActive: active,
1178
- indicator: item.indicator,
1179
- disabled: item.disabled,
1180
- collapsed,
1181
- size,
1182
- variant
1674
+ function SidebarRow({ item }) {
1675
+ const row = useRow();
1676
+ if (item.children?.length) {
1677
+ return row.collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RailParent, { item }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ParentRow, { item });
1678
+ }
1679
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LeafRow, { item });
1680
+ }
1681
+ function navigateHandler(row) {
1682
+ return (event) => {
1683
+ if (!event.defaultPrevented) row.onNavigate();
1684
+ };
1685
+ }
1686
+ function LeafRow({ item }) {
1687
+ const row = useRow();
1688
+ const active = isRowActive(item, row);
1689
+ const common = {
1690
+ icon: item.icon,
1691
+ label: item.label,
1692
+ isActive: active,
1693
+ indicator: item.indicator,
1694
+ disabled: item.disabled,
1695
+ collapsed: row.collapsed,
1696
+ density: row.density
1697
+ };
1698
+ let element;
1699
+ if (item.href) {
1700
+ element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: item.href, target: "_blank", rel: "noreferrer" }) });
1701
+ } else if (item.to) {
1702
+ const { Link: Link2 } = row;
1703
+ element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: item.to }) });
1704
+ } else {
1705
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavItem, { ...common });
1706
+ }
1707
+ if (!row.collapsed) return element;
1708
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: element });
1709
+ }
1710
+ function ParentRow({ item }) {
1711
+ const row = useRow();
1712
+ const children = item.children ?? [];
1713
+ const childActive = children.some((child) => isRowActive(child, row));
1714
+ const [open, setOpen] = (0, import_react15.useState)(item.defaultOpen ?? childActive);
1715
+ const regionId = (0, import_react15.useId)();
1716
+ (0, import_react15.useEffect)(() => {
1717
+ if (childActive) setOpen(true);
1718
+ }, [childActive]);
1719
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1720
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1721
+ NavItem,
1722
+ {
1723
+ asChild: true,
1724
+ icon: item.icon,
1725
+ label: item.label,
1726
+ isActive: !open && childActive,
1727
+ indicator: item.indicator,
1728
+ disabled: item.disabled,
1729
+ density: row.density,
1730
+ trailing: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1731
+ import_lucide_react5.ChevronDownIcon,
1732
+ {
1733
+ className: cn(
1734
+ "text-icon-default-secondary transition-transform motion-reduce:transition-none",
1735
+ !open && "-rotate-90"
1736
+ )
1737
+ }
1738
+ ),
1739
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-expanded": open, "aria-controls": regionId, onClick: () => setOpen(!open) })
1740
+ }
1741
+ ),
1742
+ open && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { id: regionId, className: "flex flex-col", children: children.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SubRow, { item: child, last: index === children.length - 1 }, itemKey(child))) })
1743
+ ] });
1744
+ }
1745
+ function SubRow({ item, last }) {
1746
+ const row = useRow();
1747
+ const common = {
1748
+ label: item.label,
1749
+ isActive: isRowActive(item, row),
1750
+ disabled: item.disabled,
1751
+ last,
1752
+ density: row.density
1753
+ };
1754
+ if (item.href) {
1755
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: item.href, target: "_blank", rel: "noreferrer" }) });
1756
+ }
1757
+ if (item.to) {
1758
+ const { Link: Link2 } = row;
1759
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { asChild: true, ...common, onClick: navigateHandler(row), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: item.to }) });
1760
+ }
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NavSubItem, { ...common });
1762
+ }
1763
+ var FLYOUT_ITEM = (0, import_clsx10.default)(OVERLAY_ITEM_BASE, OVERLAY_ITEM_SIZE.md, "no-underline");
1764
+ function RailParent({ item }) {
1765
+ const row = useRow();
1766
+ const children = item.children ?? [];
1767
+ const childActive = children.some((child) => isRowActive(child, row));
1768
+ const { Link: Link2 } = row;
1769
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1770
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1771
+ NavItem,
1772
+ {
1773
+ asChild: true,
1774
+ icon: item.icon,
1775
+ label: item.label,
1776
+ isActive: childActive,
1777
+ indicator: item.indicator,
1778
+ disabled: item.disabled,
1779
+ collapsed: true,
1780
+ density: row.density,
1781
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button" })
1782
+ }
1783
+ ) }) }),
1784
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenuContent, { side: "right", align: "start", children: [
1785
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuLabel, { children: item.label }),
1786
+ children.map((child) => {
1787
+ const active = isRowActive(child, row);
1788
+ const className = cn(
1789
+ FLYOUT_ITEM,
1790
+ overlayItemTone("default", Boolean(child.disabled)),
1791
+ active && "bg-brand text-brand-on-brand hover:bg-brand-hover focus:bg-brand-hover"
1792
+ );
1793
+ if (!child.to && !child.href) {
1794
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuItem, { disabled: child.disabled, children: child.label }, itemKey(child));
1183
1795
  }
1184
- )
1796
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1797
+ import_radix_ui4.DropdownMenu.Item,
1798
+ {
1799
+ asChild: true,
1800
+ disabled: child.disabled,
1801
+ className,
1802
+ onSelect: () => row.onNavigate(),
1803
+ children: child.href ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: child.href, target: "_blank", rel: "noreferrer", children: child.label }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Link2, { href: child.to, "aria-current": active ? "page" : void 0, children: child.label })
1804
+ },
1805
+ itemKey(child)
1806
+ );
1807
+ })
1808
+ ] })
1809
+ ] });
1810
+ }
1811
+ var SidebarTrigger = (0, import_react15.forwardRef)(function SidebarTrigger2({ "aria-label": ariaLabel = "Open navigation", className, onClick, variant = "subtle", ...rest }, ref) {
1812
+ const { mobileOpen, setMobileOpen } = useSidebar();
1813
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1814
+ IconButton,
1815
+ {
1816
+ ref,
1817
+ "aria-label": ariaLabel,
1818
+ "aria-expanded": mobileOpen,
1819
+ "aria-haspopup": "dialog",
1820
+ variant,
1821
+ className: cn("md:hidden", className),
1822
+ onClick: (event) => {
1823
+ onClick?.(event);
1824
+ if (!event.defaultPrevented) setMobileOpen(!mobileOpen);
1825
+ },
1826
+ ...rest,
1827
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.MenuIcon, { className: "size-5", "aria-hidden": true })
1185
1828
  }
1186
1829
  );
1187
- if (!collapsed) return link;
1188
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: item.label, side: "right", children: link });
1189
- }
1830
+ });
1190
1831
  function SidebarSeparator({ className, ...rest }) {
1191
1832
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "aria-hidden": true, className: cn("mx-1 h-px shrink-0 bg-divider", className), ...rest });
1192
1833
  }
@@ -1201,40 +1842,82 @@ function SidebarUserCard({
1201
1842
  const initial = name.trim().charAt(0);
1202
1843
  const items = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1203
1844
  menu,
1204
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1205
- DropdownMenuItem,
1206
- {
1207
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.LogOutIcon, { className: "size-3.5", "aria-hidden": true }),
1208
- onSelect: onLogout,
1209
- children: "Sign out"
1210
- }
1211
- )
1845
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuItem, { icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.LogOutIcon, { className: "size-3.5", "aria-hidden": true }), onSelect: onLogout, children: "Sign out" })
1212
1846
  ] });
1213
1847
  if (collapsed) {
1214
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("flex shrink-0 items-center justify-center p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1215
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-label": `${name} \u2014 user options`, className: "rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }) }) }),
1216
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "right", align: "end", children: items })
1217
- ] }) });
1848
+ return (
1849
+ // Figma collapsed user card: the avatar alone, 24px above and 16px below.
1850
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("flex shrink-0 items-center justify-center px-4 pb-4 pt-6", className), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1851
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-label": `${name} \u2014 user options`, className: "rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }) }) }),
1852
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "right", align: "end", children: items })
1853
+ ] }) })
1854
+ );
1218
1855
  }
1219
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex shrink-0 items-center gap-2.5 p-4", className), children: [
1220
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }),
1221
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
1222
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-sm font-semibold leading-snug text-default", children: name }),
1223
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-tiny font-regular leading-none text-default-secondary", children: role })
1224
- ] }),
1225
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1226
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1227
- "button",
1228
- {
1229
- type: "button",
1230
- "aria-label": `${name} \u2014 user options`,
1231
- className: "flex size-6 shrink-0 items-center justify-center rounded-md text-default-secondary transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1232
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react3.EllipsisVerticalIcon, { className: "size-5", "aria-hidden": true })
1233
- }
1234
- ) }),
1235
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "top", align: "end", children: items })
1856
+ return (
1857
+ // Figma: 16px padding, plus 4px more above and below the row inside it.
1858
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("flex shrink-0 items-center gap-2.5 px-4 py-5", className), children: [
1859
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Avatar, { initial, size: "lg", shape: "circle" }),
1860
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
1861
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-sm font-semibold leading-snug text-default", children: name }),
1862
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate text-body-tiny font-regular leading-none text-default-secondary", children: role })
1863
+ ] }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DropdownMenu, { children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuTrigger, { asChild: true, label: "User options", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1866
+ "button",
1867
+ {
1868
+ type: "button",
1869
+ "aria-label": `${name} \u2014 user options`,
1870
+ className: "flex size-6 shrink-0 items-center justify-center rounded-md text-default-secondary transition-colors hover:bg-brand-tertiary-hover hover:text-brand",
1871
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react5.EllipsisVerticalIcon, { className: "size-5", "aria-hidden": true })
1872
+ }
1873
+ ) }),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownMenuContent, { side: "top", align: "end", children: items })
1875
+ ] })
1236
1876
  ] })
1237
- ] });
1877
+ );
1878
+ }
1879
+
1880
+ // src/sidebar/nav-tabs.tsx
1881
+ var import_react_router_dom = require("react-router-dom");
1882
+ var import_clsx11 = __toESM(require("clsx"), 1);
1883
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1884
+ function NavTabs({ items, className }) {
1885
+ return (
1886
+ // The links inside are the tab stops.
1887
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1888
+ "div",
1889
+ {
1890
+ className: (0, import_clsx11.default)(
1891
+ "flex gap-6 overflow-x-auto border-b border-default",
1892
+ SCROLLBAR_CLASSES,
1893
+ className
1894
+ ),
1895
+ children: items.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1896
+ import_react_router_dom.NavLink,
1897
+ {
1898
+ to: tab.to,
1899
+ end: tab.end,
1900
+ className: ({ isActive }) => (0, import_clsx11.default)(
1901
+ "shrink-0 whitespace-nowrap border-b-2 pb-3 text-body-sm transition-colors",
1902
+ isActive ? "border-brand-emphasis font-semibold text-brand-emphasis" : "border-transparent font-medium text-default-secondary hover:text-default"
1903
+ ),
1904
+ children: tab.label
1905
+ },
1906
+ tab.to
1907
+ ))
1908
+ }
1909
+ )
1910
+ );
1911
+ }
1912
+
1913
+ // src/sidebar/index.tsx
1914
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1915
+ var RouterLink = (0, import_react16.forwardRef)(function RouterLink2({ href, ...rest }, ref) {
1916
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_router_dom2.Link, { ref, to: href, ...rest });
1917
+ });
1918
+ function AppSidebar(props) {
1919
+ const location = (0, import_react_router_dom2.useLocation)();
1920
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Sidebar, { ...props, currentPath: location.pathname, currentHash: location.hash, linkComponent: RouterLink });
1238
1921
  }
1239
1922
  // Annotate the CommonJS export names for ESM import in node:
1240
1923
  0 && (module.exports = {