create-auto-app 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +189 -85
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/shopping-app/.context/auto-ia-scheme.json +175 -0
- package/templates/shopping-app/.context/design-system.md +118 -0
- package/templates/shopping-app/.context/figma-variables.json +14448 -0
- package/templates/shopping-app/.context/schema.graphql +46 -0
- package/templates/shopping-app/.context/schema.json +583 -0
- package/templates/shopping-app/.context/shadcn-filter.ts +31 -0
- package/templates/shopping-app/.env +8 -0
- package/templates/shopping-app/auto.config.ts +21 -0
- package/templates/shopping-app/client/auto-configure.ts +107 -0
- package/templates/shopping-app/client/codegen.ts +16 -0
- package/templates/shopping-app/client/components.json +20 -0
- package/templates/shopping-app/client/design-system-principles.md +19 -0
- package/templates/shopping-app/client/eslint.config.ts +57 -0
- package/templates/shopping-app/client/index.html +26 -0
- package/templates/shopping-app/client/package.json +100 -0
- package/templates/shopping-app/client/postcss.config.js +6 -0
- package/templates/shopping-app/client/public/favicon.ico +0 -0
- package/templates/shopping-app/client/schema.graphql +46 -0
- package/templates/shopping-app/client/src/App.css +42 -0
- package/templates/shopping-app/client/src/App.tsx +20 -0
- package/templates/shopping-app/client/src/apolloClient.ts +8 -0
- package/templates/shopping-app/client/src/components/atoms/accordion.tsx +51 -0
- package/templates/shopping-app/client/src/components/atoms/alert-dialog.tsx +111 -0
- package/templates/shopping-app/client/src/components/atoms/alert.tsx +49 -0
- package/templates/shopping-app/client/src/components/atoms/aspect-ratio.tsx +7 -0
- package/templates/shopping-app/client/src/components/atoms/avatar.tsx +32 -0
- package/templates/shopping-app/client/src/components/atoms/badge.tsx +36 -0
- package/templates/shopping-app/client/src/components/atoms/breadcrumb.tsx +92 -0
- package/templates/shopping-app/client/src/components/atoms/button.tsx +50 -0
- package/templates/shopping-app/client/src/components/atoms/calendar.tsx +156 -0
- package/templates/shopping-app/client/src/components/atoms/card.tsx +56 -0
- package/templates/shopping-app/client/src/components/atoms/carousel.tsx +214 -0
- package/templates/shopping-app/client/src/components/atoms/chart.tsx +290 -0
- package/templates/shopping-app/client/src/components/atoms/checkbox.tsx +27 -0
- package/templates/shopping-app/client/src/components/atoms/collapsible.tsx +15 -0
- package/templates/shopping-app/client/src/components/atoms/command.tsx +135 -0
- package/templates/shopping-app/client/src/components/atoms/context-menu.tsx +209 -0
- package/templates/shopping-app/client/src/components/atoms/dialog.tsx +123 -0
- package/templates/shopping-app/client/src/components/atoms/drawer.tsx +106 -0
- package/templates/shopping-app/client/src/components/atoms/dropdown-menu.tsx +217 -0
- package/templates/shopping-app/client/src/components/atoms/hover-card.tsx +36 -0
- package/templates/shopping-app/client/src/components/atoms/input-otp.tsx +66 -0
- package/templates/shopping-app/client/src/components/atoms/input.tsx +21 -0
- package/templates/shopping-app/client/src/components/atoms/label.tsx +19 -0
- package/templates/shopping-app/client/src/components/atoms/logo.tsx +33 -0
- package/templates/shopping-app/client/src/components/atoms/menubar.tsx +234 -0
- package/templates/shopping-app/client/src/components/atoms/navigation-menu.tsx +142 -0
- package/templates/shopping-app/client/src/components/atoms/pagination.tsx +100 -0
- package/templates/shopping-app/client/src/components/atoms/popover.tsx +40 -0
- package/templates/shopping-app/client/src/components/atoms/progress.tsx +22 -0
- package/templates/shopping-app/client/src/components/atoms/radio-group.tsx +31 -0
- package/templates/shopping-app/client/src/components/atoms/resizable.tsx +46 -0
- package/templates/shopping-app/client/src/components/atoms/scroll-area.tsx +46 -0
- package/templates/shopping-app/client/src/components/atoms/select.tsx +158 -0
- package/templates/shopping-app/client/src/components/atoms/separator.tsx +26 -0
- package/templates/shopping-app/client/src/components/atoms/sheet.tsx +101 -0
- package/templates/shopping-app/client/src/components/atoms/sidebar.tsx +675 -0
- package/templates/shopping-app/client/src/components/atoms/skeleton.tsx +7 -0
- package/templates/shopping-app/client/src/components/atoms/slider.tsx +54 -0
- package/templates/shopping-app/client/src/components/atoms/sonner.tsx +23 -0
- package/templates/shopping-app/client/src/components/atoms/switch.tsx +26 -0
- package/templates/shopping-app/client/src/components/atoms/table.tsx +73 -0
- package/templates/shopping-app/client/src/components/atoms/tabs.tsx +40 -0
- package/templates/shopping-app/client/src/components/atoms/textarea.tsx +18 -0
- package/templates/shopping-app/client/src/components/atoms/toggle-group.tsx +65 -0
- package/templates/shopping-app/client/src/components/atoms/toggle.tsx +39 -0
- package/templates/shopping-app/client/src/components/atoms/tooltip.tsx +48 -0
- package/templates/shopping-app/client/src/components/molecules/QuantitySelector.tsx +8 -0
- package/templates/shopping-app/client/src/components/molecules/ShoppingCriteriaForm.tsx +8 -0
- package/templates/shopping-app/client/src/components/molecules/SuggestedItemCard.tsx +10 -0
- package/templates/shopping-app/client/src/components/organisms/AssistantChatInterface.tsx +14 -0
- package/templates/shopping-app/client/src/components/organisms/PageHeader.tsx +6 -0
- package/templates/shopping-app/client/src/components/organisms/SuggestedItemsList.tsx +15 -0
- package/templates/shopping-app/client/src/gql/fragment-masking.ts +48 -0
- package/templates/shopping-app/client/src/gql/gql.ts +47 -0
- package/templates/shopping-app/client/src/gql/graphql.ts +106 -0
- package/templates/shopping-app/client/src/gql/index.ts +2 -0
- package/templates/shopping-app/client/src/graphql/mutations.ts +13 -0
- package/templates/shopping-app/client/src/graphql/queries.ts +14 -0
- package/templates/shopping-app/client/src/hooks/use-mobile.tsx +19 -0
- package/templates/shopping-app/client/src/hooks/use-toast.ts +186 -0
- package/templates/shopping-app/client/src/index.css +153 -0
- package/templates/shopping-app/client/src/lib/utils.ts +6 -0
- package/templates/shopping-app/client/src/main.tsx +5 -0
- package/templates/shopping-app/client/src/mockApolloClient.ts +93 -0
- package/templates/shopping-app/client/src/pages/AssistantChatPage.tsx +8 -0
- package/templates/shopping-app/client/src/pages/Index.tsx +10 -0
- package/templates/shopping-app/client/src/pages/NotFound.tsx +22 -0
- package/templates/shopping-app/client/src/pages/SuggestedItemsPage.tsx +8 -0
- package/templates/shopping-app/client/tailwind.config.ts +92 -0
- package/templates/shopping-app/client/tsconfig.json +49 -0
- package/templates/shopping-app/client/vite.config.ts +17 -0
- package/templates/shopping-app/flows/shopping-assistant.flow.ts +369 -0
- package/templates/shopping-app/package.json +25 -0
- package/templates/shopping-app/pnpm-workspace.yaml +2 -0
- package/templates/shopping-app/server/package.json +25 -0
- package/templates/shopping-app/server/scripts/generate-schema.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.specs.ts +46 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.ts +36 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/events.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/handle.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/mutation.resolver.ts +29 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.specs.ts +63 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.ts +49 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/register.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.specs.ts +38 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.ts +36 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/events.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/handle.ts +31 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/mutation.resolver.ts +30 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/commands.ts +8 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.specs.ts +61 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.ts +45 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/events.ts +14 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/evolve.ts +28 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/handle.ts +59 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/mutation.resolver.ts +30 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/register.ts +10 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/state.ts +47 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.specs.ts +94 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.ts +40 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/query.resolver.ts +59 -0
- package/templates/shopping-app/server/src/domain/flows/seasonal-assistant/views-suggested-items/state.ts +9 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts +10 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.js +19 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/ReadModel.ts +26 -0
- package/templates/shopping-app/server/src/domain/shared/index.d.ts +5 -0
- package/templates/shopping-app/server/src/domain/shared/index.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/index.js +5 -0
- package/templates/shopping-app/server/src/domain/shared/index.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/index.ts +4 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts +35 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.js +155 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/reactorSpecification.ts +257 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts +4 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.js +17 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/sendCommand.ts +21 -0
- package/templates/shopping-app/server/src/domain/shared/types.d.ts +19 -0
- package/templates/shopping-app/server/src/domain/shared/types.d.ts.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/types.js +39 -0
- package/templates/shopping-app/server/src/domain/shared/types.js.map +1 -0
- package/templates/shopping-app/server/src/domain/shared/types.ts +31 -0
- package/templates/shopping-app/server/src/integrations/ai-integration.ts +76 -0
- package/templates/shopping-app/server/src/integrations/cart-integration.ts +178 -0
- package/templates/shopping-app/server/src/integrations/index.ts +3 -0
- package/templates/shopping-app/server/src/integrations/product-catalogue-integration.ts +363 -0
- package/templates/shopping-app/server/src/server.ts +43 -0
- package/templates/shopping-app/server/src/utils/index.d.ts +4 -0
- package/templates/shopping-app/server/src/utils/index.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/index.js +4 -0
- package/templates/shopping-app/server/src/utils/index.js.map +1 -0
- package/templates/shopping-app/server/src/utils/index.ts +3 -0
- package/templates/shopping-app/server/src/utils/loadProjections.d.ts +3 -0
- package/templates/shopping-app/server/src/utils/loadProjections.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadProjections.js +23 -0
- package/templates/shopping-app/server/src/utils/loadProjections.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadProjections.ts +30 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts +6 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.js +28 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadRegisterFiles.ts +41 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.d.ts +5 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.d.ts.map +1 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.js +27 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.js.map +1 -0
- package/templates/shopping-app/server/src/utils/loadResolvers.ts +36 -0
- package/templates/shopping-app/server/tsconfig.json +19 -0
- package/templates/shopping-app/server/vitest.config.ts +7 -0
- package/templates/shopping-app/tsconfig.json +21 -0
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { PanelLeftIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
import { useIsMobile } from '../../hooks/use-mobile';
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
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
|
+
|
|
15
|
+
const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
|
16
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
17
|
+
const SIDEBAR_WIDTH = '16rem';
|
|
18
|
+
const SIDEBAR_WIDTH_MOBILE = '18rem';
|
|
19
|
+
const SIDEBAR_WIDTH_ICON = '3rem';
|
|
20
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
21
|
+
|
|
22
|
+
type SidebarContextProps = {
|
|
23
|
+
state: 'expanded' | 'collapsed';
|
|
24
|
+
open: boolean;
|
|
25
|
+
setOpen: (open: boolean) => void;
|
|
26
|
+
openMobile: boolean;
|
|
27
|
+
setOpenMobile: (open: boolean) => void;
|
|
28
|
+
isMobile: boolean;
|
|
29
|
+
toggleSidebar: () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const SidebarContext = React.createContext<SidebarContextProps | null>(null);
|
|
33
|
+
|
|
34
|
+
function useSidebar() {
|
|
35
|
+
const context = React.useContext(SidebarContext);
|
|
36
|
+
if (!context) {
|
|
37
|
+
throw new Error('useSidebar must be used within a SidebarProvider.');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function SidebarProvider({
|
|
44
|
+
defaultOpen = true,
|
|
45
|
+
open: openProp,
|
|
46
|
+
onOpenChange: setOpenProp,
|
|
47
|
+
className,
|
|
48
|
+
style,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}: React.ComponentProps<'div'> & {
|
|
52
|
+
defaultOpen?: boolean;
|
|
53
|
+
open?: boolean;
|
|
54
|
+
onOpenChange?: (open: boolean) => void;
|
|
55
|
+
}) {
|
|
56
|
+
const isMobile = useIsMobile();
|
|
57
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
58
|
+
|
|
59
|
+
// This is the internal state of the sidebar.
|
|
60
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
61
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
62
|
+
const open = openProp ?? _open;
|
|
63
|
+
const setOpen = React.useCallback(
|
|
64
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
65
|
+
const openState = typeof value === 'function' ? value(open) : value;
|
|
66
|
+
if (setOpenProp) {
|
|
67
|
+
setOpenProp(openState);
|
|
68
|
+
} else {
|
|
69
|
+
_setOpen(openState);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// This sets the cookie to keep the sidebar state.
|
|
73
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
74
|
+
},
|
|
75
|
+
[setOpenProp, open],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Helper to toggle the sidebar.
|
|
79
|
+
const toggleSidebar = React.useCallback(() => {
|
|
80
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
81
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
82
|
+
|
|
83
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
86
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
toggleSidebar();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
93
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
94
|
+
}, [toggleSidebar]);
|
|
95
|
+
|
|
96
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
97
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
98
|
+
const state = open ? 'expanded' : 'collapsed';
|
|
99
|
+
|
|
100
|
+
const contextValue = React.useMemo<SidebarContextProps>(
|
|
101
|
+
() => ({
|
|
102
|
+
state,
|
|
103
|
+
open,
|
|
104
|
+
setOpen,
|
|
105
|
+
isMobile,
|
|
106
|
+
openMobile,
|
|
107
|
+
setOpenMobile,
|
|
108
|
+
toggleSidebar,
|
|
109
|
+
}),
|
|
110
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<SidebarContext.Provider value={contextValue}>
|
|
115
|
+
<TooltipProvider delayDuration={0}>
|
|
116
|
+
<div
|
|
117
|
+
data-slot="sidebar-wrapper"
|
|
118
|
+
style={
|
|
119
|
+
{
|
|
120
|
+
'--sidebar-width': SIDEBAR_WIDTH,
|
|
121
|
+
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
122
|
+
...style,
|
|
123
|
+
} as React.CSSProperties
|
|
124
|
+
}
|
|
125
|
+
className={cn('group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full', className)}
|
|
126
|
+
{...props}
|
|
127
|
+
>
|
|
128
|
+
{children}
|
|
129
|
+
</div>
|
|
130
|
+
</TooltipProvider>
|
|
131
|
+
</SidebarContext.Provider>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function Sidebar({
|
|
136
|
+
side = 'left',
|
|
137
|
+
variant = 'sidebar',
|
|
138
|
+
collapsible = 'offcanvas',
|
|
139
|
+
className,
|
|
140
|
+
children,
|
|
141
|
+
...props
|
|
142
|
+
}: React.ComponentProps<'div'> & {
|
|
143
|
+
side?: 'left' | 'right';
|
|
144
|
+
variant?: 'sidebar' | 'floating' | 'inset';
|
|
145
|
+
collapsible?: 'offcanvas' | 'icon' | 'none';
|
|
146
|
+
}) {
|
|
147
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
148
|
+
|
|
149
|
+
if (collapsible === 'none') {
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
data-slot="sidebar"
|
|
153
|
+
className={cn('bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col', className)}
|
|
154
|
+
{...props}
|
|
155
|
+
>
|
|
156
|
+
{children}
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (isMobile) {
|
|
162
|
+
return (
|
|
163
|
+
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
164
|
+
<SheetContent
|
|
165
|
+
data-sidebar="sidebar"
|
|
166
|
+
data-slot="sidebar"
|
|
167
|
+
data-mobile="true"
|
|
168
|
+
className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
169
|
+
style={
|
|
170
|
+
{
|
|
171
|
+
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
172
|
+
} as React.CSSProperties
|
|
173
|
+
}
|
|
174
|
+
side={side}
|
|
175
|
+
>
|
|
176
|
+
<SheetHeader className="sr-only">
|
|
177
|
+
<SheetTitle>Sidebar</SheetTitle>
|
|
178
|
+
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
179
|
+
</SheetHeader>
|
|
180
|
+
<div className="flex h-full w-full flex-col">{children}</div>
|
|
181
|
+
</SheetContent>
|
|
182
|
+
</Sheet>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div
|
|
188
|
+
className="group peer text-sidebar-foreground hidden md:block"
|
|
189
|
+
data-state={state}
|
|
190
|
+
data-collapsible={state === 'collapsed' ? collapsible : ''}
|
|
191
|
+
data-variant={variant}
|
|
192
|
+
data-side={side}
|
|
193
|
+
data-slot="sidebar"
|
|
194
|
+
>
|
|
195
|
+
{/* This is what handles the sidebar gap on desktop */}
|
|
196
|
+
<div
|
|
197
|
+
data-slot="sidebar-gap"
|
|
198
|
+
className={cn(
|
|
199
|
+
'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
|
|
200
|
+
'group-data-[collapsible=offcanvas]:w-0',
|
|
201
|
+
'group-data-[side=right]:rotate-180',
|
|
202
|
+
variant === 'floating' || variant === 'inset'
|
|
203
|
+
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
|
|
204
|
+
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
|
|
205
|
+
)}
|
|
206
|
+
/>
|
|
207
|
+
<div
|
|
208
|
+
data-slot="sidebar-container"
|
|
209
|
+
className={cn(
|
|
210
|
+
'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',
|
|
211
|
+
side === 'left'
|
|
212
|
+
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
|
|
213
|
+
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
|
|
214
|
+
// Adjust the padding for floating and inset variants.
|
|
215
|
+
variant === 'floating' || variant === 'inset'
|
|
216
|
+
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
|
|
217
|
+
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
|
|
218
|
+
className,
|
|
219
|
+
)}
|
|
220
|
+
{...props}
|
|
221
|
+
>
|
|
222
|
+
<div
|
|
223
|
+
data-sidebar="sidebar"
|
|
224
|
+
data-slot="sidebar-inner"
|
|
225
|
+
className="bg-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"
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
|
|
235
|
+
const { toggleSidebar } = useSidebar();
|
|
236
|
+
|
|
237
|
+
return (
|
|
238
|
+
<Button
|
|
239
|
+
data-sidebar="trigger"
|
|
240
|
+
data-slot="sidebar-trigger"
|
|
241
|
+
variant="ghost"
|
|
242
|
+
size="icon"
|
|
243
|
+
className={cn('size-7', className)}
|
|
244
|
+
onClick={(event) => {
|
|
245
|
+
onClick?.(event);
|
|
246
|
+
toggleSidebar();
|
|
247
|
+
}}
|
|
248
|
+
{...props}
|
|
249
|
+
>
|
|
250
|
+
<PanelLeftIcon />
|
|
251
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
252
|
+
</Button>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
|
257
|
+
const { toggleSidebar } = useSidebar();
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<button
|
|
261
|
+
data-sidebar="rail"
|
|
262
|
+
data-slot="sidebar-rail"
|
|
263
|
+
aria-label="Toggle Sidebar"
|
|
264
|
+
tabIndex={-1}
|
|
265
|
+
onClick={toggleSidebar}
|
|
266
|
+
title="Toggle Sidebar"
|
|
267
|
+
className={cn(
|
|
268
|
+
'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',
|
|
269
|
+
'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
|
|
270
|
+
'[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
|
|
271
|
+
'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
|
|
272
|
+
'[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
|
|
273
|
+
'[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
|
|
274
|
+
className,
|
|
275
|
+
)}
|
|
276
|
+
{...props}
|
|
277
|
+
/>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
|
|
282
|
+
return (
|
|
283
|
+
<main
|
|
284
|
+
data-slot="sidebar-inset"
|
|
285
|
+
className={cn(
|
|
286
|
+
'bg-background relative flex w-full flex-1 flex-col',
|
|
287
|
+
'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',
|
|
288
|
+
className,
|
|
289
|
+
)}
|
|
290
|
+
{...props}
|
|
291
|
+
/>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
|
|
296
|
+
return (
|
|
297
|
+
<Input
|
|
298
|
+
data-slot="sidebar-input"
|
|
299
|
+
data-sidebar="input"
|
|
300
|
+
className={cn('bg-background h-8 w-full shadow-none', className)}
|
|
301
|
+
{...props}
|
|
302
|
+
/>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
307
|
+
return (
|
|
308
|
+
<div
|
|
309
|
+
data-slot="sidebar-header"
|
|
310
|
+
data-sidebar="header"
|
|
311
|
+
className={cn('flex flex-col gap-2 p-2', className)}
|
|
312
|
+
{...props}
|
|
313
|
+
/>
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
318
|
+
return (
|
|
319
|
+
<div
|
|
320
|
+
data-slot="sidebar-footer"
|
|
321
|
+
data-sidebar="footer"
|
|
322
|
+
className={cn('flex flex-col gap-2 p-2', className)}
|
|
323
|
+
{...props}
|
|
324
|
+
/>
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
|
|
329
|
+
return (
|
|
330
|
+
<Separator
|
|
331
|
+
data-slot="sidebar-separator"
|
|
332
|
+
data-sidebar="separator"
|
|
333
|
+
className={cn('bg-sidebar-border mx-2 w-auto', className)}
|
|
334
|
+
{...props}
|
|
335
|
+
/>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
340
|
+
return (
|
|
341
|
+
<div
|
|
342
|
+
data-slot="sidebar-content"
|
|
343
|
+
data-sidebar="content"
|
|
344
|
+
className={cn(
|
|
345
|
+
'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
|
|
346
|
+
className,
|
|
347
|
+
)}
|
|
348
|
+
{...props}
|
|
349
|
+
/>
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
354
|
+
return (
|
|
355
|
+
<div
|
|
356
|
+
data-slot="sidebar-group"
|
|
357
|
+
data-sidebar="group"
|
|
358
|
+
className={cn('relative flex w-full min-w-0 flex-col p-2', className)}
|
|
359
|
+
{...props}
|
|
360
|
+
/>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function SidebarGroupLabel({
|
|
365
|
+
className,
|
|
366
|
+
asChild = false,
|
|
367
|
+
...props
|
|
368
|
+
}: React.ComponentProps<'div'> & { asChild?: boolean }) {
|
|
369
|
+
const Comp = asChild ? Slot : 'div';
|
|
370
|
+
|
|
371
|
+
return (
|
|
372
|
+
<Comp
|
|
373
|
+
data-slot="sidebar-group-label"
|
|
374
|
+
data-sidebar="group-label"
|
|
375
|
+
className={cn(
|
|
376
|
+
'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',
|
|
377
|
+
'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
|
|
378
|
+
className,
|
|
379
|
+
)}
|
|
380
|
+
{...props}
|
|
381
|
+
/>
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function SidebarGroupAction({
|
|
386
|
+
className,
|
|
387
|
+
asChild = false,
|
|
388
|
+
...props
|
|
389
|
+
}: React.ComponentProps<'button'> & { asChild?: boolean }) {
|
|
390
|
+
const Comp = asChild ? Slot : 'button';
|
|
391
|
+
|
|
392
|
+
return (
|
|
393
|
+
<Comp
|
|
394
|
+
data-slot="sidebar-group-action"
|
|
395
|
+
data-sidebar="group-action"
|
|
396
|
+
className={cn(
|
|
397
|
+
'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',
|
|
398
|
+
// Increases the hit area of the button on mobile.
|
|
399
|
+
'after:absolute after:-inset-2 md:after:hidden',
|
|
400
|
+
'group-data-[collapsible=icon]:hidden',
|
|
401
|
+
className,
|
|
402
|
+
)}
|
|
403
|
+
{...props}
|
|
404
|
+
/>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
409
|
+
return (
|
|
410
|
+
<div
|
|
411
|
+
data-slot="sidebar-group-content"
|
|
412
|
+
data-sidebar="group-content"
|
|
413
|
+
className={cn('w-full text-sm', className)}
|
|
414
|
+
{...props}
|
|
415
|
+
/>
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
|
|
420
|
+
return (
|
|
421
|
+
<ul
|
|
422
|
+
data-slot="sidebar-menu"
|
|
423
|
+
data-sidebar="menu"
|
|
424
|
+
className={cn('flex w-full min-w-0 flex-col gap-1', className)}
|
|
425
|
+
{...props}
|
|
426
|
+
/>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
431
|
+
return (
|
|
432
|
+
<li
|
|
433
|
+
data-slot="sidebar-menu-item"
|
|
434
|
+
data-sidebar="menu-item"
|
|
435
|
+
className={cn('group/menu-item relative', className)}
|
|
436
|
+
{...props}
|
|
437
|
+
/>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const sidebarMenuButtonVariants = cva(
|
|
442
|
+
'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',
|
|
443
|
+
{
|
|
444
|
+
variants: {
|
|
445
|
+
variant: {
|
|
446
|
+
default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
|
447
|
+
outline:
|
|
448
|
+
'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))]',
|
|
449
|
+
},
|
|
450
|
+
size: {
|
|
451
|
+
default: 'h-8 text-sm',
|
|
452
|
+
sm: 'h-7 text-xs',
|
|
453
|
+
lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!',
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
defaultVariants: {
|
|
457
|
+
variant: 'default',
|
|
458
|
+
size: 'default',
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
);
|
|
462
|
+
|
|
463
|
+
function SidebarMenuButton({
|
|
464
|
+
asChild = false,
|
|
465
|
+
isActive = false,
|
|
466
|
+
variant = 'default',
|
|
467
|
+
size = 'default',
|
|
468
|
+
tooltip,
|
|
469
|
+
className,
|
|
470
|
+
...props
|
|
471
|
+
}: React.ComponentProps<'button'> & {
|
|
472
|
+
asChild?: boolean;
|
|
473
|
+
isActive?: boolean;
|
|
474
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
475
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
476
|
+
const Comp = asChild ? Slot : 'button';
|
|
477
|
+
const { isMobile, state } = useSidebar();
|
|
478
|
+
|
|
479
|
+
const button = (
|
|
480
|
+
<Comp
|
|
481
|
+
data-slot="sidebar-menu-button"
|
|
482
|
+
data-sidebar="menu-button"
|
|
483
|
+
data-size={size}
|
|
484
|
+
data-active={isActive}
|
|
485
|
+
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
486
|
+
{...props}
|
|
487
|
+
/>
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
if (!tooltip) {
|
|
491
|
+
return button;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (typeof tooltip === 'string') {
|
|
495
|
+
tooltip = {
|
|
496
|
+
children: tooltip,
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return (
|
|
501
|
+
<Tooltip>
|
|
502
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
503
|
+
<TooltipContent side="right" align="center" hidden={state !== 'collapsed' || isMobile} {...tooltip} />
|
|
504
|
+
</Tooltip>
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function SidebarMenuAction({
|
|
509
|
+
className,
|
|
510
|
+
asChild = false,
|
|
511
|
+
showOnHover = false,
|
|
512
|
+
...props
|
|
513
|
+
}: React.ComponentProps<'button'> & {
|
|
514
|
+
asChild?: boolean;
|
|
515
|
+
showOnHover?: boolean;
|
|
516
|
+
}) {
|
|
517
|
+
const Comp = asChild ? Slot : 'button';
|
|
518
|
+
|
|
519
|
+
return (
|
|
520
|
+
<Comp
|
|
521
|
+
data-slot="sidebar-menu-action"
|
|
522
|
+
data-sidebar="menu-action"
|
|
523
|
+
className={cn(
|
|
524
|
+
'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',
|
|
525
|
+
// Increases the hit area of the button on mobile.
|
|
526
|
+
'after:absolute after:-inset-2 md:after:hidden',
|
|
527
|
+
'peer-data-[size=sm]/menu-button:top-1',
|
|
528
|
+
'peer-data-[size=default]/menu-button:top-1.5',
|
|
529
|
+
'peer-data-[size=lg]/menu-button:top-2.5',
|
|
530
|
+
'group-data-[collapsible=icon]:hidden',
|
|
531
|
+
showOnHover &&
|
|
532
|
+
'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',
|
|
533
|
+
className,
|
|
534
|
+
)}
|
|
535
|
+
{...props}
|
|
536
|
+
/>
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
|
|
541
|
+
return (
|
|
542
|
+
<div
|
|
543
|
+
data-slot="sidebar-menu-badge"
|
|
544
|
+
data-sidebar="menu-badge"
|
|
545
|
+
className={cn(
|
|
546
|
+
'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',
|
|
547
|
+
'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
|
|
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
|
+
className,
|
|
553
|
+
)}
|
|
554
|
+
{...props}
|
|
555
|
+
/>
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function SidebarMenuSkeleton({
|
|
560
|
+
className,
|
|
561
|
+
showIcon = false,
|
|
562
|
+
...props
|
|
563
|
+
}: React.ComponentProps<'div'> & {
|
|
564
|
+
showIcon?: boolean;
|
|
565
|
+
}) {
|
|
566
|
+
// Random width between 50 to 90%.
|
|
567
|
+
const width = React.useMemo(() => {
|
|
568
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
569
|
+
}, []);
|
|
570
|
+
|
|
571
|
+
return (
|
|
572
|
+
<div
|
|
573
|
+
data-slot="sidebar-menu-skeleton"
|
|
574
|
+
data-sidebar="menu-skeleton"
|
|
575
|
+
className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}
|
|
576
|
+
{...props}
|
|
577
|
+
>
|
|
578
|
+
{showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
|
|
579
|
+
<Skeleton
|
|
580
|
+
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
581
|
+
data-sidebar="menu-skeleton-text"
|
|
582
|
+
style={
|
|
583
|
+
{
|
|
584
|
+
'--skeleton-width': width,
|
|
585
|
+
} as React.CSSProperties
|
|
586
|
+
}
|
|
587
|
+
/>
|
|
588
|
+
</div>
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
|
|
593
|
+
return (
|
|
594
|
+
<ul
|
|
595
|
+
data-slot="sidebar-menu-sub"
|
|
596
|
+
data-sidebar="menu-sub"
|
|
597
|
+
className={cn(
|
|
598
|
+
'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',
|
|
599
|
+
'group-data-[collapsible=icon]:hidden',
|
|
600
|
+
className,
|
|
601
|
+
)}
|
|
602
|
+
{...props}
|
|
603
|
+
/>
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
608
|
+
return (
|
|
609
|
+
<li
|
|
610
|
+
data-slot="sidebar-menu-sub-item"
|
|
611
|
+
data-sidebar="menu-sub-item"
|
|
612
|
+
className={cn('group/menu-sub-item relative', className)}
|
|
613
|
+
{...props}
|
|
614
|
+
/>
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function SidebarMenuSubButton({
|
|
619
|
+
asChild = false,
|
|
620
|
+
size = 'md',
|
|
621
|
+
isActive = false,
|
|
622
|
+
className,
|
|
623
|
+
...props
|
|
624
|
+
}: React.ComponentProps<'a'> & {
|
|
625
|
+
asChild?: boolean;
|
|
626
|
+
size?: 'sm' | 'md';
|
|
627
|
+
isActive?: boolean;
|
|
628
|
+
}) {
|
|
629
|
+
const Comp = asChild ? Slot : 'a';
|
|
630
|
+
|
|
631
|
+
return (
|
|
632
|
+
<Comp
|
|
633
|
+
data-slot="sidebar-menu-sub-button"
|
|
634
|
+
data-sidebar="menu-sub-button"
|
|
635
|
+
data-size={size}
|
|
636
|
+
data-active={isActive}
|
|
637
|
+
className={cn(
|
|
638
|
+
'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',
|
|
639
|
+
'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
|
|
640
|
+
size === 'sm' && 'text-xs',
|
|
641
|
+
size === 'md' && 'text-sm',
|
|
642
|
+
'group-data-[collapsible=icon]:hidden',
|
|
643
|
+
className,
|
|
644
|
+
)}
|
|
645
|
+
{...props}
|
|
646
|
+
/>
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export {
|
|
651
|
+
Sidebar,
|
|
652
|
+
SidebarContent,
|
|
653
|
+
SidebarFooter,
|
|
654
|
+
SidebarGroup,
|
|
655
|
+
SidebarGroupAction,
|
|
656
|
+
SidebarGroupContent,
|
|
657
|
+
SidebarGroupLabel,
|
|
658
|
+
SidebarHeader,
|
|
659
|
+
SidebarInput,
|
|
660
|
+
SidebarInset,
|
|
661
|
+
SidebarMenu,
|
|
662
|
+
SidebarMenuAction,
|
|
663
|
+
SidebarMenuBadge,
|
|
664
|
+
SidebarMenuButton,
|
|
665
|
+
SidebarMenuItem,
|
|
666
|
+
SidebarMenuSkeleton,
|
|
667
|
+
SidebarMenuSub,
|
|
668
|
+
SidebarMenuSubButton,
|
|
669
|
+
SidebarMenuSubItem,
|
|
670
|
+
SidebarProvider,
|
|
671
|
+
SidebarRail,
|
|
672
|
+
SidebarSeparator,
|
|
673
|
+
SidebarTrigger,
|
|
674
|
+
useSidebar,
|
|
675
|
+
};
|