@vuer-ai/vuer-uikit 0.0.96 → 0.0.98
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/README.md +106 -7
- package/cli/dial-cli.js +49 -7
- package/dist/SyncScroll/SyncScroll.cjs +10 -10
- package/dist/SyncScroll/SyncScroll.mjs +3 -3
- package/dist/SyncScroll/index.cjs +10 -10
- package/dist/SyncScroll/index.mjs +3 -3
- package/dist/chunk-3HEZVWRW.mjs +62 -0
- package/dist/chunk-4KWGGESI.cjs +494 -0
- package/dist/{chunk-CCMKL2OA.cjs → chunk-7GWDO25E.cjs} +2 -2
- package/dist/chunk-A5LCX2UQ.cjs +208 -0
- package/dist/chunk-BEJIZ56L.mjs +300 -0
- package/dist/chunk-C7VGRU3O.mjs +283 -0
- package/dist/{chunk-LONOMMFA.cjs → chunk-LJMNHTTG.cjs} +21 -21
- package/dist/chunk-O66RESRR.cjs +285 -0
- package/dist/{chunk-RINTUFYQ.cjs → chunk-RMK6W774.cjs} +24 -19
- package/dist/{chunk-BFQ2WL5U.mjs → chunk-TTYSYGVE.mjs} +2 -2
- package/dist/chunk-VA3PEYFM.mjs +489 -0
- package/dist/chunk-VBBJSIY7.cjs +308 -0
- package/dist/{chunk-AIINOWEH.mjs → chunk-W4JCKCW7.mjs} +5 -5
- package/dist/chunk-WWGF6TBZ.mjs +206 -0
- package/dist/chunk-ZGN4UEJR.cjs +679 -0
- package/dist/chunk-ZQLRMOUW.mjs +661 -0
- package/dist/dial/DialPanel.cjs +24 -24
- package/dist/dial/DialPanel.mjs +23 -23
- package/dist/dial/DialProvider.cjs +3 -3
- package/dist/dial/DialProvider.d.cts +1 -0
- package/dist/dial/DialProvider.d.ts +1 -0
- package/dist/dial/DialProvider.example.cjs +72 -0
- package/dist/dial/DialProvider.example.d.cts +7 -0
- package/dist/dial/DialProvider.example.d.ts +7 -0
- package/dist/dial/DialProvider.example.mjs +68 -0
- package/dist/dial/DialProvider.mjs +1 -1
- package/dist/dial/index.cjs +42 -42
- package/dist/dial/index.mjs +23 -23
- package/dist/dial/wrapped-inputs/ControlledInputs.cjs +27 -27
- package/dist/dial/wrapped-inputs/ControlledInputs.mjs +23 -23
- package/dist/dial/wrapped-inputs/DialInputs.cjs +34 -34
- package/dist/dial/wrapped-inputs/DialInputs.mjs +23 -23
- package/dist/dial/wrapped-inputs/DialVectorInput.cjs +24 -24
- package/dist/dial/wrapped-inputs/DialVectorInput.mjs +23 -23
- package/dist/dial/wrapped-inputs/index.cjs +39 -39
- package/dist/dial/wrapped-inputs/index.mjs +23 -23
- package/dist/highlight-cursor/cursor-provider.cjs +3 -3
- package/dist/highlight-cursor/cursor-provider.mjs +2 -2
- package/dist/highlight-cursor/enhanced-components.cjs +10 -10
- package/dist/highlight-cursor/enhanced-components.mjs +5 -5
- package/dist/highlight-cursor/index.cjs +16 -16
- package/dist/highlight-cursor/index.mjs +6 -6
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.cjs +190 -190
- package/dist/index.mjs +23 -23
- package/dist/ui/UIKitBadge.cjs +6 -6
- package/dist/ui/UIKitBadge.mjs +2 -2
- package/dist/ui/avatar.cjs +1 -1
- package/dist/ui/avatar.mjs +1 -1
- package/dist/ui/badge.cjs +1 -1
- package/dist/ui/badge.d.cts +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/dist/ui/badge.mjs +1 -1
- package/dist/ui/button.cjs +1 -1
- package/dist/ui/button.mjs +1 -1
- package/dist/ui/card.cjs +1 -1
- package/dist/ui/card.mjs +1 -1
- package/dist/ui/checkbox.cjs +1 -1
- package/dist/ui/checkbox.mjs +1 -1
- package/dist/ui/collapsible.cjs +1 -1
- package/dist/ui/collapsible.mjs +1 -1
- package/dist/ui/drawer.cjs +1 -1
- package/dist/ui/drawer.mjs +1 -1
- package/dist/ui/dropdown.cjs +1 -1
- package/dist/ui/dropdown.mjs +1 -1
- package/dist/ui/index.cjs +107 -107
- package/dist/ui/index.mjs +17 -17
- package/dist/ui/inputs/color-input.cjs +1 -1
- package/dist/ui/inputs/color-input.mjs +1 -1
- package/dist/ui/inputs/index.cjs +11 -11
- package/dist/ui/inputs/index.mjs +3 -3
- package/dist/ui/inputs/input-numbers.cjs +1 -1
- package/dist/ui/inputs/input-numbers.mjs +1 -1
- package/dist/ui/inputs/input.cjs +1 -1
- package/dist/ui/inputs/input.d.cts +1 -1
- package/dist/ui/inputs/input.d.ts +1 -1
- package/dist/ui/inputs/input.mjs +1 -1
- package/dist/ui/inputs/number-inputs/CmInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/CmInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/DegInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/DegInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerDegInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerDegInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerRadInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/EulerRadInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/InchInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/InchInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/IntInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/IntInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/KVectorInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/KVectorInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/QuaternionInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/QuaternionInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/RadInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/RadInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/TimeInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/TimeInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/Vec3Input.cjs +1 -1
- package/dist/ui/inputs/number-inputs/Vec3Input.mjs +1 -1
- package/dist/ui/inputs/number-inputs/VectorInput.cjs +1 -1
- package/dist/ui/inputs/number-inputs/VectorInput.mjs +1 -1
- package/dist/ui/inputs/number-inputs/index.cjs +11 -11
- package/dist/ui/inputs/number-inputs/index.mjs +3 -3
- package/dist/ui/inputs/presets-input.cjs +1 -1
- package/dist/ui/inputs/presets-input.mjs +1 -1
- package/dist/ui/label.cjs +1 -1
- package/dist/ui/label.mjs +1 -1
- package/dist/ui/layout.cjs +1 -1
- package/dist/ui/layout.mjs +1 -1
- package/dist/ui/layouts/dock-layout/DockLayoutView.cjs +1 -1
- package/dist/ui/layouts/dock-layout/DockLayoutView.mjs +1 -1
- package/dist/ui/layouts/dock-layout/LayoutSlots.cjs +1 -1
- package/dist/ui/layouts/dock-layout/LayoutSlots.mjs +1 -1
- package/dist/ui/layouts/dock-layout/index.cjs +1 -1
- package/dist/ui/layouts/dock-layout/index.mjs +1 -1
- package/dist/ui/layouts/index.cjs +2 -2
- package/dist/ui/layouts/index.mjs +2 -2
- package/dist/ui/layouts/liquid-layout/LayoutSlots.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/LayoutSlots.mjs +1 -1
- package/dist/ui/layouts/liquid-layout/LiquidLayoutView.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/LiquidLayoutView.mjs +1 -1
- package/dist/ui/layouts/liquid-layout/index.cjs +1 -1
- package/dist/ui/layouts/liquid-layout/index.mjs +1 -1
- package/dist/ui/modal.cjs +1 -1
- package/dist/ui/modal.mjs +1 -1
- package/dist/ui/navigation.cjs +1 -1
- package/dist/ui/navigation.mjs +1 -1
- package/dist/ui/pagination.cjs +1 -1
- package/dist/ui/pagination.mjs +1 -1
- package/dist/ui/panel.cjs +1 -1
- package/dist/ui/panel.mjs +1 -1
- package/dist/ui/popover.cjs +1 -1
- package/dist/ui/popover.mjs +1 -1
- package/dist/ui/radio-group.cjs +1 -1
- package/dist/ui/radio-group.mjs +1 -1
- package/dist/ui/resizable.cjs +1 -1
- package/dist/ui/resizable.mjs +1 -1
- package/dist/ui/select.cjs +1 -1
- package/dist/ui/select.d.cts +1 -1
- package/dist/ui/select.d.ts +1 -1
- package/dist/ui/select.mjs +1 -1
- package/dist/ui/separator.cjs +1 -1
- package/dist/ui/separator.mjs +1 -1
- package/dist/ui/sheet.cjs +1 -1
- package/dist/ui/sheet.mjs +1 -1
- package/dist/ui/sidebar.cjs +26 -26
- package/dist/ui/sidebar.mjs +2 -2
- package/dist/ui/simple-tree-view.cjs +1 -1
- package/dist/ui/simple-tree-view.mjs +1 -1
- package/dist/ui/skeleton.cjs +1 -1
- package/dist/ui/skeleton.mjs +1 -1
- package/dist/ui/slider.cjs +1 -1
- package/dist/ui/slider.mjs +1 -1
- package/dist/ui/switch.cjs +1 -1
- package/dist/ui/switch.mjs +1 -1
- package/dist/ui/table.cjs +1 -1
- package/dist/ui/table.mjs +1 -1
- package/dist/ui/tabs.cjs +1 -1
- package/dist/ui/tabs.mjs +1 -1
- package/dist/ui/textarea.cjs +1 -1
- package/dist/ui/textarea.d.cts +1 -1
- package/dist/ui/textarea.d.ts +1 -1
- package/dist/ui/textarea.mjs +1 -1
- package/dist/ui/theme/ThemeToggles.cjs +1 -1
- package/dist/ui/theme/ThemeToggles.mjs +1 -1
- package/dist/ui/theme/index.cjs +1 -1
- package/dist/ui/theme/index.mjs +1 -1
- package/dist/ui/toggle-buttons.cjs +1 -1
- package/dist/ui/toggle-buttons.mjs +1 -1
- package/dist/ui/toggle-group.cjs +1 -1
- package/dist/ui/toggle-group.mjs +1 -1
- package/dist/ui/toggle.cjs +1 -1
- package/dist/ui/toggle.mjs +1 -1
- package/dist/ui/toolbar.cjs +1 -1
- package/dist/ui/toolbar.mjs +1 -1
- package/dist/ui/tooltip.cjs +1 -1
- package/dist/ui/tooltip.mjs +1 -1
- package/dist/ui/tree-view/TreeSearchBar.cjs +1 -1
- package/dist/ui/tree-view/TreeSearchBar.mjs +1 -1
- package/dist/ui/tree-view/TreeView.cjs +1 -1
- package/dist/ui/tree-view/TreeView.mjs +1 -1
- package/dist/ui/tree-view/index.cjs +6 -6
- package/dist/ui/tree-view/index.mjs +2 -2
- package/dist/ui/tree-view-legacy.cjs +9 -9
- package/dist/ui/tree-view-legacy.mjs +5 -5
- package/dist/ui/waterfall/CursorOverlay.cjs +1 -1
- package/dist/ui/waterfall/CursorOverlay.mjs +1 -1
- package/dist/ui/waterfall/TimelineEvent.cjs +1 -1
- package/dist/ui/waterfall/TimelineEvent.mjs +1 -1
- package/dist/ui/waterfall/TimelineProcessBar.cjs +1 -1
- package/dist/ui/waterfall/TimelineProcessBar.mjs +1 -1
- package/dist/ui/waterfall/Wedges.cjs +1 -1
- package/dist/ui/waterfall/Wedges.mjs +1 -1
- package/dist/ui/waterfall/index.cjs +8 -8
- package/dist/ui/waterfall/index.mjs +7 -7
- package/package.json +28 -2
- package/src/SyncScroll/README.md +283 -0
- package/src/SyncScroll/SyncScroll.tsx +361 -0
- package/src/SyncScroll/index.ts +22 -0
- package/src/SyncScroll/useSyncScroll.tsx +226 -0
- package/src/cli/dial-cli.ts +1133 -0
- package/src/dial/DialPanel.tsx +208 -0
- package/src/dial/DialProvider.example.tsx +80 -0
- package/src/dial/DialProvider.tsx +138 -0
- package/src/dial/index.ts +26 -0
- package/src/dial/wrapped-inputs/ControlledInputs.tsx +176 -0
- package/src/dial/wrapped-inputs/DialInputs.tsx +401 -0
- package/src/dial/wrapped-inputs/DialVectorInput.tsx +125 -0
- package/src/dial/wrapped-inputs/index.ts +25 -0
- package/src/highlight-cursor/cursor-context.tsx +23 -0
- package/src/highlight-cursor/cursor-provider.tsx +264 -0
- package/src/highlight-cursor/enhanced-components.tsx +16 -0
- package/src/highlight-cursor/index.ts +21 -0
- package/src/highlight-cursor/tabs-cursor-context.tsx +121 -0
- package/src/highlight-cursor/types.ts +40 -0
- package/src/highlight-cursor/with-cursor.tsx +144 -0
- package/src/hooks/clientOnly.tsx +54 -0
- package/src/hooks/cn.ts +33 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useDocument.tsx +18 -0
- package/src/hooks/useDragSelect.ts +116 -0
- package/src/hooks/useIsMobile.ts +35 -0
- package/src/hooks/useLocalStorage.ts +122 -0
- package/src/hooks/useLocation.tsx +95 -0
- package/src/hooks/useQueryParams.tsx +31 -0
- package/src/hooks/useWindow.tsx +18 -0
- package/src/index.css +5 -0
- package/src/index.ts +5 -0
- package/src/styles/.editorconfig +0 -0
- package/src/styles/theme.css +152 -0
- package/src/styles/toast.css +67 -0
- package/src/styles/variables.css +229 -0
- package/src/ui/UIKitBadge.tsx +171 -0
- package/src/ui/avatar.tsx +221 -0
- package/src/ui/badge.tsx +74 -0
- package/src/ui/button.tsx +143 -0
- package/src/ui/card.tsx +146 -0
- package/src/ui/checkbox.tsx +78 -0
- package/src/ui/collapsible.tsx +43 -0
- package/src/ui/drag-selectable/DragSelectProvider.tsx +178 -0
- package/src/ui/drag-selectable/createSelectable.tsx +43 -0
- package/src/ui/drag-selectable/index.ts +2 -0
- package/src/ui/drawer.tsx +137 -0
- package/src/ui/dropdown.tsx +707 -0
- package/src/ui/icons/MouseCursorIcons.tsx +39 -0
- package/src/ui/icons/cursor.tsx +38 -0
- package/src/ui/icons/index.ts +2 -0
- package/src/ui/index.ts +45 -0
- package/src/ui/inputs/color-input.tsx +61 -0
- package/src/ui/inputs/index.tsx +5 -0
- package/src/ui/inputs/input-numbers.tsx +394 -0
- package/src/ui/inputs/input.tsx +155 -0
- package/src/ui/inputs/number-inputs/CmInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/DegInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/EulerDegInput.tsx +14 -0
- package/src/ui/inputs/number-inputs/EulerInput.tsx +30 -0
- package/src/ui/inputs/number-inputs/EulerRadInput.tsx +14 -0
- package/src/ui/inputs/number-inputs/InchInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/IntInput.tsx +46 -0
- package/src/ui/inputs/number-inputs/KVectorInput.tsx +20 -0
- package/src/ui/inputs/number-inputs/QuaternionInput.tsx +27 -0
- package/src/ui/inputs/number-inputs/RadInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/TimeInput.tsx +26 -0
- package/src/ui/inputs/number-inputs/Vec3Input.tsx +26 -0
- package/src/ui/inputs/number-inputs/VectorInput.tsx +38 -0
- package/src/ui/inputs/number-inputs/index.ts +38 -0
- package/src/ui/inputs/presets-input.tsx +59 -0
- package/src/ui/label.tsx +35 -0
- package/src/ui/layout.tsx +43 -0
- package/src/ui/layouts/dock-layout/DockLayoutView.tsx +128 -0
- package/src/ui/layouts/dock-layout/LayoutSlots.tsx +85 -0
- package/src/ui/layouts/dock-layout/index.tsx +2 -0
- package/src/ui/layouts/index.ts +2 -0
- package/src/ui/layouts/liquid-layout/LayoutSlots.tsx +82 -0
- package/src/ui/layouts/liquid-layout/LiquidLayoutView.tsx +76 -0
- package/src/ui/layouts/liquid-layout/index.ts +1 -0
- package/src/ui/modal.tsx +211 -0
- package/src/ui/navigation.tsx +86 -0
- package/src/ui/pagination.tsx +129 -0
- package/src/ui/panel.tsx +146 -0
- package/src/ui/popover.tsx +112 -0
- package/src/ui/radio-group.tsx +63 -0
- package/src/ui/resizable.tsx +52 -0
- package/src/ui/select.tsx +365 -0
- package/src/ui/separator.tsx +26 -0
- package/src/ui/sheet.tsx +257 -0
- package/src/ui/sidebar.tsx +695 -0
- package/src/ui/simple-tree-view.tsx +604 -0
- package/src/ui/skeleton.tsx +15 -0
- package/src/ui/slider.tsx +204 -0
- package/src/ui/switch.tsx +45 -0
- package/src/ui/table.tsx +99 -0
- package/src/ui/tabs.tsx +192 -0
- package/src/ui/textarea.tsx +55 -0
- package/src/ui/theme/ThemeProvider.tsx +319 -0
- package/src/ui/theme/ThemeToggles.tsx +84 -0
- package/src/ui/theme/index.ts +21 -0
- package/src/ui/theme/themeScript.tsx +179 -0
- package/src/ui/theme/types.ts +61 -0
- package/src/ui/toast.tsx +30 -0
- package/src/ui/toggle-buttons.tsx +290 -0
- package/src/ui/toggle-group.tsx +236 -0
- package/src/ui/toggle.tsx +94 -0
- package/src/ui/toolbar.tsx +54 -0
- package/src/ui/tooltip.tsx +171 -0
- package/src/ui/tree-view/TreeSearchBar.tsx +88 -0
- package/src/ui/tree-view/TreeView.tsx +232 -0
- package/src/ui/tree-view/hooks.tsx +289 -0
- package/src/ui/tree-view/index.ts +4 -0
- package/src/ui/tree-view/types.ts +23 -0
- package/src/ui/tree-view-legacy.tsx +644 -0
- package/src/ui/version-badge.tsx +0 -0
- package/src/ui/waterfall/CursorOverlay.tsx +96 -0
- package/src/ui/waterfall/NavigationControls.tsx +42 -0
- package/src/ui/waterfall/Tick.tsx +51 -0
- package/src/ui/waterfall/TimeRuleEventDot.tsx +19 -0
- package/src/ui/waterfall/TimelineEvent.tsx +60 -0
- package/src/ui/waterfall/TimelineProcessBar.tsx +207 -0
- package/src/ui/waterfall/Wedges.tsx +67 -0
- package/src/ui/waterfall/WheelZoomContext.tsx +128 -0
- package/src/ui/waterfall/hooks/useTimelineState.tsx +134 -0
- package/src/ui/waterfall/hooks/useViewport.tsx +293 -0
- package/src/ui/waterfall/index.tsx +326 -0
- package/src/ui/waterfall/types.ts +20 -0
- package/src/ui/waterfall/utils.ts +91 -0
- package/dist/chunk-W2YAQV5N.mjs +0 -57
- package/dist/{chunk-QLCEHV4Q.mjs → chunk-2OZK5DY5.mjs} +2 -2
- package/dist/{chunk-Z35DNFRZ.cjs → chunk-7IS37C3P.cjs} +2 -2
- package/dist/{chunk-4AOAH77D.mjs → chunk-A2PCEL5S.mjs} +2 -2
- package/dist/{chunk-K4VD5PPY.mjs → chunk-BIUDC66P.mjs} +1 -1
- package/dist/{chunk-RKJR6RZU.cjs → chunk-OYNLQTHW.cjs} +1 -1
- package/dist/{chunk-VE3XLQLO.cjs → chunk-QUFZWF4E.cjs} +2 -2
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import { cva, VariantProps } from "class-variance-authority";
|
|
3
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useState,
|
|
11
|
+
CSSProperties,
|
|
12
|
+
ComponentProps,
|
|
13
|
+
MouseEvent,
|
|
14
|
+
} from "react";
|
|
15
|
+
|
|
16
|
+
import { cn } from "../hooks";
|
|
17
|
+
import { useIsMobile } from "../hooks/useIsMobile";
|
|
18
|
+
import { Button } from "../ui/button";
|
|
19
|
+
import { InputRoot } from "./inputs/input";
|
|
20
|
+
import { Separator } from "../ui/separator";
|
|
21
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "../ui/sheet";
|
|
22
|
+
import { Skeleton } from "../ui/skeleton";
|
|
23
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
|
|
24
|
+
|
|
25
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
26
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
27
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
28
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
29
|
+
|
|
30
|
+
type SidebarContextProps = {
|
|
31
|
+
state: "expanded" | "collapsed";
|
|
32
|
+
open: boolean;
|
|
33
|
+
setOpen: (open: boolean) => void;
|
|
34
|
+
openMobile: boolean;
|
|
35
|
+
setOpenMobile: (open: boolean) => void;
|
|
36
|
+
isMobile: boolean;
|
|
37
|
+
toggleSidebar: () => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const SidebarContext = createContext<SidebarContextProps | null>(null);
|
|
41
|
+
|
|
42
|
+
function useSidebar() {
|
|
43
|
+
const context = useContext(SidebarContext);
|
|
44
|
+
if (!context) {
|
|
45
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function SidebarProvider({
|
|
52
|
+
defaultOpen = true,
|
|
53
|
+
open: openProp,
|
|
54
|
+
onOpenChange: setOpenProp,
|
|
55
|
+
className,
|
|
56
|
+
style,
|
|
57
|
+
children,
|
|
58
|
+
...props
|
|
59
|
+
}: ComponentProps<"div"> & {
|
|
60
|
+
defaultOpen?: boolean;
|
|
61
|
+
open?: boolean;
|
|
62
|
+
onOpenChange?: (open: boolean) => void;
|
|
63
|
+
}) {
|
|
64
|
+
const isMobile = useIsMobile();
|
|
65
|
+
const [openMobile, setOpenMobile] = useState(false);
|
|
66
|
+
|
|
67
|
+
const [_open, _setOpen] = useState(defaultOpen);
|
|
68
|
+
const open = openProp ?? _open;
|
|
69
|
+
const setOpen = useCallback(
|
|
70
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
71
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
72
|
+
if (setOpenProp) {
|
|
73
|
+
setOpenProp(openState);
|
|
74
|
+
} else {
|
|
75
|
+
_setOpen(openState);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[setOpenProp, open],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const toggleSidebar = useCallback(() => {
|
|
82
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
83
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
87
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
toggleSidebar();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
94
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
95
|
+
}, [toggleSidebar]);
|
|
96
|
+
|
|
97
|
+
const state = open ? "expanded" : "collapsed";
|
|
98
|
+
|
|
99
|
+
const contextValue = useMemo<SidebarContextProps>(
|
|
100
|
+
() => ({
|
|
101
|
+
state,
|
|
102
|
+
open,
|
|
103
|
+
setOpen,
|
|
104
|
+
isMobile,
|
|
105
|
+
openMobile,
|
|
106
|
+
setOpenMobile,
|
|
107
|
+
toggleSidebar,
|
|
108
|
+
}),
|
|
109
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<SidebarContext.Provider value={contextValue}>
|
|
114
|
+
<TooltipProvider delayDuration={0}>
|
|
115
|
+
<div
|
|
116
|
+
data-slot="sidebar-wrapper"
|
|
117
|
+
style={
|
|
118
|
+
{
|
|
119
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
120
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
121
|
+
...style,
|
|
122
|
+
} as CSSProperties
|
|
123
|
+
}
|
|
124
|
+
className={cn(
|
|
125
|
+
"group/sidebar-wrapper has-data-[variant=inset]:bg-bg-primary relative flex min-h-svh w-full",
|
|
126
|
+
className,
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
>
|
|
130
|
+
{children}
|
|
131
|
+
</div>
|
|
132
|
+
</TooltipProvider>
|
|
133
|
+
</SidebarContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function Sidebar({
|
|
138
|
+
side = "left",
|
|
139
|
+
variant = "sidebar",
|
|
140
|
+
collapsible = "offcanvas",
|
|
141
|
+
className,
|
|
142
|
+
children,
|
|
143
|
+
...props
|
|
144
|
+
}: ComponentProps<"div"> & {
|
|
145
|
+
side?: "left" | "right";
|
|
146
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
147
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
148
|
+
}) {
|
|
149
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
150
|
+
|
|
151
|
+
if (collapsible === "none") {
|
|
152
|
+
return (
|
|
153
|
+
<div
|
|
154
|
+
data-slot="sidebar"
|
|
155
|
+
className={cn("flex h-full w-(--sidebar-width) flex-col", className)}
|
|
156
|
+
{...props}
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (isMobile) {
|
|
164
|
+
return (
|
|
165
|
+
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
166
|
+
<SheetContent
|
|
167
|
+
data-sidebar="sidebar"
|
|
168
|
+
data-slot="sidebar"
|
|
169
|
+
data-mobile="true"
|
|
170
|
+
className="bg-bg-primary text-text-primary w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
171
|
+
style={
|
|
172
|
+
{
|
|
173
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
174
|
+
} as CSSProperties
|
|
175
|
+
}
|
|
176
|
+
side={side}
|
|
177
|
+
>
|
|
178
|
+
<SheetHeader className="sr-only">
|
|
179
|
+
<SheetTitle>Sidebar</SheetTitle>
|
|
180
|
+
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
181
|
+
</SheetHeader>
|
|
182
|
+
<div className="flex h-full w-full flex-col">{children}</div>
|
|
183
|
+
</SheetContent>
|
|
184
|
+
</Sheet>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<div
|
|
190
|
+
className="group peer hidden md:block"
|
|
191
|
+
data-state={state}
|
|
192
|
+
data-collapsible={state === "collapsed" ? collapsible : ""}
|
|
193
|
+
data-variant={variant}
|
|
194
|
+
data-side={side}
|
|
195
|
+
data-slot="sidebar"
|
|
196
|
+
>
|
|
197
|
+
<div
|
|
198
|
+
data-slot="sidebar-gap"
|
|
199
|
+
className={cn(
|
|
200
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
201
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
202
|
+
"group-data-[side=right]:rotate-180",
|
|
203
|
+
variant === "floating" || variant === "inset"
|
|
204
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
205
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
206
|
+
)}
|
|
207
|
+
/>
|
|
208
|
+
<div
|
|
209
|
+
data-slot="sidebar-container"
|
|
210
|
+
className={cn(
|
|
211
|
+
"border-line-primary fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) border-r transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
212
|
+
side === "left"
|
|
213
|
+
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
214
|
+
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
215
|
+
variant === "floating" || variant === "inset"
|
|
216
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
217
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
218
|
+
className,
|
|
219
|
+
)}
|
|
220
|
+
{...props}
|
|
221
|
+
>
|
|
222
|
+
<div
|
|
223
|
+
data-sidebar="sidebar"
|
|
224
|
+
data-slot="sidebar-inner"
|
|
225
|
+
className="bg-bg-primary liquid:liquid-bg group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:rounded-uk-lg flex h-full w-full flex-col font-normal group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function SidebarTrigger({ className, onClick, ...props }: ComponentProps<typeof Button>) {
|
|
235
|
+
const { toggleSidebar, state } = useSidebar();
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<Button
|
|
239
|
+
data-sidebar="trigger"
|
|
240
|
+
data-slot="sidebar-trigger"
|
|
241
|
+
variant="ghost"
|
|
242
|
+
icon={true}
|
|
243
|
+
className={cn(
|
|
244
|
+
"absolute top-[0px] size-7 transition-[left] duration-200 ease-linear",
|
|
245
|
+
state === "collapsed" && "left-[2px]",
|
|
246
|
+
state === "expanded" && "left-[var(--sidebar-width)]",
|
|
247
|
+
className,
|
|
248
|
+
)}
|
|
249
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => {
|
|
250
|
+
onClick?.(event);
|
|
251
|
+
toggleSidebar();
|
|
252
|
+
}}
|
|
253
|
+
{...props}
|
|
254
|
+
>
|
|
255
|
+
<PanelLeftIcon />
|
|
256
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
257
|
+
</Button>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function SidebarRail({ className, ...props }: ComponentProps<"button">) {
|
|
262
|
+
const { toggleSidebar } = useSidebar();
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<button
|
|
266
|
+
data-sidebar="rail"
|
|
267
|
+
data-slot="sidebar-rail"
|
|
268
|
+
aria-label="Toggle Sidebar"
|
|
269
|
+
tabIndex={-1}
|
|
270
|
+
onClick={toggleSidebar}
|
|
271
|
+
title="Toggle Sidebar"
|
|
272
|
+
className={cn(
|
|
273
|
+
"hover:after:bg-line-primary absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
|
|
274
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
275
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
276
|
+
"hover:group-data-[collapsible=offcanvas]:bg-bg-primary group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
|
|
277
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
278
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
279
|
+
className,
|
|
280
|
+
)}
|
|
281
|
+
{...props}
|
|
282
|
+
/>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function SidebarInset({ className, ...props }: ComponentProps<"main">) {
|
|
287
|
+
return (
|
|
288
|
+
<main
|
|
289
|
+
data-slot="sidebar-inset"
|
|
290
|
+
className={cn(
|
|
291
|
+
"relative flex w-full flex-1 flex-col",
|
|
292
|
+
"md:peer-data-[variant=inset]:rounded-uk-xl md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
293
|
+
className,
|
|
294
|
+
)}
|
|
295
|
+
{...props}
|
|
296
|
+
/>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function SidebarInput({ className, ...props }: ComponentProps<typeof InputRoot>) {
|
|
301
|
+
return (
|
|
302
|
+
<InputRoot
|
|
303
|
+
data-slot="sidebar-input"
|
|
304
|
+
data-sidebar="input"
|
|
305
|
+
className={cn(
|
|
306
|
+
"bg-bg-secondary px-lg py-xs text-uk-sm leading-uk-sm h-[28px] w-full shadow-none group-data-[collapsible=icon]:hidden",
|
|
307
|
+
className,
|
|
308
|
+
)}
|
|
309
|
+
{...props}
|
|
310
|
+
/>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function SidebarHeader({ className, ...props }: ComponentProps<"div">) {
|
|
315
|
+
return (
|
|
316
|
+
<div
|
|
317
|
+
data-slot="sidebar-header"
|
|
318
|
+
data-sidebar="header"
|
|
319
|
+
className={cn("text-uk-lg leading-uk-lg px-md flex flex-col", className)}
|
|
320
|
+
{...props}
|
|
321
|
+
/>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function SidebarFooter({ className, ...props }: ComponentProps<"div">) {
|
|
326
|
+
return (
|
|
327
|
+
<div
|
|
328
|
+
data-slot="sidebar-footer"
|
|
329
|
+
data-sidebar="footer"
|
|
330
|
+
className={cn("px-lg flex flex-col", className)}
|
|
331
|
+
{...props}
|
|
332
|
+
/>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function SidebarSeparator({ className, ...props }: ComponentProps<typeof Separator>) {
|
|
337
|
+
return (
|
|
338
|
+
<Separator
|
|
339
|
+
data-slot="sidebar-separator"
|
|
340
|
+
data-sidebar="separator"
|
|
341
|
+
className={cn("bg-line-primary -ml-lg", className)}
|
|
342
|
+
style={{
|
|
343
|
+
width: "calc(100% + var(--spacing-lg) * 2)",
|
|
344
|
+
}}
|
|
345
|
+
{...props}
|
|
346
|
+
/>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function SidebarContent({ className, ...props }: ComponentProps<"div">) {
|
|
351
|
+
return (
|
|
352
|
+
<div
|
|
353
|
+
data-slot="sidebar-content"
|
|
354
|
+
data-sidebar="content"
|
|
355
|
+
className={cn(
|
|
356
|
+
"px-md lgflex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
357
|
+
className,
|
|
358
|
+
)}
|
|
359
|
+
{...props}
|
|
360
|
+
/>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function SidebarGroup({ className, ...props }: ComponentProps<"div">) {
|
|
365
|
+
return (
|
|
366
|
+
<div
|
|
367
|
+
data-slot="sidebar-group"
|
|
368
|
+
data-sidebar="group"
|
|
369
|
+
className={cn("relative flex w-full min-w-0 flex-col", className)}
|
|
370
|
+
{...props}
|
|
371
|
+
/>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function SidebarGroupLabel({
|
|
376
|
+
className,
|
|
377
|
+
asChild = false,
|
|
378
|
+
...props
|
|
379
|
+
}: ComponentProps<"div"> & { asChild?: boolean }) {
|
|
380
|
+
const Comp = asChild ? Slot : "div";
|
|
381
|
+
|
|
382
|
+
return (
|
|
383
|
+
<Comp
|
|
384
|
+
data-slot="sidebar-group-label"
|
|
385
|
+
data-sidebar="group-label"
|
|
386
|
+
className={cn(
|
|
387
|
+
"text-text-primary ring-sidebar-ring rounded-uk-md text-uk-md leading-uk-md flex h-[36px] shrink-0 items-center font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
388
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
389
|
+
className,
|
|
390
|
+
)}
|
|
391
|
+
{...props}
|
|
392
|
+
/>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function SidebarGroupAction({
|
|
397
|
+
className,
|
|
398
|
+
asChild = false,
|
|
399
|
+
...props
|
|
400
|
+
}: ComponentProps<"button"> & { asChild?: boolean }) {
|
|
401
|
+
const Comp = asChild ? Slot : "button";
|
|
402
|
+
|
|
403
|
+
return (
|
|
404
|
+
<Comp
|
|
405
|
+
data-slot="sidebar-group-action"
|
|
406
|
+
data-sidebar="group-action"
|
|
407
|
+
className={cn(
|
|
408
|
+
"hover:bg-bg-secondary rounded-uk-md absolute top-[6px] right-[12px] flex aspect-square w-5 items-center justify-center p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
409
|
+
"after:absolute after:-inset-2 md:after:hidden",
|
|
410
|
+
"group-data-[collapsible=icon]:hidden",
|
|
411
|
+
className,
|
|
412
|
+
)}
|
|
413
|
+
{...props}
|
|
414
|
+
/>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function SidebarGroupContent({ className, ...props }: ComponentProps<"div">) {
|
|
419
|
+
return (
|
|
420
|
+
<div
|
|
421
|
+
data-slot="sidebar-group-content"
|
|
422
|
+
data-sidebar="group-content"
|
|
423
|
+
className={cn("text-uk-sm w-full", className)}
|
|
424
|
+
{...props}
|
|
425
|
+
/>
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function SidebarMenu({ className, ...props }: ComponentProps<"ul">) {
|
|
430
|
+
return (
|
|
431
|
+
<ul
|
|
432
|
+
data-slot="sidebar-menu"
|
|
433
|
+
data-sidebar="menu"
|
|
434
|
+
className={cn("gap-lg flex w-full min-w-0 flex-col", className)}
|
|
435
|
+
style={{
|
|
436
|
+
paddingLeft: "0px",
|
|
437
|
+
marginBottom: "0px",
|
|
438
|
+
}}
|
|
439
|
+
{...props}
|
|
440
|
+
/>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function SidebarMenuItem({ className, ...props }: ComponentProps<"li">) {
|
|
445
|
+
return (
|
|
446
|
+
<li
|
|
447
|
+
data-slot="sidebar-menu-item"
|
|
448
|
+
data-sidebar="menu-item"
|
|
449
|
+
className={cn("group/menu-item relative", className)}
|
|
450
|
+
style={{
|
|
451
|
+
paddingBottom: "0px",
|
|
452
|
+
marginBottom: "0px",
|
|
453
|
+
}}
|
|
454
|
+
{...props}
|
|
455
|
+
/>
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const sidebarMenuButtonVariants = cva(
|
|
460
|
+
"peer/menu-button flex w-full items-center gap-md overflow-hidden rounde-uk-md text-left text-uk-lg leading-uk-lg outline-hidden ring-sidebar-ring transition-[width,height,padding] text-text-primary focus-visible:ring-2 active:text-text-highlight disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 font-medium group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-[16px] [&>svg]:shrink-0",
|
|
461
|
+
{
|
|
462
|
+
variants: {
|
|
463
|
+
variant: {
|
|
464
|
+
default: "",
|
|
465
|
+
outline: "",
|
|
466
|
+
},
|
|
467
|
+
size: {
|
|
468
|
+
default: "h-[36px] text-uk-lg leading-uk-lg",
|
|
469
|
+
sm: "h-[30px] text-uk-sm leading-uk-sm",
|
|
470
|
+
lg: "h-[32px] text-uk-lg leading-uk-lg group-data-[collapsible=icon]:p-0!",
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
defaultVariants: {
|
|
474
|
+
variant: "default",
|
|
475
|
+
size: "default",
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
);
|
|
479
|
+
|
|
480
|
+
function SidebarMenuButton({
|
|
481
|
+
asChild = false,
|
|
482
|
+
isActive = false,
|
|
483
|
+
variant = "default",
|
|
484
|
+
size = "default",
|
|
485
|
+
tooltip,
|
|
486
|
+
className,
|
|
487
|
+
...props
|
|
488
|
+
}: ComponentProps<"button"> & {
|
|
489
|
+
asChild?: boolean;
|
|
490
|
+
isActive?: boolean;
|
|
491
|
+
tooltip?: string | ComponentProps<typeof TooltipContent>;
|
|
492
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
493
|
+
const Comp = asChild ? Slot : "button";
|
|
494
|
+
const { isMobile, state } = useSidebar();
|
|
495
|
+
|
|
496
|
+
const button = (
|
|
497
|
+
<Comp
|
|
498
|
+
data-slot="sidebar-menu-button"
|
|
499
|
+
data-sidebar="menu-button"
|
|
500
|
+
data-size={size}
|
|
501
|
+
data-active={isActive}
|
|
502
|
+
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
503
|
+
{...props}
|
|
504
|
+
/>
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
if (!tooltip) {
|
|
508
|
+
return button;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (typeof tooltip === "string") {
|
|
512
|
+
tooltip = {
|
|
513
|
+
children: tooltip,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return (
|
|
518
|
+
<Tooltip>
|
|
519
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
520
|
+
<TooltipContent
|
|
521
|
+
side="right"
|
|
522
|
+
align="center"
|
|
523
|
+
hidden={state !== "collapsed" || isMobile}
|
|
524
|
+
{...tooltip}
|
|
525
|
+
/>
|
|
526
|
+
</Tooltip>
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function SidebarMenuAction({
|
|
531
|
+
className,
|
|
532
|
+
asChild = false,
|
|
533
|
+
showOnHover = false,
|
|
534
|
+
...props
|
|
535
|
+
}: ComponentProps<"button"> & {
|
|
536
|
+
asChild?: boolean;
|
|
537
|
+
showOnHover?: boolean;
|
|
538
|
+
}) {
|
|
539
|
+
const Comp = asChild ? Slot : "button";
|
|
540
|
+
|
|
541
|
+
return (
|
|
542
|
+
<Comp
|
|
543
|
+
data-slot="sidebar-menu-action"
|
|
544
|
+
data-sidebar="menu-action"
|
|
545
|
+
className={cn(
|
|
546
|
+
"hover:bg-bg-secondary rounded-uk-md absolute top-[6px] right-[12px] flex aspect-square w-5 items-center justify-center p-0 outline-hidden transition-transform [&>svg]:size-4 [&>svg]:shrink-0",
|
|
547
|
+
"group-data-[collapsible=icon]:hidden",
|
|
548
|
+
showOnHover &&
|
|
549
|
+
"peer-data-[active=true]/menu-button:text-text-highlight group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
|
|
550
|
+
className,
|
|
551
|
+
)}
|
|
552
|
+
{...props}
|
|
553
|
+
/>
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function SidebarMenuBadge({ className, ...props }: ComponentProps<"div">) {
|
|
558
|
+
return (
|
|
559
|
+
<div
|
|
560
|
+
data-slot="sidebar-menu-badge"
|
|
561
|
+
data-sidebar="menu-badge"
|
|
562
|
+
className={cn(
|
|
563
|
+
"text-text-primary rounded-uk-md text-uk-sm pointer-events-none absolute top-[6px] right-[12px] flex min-w-5 items-center justify-center font-medium tabular-nums select-none",
|
|
564
|
+
"group-data-[collapsible=icon]:hidden",
|
|
565
|
+
className,
|
|
566
|
+
)}
|
|
567
|
+
{...props}
|
|
568
|
+
/>
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function SidebarMenuSkeleton({
|
|
573
|
+
className,
|
|
574
|
+
showIcon = false,
|
|
575
|
+
...props
|
|
576
|
+
}: ComponentProps<"div"> & {
|
|
577
|
+
showIcon?: boolean;
|
|
578
|
+
}) {
|
|
579
|
+
// Random width between 50 to 90%.
|
|
580
|
+
const width = useMemo(() => {
|
|
581
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
582
|
+
}, []);
|
|
583
|
+
|
|
584
|
+
return (
|
|
585
|
+
<div
|
|
586
|
+
data-slot="sidebar-menu-skeleton"
|
|
587
|
+
data-sidebar="menu-skeleton"
|
|
588
|
+
className={cn("rounded-uk-md flex h-8 items-center gap-2 px-2", className)}
|
|
589
|
+
{...props}
|
|
590
|
+
>
|
|
591
|
+
{showIcon && <Skeleton className="rounded-uk-md size-4" data-sidebar="menu-skeleton-icon" />}
|
|
592
|
+
<Skeleton
|
|
593
|
+
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
594
|
+
data-sidebar="menu-skeleton-text"
|
|
595
|
+
style={
|
|
596
|
+
{
|
|
597
|
+
"--skeleton-width": width,
|
|
598
|
+
} as CSSProperties
|
|
599
|
+
}
|
|
600
|
+
/>
|
|
601
|
+
</div>
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function SidebarMenuSub({ className, ...props }: ComponentProps<"ul">) {
|
|
606
|
+
return (
|
|
607
|
+
<ul
|
|
608
|
+
data-slot="sidebar-menu-sub"
|
|
609
|
+
data-sidebar="menu-sub"
|
|
610
|
+
className={cn(
|
|
611
|
+
"gap-sm mt-sm flex min-w-0 translate-x-px flex-col",
|
|
612
|
+
"group-data-[collapsible=icon]:hidden",
|
|
613
|
+
className,
|
|
614
|
+
)}
|
|
615
|
+
style={{
|
|
616
|
+
paddingLeft: "0px",
|
|
617
|
+
marginBottom: "0px",
|
|
618
|
+
}}
|
|
619
|
+
{...props}
|
|
620
|
+
/>
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function SidebarMenuSubItem({ className, ...props }: ComponentProps<"li">) {
|
|
625
|
+
return (
|
|
626
|
+
<li
|
|
627
|
+
data-slot="sidebar-menu-sub-item"
|
|
628
|
+
data-sidebar="menu-sub-item"
|
|
629
|
+
className={cn("group/menu-sub-item relative", className)}
|
|
630
|
+
style={{
|
|
631
|
+
paddingBottom: "0px",
|
|
632
|
+
marginBottom: "0px",
|
|
633
|
+
}}
|
|
634
|
+
{...props}
|
|
635
|
+
/>
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function SidebarMenuSubButton({
|
|
640
|
+
asChild = false,
|
|
641
|
+
size = "md",
|
|
642
|
+
isActive = false,
|
|
643
|
+
className,
|
|
644
|
+
...props
|
|
645
|
+
}: ComponentProps<"a"> & {
|
|
646
|
+
asChild?: boolean;
|
|
647
|
+
size?: "sm" | "md";
|
|
648
|
+
isActive?: boolean;
|
|
649
|
+
}) {
|
|
650
|
+
const Comp = asChild ? Slot : "a";
|
|
651
|
+
|
|
652
|
+
return (
|
|
653
|
+
<Comp
|
|
654
|
+
data-slot="sidebar-menu-sub-button"
|
|
655
|
+
data-sidebar="menu-sub-button"
|
|
656
|
+
data-size={size}
|
|
657
|
+
data-active={isActive}
|
|
658
|
+
className={cn(
|
|
659
|
+
"text-text-primary ring-sidebar-ring hover:bg-bg-secondary hover:text-text-primary active:bg-bg-tertiary active:text-text-highlight [&>svg]:text-icon-primary gap-md rounded-uk-md px-lg flex h-[32px] min-w-0 -translate-x-px items-center overflow-hidden outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-[16px] [&>svg]:shrink-0",
|
|
660
|
+
size === "sm" && "text-uk-sm leading-uk-sm",
|
|
661
|
+
size === "md" && "text-uk-md leading-uk-md",
|
|
662
|
+
"group-data-[collapsible=icon]:hidden",
|
|
663
|
+
className,
|
|
664
|
+
)}
|
|
665
|
+
{...props}
|
|
666
|
+
/>
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export {
|
|
671
|
+
Sidebar,
|
|
672
|
+
SidebarContent,
|
|
673
|
+
SidebarFooter,
|
|
674
|
+
SidebarGroup,
|
|
675
|
+
SidebarGroupAction,
|
|
676
|
+
SidebarGroupContent,
|
|
677
|
+
SidebarGroupLabel,
|
|
678
|
+
SidebarHeader,
|
|
679
|
+
SidebarInput,
|
|
680
|
+
SidebarInset,
|
|
681
|
+
SidebarMenu,
|
|
682
|
+
SidebarMenuAction,
|
|
683
|
+
SidebarMenuBadge,
|
|
684
|
+
SidebarMenuButton,
|
|
685
|
+
SidebarMenuItem,
|
|
686
|
+
SidebarMenuSkeleton,
|
|
687
|
+
SidebarMenuSub,
|
|
688
|
+
SidebarMenuSubButton,
|
|
689
|
+
SidebarMenuSubItem,
|
|
690
|
+
SidebarProvider,
|
|
691
|
+
SidebarRail,
|
|
692
|
+
SidebarSeparator,
|
|
693
|
+
SidebarTrigger,
|
|
694
|
+
useSidebar,
|
|
695
|
+
};
|