@phsa.tec/design-system-react 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +390 -209
- package/dist/index.d.mts +485 -0
- package/dist/index.d.ts +485 -0
- package/dist/index.js +4259 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4186 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -6
- package/.eslintrc.json +0 -7
- package/.github/workflows/deploy-storybook.yml +0 -75
- package/.storybook/main.ts +0 -16
- package/.storybook/preview.ts +0 -15
- package/components.json +0 -21
- package/jest.config.ts +0 -25
- package/next.config.ts +0 -7
- package/postcss.config.mjs +0 -8
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/src/app/columns.tsx +0 -178
- package/src/app/favicon.ico +0 -0
- package/src/app/fonts/GeistMonoVF.woff +0 -0
- package/src/app/fonts/GeistVF.woff +0 -0
- package/src/app/globals.css +0 -94
- package/src/app/layout.tsx +0 -35
- package/src/app/page.tsx +0 -7
- package/src/components/actions/AlertDialog/AlertDialog.tsx +0 -45
- package/src/components/actions/AlertDialog/alert-dialog.stories.tsx +0 -21
- package/src/components/actions/AlertDialog/index.ts +0 -1
- package/src/components/actions/Button/Button.stories.ts +0 -38
- package/src/components/actions/Button/Button.tsx +0 -23
- package/src/components/actions/Button/index.ts +0 -1
- package/src/components/actions/Collapsible/index.ts +0 -1
- package/src/components/actions/Dialog/Dialog.stories.tsx +0 -70
- package/src/components/actions/Dialog/Dialog.tsx +0 -87
- package/src/components/actions/Dialog/components/DialogWithActions/index.tsx +0 -40
- package/src/components/actions/Dialog/index.ts +0 -1
- package/src/components/actions/Steps/Steps.stories.tsx +0 -25
- package/src/components/actions/Steps/Steps.tsx +0 -51
- package/src/components/actions/Steps/index.ts +0 -1
- package/src/components/actions/index.ts +0 -5
- package/src/components/dataDisplay/Avatar/Avatar.stories.tsx +0 -22
- package/src/components/dataDisplay/Avatar/Avatar.tsx +0 -21
- package/src/components/dataDisplay/Avatar/index.ts +0 -2
- package/src/components/dataDisplay/Badge/Badge.stories.tsx +0 -36
- package/src/components/dataDisplay/Badge/index.ts +0 -1
- package/src/components/dataDisplay/Card/Card.stories.tsx +0 -24
- package/src/components/dataDisplay/Card/Card.tsx +0 -34
- package/src/components/dataDisplay/Card/index.ts +0 -1
- package/src/components/dataDisplay/DataPairList/DataPairList.tsx +0 -56
- package/src/components/dataDisplay/DataPairList/data-pair-list.stories.tsx +0 -87
- package/src/components/dataDisplay/DataPairList/index.ts +0 -2
- package/src/components/dataDisplay/DataPairList/types.ts +0 -10
- package/src/components/dataDisplay/DropDownMenu/index.ts +0 -1
- package/src/components/dataDisplay/ErrorMessage/ErrorMessage.tsx +0 -6
- package/src/components/dataDisplay/ErrorMessage/index.ts +0 -1
- package/src/components/dataDisplay/Icon/Icon.stories.tsx +0 -21
- package/src/components/dataDisplay/Icon/Icon.tsx +0 -47
- package/src/components/dataDisplay/Icon/index.ts +0 -1
- package/src/components/dataDisplay/Icon/types.ts +0 -6
- package/src/components/dataDisplay/Label/Label.stories.tsx +0 -21
- package/src/components/dataDisplay/Label/Label.tsx +0 -10
- package/src/components/dataDisplay/Label/index.ts +0 -1
- package/src/components/dataDisplay/Table/Table.tsx +0 -173
- package/src/components/dataDisplay/Table/columns.tsx +0 -223
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-column-header.tsx +0 -72
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-pagination.tsx +0 -91
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-toolbar.tsx +0 -17
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table-view-options.tsx +0 -58
- package/src/components/dataDisplay/Table/components/DynamicTable/data-table.stories.tsx +0 -118
- package/src/components/dataDisplay/Table/components/DynamicTable/index.tsx +0 -136
- package/src/components/dataDisplay/Table/components/DynamicTable/types.ts +0 -43
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-column-header.tsx +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-faceted-filter.tsx +0 -147
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-pagination.tsx +0 -97
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-row-actions.tsx +0 -78
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-toolbar.tsx +0 -60
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table-view-options.tsx +0 -59
- package/src/components/dataDisplay/Table/custom/CustomTable/data-table.tsx +0 -145
- package/src/components/dataDisplay/Table/custom/CustomTable/data.ts +0 -71
- package/src/components/dataDisplay/Table/custom/CustomTable/index.tsx +0 -34
- package/src/components/dataDisplay/Table/custom/CustomTable/schema.ts +0 -11
- package/src/components/dataDisplay/Table/index.ts +0 -2
- package/src/components/dataDisplay/Table/table.stories.tsx +0 -147
- package/src/components/dataDisplay/Table/types.ts +0 -15
- package/src/components/dataDisplay/Tabs/Tabs.stories.tsx +0 -34
- package/src/components/dataDisplay/Tabs/Tabs.tsx +0 -53
- package/src/components/dataDisplay/Tabs/index.ts +0 -1
- package/src/components/dataDisplay/Text/Text.stories.tsx +0 -66
- package/src/components/dataDisplay/Text/Text.tsx +0 -56
- package/src/components/dataDisplay/Text/index.ts +0 -1
- package/src/components/dataDisplay/index.ts +0 -8
- package/src/components/dataInput/Input/components/Input/Input.stories.tsx +0 -99
- package/src/components/dataInput/Input/components/Input/InputBase.tsx +0 -50
- package/src/components/dataInput/Input/components/Input/__tests__/input.test.tsx +0 -38
- package/src/components/dataInput/Input/components/Input/index.tsx +0 -48
- package/src/components/dataInput/Input/components/Input/types.ts +0 -15
- package/src/components/dataInput/Input/components/InputBase/index.tsx +0 -31
- package/src/components/dataInput/Input/components/MaskInput/__tests__/mask-input.test.tsx +0 -77
- package/src/components/dataInput/Input/components/MaskInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/MaskInput/mask-input.stories.tsx +0 -85
- package/src/components/dataInput/Input/components/MaskInput/mask-input.tsx +0 -73
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInput.tsx +0 -105
- package/src/components/dataInput/Input/components/MultipleInput/MultipleInputBase.tsx +0 -100
- package/src/components/dataInput/Input/components/MultipleInput/MultipleMaskInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/MultipleNumberInput.tsx +0 -35
- package/src/components/dataInput/Input/components/MultipleInput/__tests__/multiple-input.test.tsx +0 -152
- package/src/components/dataInput/Input/components/MultipleInput/index.ts +0 -2
- package/src/components/dataInput/Input/components/MultipleInput/multiple-input.stories.tsx +0 -96
- package/src/components/dataInput/Input/components/NumberInput/__tests__/number-input.test.tsx +0 -175
- package/src/components/dataInput/Input/components/NumberInput/index.ts +0 -1
- package/src/components/dataInput/Input/components/NumberInput/number-input.stories.tsx +0 -76
- package/src/components/dataInput/Input/components/NumberInput/number-input.tsx +0 -70
- package/src/components/dataInput/Input/index.ts +0 -4
- package/src/components/dataInput/Select/MultiSelect/MultiSelect.stories.tsx +0 -119
- package/src/components/dataInput/Select/MultiSelect/MultiSelectBase.tsx +0 -135
- package/src/components/dataInput/Select/MultiSelect/index.tsx +0 -75
- package/src/components/dataInput/Select/Select.stories.tsx +0 -61
- package/src/components/dataInput/Select/Select.tsx +0 -73
- package/src/components/dataInput/Select/SelectBase.tsx +0 -58
- package/src/components/dataInput/Select/index.ts +0 -2
- package/src/components/dataInput/Switch/Switch.stories.tsx +0 -75
- package/src/components/dataInput/Switch/Switch.tsx +0 -52
- package/src/components/dataInput/Switch/index.ts +0 -1
- package/src/components/dataInput/checkbox/Checkbox.tsx +0 -57
- package/src/components/dataInput/checkbox/Checkbox_old.tsx +0 -58
- package/src/components/dataInput/checkbox/Checkout.stories.tsx +0 -62
- package/src/components/dataInput/checkbox/index.ts +0 -1
- package/src/components/dataInput/form/Form.tsx +0 -47
- package/src/components/dataInput/form/index.ts +0 -3
- package/src/components/dataInput/index.ts +0 -5
- package/src/components/feedback/ErrorLabel/index.tsx +0 -24
- package/src/components/feedback/Spinner/index.ts +0 -1
- package/src/components/feedback/Toast/Toast.stories.tsx +0 -45
- package/src/components/feedback/Toast/index.ts +0 -2
- package/src/components/feedback/index.ts +0 -2
- package/src/components/index.ts +0 -6
- package/src/components/layout/Crud/components/Table/index.tsx +0 -183
- package/src/components/layout/Crud/components/Table/types.ts +0 -15
- package/src/components/layout/Crud/crud.stories.tsx +0 -317
- package/src/components/layout/Crud/hook/useCrudLayout/index.tsx +0 -94
- package/src/components/layout/Crud/hook/useRequest/index.tsx +0 -156
- package/src/components/layout/Crud/index.tsx +0 -295
- package/src/components/layout/Crud/store/CrudLayoutStore.ts +0 -75
- package/src/components/layout/Crud/types.ts +0 -14
- package/src/components/layout/Drawer/CustomDrawer/index.tsx +0 -33
- package/src/components/layout/Drawer/Drawer.stories.tsx +0 -80
- package/src/components/layout/Drawer/index.ts +0 -2
- package/src/components/layout/PageLayout/PageLayout.stories.tsx +0 -42
- package/src/components/layout/PageLayout/index.tsx +0 -28
- package/src/components/layout/Separator/index.ts +0 -1
- package/src/components/layout/Sheet/Sheet.stories.tsx +0 -28
- package/src/components/layout/Sheet/Sheet.tsx +0 -22
- package/src/components/layout/Sheet/index.ts +0 -1
- package/src/components/layout/Sidebar/Sidebar.stories.tsx +0 -116
- package/src/components/layout/Sidebar/Sidebar.tsx +0 -50
- package/src/components/layout/Sidebar/components/app-sidebar.tsx +0 -203
- package/src/components/layout/Sidebar/components/footer-sidebar.tsx +0 -17
- package/src/components/layout/Sidebar/components/header-sidebar.tsx +0 -90
- package/src/components/layout/Sidebar/components/menus.tsx +0 -55
- package/src/components/layout/Sidebar/components/nav-projects.tsx +0 -88
- package/src/components/layout/Sidebar/components/nav-user.tsx +0 -114
- package/src/components/layout/Sidebar/components/team-switcher.tsx +0 -85
- package/src/components/layout/Sidebar/index.ts +0 -2
- package/src/components/layout/Sidebar/provider/index.tsx +0 -51
- package/src/components/layout/Tabs/Tabs.tsx +0 -51
- package/src/components/layout/Tabs/index.ts +0 -1
- package/src/components/layout/Tabs/tabs.stories.tsx +0 -57
- package/src/components/layout/index.ts +0 -6
- package/src/components/navigation/Breadcrumbs/Breadcrumbs.tsx +0 -66
- package/src/components/navigation/Breadcrumbs/index.ts +0 -2
- package/src/components/navigation/index.ts +0 -1
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/alert.tsx +0 -59
- package/src/components/ui/avatar.tsx +0 -50
- package/src/components/ui/badge.tsx +0 -40
- package/src/components/ui/breadcrumb.tsx +0 -115
- package/src/components/ui/button.tsx +0 -57
- package/src/components/ui/card.tsx +0 -83
- package/src/components/ui/checkbox.tsx +0 -34
- package/src/components/ui/collapsible.tsx +0 -11
- package/src/components/ui/command.tsx +0 -153
- package/src/components/ui/dialog.tsx +0 -124
- package/src/components/ui/drawer.tsx +0 -117
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/form.tsx +0 -179
- package/src/components/ui/input.tsx +0 -24
- package/src/components/ui/label.tsx +0 -30
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/select.tsx +0 -161
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/sheet.tsx +0 -140
- package/src/components/ui/sidebar.tsx +0 -763
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/spinner.tsx +0 -54
- package/src/components/ui/switch.tsx +0 -33
- package/src/components/ui/table.tsx +0 -120
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/toast.tsx +0 -130
- package/src/components/ui/toaster.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/hooks/use-conditional-controller.tsx +0 -35
- package/src/hooks/use-mask.tsx +0 -116
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/hooks/use-toast.ts +0 -191
- package/src/index.ts +0 -1
- package/src/introduction.mdx +0 -132
- package/src/lib/utils.ts +0 -6
- package/tailwind.config.ts +0 -83
- package/tsconfig.json +0 -27
|
@@ -1,763 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
-
import { VariantProps, cva } from "class-variance-authority";
|
|
6
|
-
import { PanelLeft } from "lucide-react";
|
|
7
|
-
|
|
8
|
-
import { useIsMobile } from "../../hooks/use-mobile";
|
|
9
|
-
import { cn } from "../../lib/utils";
|
|
10
|
-
import { Button } from "../../components/ui/button";
|
|
11
|
-
import { Input } from "../../components/ui/input";
|
|
12
|
-
import { Separator } from "../../components/ui/separator";
|
|
13
|
-
import { Sheet, SheetContent } from "../../components/ui/sheet";
|
|
14
|
-
import { Skeleton } from "../../components/ui/skeleton";
|
|
15
|
-
import {
|
|
16
|
-
Tooltip,
|
|
17
|
-
TooltipContent,
|
|
18
|
-
TooltipProvider,
|
|
19
|
-
TooltipTrigger,
|
|
20
|
-
} from "../../components/ui/tooltip";
|
|
21
|
-
|
|
22
|
-
const SIDEBAR_COOKIE_NAME = "sidebar:state";
|
|
23
|
-
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
24
|
-
const SIDEBAR_WIDTH = "16rem";
|
|
25
|
-
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
26
|
-
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
27
|
-
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
28
|
-
|
|
29
|
-
type SidebarContext = {
|
|
30
|
-
state: "expanded" | "collapsed";
|
|
31
|
-
open: boolean;
|
|
32
|
-
setOpen: (open: boolean) => void;
|
|
33
|
-
openMobile: boolean;
|
|
34
|
-
setOpenMobile: (open: boolean) => void;
|
|
35
|
-
isMobile: boolean;
|
|
36
|
-
toggleSidebar: () => void;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const SidebarContext = React.createContext<SidebarContext | null>(null);
|
|
40
|
-
|
|
41
|
-
function useSidebar() {
|
|
42
|
-
const context = React.useContext(SidebarContext);
|
|
43
|
-
if (!context) {
|
|
44
|
-
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return context;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const SidebarProvider = React.forwardRef<
|
|
51
|
-
HTMLDivElement,
|
|
52
|
-
React.ComponentProps<"div"> & {
|
|
53
|
-
defaultOpen?: boolean;
|
|
54
|
-
open?: boolean;
|
|
55
|
-
onOpenChange?: (open: boolean) => void;
|
|
56
|
-
}
|
|
57
|
-
>(
|
|
58
|
-
(
|
|
59
|
-
{
|
|
60
|
-
defaultOpen = true,
|
|
61
|
-
open: openProp,
|
|
62
|
-
onOpenChange: setOpenProp,
|
|
63
|
-
className,
|
|
64
|
-
style,
|
|
65
|
-
children,
|
|
66
|
-
...props
|
|
67
|
-
},
|
|
68
|
-
ref
|
|
69
|
-
) => {
|
|
70
|
-
const isMobile = useIsMobile();
|
|
71
|
-
const [openMobile, setOpenMobile] = React.useState(false);
|
|
72
|
-
|
|
73
|
-
// This is the internal state of the sidebar.
|
|
74
|
-
// We use openProp and setOpenProp for control from outside the component.
|
|
75
|
-
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
76
|
-
const open = openProp ?? _open;
|
|
77
|
-
const setOpen = React.useCallback(
|
|
78
|
-
(value: boolean | ((value: boolean) => boolean)) => {
|
|
79
|
-
const openState = typeof value === "function" ? value(open) : value;
|
|
80
|
-
if (setOpenProp) {
|
|
81
|
-
setOpenProp(openState);
|
|
82
|
-
} else {
|
|
83
|
-
_setOpen(openState);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// This sets the cookie to keep the sidebar state.
|
|
87
|
-
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
88
|
-
},
|
|
89
|
-
[setOpenProp, open]
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Helper to toggle the sidebar.
|
|
93
|
-
const toggleSidebar = React.useCallback(() => {
|
|
94
|
-
return isMobile
|
|
95
|
-
? setOpenMobile((open) => !open)
|
|
96
|
-
: setOpen((open) => !open);
|
|
97
|
-
}, [isMobile, setOpen, setOpenMobile]);
|
|
98
|
-
|
|
99
|
-
// Adds a keyboard shortcut to toggle the sidebar.
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
102
|
-
if (
|
|
103
|
-
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
104
|
-
(event.metaKey || event.ctrlKey)
|
|
105
|
-
) {
|
|
106
|
-
event.preventDefault();
|
|
107
|
-
toggleSidebar();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
112
|
-
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
113
|
-
}, [toggleSidebar]);
|
|
114
|
-
|
|
115
|
-
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
116
|
-
// This makes it easier to style the sidebar with Tailwind classes.
|
|
117
|
-
const state = open ? "expanded" : "collapsed";
|
|
118
|
-
|
|
119
|
-
const contextValue = React.useMemo<SidebarContext>(
|
|
120
|
-
() => ({
|
|
121
|
-
state,
|
|
122
|
-
open,
|
|
123
|
-
setOpen,
|
|
124
|
-
isMobile,
|
|
125
|
-
openMobile,
|
|
126
|
-
setOpenMobile,
|
|
127
|
-
toggleSidebar,
|
|
128
|
-
}),
|
|
129
|
-
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<SidebarContext.Provider value={contextValue}>
|
|
134
|
-
<TooltipProvider delayDuration={0}>
|
|
135
|
-
<div
|
|
136
|
-
style={
|
|
137
|
-
{
|
|
138
|
-
"--sidebar-width": SIDEBAR_WIDTH,
|
|
139
|
-
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
140
|
-
...style,
|
|
141
|
-
} as React.CSSProperties
|
|
142
|
-
}
|
|
143
|
-
className={cn(
|
|
144
|
-
"group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
|
|
145
|
-
className
|
|
146
|
-
)}
|
|
147
|
-
ref={ref}
|
|
148
|
-
{...props}
|
|
149
|
-
>
|
|
150
|
-
{children}
|
|
151
|
-
</div>
|
|
152
|
-
</TooltipProvider>
|
|
153
|
-
</SidebarContext.Provider>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
SidebarProvider.displayName = "SidebarProvider";
|
|
158
|
-
|
|
159
|
-
const Sidebar = React.forwardRef<
|
|
160
|
-
HTMLDivElement,
|
|
161
|
-
React.ComponentProps<"div"> & {
|
|
162
|
-
side?: "left" | "right";
|
|
163
|
-
variant?: "sidebar" | "floating" | "inset";
|
|
164
|
-
collapsible?: "offcanvas" | "icon" | "none";
|
|
165
|
-
}
|
|
166
|
-
>(
|
|
167
|
-
(
|
|
168
|
-
{
|
|
169
|
-
side = "left",
|
|
170
|
-
variant = "sidebar",
|
|
171
|
-
collapsible = "offcanvas",
|
|
172
|
-
className,
|
|
173
|
-
children,
|
|
174
|
-
...props
|
|
175
|
-
},
|
|
176
|
-
ref
|
|
177
|
-
) => {
|
|
178
|
-
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
179
|
-
|
|
180
|
-
if (collapsible === "none") {
|
|
181
|
-
return (
|
|
182
|
-
<div
|
|
183
|
-
className={cn(
|
|
184
|
-
"flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
|
|
185
|
-
className
|
|
186
|
-
)}
|
|
187
|
-
ref={ref}
|
|
188
|
-
{...props}
|
|
189
|
-
>
|
|
190
|
-
{children}
|
|
191
|
-
</div>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (isMobile) {
|
|
196
|
-
return (
|
|
197
|
-
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
198
|
-
<SheetContent
|
|
199
|
-
data-sidebar="sidebar"
|
|
200
|
-
data-mobile="true"
|
|
201
|
-
className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
|
|
202
|
-
style={
|
|
203
|
-
{
|
|
204
|
-
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
205
|
-
} as React.CSSProperties
|
|
206
|
-
}
|
|
207
|
-
side={side}
|
|
208
|
-
>
|
|
209
|
-
<div className="flex h-full w-full flex-col">{children}</div>
|
|
210
|
-
</SheetContent>
|
|
211
|
-
</Sheet>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<div
|
|
217
|
-
ref={ref}
|
|
218
|
-
className="group peer hidden md:block text-sidebar-foreground"
|
|
219
|
-
data-state={state}
|
|
220
|
-
data-collapsible={state === "collapsed" ? collapsible : ""}
|
|
221
|
-
data-variant={variant}
|
|
222
|
-
data-side={side}
|
|
223
|
-
>
|
|
224
|
-
{/* This is what handles the sidebar gap on desktop */}
|
|
225
|
-
<div
|
|
226
|
-
className={cn(
|
|
227
|
-
"duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear",
|
|
228
|
-
"group-data-[collapsible=offcanvas]:w-0",
|
|
229
|
-
"group-data-[side=right]:rotate-180",
|
|
230
|
-
variant === "floating" || variant === "inset"
|
|
231
|
-
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
|
|
232
|
-
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
|
|
233
|
-
)}
|
|
234
|
-
/>
|
|
235
|
-
<div
|
|
236
|
-
className={cn(
|
|
237
|
-
"duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",
|
|
238
|
-
side === "left"
|
|
239
|
-
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
240
|
-
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
241
|
-
// Adjust the padding for floating and inset variants.
|
|
242
|
-
variant === "floating" || variant === "inset"
|
|
243
|
-
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
|
|
244
|
-
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
245
|
-
className
|
|
246
|
-
)}
|
|
247
|
-
{...props}
|
|
248
|
-
>
|
|
249
|
-
<div
|
|
250
|
-
data-sidebar="sidebar"
|
|
251
|
-
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"
|
|
252
|
-
>
|
|
253
|
-
{children}
|
|
254
|
-
</div>
|
|
255
|
-
</div>
|
|
256
|
-
</div>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
Sidebar.displayName = "Sidebar";
|
|
261
|
-
|
|
262
|
-
const SidebarTrigger = React.forwardRef<
|
|
263
|
-
React.ElementRef<typeof Button>,
|
|
264
|
-
React.ComponentProps<typeof Button>
|
|
265
|
-
>(({ className, onClick, ...props }, ref) => {
|
|
266
|
-
const { toggleSidebar } = useSidebar();
|
|
267
|
-
|
|
268
|
-
return (
|
|
269
|
-
<Button
|
|
270
|
-
ref={ref}
|
|
271
|
-
data-sidebar="trigger"
|
|
272
|
-
variant="ghost"
|
|
273
|
-
size="icon"
|
|
274
|
-
className={cn("h-7 w-7", className)}
|
|
275
|
-
onClick={(event) => {
|
|
276
|
-
onClick?.(event);
|
|
277
|
-
toggleSidebar();
|
|
278
|
-
}}
|
|
279
|
-
{...props}
|
|
280
|
-
>
|
|
281
|
-
<PanelLeft />
|
|
282
|
-
<span className="sr-only">Toggle Sidebar</span>
|
|
283
|
-
</Button>
|
|
284
|
-
);
|
|
285
|
-
});
|
|
286
|
-
SidebarTrigger.displayName = "SidebarTrigger";
|
|
287
|
-
|
|
288
|
-
const SidebarRail = React.forwardRef<
|
|
289
|
-
HTMLButtonElement,
|
|
290
|
-
React.ComponentProps<"button">
|
|
291
|
-
>(({ className, ...props }, ref) => {
|
|
292
|
-
const { toggleSidebar } = useSidebar();
|
|
293
|
-
|
|
294
|
-
return (
|
|
295
|
-
<button
|
|
296
|
-
ref={ref}
|
|
297
|
-
data-sidebar="rail"
|
|
298
|
-
aria-label="Toggle Sidebar"
|
|
299
|
-
tabIndex={-1}
|
|
300
|
-
onClick={toggleSidebar}
|
|
301
|
-
title="Toggle Sidebar"
|
|
302
|
-
className={cn(
|
|
303
|
-
"absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear 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",
|
|
304
|
-
"[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
|
|
305
|
-
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
306
|
-
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
|
|
307
|
-
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
308
|
-
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
309
|
-
className
|
|
310
|
-
)}
|
|
311
|
-
{...props}
|
|
312
|
-
/>
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
SidebarRail.displayName = "SidebarRail";
|
|
316
|
-
|
|
317
|
-
const SidebarInset = React.forwardRef<
|
|
318
|
-
HTMLDivElement,
|
|
319
|
-
React.ComponentProps<"main">
|
|
320
|
-
>(({ className, ...props }, ref) => {
|
|
321
|
-
return (
|
|
322
|
-
<main
|
|
323
|
-
ref={ref}
|
|
324
|
-
className={cn(
|
|
325
|
-
"relative flex min-h-svh flex-1 flex-col bg-background",
|
|
326
|
-
"peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
|
|
327
|
-
className
|
|
328
|
-
)}
|
|
329
|
-
{...props}
|
|
330
|
-
/>
|
|
331
|
-
);
|
|
332
|
-
});
|
|
333
|
-
SidebarInset.displayName = "SidebarInset";
|
|
334
|
-
|
|
335
|
-
const SidebarInput = React.forwardRef<
|
|
336
|
-
React.ElementRef<typeof Input>,
|
|
337
|
-
React.ComponentProps<typeof Input>
|
|
338
|
-
>(({ className, ...props }, ref) => {
|
|
339
|
-
return (
|
|
340
|
-
<Input
|
|
341
|
-
ref={ref}
|
|
342
|
-
data-sidebar="input"
|
|
343
|
-
className={cn(
|
|
344
|
-
"h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
|
|
345
|
-
className
|
|
346
|
-
)}
|
|
347
|
-
{...props}
|
|
348
|
-
/>
|
|
349
|
-
);
|
|
350
|
-
});
|
|
351
|
-
SidebarInput.displayName = "SidebarInput";
|
|
352
|
-
|
|
353
|
-
const SidebarHeader = React.forwardRef<
|
|
354
|
-
HTMLDivElement,
|
|
355
|
-
React.ComponentProps<"div">
|
|
356
|
-
>(({ className, ...props }, ref) => {
|
|
357
|
-
return (
|
|
358
|
-
<div
|
|
359
|
-
ref={ref}
|
|
360
|
-
data-sidebar="header"
|
|
361
|
-
className={cn("flex flex-col gap-2 p-2", className)}
|
|
362
|
-
{...props}
|
|
363
|
-
/>
|
|
364
|
-
);
|
|
365
|
-
});
|
|
366
|
-
SidebarHeader.displayName = "SidebarHeader";
|
|
367
|
-
|
|
368
|
-
const SidebarFooter = React.forwardRef<
|
|
369
|
-
HTMLDivElement,
|
|
370
|
-
React.ComponentProps<"div">
|
|
371
|
-
>(({ className, ...props }, ref) => {
|
|
372
|
-
return (
|
|
373
|
-
<div
|
|
374
|
-
ref={ref}
|
|
375
|
-
data-sidebar="footer"
|
|
376
|
-
className={cn("flex flex-col gap-2 p-2", className)}
|
|
377
|
-
{...props}
|
|
378
|
-
/>
|
|
379
|
-
);
|
|
380
|
-
});
|
|
381
|
-
SidebarFooter.displayName = "SidebarFooter";
|
|
382
|
-
|
|
383
|
-
const SidebarSeparator = React.forwardRef<
|
|
384
|
-
React.ElementRef<typeof Separator>,
|
|
385
|
-
React.ComponentProps<typeof Separator>
|
|
386
|
-
>(({ className, ...props }, ref) => {
|
|
387
|
-
return (
|
|
388
|
-
<Separator
|
|
389
|
-
ref={ref}
|
|
390
|
-
data-sidebar="separator"
|
|
391
|
-
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
|
392
|
-
{...props}
|
|
393
|
-
/>
|
|
394
|
-
);
|
|
395
|
-
});
|
|
396
|
-
SidebarSeparator.displayName = "SidebarSeparator";
|
|
397
|
-
|
|
398
|
-
const SidebarContent = React.forwardRef<
|
|
399
|
-
HTMLDivElement,
|
|
400
|
-
React.ComponentProps<"div">
|
|
401
|
-
>(({ className, ...props }, ref) => {
|
|
402
|
-
return (
|
|
403
|
-
<div
|
|
404
|
-
ref={ref}
|
|
405
|
-
data-sidebar="content"
|
|
406
|
-
className={cn(
|
|
407
|
-
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
408
|
-
className
|
|
409
|
-
)}
|
|
410
|
-
{...props}
|
|
411
|
-
/>
|
|
412
|
-
);
|
|
413
|
-
});
|
|
414
|
-
SidebarContent.displayName = "SidebarContent";
|
|
415
|
-
|
|
416
|
-
const SidebarGroup = React.forwardRef<
|
|
417
|
-
HTMLDivElement,
|
|
418
|
-
React.ComponentProps<"div">
|
|
419
|
-
>(({ className, ...props }, ref) => {
|
|
420
|
-
return (
|
|
421
|
-
<div
|
|
422
|
-
ref={ref}
|
|
423
|
-
data-sidebar="group"
|
|
424
|
-
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
425
|
-
{...props}
|
|
426
|
-
/>
|
|
427
|
-
);
|
|
428
|
-
});
|
|
429
|
-
SidebarGroup.displayName = "SidebarGroup";
|
|
430
|
-
|
|
431
|
-
const SidebarGroupLabel = React.forwardRef<
|
|
432
|
-
HTMLDivElement,
|
|
433
|
-
React.ComponentProps<"div"> & { asChild?: boolean }
|
|
434
|
-
>(({ className, asChild = false, ...props }, ref) => {
|
|
435
|
-
const Comp = asChild ? Slot : "div";
|
|
436
|
-
|
|
437
|
-
return (
|
|
438
|
-
<Comp
|
|
439
|
-
ref={ref}
|
|
440
|
-
data-sidebar="group-label"
|
|
441
|
-
className={cn(
|
|
442
|
-
"duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
443
|
-
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
444
|
-
className
|
|
445
|
-
)}
|
|
446
|
-
{...props}
|
|
447
|
-
/>
|
|
448
|
-
);
|
|
449
|
-
});
|
|
450
|
-
SidebarGroupLabel.displayName = "SidebarGroupLabel";
|
|
451
|
-
|
|
452
|
-
const SidebarGroupAction = React.forwardRef<
|
|
453
|
-
HTMLButtonElement,
|
|
454
|
-
React.ComponentProps<"button"> & { asChild?: boolean }
|
|
455
|
-
>(({ className, asChild = false, ...props }, ref) => {
|
|
456
|
-
const Comp = asChild ? Slot : "button";
|
|
457
|
-
|
|
458
|
-
return (
|
|
459
|
-
<Comp
|
|
460
|
-
ref={ref}
|
|
461
|
-
data-sidebar="group-action"
|
|
462
|
-
className={cn(
|
|
463
|
-
"absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
464
|
-
// Increases the hit area of the button on mobile.
|
|
465
|
-
"after:absolute after:-inset-2 after:md:hidden",
|
|
466
|
-
"group-data-[collapsible=icon]:hidden",
|
|
467
|
-
className
|
|
468
|
-
)}
|
|
469
|
-
{...props}
|
|
470
|
-
/>
|
|
471
|
-
);
|
|
472
|
-
});
|
|
473
|
-
SidebarGroupAction.displayName = "SidebarGroupAction";
|
|
474
|
-
|
|
475
|
-
const SidebarGroupContent = React.forwardRef<
|
|
476
|
-
HTMLDivElement,
|
|
477
|
-
React.ComponentProps<"div">
|
|
478
|
-
>(({ className, ...props }, ref) => (
|
|
479
|
-
<div
|
|
480
|
-
ref={ref}
|
|
481
|
-
data-sidebar="group-content"
|
|
482
|
-
className={cn("w-full text-sm", className)}
|
|
483
|
-
{...props}
|
|
484
|
-
/>
|
|
485
|
-
));
|
|
486
|
-
SidebarGroupContent.displayName = "SidebarGroupContent";
|
|
487
|
-
|
|
488
|
-
const SidebarMenu = React.forwardRef<
|
|
489
|
-
HTMLUListElement,
|
|
490
|
-
React.ComponentProps<"ul">
|
|
491
|
-
>(({ className, ...props }, ref) => (
|
|
492
|
-
<ul
|
|
493
|
-
ref={ref}
|
|
494
|
-
data-sidebar="menu"
|
|
495
|
-
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
496
|
-
{...props}
|
|
497
|
-
/>
|
|
498
|
-
));
|
|
499
|
-
SidebarMenu.displayName = "SidebarMenu";
|
|
500
|
-
|
|
501
|
-
const SidebarMenuItem = React.forwardRef<
|
|
502
|
-
HTMLLIElement,
|
|
503
|
-
React.ComponentProps<"li">
|
|
504
|
-
>(({ className, ...props }, ref) => (
|
|
505
|
-
<li
|
|
506
|
-
ref={ref}
|
|
507
|
-
data-sidebar="menu-item"
|
|
508
|
-
className={cn("group/menu-item relative", className)}
|
|
509
|
-
{...props}
|
|
510
|
-
/>
|
|
511
|
-
));
|
|
512
|
-
SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
513
|
-
|
|
514
|
-
const sidebarMenuButtonVariants = cva(
|
|
515
|
-
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none 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",
|
|
516
|
-
{
|
|
517
|
-
variants: {
|
|
518
|
-
variant: {
|
|
519
|
-
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
520
|
-
outline:
|
|
521
|
-
"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))]",
|
|
522
|
-
},
|
|
523
|
-
size: {
|
|
524
|
-
default: "h-8 text-sm",
|
|
525
|
-
sm: "h-7 text-xs",
|
|
526
|
-
lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
|
|
527
|
-
},
|
|
528
|
-
},
|
|
529
|
-
defaultVariants: {
|
|
530
|
-
variant: "default",
|
|
531
|
-
size: "default",
|
|
532
|
-
},
|
|
533
|
-
}
|
|
534
|
-
);
|
|
535
|
-
|
|
536
|
-
const SidebarMenuButton = React.forwardRef<
|
|
537
|
-
HTMLButtonElement,
|
|
538
|
-
React.ComponentProps<"button"> & {
|
|
539
|
-
asChild?: boolean;
|
|
540
|
-
isActive?: boolean;
|
|
541
|
-
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
542
|
-
} & VariantProps<typeof sidebarMenuButtonVariants>
|
|
543
|
-
>(
|
|
544
|
-
(
|
|
545
|
-
{
|
|
546
|
-
asChild = false,
|
|
547
|
-
isActive = false,
|
|
548
|
-
variant = "default",
|
|
549
|
-
size = "default",
|
|
550
|
-
tooltip,
|
|
551
|
-
className,
|
|
552
|
-
...props
|
|
553
|
-
},
|
|
554
|
-
ref
|
|
555
|
-
) => {
|
|
556
|
-
const Comp = asChild ? Slot : "button";
|
|
557
|
-
const { isMobile, state } = useSidebar();
|
|
558
|
-
|
|
559
|
-
const button = (
|
|
560
|
-
<Comp
|
|
561
|
-
ref={ref}
|
|
562
|
-
data-sidebar="menu-button"
|
|
563
|
-
data-size={size}
|
|
564
|
-
data-active={isActive}
|
|
565
|
-
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
566
|
-
{...props}
|
|
567
|
-
/>
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
if (!tooltip) {
|
|
571
|
-
return button;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
if (typeof tooltip === "string") {
|
|
575
|
-
tooltip = {
|
|
576
|
-
children: tooltip,
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return (
|
|
581
|
-
<Tooltip>
|
|
582
|
-
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
583
|
-
<TooltipContent
|
|
584
|
-
side="right"
|
|
585
|
-
align="center"
|
|
586
|
-
hidden={state !== "collapsed" || isMobile}
|
|
587
|
-
{...tooltip}
|
|
588
|
-
/>
|
|
589
|
-
</Tooltip>
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
);
|
|
593
|
-
SidebarMenuButton.displayName = "SidebarMenuButton";
|
|
594
|
-
|
|
595
|
-
const SidebarMenuAction = React.forwardRef<
|
|
596
|
-
HTMLButtonElement,
|
|
597
|
-
React.ComponentProps<"button"> & {
|
|
598
|
-
asChild?: boolean;
|
|
599
|
-
showOnHover?: boolean;
|
|
600
|
-
}
|
|
601
|
-
>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
|
|
602
|
-
const Comp = asChild ? Slot : "button";
|
|
603
|
-
|
|
604
|
-
return (
|
|
605
|
-
<Comp
|
|
606
|
-
ref={ref}
|
|
607
|
-
data-sidebar="menu-action"
|
|
608
|
-
className={cn(
|
|
609
|
-
"absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none 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",
|
|
610
|
-
// Increases the hit area of the button on mobile.
|
|
611
|
-
"after:absolute after:-inset-2 after:md:hidden",
|
|
612
|
-
"peer-data-[size=sm]/menu-button:top-1",
|
|
613
|
-
"peer-data-[size=default]/menu-button:top-1.5",
|
|
614
|
-
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
615
|
-
"group-data-[collapsible=icon]:hidden",
|
|
616
|
-
showOnHover &&
|
|
617
|
-
"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",
|
|
618
|
-
className
|
|
619
|
-
)}
|
|
620
|
-
{...props}
|
|
621
|
-
/>
|
|
622
|
-
);
|
|
623
|
-
});
|
|
624
|
-
SidebarMenuAction.displayName = "SidebarMenuAction";
|
|
625
|
-
|
|
626
|
-
const SidebarMenuBadge = React.forwardRef<
|
|
627
|
-
HTMLDivElement,
|
|
628
|
-
React.ComponentProps<"div">
|
|
629
|
-
>(({ className, ...props }, ref) => (
|
|
630
|
-
<div
|
|
631
|
-
ref={ref}
|
|
632
|
-
data-sidebar="menu-badge"
|
|
633
|
-
className={cn(
|
|
634
|
-
"absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none",
|
|
635
|
-
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
|
636
|
-
"peer-data-[size=sm]/menu-button:top-1",
|
|
637
|
-
"peer-data-[size=default]/menu-button:top-1.5",
|
|
638
|
-
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
639
|
-
"group-data-[collapsible=icon]:hidden",
|
|
640
|
-
className
|
|
641
|
-
)}
|
|
642
|
-
{...props}
|
|
643
|
-
/>
|
|
644
|
-
));
|
|
645
|
-
SidebarMenuBadge.displayName = "SidebarMenuBadge";
|
|
646
|
-
|
|
647
|
-
const SidebarMenuSkeleton = React.forwardRef<
|
|
648
|
-
HTMLDivElement,
|
|
649
|
-
React.ComponentProps<"div"> & {
|
|
650
|
-
showIcon?: boolean;
|
|
651
|
-
}
|
|
652
|
-
>(({ className, showIcon = false, ...props }, ref) => {
|
|
653
|
-
// Random width between 50 to 90%.
|
|
654
|
-
const width = React.useMemo(() => {
|
|
655
|
-
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
656
|
-
}, []);
|
|
657
|
-
|
|
658
|
-
return (
|
|
659
|
-
<div
|
|
660
|
-
ref={ref}
|
|
661
|
-
data-sidebar="menu-skeleton"
|
|
662
|
-
className={cn("rounded-md h-8 flex gap-2 px-2 items-center", className)}
|
|
663
|
-
{...props}
|
|
664
|
-
>
|
|
665
|
-
{showIcon && (
|
|
666
|
-
<Skeleton
|
|
667
|
-
className="size-4 rounded-md"
|
|
668
|
-
data-sidebar="menu-skeleton-icon"
|
|
669
|
-
/>
|
|
670
|
-
)}
|
|
671
|
-
<Skeleton
|
|
672
|
-
className="h-4 flex-1 max-w-[--skeleton-width]"
|
|
673
|
-
data-sidebar="menu-skeleton-text"
|
|
674
|
-
style={
|
|
675
|
-
{
|
|
676
|
-
"--skeleton-width": width,
|
|
677
|
-
} as React.CSSProperties
|
|
678
|
-
}
|
|
679
|
-
/>
|
|
680
|
-
</div>
|
|
681
|
-
);
|
|
682
|
-
});
|
|
683
|
-
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
|
|
684
|
-
|
|
685
|
-
const SidebarMenuSub = React.forwardRef<
|
|
686
|
-
HTMLUListElement,
|
|
687
|
-
React.ComponentProps<"ul">
|
|
688
|
-
>(({ className, ...props }, ref) => (
|
|
689
|
-
<ul
|
|
690
|
-
ref={ref}
|
|
691
|
-
data-sidebar="menu-sub"
|
|
692
|
-
className={cn(
|
|
693
|
-
"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",
|
|
694
|
-
"group-data-[collapsible=icon]:hidden",
|
|
695
|
-
className
|
|
696
|
-
)}
|
|
697
|
-
{...props}
|
|
698
|
-
/>
|
|
699
|
-
));
|
|
700
|
-
SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
701
|
-
|
|
702
|
-
const SidebarMenuSubItem = React.forwardRef<
|
|
703
|
-
HTMLLIElement,
|
|
704
|
-
React.ComponentProps<"li">
|
|
705
|
-
>(({ ...props }, ref) => <li ref={ref} {...props} />);
|
|
706
|
-
SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
707
|
-
|
|
708
|
-
const SidebarMenuSubButton = React.forwardRef<
|
|
709
|
-
HTMLAnchorElement,
|
|
710
|
-
React.ComponentProps<"a"> & {
|
|
711
|
-
asChild?: boolean;
|
|
712
|
-
size?: "sm" | "md";
|
|
713
|
-
isActive?: boolean;
|
|
714
|
-
}
|
|
715
|
-
>(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
|
|
716
|
-
const Comp = asChild ? Slot : "a";
|
|
717
|
-
|
|
718
|
-
return (
|
|
719
|
-
<Comp
|
|
720
|
-
ref={ref}
|
|
721
|
-
data-sidebar="menu-sub-button"
|
|
722
|
-
data-size={size}
|
|
723
|
-
data-active={isActive}
|
|
724
|
-
className={cn(
|
|
725
|
-
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none 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",
|
|
726
|
-
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
727
|
-
size === "sm" && "text-xs",
|
|
728
|
-
size === "md" && "text-sm",
|
|
729
|
-
"group-data-[collapsible=icon]:hidden",
|
|
730
|
-
className
|
|
731
|
-
)}
|
|
732
|
-
{...props}
|
|
733
|
-
/>
|
|
734
|
-
);
|
|
735
|
-
});
|
|
736
|
-
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
|
737
|
-
|
|
738
|
-
export {
|
|
739
|
-
Sidebar,
|
|
740
|
-
SidebarContent,
|
|
741
|
-
SidebarFooter,
|
|
742
|
-
SidebarGroup,
|
|
743
|
-
SidebarGroupAction,
|
|
744
|
-
SidebarGroupContent,
|
|
745
|
-
SidebarGroupLabel,
|
|
746
|
-
SidebarHeader,
|
|
747
|
-
SidebarInput,
|
|
748
|
-
SidebarInset,
|
|
749
|
-
SidebarMenu,
|
|
750
|
-
SidebarMenuAction,
|
|
751
|
-
SidebarMenuBadge,
|
|
752
|
-
SidebarMenuButton,
|
|
753
|
-
SidebarMenuItem,
|
|
754
|
-
SidebarMenuSkeleton,
|
|
755
|
-
SidebarMenuSub,
|
|
756
|
-
SidebarMenuSubButton,
|
|
757
|
-
SidebarMenuSubItem,
|
|
758
|
-
SidebarProvider,
|
|
759
|
-
SidebarRail,
|
|
760
|
-
SidebarSeparator,
|
|
761
|
-
SidebarTrigger,
|
|
762
|
-
useSidebar,
|
|
763
|
-
};
|