@turtleclub/ui 0.3.0-beta.8 → 0.3.0
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/.prettierrc.json +4 -0
- package/.turbo/turbo-build.log +152 -26
- package/CHANGELOG.md +338 -0
- package/dist/index.cjs +178 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25526 -4757
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/components/features/data-table.d.ts +9 -0
- package/dist/types/components/features/data-table.d.ts.map +1 -0
- package/dist/types/components/features/index.d.ts +5 -0
- package/dist/types/components/features/index.d.ts.map +1 -0
- package/dist/types/components/features/page-heading.d.ts +10 -0
- package/dist/types/components/features/page-heading.d.ts.map +1 -0
- package/dist/types/components/features/search-bar.d.ts +10 -0
- package/dist/types/components/features/search-bar.d.ts.map +1 -0
- package/dist/types/components/features/segmented-navigation.d.ts +7 -0
- package/dist/types/components/features/segmented-navigation.d.ts.map +1 -0
- package/dist/types/components/features/sidebar-layout.d.ts +36 -0
- package/dist/types/components/features/sidebar-layout.d.ts.map +1 -0
- package/dist/types/components/icons/arrow.d.ts +4 -0
- package/dist/types/components/icons/arrow.d.ts.map +1 -0
- package/dist/types/components/icons/beta.d.ts +4 -0
- package/dist/types/components/icons/beta.d.ts.map +1 -0
- package/dist/types/components/icons/dot.d.ts +4 -0
- package/dist/types/components/icons/dot.d.ts.map +1 -0
- package/dist/types/components/icons/index.d.ts +8 -0
- package/dist/types/components/icons/index.d.ts.map +1 -0
- package/dist/types/components/icons/issue.d.ts +4 -0
- package/dist/types/components/icons/issue.d.ts.map +1 -0
- package/dist/types/components/icons/turtle.d.ts +4 -0
- package/dist/types/components/icons/turtle.d.ts.map +1 -0
- package/dist/types/components/icons/update.d.ts +4 -0
- package/dist/types/components/icons/update.d.ts.map +1 -0
- package/dist/types/components/icons/warning.d.ts +4 -0
- package/dist/types/components/icons/warning.d.ts.map +1 -0
- package/dist/types/components/molecules/index.d.ts +2 -0
- package/dist/types/components/molecules/index.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/index.d.ts +3 -1
- package/dist/types/components/molecules/opportunity/index.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-apr.d.ts +8 -3
- package/dist/types/components/molecules/opportunity/opportunity-apr.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-disclaimer.d.ts +1 -2
- package/dist/types/components/molecules/opportunity/opportunity-disclaimer.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/index.d.ts +3 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/index.d.ts.map +1 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-filtering.d.ts +11 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-filtering.d.ts.map +1 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-grouping.d.ts +9 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-grouping.d.ts.map +1 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/index.d.ts +2 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/index.d.ts.map +1 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/opportunity-list.d.ts +22 -0
- package/dist/types/components/molecules/opportunity/opportunity-list/opportunity-list.d.ts.map +1 -0
- package/dist/types/components/molecules/opportunity/opportunity-rate-estimator.d.ts +1 -2
- package/dist/types/components/molecules/opportunity/opportunity-rate-estimator.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-section.d.ts +4 -0
- package/dist/types/components/molecules/opportunity/opportunity-section.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-selector.d.ts +1 -2
- package/dist/types/components/molecules/opportunity/opportunity-selector.d.ts.map +1 -1
- package/dist/types/components/molecules/opportunity/opportunity-type.d.ts +1 -2
- package/dist/types/components/molecules/opportunity/opportunity-type.d.ts.map +1 -1
- package/dist/types/components/molecules/route-details.d.ts +1 -1
- package/dist/types/components/molecules/route-details.d.ts.map +1 -1
- package/dist/types/components/molecules/slippage-selector.d.ts +1 -2
- package/dist/types/components/molecules/slippage-selector.d.ts.map +1 -1
- package/dist/types/components/molecules/swap-details.d.ts.map +1 -1
- package/dist/types/components/molecules/swap-input.d.ts +5 -1
- package/dist/types/components/molecules/swap-input.d.ts.map +1 -1
- package/dist/types/components/molecules/tabs.d.ts +18 -0
- package/dist/types/components/molecules/tabs.d.ts.map +1 -0
- package/dist/types/components/molecules/token-selector.d.ts +1 -1
- package/dist/types/components/molecules/token-selector.d.ts.map +1 -1
- package/dist/types/components/molecules/tx-status.d.ts.map +1 -1
- package/dist/types/components/molecules/widget/asset-list/asset-filters.d.ts +20 -0
- package/dist/types/components/molecules/widget/asset-list/asset-filters.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/asset-list.d.ts +35 -0
- package/dist/types/components/molecules/widget/asset-list/asset-list.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/asset-row.d.ts +12 -0
- package/dist/types/components/molecules/widget/asset-list/asset-row.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/index.d.ts +3 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/index.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/use-asset-filtering.d.ts +10 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/use-asset-filtering.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/use-asset-grouping.d.ts +9 -0
- package/dist/types/components/molecules/widget/asset-list/hooks/use-asset-grouping.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/asset-list/index.d.ts +4 -0
- package/dist/types/components/molecules/widget/asset-list/index.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/base-selector.d.ts +17 -0
- package/dist/types/components/molecules/widget/base-selector.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/campaign-item.d.ts +20 -0
- package/dist/types/components/molecules/widget/campaign-item.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/deal-item.d.ts +20 -0
- package/dist/types/components/molecules/widget/deal-item.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/index.d.ts +14 -0
- package/dist/types/components/molecules/widget/index.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/opportunity-item.d.ts +33 -0
- package/dist/types/components/molecules/widget/opportunity-item.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/widget-item-stats.d.ts +14 -0
- package/dist/types/components/molecules/widget/widget-item-stats.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/widget-item.d.ts +26 -0
- package/dist/types/components/molecules/widget/widget-item.d.ts.map +1 -0
- package/dist/types/components/molecules/widget/widget-list-items.d.ts +20 -0
- package/dist/types/components/molecules/widget/widget-list-items.d.ts.map +1 -0
- package/dist/types/components/ui/alert-dialog.d.ts +15 -0
- package/dist/types/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/types/components/ui/animated-background/animated-background.d.ts +9 -0
- package/dist/types/components/ui/animated-background/animated-background.d.ts.map +1 -0
- package/dist/types/components/ui/animated-background/index.d.ts +2 -0
- package/dist/types/components/ui/animated-background/index.d.ts.map +1 -0
- package/dist/types/components/ui/avatar.d.ts +18 -4
- package/dist/types/components/ui/avatar.d.ts.map +1 -1
- package/dist/types/components/ui/badge.d.ts +5 -4
- package/dist/types/components/ui/badge.d.ts.map +1 -1
- package/dist/types/components/ui/banner.d.ts +7 -0
- package/dist/types/components/ui/banner.d.ts.map +1 -0
- package/dist/types/components/ui/button.d.ts +8 -6
- package/dist/types/components/ui/button.d.ts.map +1 -1
- package/dist/types/components/ui/card.d.ts +10 -11
- package/dist/types/components/ui/card.d.ts.map +1 -1
- package/dist/types/components/ui/checkbox.d.ts +5 -0
- package/dist/types/components/ui/checkbox.d.ts.map +1 -0
- package/dist/types/components/ui/chip.d.ts +1 -1
- package/dist/types/components/ui/chip.d.ts.map +1 -1
- package/dist/types/components/ui/collapsible.d.ts +7 -0
- package/dist/types/components/ui/collapsible.d.ts.map +1 -0
- package/dist/types/components/ui/combobox.d.ts +148 -0
- package/dist/types/components/ui/combobox.d.ts.map +1 -0
- package/dist/types/components/ui/command.d.ts +19 -0
- package/dist/types/components/ui/command.d.ts.map +1 -0
- package/dist/types/components/ui/dialog.d.ts +10 -10
- package/dist/types/components/ui/dialog.d.ts.map +1 -1
- package/dist/types/components/ui/dropdown.d.ts +30 -0
- package/dist/types/components/ui/dropdown.d.ts.map +1 -0
- package/dist/types/components/ui/field.d.ts +26 -0
- package/dist/types/components/ui/field.d.ts.map +1 -0
- package/dist/types/components/ui/heading.d.ts +12 -0
- package/dist/types/components/ui/heading.d.ts.map +1 -0
- package/dist/types/components/ui/hover-card.d.ts +7 -7
- package/dist/types/components/ui/hover-card.d.ts.map +1 -1
- package/dist/types/components/ui/icon-animation.d.ts +1 -1
- package/dist/types/components/ui/icon-animation.d.ts.map +1 -1
- package/dist/types/components/ui/icon-list.d.ts +17 -0
- package/dist/types/components/ui/icon-list.d.ts.map +1 -0
- package/dist/types/components/ui/index.d.ts +28 -8
- package/dist/types/components/ui/index.d.ts.map +1 -1
- package/dist/types/components/ui/info-card.d.ts +4 -4
- package/dist/types/components/ui/info-card.d.ts.map +1 -1
- package/dist/types/components/ui/input-group.d.ts +17 -0
- package/dist/types/components/ui/input-group.d.ts.map +1 -0
- package/dist/types/components/ui/input.d.ts +1 -3
- package/dist/types/components/ui/input.d.ts.map +1 -1
- package/dist/types/components/ui/label-with-icon.d.ts +3 -3
- package/dist/types/components/ui/label-with-icon.d.ts.map +1 -1
- package/dist/types/components/ui/label.d.ts +1 -1
- package/dist/types/components/ui/label.d.ts.map +1 -1
- package/dist/types/components/ui/multi-select.d.ts +192 -0
- package/dist/types/components/ui/multi-select.d.ts.map +1 -0
- package/dist/types/components/ui/navigation-bar.d.ts +2 -2
- package/dist/types/components/ui/navigation-bar.d.ts.map +1 -1
- package/dist/types/components/ui/navigation-menu.d.ts +15 -0
- package/dist/types/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/types/components/ui/opportunity-details-v1.d.ts +1 -1
- package/dist/types/components/ui/opportunity-details-v1.d.ts.map +1 -1
- package/dist/types/components/ui/popover.d.ts +8 -0
- package/dist/types/components/ui/popover.d.ts.map +1 -0
- package/dist/types/components/ui/scroll-area.d.ts +2 -2
- package/dist/types/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/types/components/ui/segment-control.d.ts +19 -0
- package/dist/types/components/ui/segment-control.d.ts.map +1 -0
- package/dist/types/components/ui/select.d.ts +14 -13
- package/dist/types/components/ui/select.d.ts.map +1 -1
- package/dist/types/components/ui/separator.d.ts +1 -1
- package/dist/types/components/ui/separator.d.ts.map +1 -1
- package/dist/types/components/ui/sheet.d.ts +14 -0
- package/dist/types/components/ui/sheet.d.ts.map +1 -0
- package/dist/types/components/ui/sidebar.d.ts +69 -0
- package/dist/types/components/ui/sidebar.d.ts.map +1 -0
- package/dist/types/components/ui/skeleton.d.ts +4 -0
- package/dist/types/components/ui/skeleton.d.ts.map +1 -0
- package/dist/types/components/ui/slider.d.ts +5 -0
- package/dist/types/components/ui/slider.d.ts.map +1 -0
- package/dist/types/components/ui/sonner.d.ts +1 -2
- package/dist/types/components/ui/sonner.d.ts.map +1 -1
- package/dist/types/components/ui/switch.d.ts +1 -1
- package/dist/types/components/ui/switch.d.ts.map +1 -1
- package/dist/types/components/ui/table-shadcn.d.ts +11 -0
- package/dist/types/components/ui/table-shadcn.d.ts.map +1 -0
- package/dist/types/components/ui/table.d.ts +2 -2
- package/dist/types/components/ui/table.d.ts.map +1 -1
- package/dist/types/components/ui/textarea.d.ts +4 -0
- package/dist/types/components/ui/textarea.d.ts.map +1 -0
- package/dist/types/components/ui/toggle-group.d.ts +2 -2
- package/dist/types/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/types/components/ui/toggle.d.ts +2 -2
- package/dist/types/components/ui/toggle.d.ts.map +1 -1
- package/dist/types/components/ui/tooltip.d.ts +7 -4
- package/dist/types/components/ui/tooltip.d.ts.map +1 -1
- package/dist/types/hooks/useIsMobile.d.ts +7 -0
- package/dist/types/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +39 -28
- package/src/components/features/data-table.tsx +96 -0
- package/src/components/features/index.ts +4 -0
- package/src/components/features/page-heading.tsx +22 -0
- package/src/components/features/search-bar.tsx +50 -0
- package/src/components/features/segmented-navigation.tsx +18 -0
- package/src/components/features/sidebar-layout.tsx +190 -0
- package/src/components/icons/arrow.tsx +23 -0
- package/src/components/icons/beta.tsx +86 -0
- package/src/components/icons/dot.tsx +89 -0
- package/src/components/icons/index.ts +7 -0
- package/src/components/icons/issue.tsx +97 -0
- package/src/components/icons/turtle.tsx +143 -0
- package/src/components/icons/update.tsx +108 -0
- package/src/components/icons/warning.tsx +86 -0
- package/src/components/molecules/index.ts +2 -1
- package/src/components/molecules/opportunity/index.ts +5 -1
- package/src/components/molecules/opportunity/opportunity-apr.tsx +99 -16
- package/src/components/molecules/opportunity/opportunity-list/hooks/index.ts +2 -0
- package/src/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-filtering.ts +45 -0
- package/src/components/molecules/opportunity/opportunity-list/hooks/use-opportunity-grouping.ts +81 -0
- package/src/components/molecules/opportunity/opportunity-list/index.ts +1 -0
- package/src/components/molecules/opportunity/opportunity-list/opportunity-list.tsx +136 -0
- package/src/components/molecules/opportunity/opportunity-rate-estimator.tsx +4 -1
- package/src/components/molecules/opportunity/opportunity-section.tsx +37 -19
- package/src/components/molecules/opportunity/opportunity-selector.tsx +2 -3
- package/src/components/molecules/route-details.tsx +48 -37
- package/src/components/molecules/swap-details.tsx +2 -4
- package/src/components/molecules/swap-input.tsx +56 -21
- package/src/components/molecules/tabs.tsx +67 -0
- package/src/components/molecules/token-selector.tsx +2 -2
- package/src/components/molecules/tx-status.tsx +1 -5
- package/src/components/molecules/widget/asset-list/asset-filters.tsx +111 -0
- package/src/components/molecules/widget/asset-list/asset-list.tsx +171 -0
- package/src/components/molecules/widget/asset-list/asset-row.tsx +45 -0
- package/src/components/molecules/widget/asset-list/hooks/index.ts +2 -0
- package/src/components/molecules/widget/asset-list/hooks/use-asset-filtering.ts +42 -0
- package/src/components/molecules/widget/asset-list/hooks/use-asset-grouping.ts +78 -0
- package/src/components/molecules/widget/asset-list/index.ts +3 -0
- package/src/components/molecules/widget/base-selector.tsx +104 -0
- package/src/components/molecules/widget/campaign-item.tsx +76 -0
- package/src/components/molecules/widget/deal-item.tsx +80 -0
- package/src/components/molecules/widget/index.ts +33 -0
- package/src/components/molecules/widget/opportunity-item.tsx +91 -0
- package/src/components/molecules/widget/widget-item-stats.tsx +50 -0
- package/src/components/molecules/widget/widget-item.tsx +138 -0
- package/src/components/molecules/widget/widget-list-items.tsx +86 -0
- package/src/components/ui/alert-dialog.tsx +146 -0
- package/src/components/ui/animated-background/animated-background.tsx +174 -0
- package/src/components/ui/animated-background/index.ts +1 -0
- package/src/components/ui/avatar.tsx +34 -19
- package/src/components/ui/badge.tsx +18 -8
- package/src/components/ui/banner.tsx +78 -0
- package/src/components/ui/button.tsx +51 -21
- package/src/components/ui/card.tsx +21 -61
- package/src/components/ui/checkbox.tsx +29 -0
- package/src/components/ui/collapsible.tsx +22 -0
- package/src/components/ui/combobox.tsx +617 -0
- package/src/components/ui/command.tsx +164 -0
- package/src/components/ui/dialog.tsx +5 -9
- package/src/components/ui/dropdown.tsx +263 -0
- package/src/components/ui/field.tsx +232 -0
- package/src/components/ui/heading.tsx +49 -0
- package/src/components/ui/hover-card.tsx +10 -10
- package/src/components/ui/icon-list.tsx +141 -0
- package/src/components/ui/index.ts +29 -9
- package/src/components/ui/info-card.tsx +1 -1
- package/src/components/ui/input-group.tsx +158 -0
- package/src/components/ui/input.tsx +17 -25
- package/src/components/ui/label-with-icon.tsx +40 -30
- package/src/components/ui/label.tsx +8 -9
- package/src/components/ui/multi-select.tsx +1000 -0
- package/src/components/ui/navigation-menu.tsx +181 -0
- package/src/components/ui/opportunity-details-v1.tsx +2 -2
- package/src/components/ui/popover.tsx +42 -0
- package/src/components/ui/scroll-area.tsx +11 -11
- package/src/components/ui/segment-control.tsx +140 -0
- package/src/components/ui/select.tsx +26 -31
- package/src/components/ui/sheet.tsx +130 -0
- package/src/components/ui/sidebar.tsx +693 -0
- package/src/components/ui/skeleton.tsx +14 -0
- package/src/components/ui/slider.tsx +58 -0
- package/src/components/ui/switch.tsx +8 -11
- package/src/components/ui/{table-shad.tsx → table-shadcn.tsx} +25 -39
- package/src/components/ui/table.tsx +3 -2
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +11 -7
- package/src/hooks/useIsMobile.ts +74 -0
- package/src/index.ts +2 -0
- package/src/styles/globals.css +87 -20
- package/src/styles/themes/semantic.css +11 -5
- package/src/styles/tokens/colors.css +64 -53
- package/src/styles/tokens/radius.css +3 -34
- package/tsconfig.json +11 -15
- package/vite.config.js +41 -57
- package/dist/types/components/molecules/opportunity/opportunity-item.d.ts +0 -15
- package/dist/types/components/molecules/opportunity/opportunity-item.d.ts.map +0 -1
- package/dist/types/components/ui/table-shad.d.ts +0 -11
- package/dist/types/components/ui/table-shad.d.ts.map +0 -1
- package/src/components/molecules/opportunity/opportunity-item.tsx +0 -93
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { cva, VariantProps } from "class-variance-authority";
|
|
6
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import { Input } from "@/components/ui/input";
|
|
10
|
+
import { Separator } from "@/components/ui/separator";
|
|
11
|
+
import {
|
|
12
|
+
Sheet,
|
|
13
|
+
SheetContent,
|
|
14
|
+
SheetDescription,
|
|
15
|
+
SheetHeader,
|
|
16
|
+
SheetTitle,
|
|
17
|
+
} from "@/components/ui/sheet";
|
|
18
|
+
import { Skeleton } from "@/components/ui/skeleton";
|
|
19
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
|
20
|
+
import { useIsMobile } from "../../hooks/useIsMobile";
|
|
21
|
+
|
|
22
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
23
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
24
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
25
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
26
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
27
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
28
|
+
|
|
29
|
+
type SidebarContextProps = {
|
|
30
|
+
state: "expanded" | "collapsed";
|
|
31
|
+
open: boolean;
|
|
32
|
+
setOpen: (open: boolean) => void;
|
|
33
|
+
openMobile: boolean;
|
|
34
|
+
setOpenMobile: (open: boolean) => void;
|
|
35
|
+
isMobile: boolean;
|
|
36
|
+
toggleSidebar: () => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const SidebarContext = React.createContext<SidebarContextProps | null>(null);
|
|
40
|
+
|
|
41
|
+
function useSidebar() {
|
|
42
|
+
const context = React.useContext(SidebarContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function SidebarProvider({
|
|
51
|
+
defaultOpen = true,
|
|
52
|
+
open: openProp,
|
|
53
|
+
onOpenChange: setOpenProp,
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}: React.ComponentProps<"div"> & {
|
|
59
|
+
defaultOpen?: boolean;
|
|
60
|
+
open?: boolean;
|
|
61
|
+
onOpenChange?: (open: boolean) => void;
|
|
62
|
+
}) {
|
|
63
|
+
const { isMobile } = useIsMobile();
|
|
64
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
65
|
+
|
|
66
|
+
// This is the internal state of the sidebar.
|
|
67
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
68
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
69
|
+
const open = openProp ?? _open;
|
|
70
|
+
const setOpen = React.useCallback(
|
|
71
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
72
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
73
|
+
if (setOpenProp) {
|
|
74
|
+
setOpenProp(openState);
|
|
75
|
+
} else {
|
|
76
|
+
_setOpen(openState);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// This sets the cookie to keep the sidebar state.
|
|
80
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
81
|
+
},
|
|
82
|
+
[setOpenProp, open]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Helper to toggle the sidebar.
|
|
86
|
+
const toggleSidebar = React.useCallback(() => {
|
|
87
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
88
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
89
|
+
|
|
90
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
93
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
toggleSidebar();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
100
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
101
|
+
}, [toggleSidebar]);
|
|
102
|
+
|
|
103
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
104
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
105
|
+
const state = open ? "expanded" : "collapsed";
|
|
106
|
+
|
|
107
|
+
const contextValue = React.useMemo<SidebarContextProps>(
|
|
108
|
+
() => ({
|
|
109
|
+
state,
|
|
110
|
+
open,
|
|
111
|
+
setOpen,
|
|
112
|
+
isMobile,
|
|
113
|
+
openMobile,
|
|
114
|
+
setOpenMobile,
|
|
115
|
+
toggleSidebar,
|
|
116
|
+
}),
|
|
117
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<SidebarContext.Provider value={contextValue}>
|
|
122
|
+
<TooltipProvider delayDuration={0}>
|
|
123
|
+
<div
|
|
124
|
+
data-slot="sidebar-wrapper"
|
|
125
|
+
style={
|
|
126
|
+
{
|
|
127
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
128
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
129
|
+
...style,
|
|
130
|
+
} as React.CSSProperties
|
|
131
|
+
}
|
|
132
|
+
className={cn(
|
|
133
|
+
"group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
{...props}
|
|
137
|
+
>
|
|
138
|
+
{children}
|
|
139
|
+
</div>
|
|
140
|
+
</TooltipProvider>
|
|
141
|
+
</SidebarContext.Provider>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function Sidebar({
|
|
146
|
+
side = "left",
|
|
147
|
+
variant = "floating",
|
|
148
|
+
collapsible = "offcanvas",
|
|
149
|
+
className,
|
|
150
|
+
children,
|
|
151
|
+
...props
|
|
152
|
+
}: React.ComponentProps<"div"> & {
|
|
153
|
+
side?: "left" | "right";
|
|
154
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
155
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
156
|
+
}) {
|
|
157
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
158
|
+
|
|
159
|
+
if (collapsible === "none") {
|
|
160
|
+
return (
|
|
161
|
+
<div
|
|
162
|
+
data-slot="sidebar"
|
|
163
|
+
className={cn(
|
|
164
|
+
"bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
|
|
165
|
+
className
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
{children}
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (isMobile) {
|
|
175
|
+
return (
|
|
176
|
+
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
177
|
+
<SheetContent
|
|
178
|
+
data-sidebar="sidebar"
|
|
179
|
+
data-slot="sidebar"
|
|
180
|
+
data-mobile="true"
|
|
181
|
+
className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
182
|
+
style={
|
|
183
|
+
{
|
|
184
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
185
|
+
} as React.CSSProperties
|
|
186
|
+
}
|
|
187
|
+
side={side}
|
|
188
|
+
>
|
|
189
|
+
<SheetHeader className="sr-only">
|
|
190
|
+
<SheetTitle>Sidebar</SheetTitle>
|
|
191
|
+
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
192
|
+
</SheetHeader>
|
|
193
|
+
<div className="flex h-full w-full flex-col">{children}</div>
|
|
194
|
+
</SheetContent>
|
|
195
|
+
</Sheet>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div
|
|
201
|
+
className="group peer text-sidebar-foreground hidden md:block"
|
|
202
|
+
data-state={state}
|
|
203
|
+
data-collapsible={state === "collapsed" ? collapsible : ""}
|
|
204
|
+
data-variant={variant}
|
|
205
|
+
data-side={side}
|
|
206
|
+
data-slot="sidebar"
|
|
207
|
+
>
|
|
208
|
+
{/* This is what handles the sidebar gap on desktop */}
|
|
209
|
+
<div
|
|
210
|
+
data-slot="sidebar-gap"
|
|
211
|
+
className={cn(
|
|
212
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
213
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
214
|
+
"group-data-[side=right]:rotate-180",
|
|
215
|
+
variant === "floating" || variant === "inset"
|
|
216
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
217
|
+
: "group-data-[collapsible=icon]:w-12"
|
|
218
|
+
)}
|
|
219
|
+
/>
|
|
220
|
+
<div
|
|
221
|
+
data-slot="sidebar-container"
|
|
222
|
+
className={cn(
|
|
223
|
+
"border-border fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
224
|
+
side === "left"
|
|
225
|
+
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
226
|
+
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
227
|
+
// Adjust the padding for floating and inset variants.
|
|
228
|
+
variant === "floating" || variant === "inset"
|
|
229
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
230
|
+
: "group-data-[collapsible=icon]:w-12 group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
231
|
+
className
|
|
232
|
+
)}
|
|
233
|
+
{...props}
|
|
234
|
+
>
|
|
235
|
+
<div
|
|
236
|
+
data-sidebar="sidebar"
|
|
237
|
+
data-slot="sidebar-inner"
|
|
238
|
+
className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-[0_0_40px_0_rgba(0,0,0,0.5)]"
|
|
239
|
+
>
|
|
240
|
+
{children}
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
|
|
248
|
+
const { toggleSidebar } = useSidebar();
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<Button
|
|
252
|
+
data-sidebar="trigger"
|
|
253
|
+
data-slot="sidebar-trigger"
|
|
254
|
+
variant="default"
|
|
255
|
+
border="plain"
|
|
256
|
+
size="icon"
|
|
257
|
+
className={cn("size-7", className)}
|
|
258
|
+
onClick={(event) => {
|
|
259
|
+
onClick?.(event);
|
|
260
|
+
toggleSidebar();
|
|
261
|
+
}}
|
|
262
|
+
{...props}
|
|
263
|
+
>
|
|
264
|
+
<PanelLeftIcon />
|
|
265
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
266
|
+
</Button>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
|
271
|
+
const { toggleSidebar } = useSidebar();
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<button
|
|
275
|
+
data-sidebar="rail"
|
|
276
|
+
data-slot="sidebar-rail"
|
|
277
|
+
aria-label="Toggle Sidebar"
|
|
278
|
+
tabIndex={-1}
|
|
279
|
+
onClick={toggleSidebar}
|
|
280
|
+
title="Toggle Sidebar"
|
|
281
|
+
className={cn(
|
|
282
|
+
"hover:after:bg-sidebar-border 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",
|
|
283
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
284
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
285
|
+
"hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
|
|
286
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
287
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
288
|
+
className
|
|
289
|
+
)}
|
|
290
|
+
{...props}
|
|
291
|
+
/>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
|
296
|
+
return (
|
|
297
|
+
<main
|
|
298
|
+
data-slot="sidebar-inset"
|
|
299
|
+
className={cn(
|
|
300
|
+
"bg-background relative flex w-full flex-1 flex-col",
|
|
301
|
+
"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
302
|
+
className
|
|
303
|
+
)}
|
|
304
|
+
{...props}
|
|
305
|
+
/>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
|
|
310
|
+
return (
|
|
311
|
+
<Input
|
|
312
|
+
data-slot="sidebar-input"
|
|
313
|
+
data-sidebar="input"
|
|
314
|
+
className={cn("bg-background h-8 w-full shadow-none", className)}
|
|
315
|
+
{...props}
|
|
316
|
+
/>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
321
|
+
return (
|
|
322
|
+
<div
|
|
323
|
+
data-slot="sidebar-header"
|
|
324
|
+
data-sidebar="header"
|
|
325
|
+
className={cn("flex flex-col gap-2 px-4 pt-8", className)}
|
|
326
|
+
{...props}
|
|
327
|
+
/>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
332
|
+
return (
|
|
333
|
+
<div
|
|
334
|
+
data-slot="sidebar-footer"
|
|
335
|
+
data-sidebar="footer"
|
|
336
|
+
className={cn("flex flex-col gap-2 px-4 pb-8", className)}
|
|
337
|
+
{...props}
|
|
338
|
+
/>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
|
|
343
|
+
return (
|
|
344
|
+
<Separator
|
|
345
|
+
data-slot="sidebar-separator"
|
|
346
|
+
data-sidebar="separator"
|
|
347
|
+
className={cn("bg-sidebar-border mx-2 w-auto", className)}
|
|
348
|
+
{...props}
|
|
349
|
+
/>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
354
|
+
return (
|
|
355
|
+
<div
|
|
356
|
+
data-slot="sidebar-content"
|
|
357
|
+
data-sidebar="content"
|
|
358
|
+
className={cn(
|
|
359
|
+
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
360
|
+
className
|
|
361
|
+
)}
|
|
362
|
+
{...props}
|
|
363
|
+
/>
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
368
|
+
return (
|
|
369
|
+
<div
|
|
370
|
+
data-slot="sidebar-group"
|
|
371
|
+
data-sidebar="group"
|
|
372
|
+
className={cn("relative flex w-full min-w-0 flex-col p-4", className)}
|
|
373
|
+
{...props}
|
|
374
|
+
/>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function SidebarGroupLabel({
|
|
379
|
+
className,
|
|
380
|
+
asChild = false,
|
|
381
|
+
...props
|
|
382
|
+
}: React.ComponentProps<"div"> & { asChild?: boolean }) {
|
|
383
|
+
const Comp = asChild ? Slot : "div";
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<Comp
|
|
387
|
+
data-slot="sidebar-group-label"
|
|
388
|
+
data-sidebar="group-label"
|
|
389
|
+
className={cn(
|
|
390
|
+
"text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
391
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
392
|
+
className
|
|
393
|
+
)}
|
|
394
|
+
{...props}
|
|
395
|
+
/>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function SidebarGroupAction({
|
|
400
|
+
className,
|
|
401
|
+
asChild = false,
|
|
402
|
+
...props
|
|
403
|
+
}: React.ComponentProps<"button"> & { asChild?: boolean }) {
|
|
404
|
+
const Comp = asChild ? Slot : "button";
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
<Comp
|
|
408
|
+
data-slot="sidebar-group-action"
|
|
409
|
+
data-sidebar="group-action"
|
|
410
|
+
className={cn(
|
|
411
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
412
|
+
// Increases the hit area of the button on mobile.
|
|
413
|
+
"after:absolute after:-inset-2 md:after:hidden",
|
|
414
|
+
"group-data-[collapsible=icon]:hidden",
|
|
415
|
+
className
|
|
416
|
+
)}
|
|
417
|
+
{...props}
|
|
418
|
+
/>
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
423
|
+
return (
|
|
424
|
+
<div
|
|
425
|
+
data-slot="sidebar-group-content"
|
|
426
|
+
data-sidebar="group-content"
|
|
427
|
+
className={cn("w-full text-sm", className)}
|
|
428
|
+
{...props}
|
|
429
|
+
/>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
|
434
|
+
return (
|
|
435
|
+
<ul
|
|
436
|
+
data-slot="sidebar-menu"
|
|
437
|
+
data-sidebar="menu"
|
|
438
|
+
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
439
|
+
{...props}
|
|
440
|
+
/>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function SidebarMenuItem({ className, ...props }: React.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
|
+
{...props}
|
|
451
|
+
/>
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const sidebarMenuButtonVariants = cva(
|
|
456
|
+
"peer/menu-button ring-sidebar-ring data-[active=true]:border-gradient-accent data-[active=true]:text-primary data-[active=true]:shadow-primary data-[active=true]:hover:text-primary flex w-full items-center rounded-lg border border-transparent px-3 py-2 text-left text-sm outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:font-medium data-[active=true]:hover:bg-transparent [&>span]:pl-3 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
457
|
+
|
|
458
|
+
{
|
|
459
|
+
variants: {
|
|
460
|
+
variant: {
|
|
461
|
+
default:
|
|
462
|
+
"hover:bg-neutral-alpha-2 hover:text-foreground text-muted-foreground active:text-primary active:bg-neutral-alpha-5",
|
|
463
|
+
outline:
|
|
464
|
+
"bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
|
|
465
|
+
},
|
|
466
|
+
size: {
|
|
467
|
+
default: "h-10 text-xs",
|
|
468
|
+
sm: "h-8 text-xs",
|
|
469
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
defaultVariants: {
|
|
473
|
+
variant: "default",
|
|
474
|
+
size: "default",
|
|
475
|
+
},
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
function SidebarMenuButton({
|
|
480
|
+
asChild = false,
|
|
481
|
+
isActive = false,
|
|
482
|
+
variant = "default",
|
|
483
|
+
size = "default",
|
|
484
|
+
tooltip,
|
|
485
|
+
className,
|
|
486
|
+
...props
|
|
487
|
+
}: React.ComponentProps<"button"> & {
|
|
488
|
+
asChild?: boolean;
|
|
489
|
+
isActive?: boolean;
|
|
490
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
491
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
492
|
+
const Comp = asChild ? Slot : "button";
|
|
493
|
+
const { isMobile, state } = useSidebar();
|
|
494
|
+
|
|
495
|
+
const button = (
|
|
496
|
+
<Comp
|
|
497
|
+
data-slot="sidebar-menu-button"
|
|
498
|
+
data-sidebar="menu-button"
|
|
499
|
+
data-size={size}
|
|
500
|
+
data-active={isActive}
|
|
501
|
+
className={cn(sidebarMenuButtonVariants({ variant, size }), "group/menu-button", className)}
|
|
502
|
+
{...props}
|
|
503
|
+
/>
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
if (!tooltip) {
|
|
507
|
+
return button;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (typeof tooltip === "string") {
|
|
511
|
+
tooltip = {
|
|
512
|
+
children: tooltip,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
return (
|
|
517
|
+
<Tooltip>
|
|
518
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
519
|
+
<TooltipContent
|
|
520
|
+
side="right"
|
|
521
|
+
align="center"
|
|
522
|
+
hidden={state !== "collapsed" || isMobile}
|
|
523
|
+
{...tooltip}
|
|
524
|
+
/>
|
|
525
|
+
</Tooltip>
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function SidebarMenuAction({
|
|
530
|
+
className,
|
|
531
|
+
asChild = false,
|
|
532
|
+
showOnHover = false,
|
|
533
|
+
...props
|
|
534
|
+
}: React.ComponentProps<"button"> & {
|
|
535
|
+
asChild?: boolean;
|
|
536
|
+
showOnHover?: boolean;
|
|
537
|
+
}) {
|
|
538
|
+
const Comp = asChild ? Slot : "button";
|
|
539
|
+
|
|
540
|
+
return (
|
|
541
|
+
<Comp
|
|
542
|
+
data-slot="sidebar-menu-action"
|
|
543
|
+
data-sidebar="menu-action"
|
|
544
|
+
className={cn(
|
|
545
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
546
|
+
// Increases the hit area of the button on mobile.
|
|
547
|
+
"after:absolute after:-inset-2 md:after:hidden",
|
|
548
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
549
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
550
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
551
|
+
"group-data-[collapsible=icon]:hidden",
|
|
552
|
+
showOnHover &&
|
|
553
|
+
"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
|
|
554
|
+
className
|
|
555
|
+
)}
|
|
556
|
+
{...props}
|
|
557
|
+
/>
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">) {
|
|
562
|
+
return (
|
|
563
|
+
<div
|
|
564
|
+
data-slot="sidebar-menu-badge"
|
|
565
|
+
data-sidebar="menu-badge"
|
|
566
|
+
className={cn(
|
|
567
|
+
"text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
|
|
568
|
+
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
|
569
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
570
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
571
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
572
|
+
"group-data-[collapsible=icon]:hidden",
|
|
573
|
+
className
|
|
574
|
+
)}
|
|
575
|
+
{...props}
|
|
576
|
+
/>
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function SidebarMenuSkeleton({
|
|
581
|
+
className,
|
|
582
|
+
showIcon = false,
|
|
583
|
+
...props
|
|
584
|
+
}: React.ComponentProps<"div"> & {
|
|
585
|
+
showIcon?: boolean;
|
|
586
|
+
}) {
|
|
587
|
+
// Random width between 50 to 90%.
|
|
588
|
+
const width = React.useMemo(() => {
|
|
589
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
590
|
+
}, []);
|
|
591
|
+
|
|
592
|
+
return (
|
|
593
|
+
<div
|
|
594
|
+
data-slot="sidebar-menu-skeleton"
|
|
595
|
+
data-sidebar="menu-skeleton"
|
|
596
|
+
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
|
597
|
+
{...props}
|
|
598
|
+
>
|
|
599
|
+
{showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
|
|
600
|
+
<Skeleton
|
|
601
|
+
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
602
|
+
data-sidebar="menu-skeleton-text"
|
|
603
|
+
style={
|
|
604
|
+
{
|
|
605
|
+
"--skeleton-width": width,
|
|
606
|
+
} as React.CSSProperties
|
|
607
|
+
}
|
|
608
|
+
/>
|
|
609
|
+
</div>
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
|
614
|
+
return (
|
|
615
|
+
<ul
|
|
616
|
+
data-slot="sidebar-menu-sub"
|
|
617
|
+
data-sidebar="menu-sub"
|
|
618
|
+
className={cn(
|
|
619
|
+
"border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
|
|
620
|
+
"group-data-[collapsible=icon]:hidden",
|
|
621
|
+
className
|
|
622
|
+
)}
|
|
623
|
+
{...props}
|
|
624
|
+
/>
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
629
|
+
return (
|
|
630
|
+
<li
|
|
631
|
+
data-slot="sidebar-menu-sub-item"
|
|
632
|
+
data-sidebar="menu-sub-item"
|
|
633
|
+
className={cn("group/menu-sub-item relative", className)}
|
|
634
|
+
{...props}
|
|
635
|
+
/>
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function SidebarMenuSubButton({
|
|
640
|
+
asChild = false,
|
|
641
|
+
isActive = false,
|
|
642
|
+
variant = "default",
|
|
643
|
+
size = "sm",
|
|
644
|
+
className,
|
|
645
|
+
...props
|
|
646
|
+
}: React.ComponentProps<"a"> & {
|
|
647
|
+
asChild?: boolean;
|
|
648
|
+
isActive?: boolean;
|
|
649
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
650
|
+
const Comp = asChild ? Slot : "a";
|
|
651
|
+
|
|
652
|
+
return (
|
|
653
|
+
<Comp
|
|
654
|
+
data-slot="sidebar-menu-button"
|
|
655
|
+
data-sidebar="menu-button"
|
|
656
|
+
data-size={size}
|
|
657
|
+
data-active={isActive}
|
|
658
|
+
className={cn(
|
|
659
|
+
sidebarMenuButtonVariants({ variant, size }),
|
|
660
|
+
"group/menu-sub-button",
|
|
661
|
+
className
|
|
662
|
+
)}
|
|
663
|
+
{...props}
|
|
664
|
+
/>
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export {
|
|
669
|
+
Sidebar,
|
|
670
|
+
SidebarContent,
|
|
671
|
+
SidebarFooter,
|
|
672
|
+
SidebarGroup,
|
|
673
|
+
SidebarGroupAction,
|
|
674
|
+
SidebarGroupContent,
|
|
675
|
+
SidebarGroupLabel,
|
|
676
|
+
SidebarHeader,
|
|
677
|
+
SidebarInput,
|
|
678
|
+
SidebarInset,
|
|
679
|
+
SidebarMenu,
|
|
680
|
+
SidebarMenuAction,
|
|
681
|
+
SidebarMenuBadge,
|
|
682
|
+
SidebarMenuButton,
|
|
683
|
+
SidebarMenuItem,
|
|
684
|
+
SidebarMenuSkeleton,
|
|
685
|
+
SidebarMenuSub,
|
|
686
|
+
SidebarMenuSubButton,
|
|
687
|
+
SidebarMenuSubItem,
|
|
688
|
+
SidebarProvider,
|
|
689
|
+
SidebarRail,
|
|
690
|
+
SidebarSeparator,
|
|
691
|
+
SidebarTrigger,
|
|
692
|
+
useSidebar,
|
|
693
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="skeleton"
|
|
8
|
+
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
9
|
+
{...props}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { Skeleton };
|