@boriaui/react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/components/alert-dialog.d.ts +29 -0
- package/dist/components/alert-dialog.js +62 -0
- package/dist/components/alert.d.ts +12 -0
- package/dist/components/alert.js +35 -0
- package/dist/components/autosize-textarea.d.ts +26 -0
- package/dist/components/autosize-textarea.js +66 -0
- package/dist/components/avatar.d.ts +9 -0
- package/dist/components/avatar.js +30 -0
- package/dist/components/badge.d.ts +16 -0
- package/dist/components/badge.js +24 -0
- package/dist/components/breadcrumb.d.ts +29 -0
- package/dist/components/breadcrumb.js +64 -0
- package/dist/components/button.d.ts +15 -0
- package/dist/components/button.js +45 -0
- package/dist/components/calendar.d.ts +25 -0
- package/dist/components/calendar.js +109 -0
- package/dist/components/card.d.ts +11 -0
- package/dist/components/card.js +44 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js +29 -0
- package/dist/components/collapsible.d.ts +9 -0
- package/dist/components/collapsible.js +12 -0
- package/dist/components/command.d.ts +89 -0
- package/dist/components/command.js +79 -0
- package/dist/components/context-menu.d.ts +36 -0
- package/dist/components/context-menu.js +136 -0
- package/dist/components/dialog.d.ts +31 -0
- package/dist/components/dialog.js +58 -0
- package/dist/components/dropdown-menu.d.ts +33 -0
- package/dist/components/dropdown-menu.js +85 -0
- package/dist/components/empty.d.ts +35 -0
- package/dist/components/empty.js +61 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.js +121 -0
- package/dist/components/hover-card.d.ts +9 -0
- package/dist/components/hover-card.js +25 -0
- package/dist/components/input-group.d.ts +42 -0
- package/dist/components/input-group.js +83 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +17 -0
- package/dist/components/item.d.ts +61 -0
- package/dist/components/item.js +118 -0
- package/dist/components/kbd.d.ts +13 -0
- package/dist/components/kbd.js +21 -0
- package/dist/components/label.d.ts +7 -0
- package/dist/components/label.js +18 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.js +23 -0
- package/dist/components/radio-group.d.ts +14 -0
- package/dist/components/radio-group.js +39 -0
- package/dist/components/resizable.d.ts +34 -0
- package/dist/components/resizable.js +25 -0
- package/dist/components/scroll-area.d.ts +11 -0
- package/dist/components/scroll-area.js +35 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.js +77 -0
- package/dist/components/separator.d.ts +7 -0
- package/dist/components/separator.js +20 -0
- package/dist/components/sheet.d.ts +34 -0
- package/dist/components/sheet.js +68 -0
- package/dist/components/sidebar.d.ts +72 -0
- package/dist/components/sidebar.js +382 -0
- package/dist/components/skeleton.d.ts +9 -0
- package/dist/components/skeleton.js +13 -0
- package/dist/components/spinner.d.ts +9 -0
- package/dist/components/spinner.js +16 -0
- package/dist/components/switch.d.ts +28 -0
- package/dist/components/switch.js +31 -0
- package/dist/components/tabs.d.ts +10 -0
- package/dist/components/tabs.js +31 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/toaster.d.ts +10 -0
- package/dist/components/toaster.js +19 -0
- package/dist/components/toggle-group.d.ts +16 -0
- package/dist/components/toggle-group.js +43 -0
- package/dist/components/toggle.d.ts +16 -0
- package/dist/components/toggle.js +40 -0
- package/dist/components/tooltip.d.ts +10 -0
- package/dist/components/tooltip.js +22 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-media-query.d.ts +8 -0
- package/dist/hooks/use-media-query.js +20 -0
- package/dist/hooks/use-mobile.d.ts +4 -0
- package/dist/hooks/use-mobile.js +20 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/keyboard-guards.d.ts +11 -0
- package/dist/lib/keyboard-guards.js +21 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/lib/utils.js +10 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/theme-options.d.ts +16 -0
- package/dist/theme/theme-options.js +25 -0
- package/dist/theme/theme-provider.d.ts +50 -0
- package/dist/theme/theme-provider.js +94 -0
- package/package.json +122 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
|
+
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
10
|
+
|
|
11
|
+
//#region src/components/sheet.tsx
|
|
12
|
+
const Sheet = SheetPrimitive.Root;
|
|
13
|
+
const SheetTrigger = SheetPrimitive.Trigger;
|
|
14
|
+
const SheetClose = SheetPrimitive.Close;
|
|
15
|
+
const SheetPortal = SheetPrimitive.Portal;
|
|
16
|
+
const SheetOverlay = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Overlay, {
|
|
17
|
+
className: cn("fixed inset-0 z-50 bg-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className),
|
|
18
|
+
...props,
|
|
19
|
+
ref
|
|
20
|
+
}));
|
|
21
|
+
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
22
|
+
const sheetVariants = cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out", {
|
|
23
|
+
variants: { side: {
|
|
24
|
+
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
25
|
+
bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
26
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
27
|
+
right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"
|
|
28
|
+
} },
|
|
29
|
+
defaultVariants: { side: "right" }
|
|
30
|
+
});
|
|
31
|
+
const SheetContent = React.forwardRef(({ side = "right", className, children,...props }, ref) => /* @__PURE__ */ jsxs(SheetPortal, { children: [/* @__PURE__ */ jsx(SheetOverlay, {}), /* @__PURE__ */ jsxs(SheetPrimitive.Content, {
|
|
32
|
+
ref,
|
|
33
|
+
className: cn(sheetVariants({ side }), className),
|
|
34
|
+
...props,
|
|
35
|
+
children: [/* @__PURE__ */ jsxs(SheetPrimitive.Close, {
|
|
36
|
+
className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",
|
|
37
|
+
children: [/* @__PURE__ */ jsx(X, { className: "h-4 w-4" }), /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "sr-only",
|
|
39
|
+
children: "Close"
|
|
40
|
+
})]
|
|
41
|
+
}), children]
|
|
42
|
+
})] }));
|
|
43
|
+
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
44
|
+
const SheetHeader = ({ className,...props }) => /* @__PURE__ */ jsx("div", {
|
|
45
|
+
className: cn("flex flex-col space-y-2 text-center sm:text-left", className),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
SheetHeader.displayName = "SheetHeader";
|
|
49
|
+
const SheetFooter = ({ className,...props }) => /* @__PURE__ */ jsx("div", {
|
|
50
|
+
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
SheetFooter.displayName = "SheetFooter";
|
|
54
|
+
const SheetTitle = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Title, {
|
|
55
|
+
ref,
|
|
56
|
+
className: cn("text-lg font-semibold text-foreground", className),
|
|
57
|
+
...props
|
|
58
|
+
}));
|
|
59
|
+
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
60
|
+
const SheetDescription = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Description, {
|
|
61
|
+
ref,
|
|
62
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
63
|
+
...props
|
|
64
|
+
}));
|
|
65
|
+
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ButtonProps } from "./button.js";
|
|
2
|
+
import { TooltipContent } from "./tooltip.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { VariantProps } from "class-variance-authority";
|
|
5
|
+
import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
6
|
+
import * as class_variance_authority_types7 from "class-variance-authority/types";
|
|
7
|
+
|
|
8
|
+
//#region src/components/sidebar.d.ts
|
|
9
|
+
declare const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
10
|
+
type SidebarContextProps = {
|
|
11
|
+
state: "expanded" | "collapsed";
|
|
12
|
+
open: boolean;
|
|
13
|
+
setOpen: (open: boolean) => void;
|
|
14
|
+
openMobile: boolean;
|
|
15
|
+
setOpenMobile: (open: boolean) => void;
|
|
16
|
+
isMobile: boolean;
|
|
17
|
+
toggleSidebar: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare function useSidebar(): SidebarContextProps;
|
|
20
|
+
declare const SidebarProvider: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
21
|
+
defaultOpen?: boolean;
|
|
22
|
+
open?: boolean;
|
|
23
|
+
onOpenChange?: (open: boolean) => void;
|
|
24
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
declare const Sidebar: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
26
|
+
side?: "left" | "right";
|
|
27
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
28
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
29
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
declare const SidebarTrigger: React.ForwardRefExoticComponent<Omit<ButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
31
|
+
declare const SidebarRail: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
declare const SidebarInset: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
33
|
+
declare const SidebarInput: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
34
|
+
declare const SidebarHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
declare const SidebarFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
declare const SidebarSeparator: React.ForwardRefExoticComponent<Omit<Omit<_radix_ui_react_separator0.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
37
|
+
declare const SidebarContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
38
|
+
declare const SidebarGroup: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
declare const SidebarGroupLabel: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
42
|
+
declare const SidebarGroupAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
43
|
+
asChild?: boolean;
|
|
44
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
declare const SidebarGroupContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
declare const SidebarMenu: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
47
|
+
declare const SidebarMenuItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
48
|
+
declare const SidebarMenuButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
isActive?: boolean;
|
|
51
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
52
|
+
} & VariantProps<(props?: ({
|
|
53
|
+
variant?: "default" | "outline" | null | undefined;
|
|
54
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
55
|
+
} & class_variance_authority_types7.ClassProp) | undefined) => string>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
56
|
+
declare const SidebarMenuAction: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
57
|
+
asChild?: boolean;
|
|
58
|
+
showOnHover?: boolean;
|
|
59
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
60
|
+
declare const SidebarMenuBadge: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
61
|
+
declare const SidebarMenuSkeleton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
62
|
+
showIcon?: boolean;
|
|
63
|
+
}, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
64
|
+
declare const SidebarMenuSub: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
65
|
+
declare const SidebarMenuSubItem: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
66
|
+
declare const SidebarMenuSubButton: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
67
|
+
asChild?: boolean;
|
|
68
|
+
size?: "sm" | "md";
|
|
69
|
+
isActive?: boolean;
|
|
70
|
+
}, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { SIDEBAR_COOKIE_NAME, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { Separator } from "./separator.js";
|
|
7
|
+
import { Input } from "./input.js";
|
|
8
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "./sheet.js";
|
|
9
|
+
import { useIsMobile } from "../hooks/use-mobile.js";
|
|
10
|
+
import { Skeleton } from "./skeleton.js";
|
|
11
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
14
|
+
import { cva } from "class-variance-authority";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { PanelLeft, PanelLeftClose } from "lucide-react";
|
|
17
|
+
|
|
18
|
+
//#region src/components/sidebar.tsx
|
|
19
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
20
|
+
const SIDEBAR_COOKIE_MAX_AGE = 3600 * 24 * 7;
|
|
21
|
+
const SIDEBAR_WIDTH = "15.5rem";
|
|
22
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
23
|
+
const SIDEBAR_WIDTH_ICON = "4rem";
|
|
24
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
25
|
+
const SidebarContext = React.createContext(null);
|
|
26
|
+
function useSidebar() {
|
|
27
|
+
const context = React.useContext(SidebarContext);
|
|
28
|
+
if (!context) throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
const SidebarProvider = React.forwardRef(({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children,...props }, ref) => {
|
|
32
|
+
const isMobile = useIsMobile();
|
|
33
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
34
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
35
|
+
const open = openProp ?? _open;
|
|
36
|
+
const setOpen = React.useCallback((value) => {
|
|
37
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
38
|
+
if (setOpenProp) setOpenProp(openState);
|
|
39
|
+
else _setOpen(openState);
|
|
40
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
41
|
+
}, [setOpenProp, open]);
|
|
42
|
+
const toggleSidebar = React.useCallback(() => {
|
|
43
|
+
return isMobile ? setOpenMobile((open$1) => !open$1) : setOpen((open$1) => !open$1);
|
|
44
|
+
}, [
|
|
45
|
+
isMobile,
|
|
46
|
+
setOpen,
|
|
47
|
+
setOpenMobile
|
|
48
|
+
]);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
const handleKeyDown = (event) => {
|
|
51
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
toggleSidebar();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
57
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
58
|
+
}, [toggleSidebar]);
|
|
59
|
+
const state = open ? "expanded" : "collapsed";
|
|
60
|
+
const contextValue = React.useMemo(() => ({
|
|
61
|
+
state,
|
|
62
|
+
open,
|
|
63
|
+
setOpen,
|
|
64
|
+
isMobile,
|
|
65
|
+
openMobile,
|
|
66
|
+
setOpenMobile,
|
|
67
|
+
toggleSidebar
|
|
68
|
+
}), [
|
|
69
|
+
state,
|
|
70
|
+
open,
|
|
71
|
+
setOpen,
|
|
72
|
+
isMobile,
|
|
73
|
+
openMobile,
|
|
74
|
+
setOpenMobile,
|
|
75
|
+
toggleSidebar
|
|
76
|
+
]);
|
|
77
|
+
return /* @__PURE__ */ jsx(SidebarContext.Provider, {
|
|
78
|
+
value: contextValue,
|
|
79
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, {
|
|
80
|
+
delayDuration: 0,
|
|
81
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
82
|
+
style: {
|
|
83
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
84
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
85
|
+
...style
|
|
86
|
+
},
|
|
87
|
+
className: cn("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar", className),
|
|
88
|
+
ref,
|
|
89
|
+
...props,
|
|
90
|
+
children
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
SidebarProvider.displayName = "SidebarProvider";
|
|
96
|
+
const Sidebar = React.forwardRef(({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children,...props }, ref) => {
|
|
97
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
98
|
+
if (collapsible === "none") return /* @__PURE__ */ jsx("div", {
|
|
99
|
+
className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className),
|
|
100
|
+
ref,
|
|
101
|
+
...props,
|
|
102
|
+
children
|
|
103
|
+
});
|
|
104
|
+
if (isMobile) return /* @__PURE__ */ jsx(Sheet, {
|
|
105
|
+
open: openMobile,
|
|
106
|
+
onOpenChange: setOpenMobile,
|
|
107
|
+
...props,
|
|
108
|
+
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
109
|
+
"data-sidebar": "sidebar",
|
|
110
|
+
"data-mobile": "true",
|
|
111
|
+
className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
|
|
112
|
+
style: { "--sidebar-width": SIDEBAR_WIDTH_MOBILE },
|
|
113
|
+
side,
|
|
114
|
+
children: [/* @__PURE__ */ jsxs(SheetHeader, {
|
|
115
|
+
className: "sr-only",
|
|
116
|
+
children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Sidebar" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Displays the mobile sidebar." })]
|
|
117
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: "flex h-full w-full flex-col",
|
|
119
|
+
children
|
|
120
|
+
})]
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
124
|
+
ref,
|
|
125
|
+
className: "group peer hidden text-sidebar-foreground md:block",
|
|
126
|
+
"data-state": state,
|
|
127
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
128
|
+
"data-variant": variant,
|
|
129
|
+
"data-side": side,
|
|
130
|
+
children: [/* @__PURE__ */ jsx("div", { className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear motion-reduce:transition-none", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)") }), /* @__PURE__ */ jsx("div", {
|
|
131
|
+
className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear motion-reduce:transition-none md:flex", side === "left" ? "left-0 group-data-[collapsible=offcanvas]:-left-(--sidebar-width)" : "right-0 group-data-[collapsible=offcanvas]:-right-(--sidebar-width)", variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className),
|
|
132
|
+
...props,
|
|
133
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
134
|
+
"data-sidebar": "sidebar",
|
|
135
|
+
className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm",
|
|
136
|
+
children
|
|
137
|
+
})
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
Sidebar.displayName = "Sidebar";
|
|
142
|
+
const SidebarTrigger = React.forwardRef(({ className, onClick,...props }, ref) => {
|
|
143
|
+
const { toggleSidebar, state } = useSidebar();
|
|
144
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
145
|
+
ref,
|
|
146
|
+
"data-sidebar": "trigger",
|
|
147
|
+
variant: "ghost",
|
|
148
|
+
size: "icon",
|
|
149
|
+
className: cn("h-7 w-7", className),
|
|
150
|
+
onClick: (event) => {
|
|
151
|
+
onClick?.(event);
|
|
152
|
+
toggleSidebar();
|
|
153
|
+
},
|
|
154
|
+
...props,
|
|
155
|
+
children: [state === "collapsed" ? /* @__PURE__ */ jsx(PanelLeft, {}) : /* @__PURE__ */ jsx(PanelLeftClose, {}), /* @__PURE__ */ jsx("span", {
|
|
156
|
+
className: "sr-only",
|
|
157
|
+
children: "Toggle Sidebar"
|
|
158
|
+
})]
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
SidebarTrigger.displayName = "SidebarTrigger";
|
|
162
|
+
const SidebarRail = React.forwardRef(({ className,...props }, ref) => {
|
|
163
|
+
const { toggleSidebar } = useSidebar();
|
|
164
|
+
return /* @__PURE__ */ jsx("button", {
|
|
165
|
+
ref,
|
|
166
|
+
"data-sidebar": "rail",
|
|
167
|
+
"aria-label": "Toggle Sidebar",
|
|
168
|
+
tabIndex: -1,
|
|
169
|
+
onClick: toggleSidebar,
|
|
170
|
+
title: "Toggle Sidebar",
|
|
171
|
+
className: cn("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear motion-reduce:transition-none after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className),
|
|
172
|
+
...props
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
SidebarRail.displayName = "SidebarRail";
|
|
176
|
+
const SidebarInset = React.forwardRef(({ className,...props }, ref) => {
|
|
177
|
+
return /* @__PURE__ */ jsx("main", {
|
|
178
|
+
ref,
|
|
179
|
+
className: cn("relative flex w-full flex-1 flex-col bg-background", "md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-lg md:peer-data-[variant=inset]:shadow-sm", className),
|
|
180
|
+
...props
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
SidebarInset.displayName = "SidebarInset";
|
|
184
|
+
const SidebarInput = React.forwardRef(({ className,...props }, ref) => {
|
|
185
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
186
|
+
ref,
|
|
187
|
+
"data-sidebar": "input",
|
|
188
|
+
className: cn("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring", className),
|
|
189
|
+
...props
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
SidebarInput.displayName = "SidebarInput";
|
|
193
|
+
const SidebarHeader = React.forwardRef(({ className,...props }, ref) => {
|
|
194
|
+
return /* @__PURE__ */ jsx("div", {
|
|
195
|
+
ref,
|
|
196
|
+
"data-sidebar": "header",
|
|
197
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
198
|
+
...props
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
SidebarHeader.displayName = "SidebarHeader";
|
|
202
|
+
const SidebarFooter = React.forwardRef(({ className,...props }, ref) => {
|
|
203
|
+
return /* @__PURE__ */ jsx("div", {
|
|
204
|
+
ref,
|
|
205
|
+
"data-sidebar": "footer",
|
|
206
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
207
|
+
...props
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
SidebarFooter.displayName = "SidebarFooter";
|
|
211
|
+
const SidebarSeparator = React.forwardRef(({ className,...props }, ref) => {
|
|
212
|
+
return /* @__PURE__ */ jsx(Separator, {
|
|
213
|
+
ref,
|
|
214
|
+
"data-sidebar": "separator",
|
|
215
|
+
className: cn("mx-2 w-auto bg-sidebar-border", className),
|
|
216
|
+
...props
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
SidebarSeparator.displayName = "SidebarSeparator";
|
|
220
|
+
const SidebarContent = React.forwardRef(({ className,...props }, ref) => {
|
|
221
|
+
return /* @__PURE__ */ jsx("div", {
|
|
222
|
+
ref,
|
|
223
|
+
"data-sidebar": "content",
|
|
224
|
+
className: cn("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className),
|
|
225
|
+
...props
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
SidebarContent.displayName = "SidebarContent";
|
|
229
|
+
const SidebarGroup = React.forwardRef(({ className,...props }, ref) => {
|
|
230
|
+
return /* @__PURE__ */ jsx("div", {
|
|
231
|
+
ref,
|
|
232
|
+
"data-sidebar": "group",
|
|
233
|
+
className: cn("relative flex w-full min-w-0 flex-col p-2", className),
|
|
234
|
+
...props
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
SidebarGroup.displayName = "SidebarGroup";
|
|
238
|
+
const SidebarGroupLabel = React.forwardRef(({ className, asChild = false,...props }, ref) => {
|
|
239
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
240
|
+
ref,
|
|
241
|
+
"data-sidebar": "group-label",
|
|
242
|
+
className: cn("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-hidden ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear motion-reduce:transition-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0", className),
|
|
243
|
+
...props
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
SidebarGroupLabel.displayName = "SidebarGroupLabel";
|
|
247
|
+
const SidebarGroupAction = React.forwardRef(({ className, asChild = false,...props }, ref) => {
|
|
248
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
249
|
+
ref,
|
|
250
|
+
"data-sidebar": "group-action",
|
|
251
|
+
className: cn("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", "after:absolute after:-inset-2 md:after:hidden", "group-data-[collapsible=icon]:hidden", className),
|
|
252
|
+
...props
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
SidebarGroupAction.displayName = "SidebarGroupAction";
|
|
256
|
+
const SidebarGroupContent = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
257
|
+
ref,
|
|
258
|
+
"data-sidebar": "group-content",
|
|
259
|
+
className: cn("w-full text-sm", className),
|
|
260
|
+
...props
|
|
261
|
+
}));
|
|
262
|
+
SidebarGroupContent.displayName = "SidebarGroupContent";
|
|
263
|
+
const SidebarMenu = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("ul", {
|
|
264
|
+
ref,
|
|
265
|
+
"data-sidebar": "menu",
|
|
266
|
+
className: cn("flex w-full min-w-0 flex-col gap-1", className),
|
|
267
|
+
...props
|
|
268
|
+
}));
|
|
269
|
+
SidebarMenu.displayName = "SidebarMenu";
|
|
270
|
+
const SidebarMenuItem = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("li", {
|
|
271
|
+
ref,
|
|
272
|
+
"data-sidebar": "menu-item",
|
|
273
|
+
className: cn("group/menu-item relative", className),
|
|
274
|
+
...props
|
|
275
|
+
}));
|
|
276
|
+
SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
277
|
+
const sidebarMenuButtonVariants = cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] motion-reduce:transition-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground 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 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0", {
|
|
278
|
+
variants: {
|
|
279
|
+
variant: {
|
|
280
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
281
|
+
outline: "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"
|
|
282
|
+
},
|
|
283
|
+
size: {
|
|
284
|
+
default: "h-8 text-sm",
|
|
285
|
+
sm: "h-7 text-xs",
|
|
286
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
defaultVariants: {
|
|
290
|
+
variant: "default",
|
|
291
|
+
size: "default"
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
const SidebarMenuButton = React.forwardRef(({ asChild = false, isActive = false, variant = "default", size = "default", tooltip, className,...props }, ref) => {
|
|
295
|
+
const Comp = asChild ? Slot : "button";
|
|
296
|
+
const { isMobile, state } = useSidebar();
|
|
297
|
+
const button = /* @__PURE__ */ jsx(Comp, {
|
|
298
|
+
ref,
|
|
299
|
+
"data-sidebar": "menu-button",
|
|
300
|
+
"data-size": size,
|
|
301
|
+
"data-active": isActive,
|
|
302
|
+
className: cn(sidebarMenuButtonVariants({
|
|
303
|
+
variant,
|
|
304
|
+
size
|
|
305
|
+
}), className),
|
|
306
|
+
...props
|
|
307
|
+
});
|
|
308
|
+
if (!tooltip) return button;
|
|
309
|
+
if (typeof tooltip === "string") tooltip = { children: tooltip };
|
|
310
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
311
|
+
asChild: true,
|
|
312
|
+
children: button
|
|
313
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
314
|
+
side: "right",
|
|
315
|
+
align: "center",
|
|
316
|
+
hidden: state !== "collapsed" || isMobile,
|
|
317
|
+
...tooltip
|
|
318
|
+
})] });
|
|
319
|
+
});
|
|
320
|
+
SidebarMenuButton.displayName = "SidebarMenuButton";
|
|
321
|
+
const SidebarMenuAction = React.forwardRef(({ className, asChild = false, showOnHover = false,...props }, ref) => {
|
|
322
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
323
|
+
ref,
|
|
324
|
+
"data-sidebar": "menu-action",
|
|
325
|
+
className: cn("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0", "after:absolute after:-inset-2 md:after:hidden", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", showOnHover && "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0", className),
|
|
326
|
+
...props
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
SidebarMenuAction.displayName = "SidebarMenuAction";
|
|
330
|
+
const SidebarMenuBadge = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
331
|
+
ref,
|
|
332
|
+
"data-sidebar": "menu-badge",
|
|
333
|
+
className: cn("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground", "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground", "peer-data-[size=sm]/menu-button:top-1", "peer-data-[size=default]/menu-button:top-1.5", "peer-data-[size=lg]/menu-button:top-2.5", "group-data-[collapsible=icon]:hidden", className),
|
|
334
|
+
...props
|
|
335
|
+
}));
|
|
336
|
+
SidebarMenuBadge.displayName = "SidebarMenuBadge";
|
|
337
|
+
const SidebarMenuSkeleton = React.forwardRef(({ className, showIcon = false,...props }, ref) => {
|
|
338
|
+
const width = React.useMemo(() => {
|
|
339
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
340
|
+
}, []);
|
|
341
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
342
|
+
ref,
|
|
343
|
+
"data-sidebar": "menu-skeleton",
|
|
344
|
+
className: cn("flex h-8 items-center gap-2 rounded-md px-2", className),
|
|
345
|
+
...props,
|
|
346
|
+
children: [showIcon && /* @__PURE__ */ jsx(Skeleton, {
|
|
347
|
+
className: "size-4 rounded-md",
|
|
348
|
+
"data-sidebar": "menu-skeleton-icon"
|
|
349
|
+
}), /* @__PURE__ */ jsx(Skeleton, {
|
|
350
|
+
className: "h-4 max-w-(--skeleton-width) flex-1",
|
|
351
|
+
"data-sidebar": "menu-skeleton-text",
|
|
352
|
+
style: { "--skeleton-width": width }
|
|
353
|
+
})]
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
|
|
357
|
+
const SidebarMenuSub = React.forwardRef(({ className,...props }, ref) => /* @__PURE__ */ jsx("ul", {
|
|
358
|
+
ref,
|
|
359
|
+
"data-sidebar": "menu-sub",
|
|
360
|
+
className: cn("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5", "group-data-[collapsible=icon]:hidden", className),
|
|
361
|
+
...props
|
|
362
|
+
}));
|
|
363
|
+
SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
364
|
+
const SidebarMenuSubItem = React.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("li", {
|
|
365
|
+
ref,
|
|
366
|
+
...props
|
|
367
|
+
}));
|
|
368
|
+
SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
369
|
+
const SidebarMenuSubButton = React.forwardRef(({ asChild = false, size = "md", isActive, className,...props }, ref) => {
|
|
370
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "a", {
|
|
371
|
+
ref,
|
|
372
|
+
"data-sidebar": "menu-sub-button",
|
|
373
|
+
"data-size": size,
|
|
374
|
+
"data-active": isActive,
|
|
375
|
+
className: cn("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-hidden ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground", size === "sm" && "text-xs", size === "md" && "text-sm", "group-data-[collapsible=icon]:hidden", className),
|
|
376
|
+
...props
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
export { SIDEBAR_COOKIE_NAME, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/skeleton.tsx
|
|
5
|
+
function Skeleton({ className,...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
className: cn("animate-pulse rounded-md bg-primary/10", className),
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Skeleton };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Loader2Icon } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/spinner.tsx
|
|
6
|
+
function Spinner({ className,...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(Loader2Icon, {
|
|
8
|
+
role: "status",
|
|
9
|
+
"aria-label": "Loading",
|
|
10
|
+
className: cn("size-4 animate-spin", className),
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Spinner };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/switch.d.ts
|
|
4
|
+
interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
|
|
5
|
+
/** Whether the switch is on. */
|
|
6
|
+
checked: boolean;
|
|
7
|
+
/** Renders the mixed third state: `aria-checked="mixed"`. */
|
|
8
|
+
indeterminate?: boolean;
|
|
9
|
+
/** Called with the next value when the user toggles. */
|
|
10
|
+
onCheckedChange: (checked: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Minimal accessible switch (shadcn-style track + thumb) built on a native
|
|
14
|
+
* `<button role="switch">` so no extra dependency is needed. Keyboard- and
|
|
15
|
+
* screen-reader-friendly via `aria-checked`; the visual state follows the
|
|
16
|
+
* checked prop. The optional `indeterminate` state mirrors the Checkbox
|
|
17
|
+
* tri-state contract: `aria-checked="mixed"` + `data-state="indeterminate"`,
|
|
18
|
+
* and a click resolves the mixed value to ON.
|
|
19
|
+
*/
|
|
20
|
+
declare function Switch({
|
|
21
|
+
checked,
|
|
22
|
+
indeterminate,
|
|
23
|
+
onCheckedChange,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: SwitchProps): React.JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Switch };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/switch.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Minimal accessible switch (shadcn-style track + thumb) built on a native
|
|
11
|
+
* `<button role="switch">` so no extra dependency is needed. Keyboard- and
|
|
12
|
+
* screen-reader-friendly via `aria-checked`; the visual state follows the
|
|
13
|
+
* checked prop. The optional `indeterminate` state mirrors the Checkbox
|
|
14
|
+
* tri-state contract: `aria-checked="mixed"` + `data-state="indeterminate"`,
|
|
15
|
+
* and a click resolves the mixed value to ON.
|
|
16
|
+
*/
|
|
17
|
+
function Switch({ checked, indeterminate = false, onCheckedChange, className,...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx("button", {
|
|
19
|
+
type: "button",
|
|
20
|
+
role: "switch",
|
|
21
|
+
"aria-checked": indeterminate ? "mixed" : checked,
|
|
22
|
+
"data-state": indeterminate ? "indeterminate" : checked ? "checked" : "unchecked",
|
|
23
|
+
onClick: () => onCheckedChange(indeterminate ? true : !checked),
|
|
24
|
+
className: cn("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", checked ? "bg-primary" : "bg-input", className),
|
|
25
|
+
...props,
|
|
26
|
+
children: /* @__PURE__ */ jsx("span", { className: cn("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform", indeterminate ? "translate-x-2" : checked ? "translate-x-4" : "translate-x-0") })
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Switch };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
3
|
+
|
|
4
|
+
//#region src/components/tabs.d.ts
|
|
5
|
+
declare const Tabs: React.ForwardRefExoticComponent<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
declare const TabsContent: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|