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