@carlonicora/nextjs-jsonapi 1.0.3 → 1.0.4
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/package.json +2 -1
- package/src/atoms/index.ts +1 -0
- package/src/atoms/recentPagesAtom.ts +10 -0
- package/src/client/context/JsonApiContext.ts +61 -0
- package/src/client/context/JsonApiProvider.tsx +27 -0
- package/src/client/context/index.ts +2 -0
- package/src/client/hooks/index.ts +3 -0
- package/src/client/hooks/useJsonApiGet.ts +188 -0
- package/src/client/hooks/useJsonApiMutation.ts +193 -0
- package/src/client/hooks/useRehydration.ts +47 -0
- package/src/client/index.ts +11 -0
- package/src/client/request.ts +97 -0
- package/src/client/token.ts +10 -0
- package/src/components/containers/PageContainer.tsx +15 -0
- package/src/components/containers/ReactMarkdownContainer.tsx +119 -0
- package/src/components/containers/TabsContainer.tsx +93 -0
- package/src/components/containers/index.ts +3 -0
- package/src/components/contents/AttributeElement.tsx +20 -0
- package/src/components/contents/index.ts +1 -0
- package/src/components/details/AllowedUsersDetails.tsx +23 -0
- package/src/components/details/index.ts +1 -0
- package/src/components/editors/BlockNoteDiffInlineContent.tsx +152 -0
- package/src/components/editors/BlockNoteEditor.tsx +404 -0
- package/src/components/editors/BlockNoteEditorContainer.tsx +13 -0
- package/src/components/editors/BlockNoteEditorFormattingToolbar.tsx +38 -0
- package/src/components/editors/index.ts +1 -0
- package/src/components/errors/ErrorDetails.tsx +41 -0
- package/src/components/errors/errorToast.ts +9 -0
- package/src/components/errors/index.ts +2 -0
- package/src/components/forms/CommonAssociationForm.tsx +162 -0
- package/src/components/forms/CommonDeleter.tsx +94 -0
- package/src/components/forms/CommonEditorButtons.tsx +30 -0
- package/src/components/forms/CommonEditorHeader.tsx +35 -0
- package/src/components/forms/CommonEditorTrigger.tsx +26 -0
- package/src/components/forms/DatePickerPopover.tsx +219 -0
- package/src/components/forms/DateRangeSelector.tsx +110 -0
- package/src/components/forms/FileUploader.tsx +324 -0
- package/src/components/forms/FormCheckbox.tsx +66 -0
- package/src/components/forms/FormContainerGeneric.tsx +39 -0
- package/src/components/forms/FormDate.tsx +247 -0
- package/src/components/forms/FormDateTime.tsx +231 -0
- package/src/components/forms/FormInput.tsx +110 -0
- package/src/components/forms/FormPassword.tsx +54 -0
- package/src/components/forms/FormPlaceAutocomplete.tsx +286 -0
- package/src/components/forms/FormSelect.tsx +72 -0
- package/src/components/forms/FormSlider.tsx +51 -0
- package/src/components/forms/FormSwitch.tsx +25 -0
- package/src/components/forms/FormTextarea.tsx +44 -0
- package/src/components/forms/MultiFileUploader.tsx +107 -0
- package/src/components/forms/PasswordInput.tsx +47 -0
- package/src/components/forms/index.ts +21 -0
- package/src/components/index.ts +11 -0
- package/src/components/navigations/Breadcrumb.tsx +83 -0
- package/src/components/navigations/ContentTitle.tsx +39 -0
- package/src/components/navigations/Header.tsx +27 -0
- package/src/components/navigations/ModeToggleSwitch.tsx +25 -0
- package/src/components/navigations/PageSection.tsx +64 -0
- package/src/components/navigations/RecentPagesNavigator.tsx +52 -0
- package/src/components/navigations/index.ts +6 -0
- package/src/components/pages/PageContainerContentDetails.tsx +76 -0
- package/src/components/pages/PageContentContainer.tsx +31 -0
- package/src/components/pages/index.ts +2 -0
- package/src/components/tables/ContentListTable.tsx +165 -0
- package/src/components/tables/ContentTableSearch.tsx +105 -0
- package/src/components/tables/cells/cell.component.tsx +18 -0
- package/src/components/tables/cells/cell.date.tsx +16 -0
- package/src/components/tables/cells/cell.id.tsx +27 -0
- package/src/components/tables/cells/cell.link.tsx +18 -0
- package/src/components/tables/cells/cell.text.tsx +12 -0
- package/src/components/tables/cells/cell.url.tsx +13 -0
- package/src/components/tables/cells/index.ts +5 -0
- package/src/components/tables/index.ts +3 -0
- package/src/contexts/SharedContext.tsx +35 -0
- package/src/contexts/index.ts +2 -0
- package/src/core/abstracts/AbstractApiData.ts +138 -0
- package/src/core/abstracts/AbstractService.ts +263 -0
- package/src/core/abstracts/index.ts +2 -0
- package/src/core/endpoint/EndpointCreator.ts +97 -0
- package/src/core/endpoint/index.ts +1 -0
- package/src/core/factories/JsonApiDataFactory.ts +12 -0
- package/src/core/factories/RehydrationFactory.ts +30 -0
- package/src/core/factories/index.ts +2 -0
- package/src/core/fields/FieldSelector.ts +15 -0
- package/src/core/fields/index.ts +1 -0
- package/src/core/index.ts +20 -0
- package/src/core/interfaces/ApiData.ts +8 -0
- package/src/core/interfaces/ApiDataInterface.ts +15 -0
- package/src/core/interfaces/ApiRequestDataTypeInterface.ts +14 -0
- package/src/core/interfaces/ApiResponseInterface.ts +17 -0
- package/src/core/interfaces/JsonApiHydratedDataInterface.ts +5 -0
- package/src/core/interfaces/index.ts +5 -0
- package/src/core/registry/DataClassRegistry.ts +51 -0
- package/src/core/registry/ModuleRegistrar.ts +43 -0
- package/src/core/registry/ModuleRegistry.ts +64 -0
- package/src/core/registry/index.ts +3 -0
- package/src/core/utils/index.ts +2 -0
- package/src/core/utils/rehydrate.ts +24 -0
- package/src/core/utils/translateResponse.ts +125 -0
- package/src/features/auth/auth.module.ts +9 -0
- package/src/features/auth/config.ts +57 -0
- package/src/features/auth/data/auth.interface.ts +31 -0
- package/src/features/auth/data/auth.service.ts +159 -0
- package/src/features/auth/data/auth.ts +54 -0
- package/src/features/auth/data/index.ts +3 -0
- package/src/features/auth/index.ts +3 -0
- package/src/features/company/company.module.ts +10 -0
- package/src/features/company/data/company.fields.ts +6 -0
- package/src/features/company/data/company.interface.ts +28 -0
- package/src/features/company/data/company.service.ts +73 -0
- package/src/features/company/data/company.ts +104 -0
- package/src/features/company/data/index.ts +4 -0
- package/src/features/company/index.ts +2 -0
- package/src/features/content/content.module.ts +20 -0
- package/src/features/content/data/content.fields.ts +13 -0
- package/src/features/content/data/content.interface.ts +23 -0
- package/src/features/content/data/content.service.ts +75 -0
- package/src/features/content/data/content.ts +85 -0
- package/src/features/content/data/index.ts +4 -0
- package/src/features/content/index.ts +2 -0
- package/src/features/feature/components/forms/FormFeatures.tsx +149 -0
- package/src/features/feature/components/index.ts +1 -0
- package/src/features/feature/data/feature.interface.ts +9 -0
- package/src/features/feature/data/feature.service.ts +19 -0
- package/src/features/feature/data/feature.ts +33 -0
- package/src/features/feature/data/index.ts +3 -0
- package/src/features/feature/feature.module.ts +10 -0
- package/src/features/feature/index.ts +3 -0
- package/src/features/index.ts +12 -0
- package/src/features/module/data/index.ts +2 -0
- package/src/features/module/data/module.interface.ts +12 -0
- package/src/features/module/data/module.ts +42 -0
- package/src/features/module/index.ts +2 -0
- package/src/features/module/module.module.ts +10 -0
- package/src/features/notification/data/index.ts +4 -0
- package/src/features/notification/data/notification.fields.ts +8 -0
- package/src/features/notification/data/notification.interface.ts +14 -0
- package/src/features/notification/data/notification.service.ts +34 -0
- package/src/features/notification/data/notification.ts +51 -0
- package/src/features/notification/index.ts +2 -0
- package/src/features/notification/notification.module.ts +10 -0
- package/src/features/push/data/index.ts +3 -0
- package/src/features/push/data/push.interface.ts +8 -0
- package/src/features/push/data/push.service.ts +17 -0
- package/src/features/push/data/push.ts +18 -0
- package/src/features/push/index.ts +2 -0
- package/src/features/push/push.module.ts +10 -0
- package/src/features/role/data/index.ts +4 -0
- package/src/features/role/data/role.fields.ts +8 -0
- package/src/features/role/data/role.interface.ts +16 -0
- package/src/features/role/data/role.service.ts +117 -0
- package/src/features/role/data/role.ts +62 -0
- package/src/features/role/index.ts +2 -0
- package/src/features/role/role.module.ts +10 -0
- package/src/features/s3/data/index.ts +3 -0
- package/src/features/s3/data/s3.interface.ts +11 -0
- package/src/features/s3/data/s3.service.ts +30 -0
- package/src/features/s3/data/s3.ts +60 -0
- package/src/features/s3/index.ts +2 -0
- package/src/features/s3/s3.module.ts +10 -0
- package/src/features/search/index.ts +1 -0
- package/src/features/search/interfaces/index.ts +1 -0
- package/src/features/search/interfaces/search.result.interface.ts +3 -0
- package/src/features/user/author.module.ts +10 -0
- package/src/features/user/components/index.ts +2 -0
- package/src/features/user/components/lists/ContributorsList.tsx +41 -0
- package/src/features/user/components/lists/index.ts +1 -0
- package/src/features/user/components/widgets/UserAvatar.tsx +86 -0
- package/src/features/user/components/widgets/index.ts +1 -0
- package/src/features/user/contexts/CurrentUserContext.tsx +156 -0
- package/src/features/user/contexts/index.ts +1 -0
- package/src/features/user/data/index.ts +4 -0
- package/src/features/user/data/user.fields.ts +8 -0
- package/src/features/user/data/user.interface.ts +41 -0
- package/src/features/user/data/user.service.ts +246 -0
- package/src/features/user/data/user.ts +162 -0
- package/src/features/user/index.ts +4 -0
- package/src/features/user/user.module.ts +21 -0
- package/src/hooks/TableGeneratorRegistry.ts +53 -0
- package/src/hooks/index.ts +33 -0
- package/src/hooks/types.ts +35 -0
- package/src/hooks/url.rewriter.ts +22 -0
- package/src/hooks/useCustomD3Graph.tsx +705 -0
- package/src/hooks/useDataListRetriever.ts +349 -0
- package/src/hooks/useDebounce.ts +33 -0
- package/src/hooks/usePageUrlGenerator.ts +50 -0
- package/src/hooks/useTableGenerator.ts +16 -0
- package/src/i18n/config.ts +73 -0
- package/src/i18n/index.ts +18 -0
- package/src/index.ts +16 -0
- package/src/interfaces/breadcrumb.item.data.interface.ts +4 -0
- package/src/interfaces/d3.link.interface.ts +7 -0
- package/src/interfaces/d3.node.interface.ts +12 -0
- package/src/interfaces/index.ts +3 -0
- package/src/permissions/check.ts +127 -0
- package/src/permissions/index.ts +2 -0
- package/src/permissions/types.ts +109 -0
- package/src/roles/config.ts +46 -0
- package/src/roles/index.ts +1 -0
- package/src/server/cache.ts +28 -0
- package/src/server/index.ts +3 -0
- package/src/server/request.ts +113 -0
- package/src/server/token.ts +10 -0
- package/src/shadcnui/custom/kanban.tsx +1001 -0
- package/src/shadcnui/custom/link.tsx +18 -0
- package/src/shadcnui/custom/multi-select.tsx +382 -0
- package/src/shadcnui/index.ts +49 -0
- package/src/shadcnui/ui/accordion.tsx +52 -0
- package/src/shadcnui/ui/alert-dialog.tsx +141 -0
- package/src/shadcnui/ui/alert.tsx +43 -0
- package/src/shadcnui/ui/avatar.tsx +50 -0
- package/src/shadcnui/ui/badge.tsx +40 -0
- package/src/shadcnui/ui/breadcrumb.tsx +115 -0
- package/src/shadcnui/ui/button.tsx +51 -0
- package/src/shadcnui/ui/calendar.tsx +73 -0
- package/src/shadcnui/ui/card.tsx +43 -0
- package/src/shadcnui/ui/carousel.tsx +225 -0
- package/src/shadcnui/ui/chart.tsx +320 -0
- package/src/shadcnui/ui/checkbox.tsx +29 -0
- package/src/shadcnui/ui/collapsible.tsx +11 -0
- package/src/shadcnui/ui/command.tsx +155 -0
- package/src/shadcnui/ui/context-menu.tsx +179 -0
- package/src/shadcnui/ui/dialog.tsx +96 -0
- package/src/shadcnui/ui/drawer.tsx +89 -0
- package/src/shadcnui/ui/dropdown-menu.tsx +205 -0
- package/src/shadcnui/ui/form.tsx +138 -0
- package/src/shadcnui/ui/hover-card.tsx +29 -0
- package/src/shadcnui/ui/input.tsx +21 -0
- package/src/shadcnui/ui/label.tsx +26 -0
- package/src/shadcnui/ui/navigation-menu.tsx +168 -0
- package/src/shadcnui/ui/popover.tsx +33 -0
- package/src/shadcnui/ui/progress.tsx +25 -0
- package/src/shadcnui/ui/radio-group.tsx +37 -0
- package/src/shadcnui/ui/resizable.tsx +47 -0
- package/src/shadcnui/ui/scroll-area.tsx +40 -0
- package/src/shadcnui/ui/select.tsx +164 -0
- package/src/shadcnui/ui/separator.tsx +28 -0
- package/src/shadcnui/ui/sheet.tsx +139 -0
- package/src/shadcnui/ui/sidebar.tsx +677 -0
- package/src/shadcnui/ui/skeleton.tsx +13 -0
- package/src/shadcnui/ui/slider.tsx +25 -0
- package/src/shadcnui/ui/sonner.tsx +25 -0
- package/src/shadcnui/ui/switch.tsx +31 -0
- package/src/shadcnui/ui/table.tsx +120 -0
- package/src/shadcnui/ui/tabs.tsx +55 -0
- package/src/shadcnui/ui/textarea.tsx +24 -0
- package/src/shadcnui/ui/toggle.tsx +39 -0
- package/src/shadcnui/ui/tooltip.tsx +61 -0
- package/src/unified/JsonApiRequest.ts +325 -0
- package/src/unified/index.ts +1 -0
- package/src/utils/blocknote-diff.util.ts +815 -0
- package/src/utils/blocknote-word-diff-renderer.util.ts +413 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/compose-refs.ts +61 -0
- package/src/utils/date-formatter.ts +53 -0
- package/src/utils/exists.ts +7 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/schemas/entity.object.schema.ts +8 -0
- package/src/utils/schemas/index.ts +2 -0
- package/src/utils/schemas/user.object.schema.ts +9 -0
- package/src/utils/table-options.ts +67 -0
- package/src/utils/use-mobile.tsx +21 -0
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva, VariantProps } from "class-variance-authority";
|
|
5
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
import { Button } from "./button";
|
|
9
|
+
import { Input } from "./input";
|
|
10
|
+
import { Separator } from "./separator";
|
|
11
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "./sheet";
|
|
12
|
+
import { Skeleton } from "./skeleton";
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip";
|
|
14
|
+
import { useIsMobile } from "../../utils/use-mobile";
|
|
15
|
+
import { cn } from "../../utils/cn";
|
|
16
|
+
|
|
17
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
18
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
19
|
+
export const SIDEBAR_WIDTH = "16rem";
|
|
20
|
+
export const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
21
|
+
export const SIDEBAR_WIDTH_ICON = "3rem";
|
|
22
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "";
|
|
23
|
+
|
|
24
|
+
type SidebarContextProps = {
|
|
25
|
+
state: "expanded" | "collapsed";
|
|
26
|
+
open: boolean;
|
|
27
|
+
setOpen: (open: boolean) => void;
|
|
28
|
+
openMobile: boolean;
|
|
29
|
+
setOpenMobile: (open: boolean) => void;
|
|
30
|
+
isMobile: boolean;
|
|
31
|
+
toggleSidebar: () => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const SidebarContext = React.createContext<SidebarContextProps | null>(null);
|
|
35
|
+
|
|
36
|
+
function useSidebar() {
|
|
37
|
+
const context = React.useContext(SidebarContext);
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function SidebarProvider({
|
|
46
|
+
defaultOpen = true,
|
|
47
|
+
open: openProp,
|
|
48
|
+
onOpenChange: setOpenProp,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<"div"> & {
|
|
54
|
+
defaultOpen?: boolean;
|
|
55
|
+
open?: boolean;
|
|
56
|
+
onOpenChange?: (open: boolean) => void;
|
|
57
|
+
}) {
|
|
58
|
+
const isMobile = useIsMobile();
|
|
59
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
60
|
+
|
|
61
|
+
// This is the internal state of the sidebar.
|
|
62
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
63
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
64
|
+
const open = openProp ?? _open;
|
|
65
|
+
const setOpen = React.useCallback(
|
|
66
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
67
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
68
|
+
if (setOpenProp) {
|
|
69
|
+
setOpenProp(openState);
|
|
70
|
+
} else {
|
|
71
|
+
_setOpen(openState);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// This sets the cookie to keep the sidebar state.
|
|
75
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
76
|
+
},
|
|
77
|
+
[setOpenProp, open],
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Helper to toggle the sidebar.
|
|
81
|
+
const toggleSidebar = React.useCallback(() => {
|
|
82
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
83
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
84
|
+
|
|
85
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
88
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
toggleSidebar();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
95
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
96
|
+
}, [toggleSidebar]);
|
|
97
|
+
|
|
98
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
99
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
100
|
+
const state = open ? "expanded" : "collapsed";
|
|
101
|
+
|
|
102
|
+
const contextValue = React.useMemo<SidebarContextProps>(
|
|
103
|
+
() => ({
|
|
104
|
+
state,
|
|
105
|
+
open,
|
|
106
|
+
setOpen,
|
|
107
|
+
isMobile,
|
|
108
|
+
openMobile,
|
|
109
|
+
setOpenMobile,
|
|
110
|
+
toggleSidebar,
|
|
111
|
+
}),
|
|
112
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<SidebarContext.Provider value={contextValue}>
|
|
117
|
+
<TooltipProvider delayDuration={0}>
|
|
118
|
+
<div
|
|
119
|
+
data-slot="sidebar-wrapper"
|
|
120
|
+
style={
|
|
121
|
+
{
|
|
122
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
123
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
124
|
+
...style,
|
|
125
|
+
} as React.CSSProperties
|
|
126
|
+
}
|
|
127
|
+
className={cn("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", className)}
|
|
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
|
+
}: React.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("bg-sidebar text-sidebar-foreground 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-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
171
|
+
style={
|
|
172
|
+
{
|
|
173
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
174
|
+
} as React.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 text-sidebar-foreground 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
|
+
{/* This is what handles the sidebar gap on desktop */}
|
|
198
|
+
<div
|
|
199
|
+
data-slot="sidebar-gap"
|
|
200
|
+
className={cn(
|
|
201
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
202
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
203
|
+
"group-data-[side=right]:rotate-180",
|
|
204
|
+
variant === "floating" || variant === "inset"
|
|
205
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
206
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
207
|
+
)}
|
|
208
|
+
/>
|
|
209
|
+
<div
|
|
210
|
+
data-slot="sidebar-container"
|
|
211
|
+
className={cn(
|
|
212
|
+
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
213
|
+
side === "left"
|
|
214
|
+
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
215
|
+
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
216
|
+
// Adjust the padding for floating and inset variants.
|
|
217
|
+
variant === "floating" || variant === "inset"
|
|
218
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
219
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
220
|
+
className,
|
|
221
|
+
)}
|
|
222
|
+
{...props}
|
|
223
|
+
>
|
|
224
|
+
<div
|
|
225
|
+
data-sidebar="sidebar"
|
|
226
|
+
data-slot="sidebar-inner"
|
|
227
|
+
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-sm"
|
|
228
|
+
>
|
|
229
|
+
{children}
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
|
|
237
|
+
const { toggleSidebar } = useSidebar();
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<Button
|
|
241
|
+
data-sidebar="trigger"
|
|
242
|
+
data-slot="sidebar-trigger"
|
|
243
|
+
variant="ghost"
|
|
244
|
+
size="icon"
|
|
245
|
+
className={cn("size-7", className)}
|
|
246
|
+
onClick={(event) => {
|
|
247
|
+
onClick?.(event);
|
|
248
|
+
toggleSidebar();
|
|
249
|
+
}}
|
|
250
|
+
{...props}
|
|
251
|
+
>
|
|
252
|
+
<PanelLeftIcon />
|
|
253
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
254
|
+
</Button>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
|
259
|
+
const { toggleSidebar } = useSidebar();
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<button
|
|
263
|
+
data-sidebar="rail"
|
|
264
|
+
data-slot="sidebar-rail"
|
|
265
|
+
aria-label="Toggle Sidebar"
|
|
266
|
+
tabIndex={-1}
|
|
267
|
+
onClick={toggleSidebar}
|
|
268
|
+
title="Toggle Sidebar"
|
|
269
|
+
className={cn(
|
|
270
|
+
"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",
|
|
271
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
272
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
273
|
+
"hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
|
|
274
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
275
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
276
|
+
className,
|
|
277
|
+
)}
|
|
278
|
+
{...props}
|
|
279
|
+
/>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
|
284
|
+
return (
|
|
285
|
+
<main
|
|
286
|
+
data-slot="sidebar-inset"
|
|
287
|
+
className={cn(
|
|
288
|
+
"bg-background relative flex w-full flex-1 flex-col",
|
|
289
|
+
"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",
|
|
290
|
+
className,
|
|
291
|
+
)}
|
|
292
|
+
{...props}
|
|
293
|
+
/>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
|
|
298
|
+
return (
|
|
299
|
+
<Input
|
|
300
|
+
data-slot="sidebar-input"
|
|
301
|
+
data-sidebar="input"
|
|
302
|
+
className={cn("bg-background h-8 w-full shadow-none", className)}
|
|
303
|
+
{...props}
|
|
304
|
+
/>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
309
|
+
return (
|
|
310
|
+
<div
|
|
311
|
+
data-slot="sidebar-header"
|
|
312
|
+
data-sidebar="header"
|
|
313
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
314
|
+
{...props}
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
320
|
+
return (
|
|
321
|
+
<div
|
|
322
|
+
data-slot="sidebar-footer"
|
|
323
|
+
data-sidebar="footer"
|
|
324
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
325
|
+
{...props}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
|
|
331
|
+
return (
|
|
332
|
+
<Separator
|
|
333
|
+
data-slot="sidebar-separator"
|
|
334
|
+
data-sidebar="separator"
|
|
335
|
+
className={cn("bg-sidebar-border mx-2 w-auto", className)}
|
|
336
|
+
{...props}
|
|
337
|
+
/>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
342
|
+
return (
|
|
343
|
+
<div
|
|
344
|
+
data-slot="sidebar-content"
|
|
345
|
+
data-sidebar="content"
|
|
346
|
+
className={cn(
|
|
347
|
+
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
348
|
+
className,
|
|
349
|
+
)}
|
|
350
|
+
{...props}
|
|
351
|
+
/>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
356
|
+
return (
|
|
357
|
+
<div
|
|
358
|
+
data-slot="sidebar-group"
|
|
359
|
+
data-sidebar="group"
|
|
360
|
+
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
361
|
+
{...props}
|
|
362
|
+
/>
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function SidebarGroupLabel({
|
|
367
|
+
className,
|
|
368
|
+
asChild = false,
|
|
369
|
+
...props
|
|
370
|
+
}: React.ComponentProps<"div"> & { asChild?: boolean }) {
|
|
371
|
+
const Comp = asChild ? Slot : "div";
|
|
372
|
+
|
|
373
|
+
return (
|
|
374
|
+
<Comp
|
|
375
|
+
data-slot="sidebar-group-label"
|
|
376
|
+
data-sidebar="group-label"
|
|
377
|
+
className={cn(
|
|
378
|
+
"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",
|
|
379
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
380
|
+
className,
|
|
381
|
+
)}
|
|
382
|
+
{...props}
|
|
383
|
+
/>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function SidebarGroupAction({
|
|
388
|
+
className,
|
|
389
|
+
asChild = false,
|
|
390
|
+
...props
|
|
391
|
+
}: React.ComponentProps<"button"> & { asChild?: boolean }) {
|
|
392
|
+
const Comp = asChild ? Slot : "button";
|
|
393
|
+
|
|
394
|
+
return (
|
|
395
|
+
<Comp
|
|
396
|
+
data-slot="sidebar-group-action"
|
|
397
|
+
data-sidebar="group-action"
|
|
398
|
+
className={cn(
|
|
399
|
+
"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",
|
|
400
|
+
// Increases the hit area of the button on mobile.
|
|
401
|
+
"after:absolute after:-inset-2 md:after:hidden",
|
|
402
|
+
"group-data-[collapsible=icon]:hidden",
|
|
403
|
+
className,
|
|
404
|
+
)}
|
|
405
|
+
{...props}
|
|
406
|
+
/>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
411
|
+
return (
|
|
412
|
+
<div
|
|
413
|
+
data-slot="sidebar-group-content"
|
|
414
|
+
data-sidebar="group-content"
|
|
415
|
+
className={cn("w-full text-sm", className)}
|
|
416
|
+
{...props}
|
|
417
|
+
/>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
|
422
|
+
return (
|
|
423
|
+
<ul
|
|
424
|
+
data-slot="sidebar-menu"
|
|
425
|
+
data-sidebar="menu"
|
|
426
|
+
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
427
|
+
{...props}
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
433
|
+
return (
|
|
434
|
+
<li
|
|
435
|
+
data-slot="sidebar-menu-item"
|
|
436
|
+
data-sidebar="menu-item"
|
|
437
|
+
className={cn("group/menu-item relative", className)}
|
|
438
|
+
{...props}
|
|
439
|
+
/>
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const sidebarMenuButtonVariants = cva(
|
|
444
|
+
"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] 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",
|
|
445
|
+
{
|
|
446
|
+
variants: {
|
|
447
|
+
variant: {
|
|
448
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
449
|
+
outline:
|
|
450
|
+
"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
|
|
451
|
+
},
|
|
452
|
+
size: {
|
|
453
|
+
default: "h-8 text-sm",
|
|
454
|
+
sm: "h-7 text-xs",
|
|
455
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
defaultVariants: {
|
|
459
|
+
variant: "default",
|
|
460
|
+
size: "default",
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
function SidebarMenuButton({
|
|
466
|
+
asChild = false,
|
|
467
|
+
isActive = false,
|
|
468
|
+
variant = "default",
|
|
469
|
+
size = "default",
|
|
470
|
+
tooltip,
|
|
471
|
+
className,
|
|
472
|
+
...props
|
|
473
|
+
}: React.ComponentProps<"button"> & {
|
|
474
|
+
asChild?: boolean;
|
|
475
|
+
isActive?: boolean;
|
|
476
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
477
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
478
|
+
const Comp = asChild ? Slot : "button";
|
|
479
|
+
const { isMobile, state } = useSidebar();
|
|
480
|
+
|
|
481
|
+
const button = (
|
|
482
|
+
<Comp
|
|
483
|
+
data-slot="sidebar-menu-button"
|
|
484
|
+
data-sidebar="menu-button"
|
|
485
|
+
data-size={size}
|
|
486
|
+
data-active={isActive}
|
|
487
|
+
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
488
|
+
{...props}
|
|
489
|
+
/>
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
if (!tooltip) {
|
|
493
|
+
return button;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (typeof tooltip === "string") {
|
|
497
|
+
tooltip = {
|
|
498
|
+
children: tooltip,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return (
|
|
503
|
+
<Tooltip>
|
|
504
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
505
|
+
<TooltipContent side="right" align="center" hidden={state !== "collapsed" || isMobile} {...tooltip} />
|
|
506
|
+
</Tooltip>
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function SidebarMenuAction({
|
|
511
|
+
className,
|
|
512
|
+
asChild = false,
|
|
513
|
+
showOnHover = false,
|
|
514
|
+
...props
|
|
515
|
+
}: React.ComponentProps<"button"> & {
|
|
516
|
+
asChild?: boolean;
|
|
517
|
+
showOnHover?: boolean;
|
|
518
|
+
}) {
|
|
519
|
+
const Comp = asChild ? Slot : "button";
|
|
520
|
+
|
|
521
|
+
return (
|
|
522
|
+
<Comp
|
|
523
|
+
data-slot="sidebar-menu-action"
|
|
524
|
+
data-sidebar="menu-action"
|
|
525
|
+
className={cn(
|
|
526
|
+
"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",
|
|
527
|
+
// Increases the hit area of the button on mobile.
|
|
528
|
+
"after:absolute after:-inset-2 md:after:hidden",
|
|
529
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
530
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
531
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
532
|
+
"group-data-[collapsible=icon]:hidden",
|
|
533
|
+
showOnHover &&
|
|
534
|
+
"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",
|
|
535
|
+
className,
|
|
536
|
+
)}
|
|
537
|
+
{...props}
|
|
538
|
+
/>
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">) {
|
|
543
|
+
return (
|
|
544
|
+
<div
|
|
545
|
+
data-slot="sidebar-menu-badge"
|
|
546
|
+
data-sidebar="menu-badge"
|
|
547
|
+
className={cn(
|
|
548
|
+
"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",
|
|
549
|
+
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
|
550
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
551
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
552
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
553
|
+
"group-data-[collapsible=icon]:hidden",
|
|
554
|
+
className,
|
|
555
|
+
)}
|
|
556
|
+
{...props}
|
|
557
|
+
/>
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function SidebarMenuSkeleton({
|
|
562
|
+
className,
|
|
563
|
+
showIcon = false,
|
|
564
|
+
...props
|
|
565
|
+
}: React.ComponentProps<"div"> & {
|
|
566
|
+
showIcon?: boolean;
|
|
567
|
+
}) {
|
|
568
|
+
// Random width between 50 to 90%.
|
|
569
|
+
const width = React.useMemo(() => {
|
|
570
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
571
|
+
}, []);
|
|
572
|
+
|
|
573
|
+
return (
|
|
574
|
+
<div
|
|
575
|
+
data-slot="sidebar-menu-skeleton"
|
|
576
|
+
data-sidebar="menu-skeleton"
|
|
577
|
+
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
|
578
|
+
{...props}
|
|
579
|
+
>
|
|
580
|
+
{showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
|
|
581
|
+
<Skeleton
|
|
582
|
+
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
583
|
+
data-sidebar="menu-skeleton-text"
|
|
584
|
+
style={
|
|
585
|
+
{
|
|
586
|
+
"--skeleton-width": width,
|
|
587
|
+
} as React.CSSProperties
|
|
588
|
+
}
|
|
589
|
+
/>
|
|
590
|
+
</div>
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
|
595
|
+
return (
|
|
596
|
+
<ul
|
|
597
|
+
data-slot="sidebar-menu-sub"
|
|
598
|
+
data-sidebar="menu-sub"
|
|
599
|
+
className={cn(
|
|
600
|
+
"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",
|
|
601
|
+
"group-data-[collapsible=icon]:hidden",
|
|
602
|
+
className,
|
|
603
|
+
)}
|
|
604
|
+
{...props}
|
|
605
|
+
/>
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
610
|
+
return (
|
|
611
|
+
<li
|
|
612
|
+
data-slot="sidebar-menu-sub-item"
|
|
613
|
+
data-sidebar="menu-sub-item"
|
|
614
|
+
className={cn("group/menu-sub-item relative", className)}
|
|
615
|
+
{...props}
|
|
616
|
+
/>
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function SidebarMenuSubButton({
|
|
621
|
+
asChild = false,
|
|
622
|
+
size = "md",
|
|
623
|
+
isActive = false,
|
|
624
|
+
className,
|
|
625
|
+
...props
|
|
626
|
+
}: React.ComponentProps<"a"> & {
|
|
627
|
+
asChild?: boolean;
|
|
628
|
+
size?: "sm" | "md";
|
|
629
|
+
isActive?: boolean;
|
|
630
|
+
}) {
|
|
631
|
+
const Comp = asChild ? Slot : "a";
|
|
632
|
+
|
|
633
|
+
return (
|
|
634
|
+
<Comp
|
|
635
|
+
data-slot="sidebar-menu-sub-button"
|
|
636
|
+
data-sidebar="menu-sub-button"
|
|
637
|
+
data-size={size}
|
|
638
|
+
data-active={isActive}
|
|
639
|
+
className={cn(
|
|
640
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 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-4 [&>svg]:shrink-0",
|
|
641
|
+
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
642
|
+
size === "sm" && "text-xs",
|
|
643
|
+
size === "md" && "text-sm",
|
|
644
|
+
"group-data-[collapsible=icon]:hidden",
|
|
645
|
+
className,
|
|
646
|
+
)}
|
|
647
|
+
{...props}
|
|
648
|
+
/>
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export {
|
|
653
|
+
Sidebar,
|
|
654
|
+
SidebarContent,
|
|
655
|
+
SidebarFooter,
|
|
656
|
+
SidebarGroup,
|
|
657
|
+
SidebarGroupAction,
|
|
658
|
+
SidebarGroupContent,
|
|
659
|
+
SidebarGroupLabel,
|
|
660
|
+
SidebarHeader,
|
|
661
|
+
SidebarInput,
|
|
662
|
+
SidebarInset,
|
|
663
|
+
SidebarMenu,
|
|
664
|
+
SidebarMenuAction,
|
|
665
|
+
SidebarMenuBadge,
|
|
666
|
+
SidebarMenuButton,
|
|
667
|
+
SidebarMenuItem,
|
|
668
|
+
SidebarMenuSkeleton,
|
|
669
|
+
SidebarMenuSub,
|
|
670
|
+
SidebarMenuSubButton,
|
|
671
|
+
SidebarMenuSubItem,
|
|
672
|
+
SidebarProvider,
|
|
673
|
+
SidebarRail,
|
|
674
|
+
SidebarSeparator,
|
|
675
|
+
SidebarTrigger,
|
|
676
|
+
useSidebar,
|
|
677
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "../../utils/cn"
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton }
|