@surreal-ui/react 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.js +955 -7227
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +14 -0
- package/package.json +25 -8
- package/CHANGELOG.md +0 -142
- package/src/components/GlassmorphismAlert.tsx +0 -43
- package/src/components/GlassmorphismButton.tsx +0 -20
- package/src/components/GlassmorphismCard.tsx +0 -43
- package/src/components/GlassmorphismEmptyState.tsx +0 -20
- package/src/components/GlassmorphismInputGroup.tsx +0 -148
- package/src/components/GlassmorphismMenubar.tsx +0 -96
- package/src/components/GlassmorphismScrollArea.tsx +0 -67
- package/src/components/GlassmorphismTable.tsx +0 -61
- package/src/components/GlassmorphismTypography.tsx +0 -31
- package/src/components/MinimalistAccordion.tsx +0 -215
- package/src/components/MinimalistAlert.tsx +0 -43
- package/src/components/MinimalistAlertDialog.tsx +0 -318
- package/src/components/MinimalistAspectRatio.tsx +0 -30
- package/src/components/MinimalistAvatar.tsx +0 -149
- package/src/components/MinimalistBadge.tsx +0 -49
- package/src/components/MinimalistBreadcrumb.tsx +0 -109
- package/src/components/MinimalistButton.tsx +0 -86
- package/src/components/MinimalistButtonGroup.tsx +0 -86
- package/src/components/MinimalistCalendar.tsx +0 -355
- package/src/components/MinimalistCard.tsx +0 -89
- package/src/components/MinimalistCarousel.tsx +0 -266
- package/src/components/MinimalistChart.tsx +0 -296
- package/src/components/MinimalistCheckbox.tsx +0 -117
- package/src/components/MinimalistCodeBlock.tsx +0 -203
- package/src/components/MinimalistCollapsible.tsx +0 -134
- package/src/components/MinimalistCommand.tsx +0 -344
- package/src/components/MinimalistContextMenu.tsx +0 -408
- package/src/components/MinimalistDialog.tsx +0 -273
- package/src/components/MinimalistDrawer.tsx +0 -220
- package/src/components/MinimalistDropdownMenu.tsx +0 -431
- package/src/components/MinimalistEmpty.tsx +0 -105
- package/src/components/MinimalistEmptyState.tsx +0 -34
- package/src/components/MinimalistField.tsx +0 -275
- package/src/components/MinimalistForm.tsx +0 -205
- package/src/components/MinimalistHoverCard.tsx +0 -48
- package/src/components/MinimalistInput.tsx +0 -24
- package/src/components/MinimalistInputGroup.tsx +0 -180
- package/src/components/MinimalistInputOtp.tsx +0 -189
- package/src/components/MinimalistItem.tsx +0 -182
- package/src/components/MinimalistKbd.tsx +0 -46
- package/src/components/MinimalistLabel.tsx +0 -19
- package/src/components/MinimalistMenubar.tsx +0 -491
- package/src/components/MinimalistNativeSelect.tsx +0 -77
- package/src/components/MinimalistNavigationMenu.tsx +0 -198
- package/src/components/MinimalistPagination.tsx +0 -152
- package/src/components/MinimalistPopover.tsx +0 -229
- package/src/components/MinimalistProgress.tsx +0 -39
- package/src/components/MinimalistRadioGroup.tsx +0 -115
- package/src/components/MinimalistRangeCalendar.tsx +0 -396
- package/src/components/MinimalistResizable.tsx +0 -54
- package/src/components/MinimalistScrollArea.tsx +0 -41
- package/src/components/MinimalistSelect.tsx +0 -262
- package/src/components/MinimalistSeparator.tsx +0 -45
- package/src/components/MinimalistSheet.tsx +0 -247
- package/src/components/MinimalistSidebar.tsx +0 -638
- package/src/components/MinimalistSkeleton.tsx +0 -16
- package/src/components/MinimalistSlider.tsx +0 -213
- package/src/components/MinimalistSonner.tsx +0 -41
- package/src/components/MinimalistSpinner.tsx +0 -39
- package/src/components/MinimalistSwitch.tsx +0 -92
- package/src/components/MinimalistTable.tsx +0 -65
- package/src/components/MinimalistTabs.tsx +0 -171
- package/src/components/MinimalistTextarea.tsx +0 -24
- package/src/components/MinimalistToggle.tsx +0 -74
- package/src/components/MinimalistToggleGroup.tsx +0 -197
- package/src/components/MinimalistTooltip.tsx +0 -172
- package/src/components/MinimalistTypography.tsx +0 -33
- package/src/components/NeubrutalismCard.tsx +0 -84
- package/src/components/NeubrutalismItem.tsx +0 -48
- package/src/components/ShadcnAccordion.tsx +0 -215
- package/src/components/ShadcnAlertDialog.tsx +0 -318
- package/src/components/ShadcnAspectRatio.tsx +0 -30
- package/src/components/ShadcnAvatar.tsx +0 -149
- package/src/components/ShadcnBadge.tsx +0 -49
- package/src/components/ShadcnBreadcrumb.tsx +0 -109
- package/src/components/ShadcnButton.tsx +0 -86
- package/src/components/ShadcnButtonGroup.tsx +0 -86
- package/src/components/ShadcnCalendar.tsx +0 -355
- package/src/components/ShadcnCarousel.tsx +0 -266
- package/src/components/ShadcnChart.tsx +0 -296
- package/src/components/ShadcnCheckbox.tsx +0 -117
- package/src/components/ShadcnCodeBlock.tsx +0 -203
- package/src/components/ShadcnCollapsible.tsx +0 -134
- package/src/components/ShadcnCommand.tsx +0 -344
- package/src/components/ShadcnContextMenu.tsx +0 -408
- package/src/components/ShadcnDialog.tsx +0 -273
- package/src/components/ShadcnDrawer.tsx +0 -220
- package/src/components/ShadcnDropdownMenu.tsx +0 -431
- package/src/components/ShadcnEmpty.tsx +0 -105
- package/src/components/ShadcnField.tsx +0 -275
- package/src/components/ShadcnForm.tsx +0 -205
- package/src/components/ShadcnHoverCard.tsx +0 -48
- package/src/components/ShadcnInput.tsx +0 -24
- package/src/components/ShadcnInputGroup.tsx +0 -180
- package/src/components/ShadcnInputOtp.tsx +0 -189
- package/src/components/ShadcnItem.tsx +0 -182
- package/src/components/ShadcnKbd.tsx +0 -46
- package/src/components/ShadcnLabel.tsx +0 -19
- package/src/components/ShadcnMenubar.tsx +0 -491
- package/src/components/ShadcnNativeSelect.tsx +0 -77
- package/src/components/ShadcnNavigationMenu.tsx +0 -198
- package/src/components/ShadcnPagination.tsx +0 -152
- package/src/components/ShadcnPopover.tsx +0 -229
- package/src/components/ShadcnProgress.tsx +0 -39
- package/src/components/ShadcnRadioGroup.tsx +0 -115
- package/src/components/ShadcnRangeCalendar.tsx +0 -396
- package/src/components/ShadcnSelect.tsx +0 -262
- package/src/components/ShadcnSeparator.tsx +0 -45
- package/src/components/ShadcnSheet.tsx +0 -247
- package/src/components/ShadcnSidebar.tsx +0 -638
- package/src/components/ShadcnSkeleton.tsx +0 -16
- package/src/components/ShadcnSlider.tsx +0 -213
- package/src/components/ShadcnSonner.tsx +0 -41
- package/src/components/ShadcnSpinner.tsx +0 -39
- package/src/components/ShadcnSwitch.tsx +0 -92
- package/src/components/ShadcnTabs.tsx +0 -171
- package/src/components/ShadcnTextarea.tsx +0 -24
- package/src/components/ShadcnToggle.tsx +0 -74
- package/src/components/ShadcnToggleGroup.tsx +0 -197
- package/src/components/ShadcnTooltip.tsx +0 -172
- package/src/index.ts +0 -124
- package/tsconfig.json +0 -10
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { PanelLeft } from 'lucide-react';
|
|
3
|
-
import { cn, cva, type VariantProps } from '@surreal-ui/core';
|
|
4
|
-
|
|
5
|
-
export const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
|
6
|
-
export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
7
|
-
export const SIDEBAR_WIDTH = '16rem';
|
|
8
|
-
export const SIDEBAR_WIDTH_MOBILE = '18rem';
|
|
9
|
-
export const SIDEBAR_WIDTH_ICON = '3rem';
|
|
10
|
-
export const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
11
|
-
|
|
12
|
-
interface SidebarContextType {
|
|
13
|
-
state: 'expanded' | 'collapsed';
|
|
14
|
-
open: boolean;
|
|
15
|
-
setOpen: (open: boolean | ((value: boolean) => boolean)) => void;
|
|
16
|
-
openMobile: boolean;
|
|
17
|
-
setOpenMobile: (open: boolean | ((value: boolean) => boolean)) => void;
|
|
18
|
-
isMobile: boolean;
|
|
19
|
-
toggleSidebar: () => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const SidebarContext = React.createContext<SidebarContextType | null>(null);
|
|
23
|
-
|
|
24
|
-
export function useSidebar() {
|
|
25
|
-
const context = React.useContext(SidebarContext);
|
|
26
|
-
if (!context) {
|
|
27
|
-
throw new Error('useSidebar must be used within a SidebarProvider');
|
|
28
|
-
}
|
|
29
|
-
return context;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface SidebarProviderProps extends React.ComponentProps<'div'> {
|
|
33
|
-
defaultOpen?: boolean;
|
|
34
|
-
open?: boolean;
|
|
35
|
-
onOpenChange?: (open: boolean) => void;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function SidebarProvider({
|
|
39
|
-
defaultOpen = true,
|
|
40
|
-
open: openProp,
|
|
41
|
-
onOpenChange: setOpenProp,
|
|
42
|
-
className,
|
|
43
|
-
style,
|
|
44
|
-
children,
|
|
45
|
-
...props
|
|
46
|
-
}: SidebarProviderProps) {
|
|
47
|
-
const [isMobile, setIsMobile] = React.useState(false);
|
|
48
|
-
const [openMobile, setOpenMobile] = React.useState(false);
|
|
49
|
-
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
50
|
-
const open = openProp ?? _open;
|
|
51
|
-
|
|
52
|
-
const setOpen = React.useCallback(
|
|
53
|
-
(value: boolean | ((value: boolean) => boolean)) => {
|
|
54
|
-
const openState = typeof value === 'function' ? value(open) : value;
|
|
55
|
-
if (setOpenProp) {
|
|
56
|
-
setOpenProp(openState);
|
|
57
|
-
} else {
|
|
58
|
-
_setOpen(openState);
|
|
59
|
-
}
|
|
60
|
-
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
61
|
-
},
|
|
62
|
-
[setOpenProp, open]
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
React.useEffect(() => {
|
|
66
|
-
const checkMobile = () => {
|
|
67
|
-
setIsMobile(window.innerWidth < 768);
|
|
68
|
-
};
|
|
69
|
-
checkMobile();
|
|
70
|
-
window.addEventListener('resize', checkMobile);
|
|
71
|
-
return () => window.removeEventListener('resize', checkMobile);
|
|
72
|
-
}, []);
|
|
73
|
-
|
|
74
|
-
const toggleSidebar = React.useCallback(() => {
|
|
75
|
-
return isMobile ? setOpenMobile((prev) => !prev) : setOpen((prev) => !prev);
|
|
76
|
-
}, [isMobile, setOpen]);
|
|
77
|
-
|
|
78
|
-
React.useEffect(() => {
|
|
79
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
80
|
-
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
81
|
-
event.preventDefault();
|
|
82
|
-
toggleSidebar();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
86
|
-
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
87
|
-
}, [toggleSidebar]);
|
|
88
|
-
|
|
89
|
-
const state = open ? 'expanded' : 'collapsed';
|
|
90
|
-
|
|
91
|
-
const contextValue = React.useMemo<SidebarContextType>(
|
|
92
|
-
() => ({
|
|
93
|
-
state,
|
|
94
|
-
open,
|
|
95
|
-
setOpen,
|
|
96
|
-
isMobile,
|
|
97
|
-
openMobile,
|
|
98
|
-
setOpenMobile,
|
|
99
|
-
toggleSidebar
|
|
100
|
-
}),
|
|
101
|
-
[state, open, setOpen, isMobile, openMobile, toggleSidebar]
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<SidebarContext.Provider value={contextValue}>
|
|
106
|
-
<div
|
|
107
|
-
data-slot="sidebar-wrapper"
|
|
108
|
-
style={
|
|
109
|
-
{
|
|
110
|
-
'--sidebar-width': SIDEBAR_WIDTH,
|
|
111
|
-
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
112
|
-
...style
|
|
113
|
-
} as React.CSSProperties
|
|
114
|
-
}
|
|
115
|
-
className={cn(
|
|
116
|
-
'group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar',
|
|
117
|
-
className
|
|
118
|
-
)}
|
|
119
|
-
{...props}
|
|
120
|
-
>
|
|
121
|
-
{children}
|
|
122
|
-
</div>
|
|
123
|
-
</SidebarContext.Provider>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface ShadcnSidebarProps extends React.ComponentProps<'div'> {
|
|
128
|
-
side?: 'left' | 'right';
|
|
129
|
-
variant?: 'sidebar' | 'floating' | 'inset';
|
|
130
|
-
collapsible?: 'offcanvas' | 'icon' | 'none';
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export const ShadcnSidebar = React.forwardRef<HTMLDivElement, SidebarProps>(
|
|
134
|
-
(
|
|
135
|
-
{
|
|
136
|
-
side = 'left',
|
|
137
|
-
variant = 'sidebar',
|
|
138
|
-
collapsible = 'offcanvas',
|
|
139
|
-
className,
|
|
140
|
-
children,
|
|
141
|
-
...props
|
|
142
|
-
},
|
|
143
|
-
ref
|
|
144
|
-
) => {
|
|
145
|
-
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
146
|
-
|
|
147
|
-
if (collapsible === 'none') {
|
|
148
|
-
return (
|
|
149
|
-
<div
|
|
150
|
-
ref={ref}
|
|
151
|
-
className={cn(
|
|
152
|
-
'flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground border-r border-sidebar-border',
|
|
153
|
-
className
|
|
154
|
-
)}
|
|
155
|
-
{...props}
|
|
156
|
-
>
|
|
157
|
-
{children}
|
|
158
|
-
</div>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (isMobile) {
|
|
163
|
-
return (
|
|
164
|
-
<>
|
|
165
|
-
{openMobile && (
|
|
166
|
-
<div
|
|
167
|
-
className="fixed inset-0 z-40 bg-black/60 md:hidden animate-in fade-in-0 duration-200"
|
|
168
|
-
onClick={() => setOpenMobile(false)}
|
|
169
|
-
/>
|
|
170
|
-
)}
|
|
171
|
-
<div
|
|
172
|
-
ref={ref}
|
|
173
|
-
data-sidebar="sidebar"
|
|
174
|
-
data-slot="sidebar"
|
|
175
|
-
data-mobile="true"
|
|
176
|
-
data-state={openMobile ? 'open' : 'closed'}
|
|
177
|
-
className={cn(
|
|
178
|
-
'fixed inset-y-0 z-50 flex h-full w-(--sidebar-width) flex-col bg-sidebar p-0 text-sidebar-foreground shadow-2xl transition-transform duration-200 ease-in-out md:hidden',
|
|
179
|
-
side === 'left'
|
|
180
|
-
? openMobile
|
|
181
|
-
? 'left-0 translate-x-0'
|
|
182
|
-
: 'left-0 -translate-x-full'
|
|
183
|
-
: openMobile
|
|
184
|
-
? 'right-0 translate-x-0'
|
|
185
|
-
: 'right-0 translate-x-full',
|
|
186
|
-
className
|
|
187
|
-
)}
|
|
188
|
-
style={{ '--sidebar-width': SIDEBAR_WIDTH_MOBILE } as React.CSSProperties}
|
|
189
|
-
{...props}
|
|
190
|
-
>
|
|
191
|
-
<div className="flex h-full w-full flex-col">{children}</div>
|
|
192
|
-
</div>
|
|
193
|
-
</>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div
|
|
199
|
-
ref={ref}
|
|
200
|
-
className="group peer hidden text-sidebar-foreground md:block"
|
|
201
|
-
data-state={state}
|
|
202
|
-
data-collapsible={state === 'collapsed' ? collapsible : ''}
|
|
203
|
-
data-variant={variant}
|
|
204
|
-
data-side={side}
|
|
205
|
-
data-slot="sidebar"
|
|
206
|
-
>
|
|
207
|
-
<div
|
|
208
|
-
data-slot="sidebar-gap"
|
|
209
|
-
className={cn(
|
|
210
|
-
'transition-[width] duration-200 ease-linear relative w-(--sidebar-width) bg-transparent',
|
|
211
|
-
'group-data-[collapsible=offcanvas]:w-0',
|
|
212
|
-
'group-data-[side=right]:rotate-180',
|
|
213
|
-
variant === 'floating' || variant === 'inset'
|
|
214
|
-
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+theme(spacing.4))]'
|
|
215
|
-
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)'
|
|
216
|
-
)}
|
|
217
|
-
/>
|
|
218
|
-
<div
|
|
219
|
-
data-slot="sidebar-container"
|
|
220
|
-
className={cn(
|
|
221
|
-
'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',
|
|
222
|
-
side === 'left'
|
|
223
|
-
? 'start-0 group-data-[collapsible=offcanvas]:start-[calc(var(--sidebar-width)*-1)]'
|
|
224
|
-
: 'end-0 group-data-[collapsible=offcanvas]:end-[calc(var(--sidebar-width)*-1)]',
|
|
225
|
-
variant === 'floating' || variant === 'inset'
|
|
226
|
-
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+theme(spacing.4)+2px)]'
|
|
227
|
-
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s border-sidebar-border',
|
|
228
|
-
className
|
|
229
|
-
)}
|
|
230
|
-
{...props}
|
|
231
|
-
>
|
|
232
|
-
<div
|
|
233
|
-
data-sidebar="sidebar"
|
|
234
|
-
data-slot="sidebar-inner"
|
|
235
|
-
className="bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border flex size-full flex-col"
|
|
236
|
-
>
|
|
237
|
-
{children}
|
|
238
|
-
</div>
|
|
239
|
-
</div>
|
|
240
|
-
</div>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
Sidebar.displayName = 'Sidebar';
|
|
245
|
-
|
|
246
|
-
export const ShadcnSidebarTrigger = React.forwardRef<
|
|
247
|
-
HTMLButtonElement,
|
|
248
|
-
React.ComponentProps<'button'>
|
|
249
|
-
>(({ className, onClick, ...props }, ref) => {
|
|
250
|
-
const { toggleSidebar } = useSidebar();
|
|
251
|
-
return (
|
|
252
|
-
<button
|
|
253
|
-
ref={ref}
|
|
254
|
-
type="button"
|
|
255
|
-
data-sidebar="trigger"
|
|
256
|
-
data-slot="sidebar-trigger"
|
|
257
|
-
className={cn(
|
|
258
|
-
'inline-flex items-center justify-center size-8 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground text-sidebar-foreground transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-sidebar-ring',
|
|
259
|
-
className
|
|
260
|
-
)}
|
|
261
|
-
onClick={(e) => {
|
|
262
|
-
onClick?.(e);
|
|
263
|
-
toggleSidebar();
|
|
264
|
-
}}
|
|
265
|
-
{...props}
|
|
266
|
-
>
|
|
267
|
-
<PanelLeft className="size-4" />
|
|
268
|
-
<span className="sr-only">Toggle Sidebar</span>
|
|
269
|
-
</button>
|
|
270
|
-
);
|
|
271
|
-
});
|
|
272
|
-
SidebarTrigger.displayName = 'SidebarTrigger';
|
|
273
|
-
|
|
274
|
-
export const SidebarRail = React.forwardRef<HTMLButtonElement, React.ComponentProps<'button'>>(
|
|
275
|
-
({ className, onClick, ...props }, ref) => {
|
|
276
|
-
const { toggleSidebar } = useSidebar();
|
|
277
|
-
return (
|
|
278
|
-
<button
|
|
279
|
-
ref={ref}
|
|
280
|
-
data-sidebar="rail"
|
|
281
|
-
data-slot="sidebar-rail"
|
|
282
|
-
aria-label="Toggle Sidebar"
|
|
283
|
-
tabIndex={-1}
|
|
284
|
-
onClick={(e) => {
|
|
285
|
-
onClick?.(e);
|
|
286
|
-
toggleSidebar();
|
|
287
|
-
}}
|
|
288
|
-
title="Toggle Sidebar"
|
|
289
|
-
className={cn(
|
|
290
|
-
'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 in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize [[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
|
|
291
|
-
className
|
|
292
|
-
)}
|
|
293
|
-
{...props}
|
|
294
|
-
/>
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
);
|
|
298
|
-
SidebarRail.displayName = 'SidebarRail';
|
|
299
|
-
|
|
300
|
-
export const SidebarInset = React.forwardRef<HTMLElement, React.ComponentProps<'main'>>(
|
|
301
|
-
({ className, ...props }, ref) => (
|
|
302
|
-
<main
|
|
303
|
-
ref={ref}
|
|
304
|
-
data-slot="sidebar-inset"
|
|
305
|
-
className={cn(
|
|
306
|
-
'bg-background 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 relative flex w-full flex-1 flex-col',
|
|
307
|
-
className
|
|
308
|
-
)}
|
|
309
|
-
{...props}
|
|
310
|
-
/>
|
|
311
|
-
)
|
|
312
|
-
);
|
|
313
|
-
SidebarInset.displayName = 'SidebarInset';
|
|
314
|
-
|
|
315
|
-
export const ShadcnSidebarInput = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
|
316
|
-
({ className, ...props }, ref) => (
|
|
317
|
-
<input
|
|
318
|
-
ref={ref}
|
|
319
|
-
data-slot="sidebar-input"
|
|
320
|
-
data-sidebar="input"
|
|
321
|
-
className={cn(
|
|
322
|
-
'h-8 w-full bg-background border border-input rounded-md px-3 text-sm shadow-none focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring',
|
|
323
|
-
className
|
|
324
|
-
)}
|
|
325
|
-
{...props}
|
|
326
|
-
/>
|
|
327
|
-
)
|
|
328
|
-
);
|
|
329
|
-
SidebarInput.displayName = 'SidebarInput';
|
|
330
|
-
|
|
331
|
-
export const ShadcnSidebarHeader = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
332
|
-
({ className, ...props }, ref) => (
|
|
333
|
-
<div
|
|
334
|
-
ref={ref}
|
|
335
|
-
data-slot="sidebar-header"
|
|
336
|
-
data-sidebar="header"
|
|
337
|
-
className={cn('gap-2 p-2 flex flex-col', className)}
|
|
338
|
-
{...props}
|
|
339
|
-
/>
|
|
340
|
-
)
|
|
341
|
-
);
|
|
342
|
-
SidebarHeader.displayName = 'SidebarHeader';
|
|
343
|
-
|
|
344
|
-
export const ShadcnSidebarFooter = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
345
|
-
({ className, ...props }, ref) => (
|
|
346
|
-
<div
|
|
347
|
-
ref={ref}
|
|
348
|
-
data-slot="sidebar-footer"
|
|
349
|
-
data-sidebar="footer"
|
|
350
|
-
className={cn('gap-2 p-2 flex flex-col', className)}
|
|
351
|
-
{...props}
|
|
352
|
-
/>
|
|
353
|
-
)
|
|
354
|
-
);
|
|
355
|
-
SidebarFooter.displayName = 'SidebarFooter';
|
|
356
|
-
|
|
357
|
-
export const ShadcnSidebarSeparator = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
358
|
-
({ className, ...props }, ref) => (
|
|
359
|
-
<div
|
|
360
|
-
ref={ref}
|
|
361
|
-
role="separator"
|
|
362
|
-
data-slot="sidebar-separator"
|
|
363
|
-
data-sidebar="separator"
|
|
364
|
-
className={cn('mx-2 bg-sidebar-border h-px w-auto', className)}
|
|
365
|
-
{...props}
|
|
366
|
-
/>
|
|
367
|
-
)
|
|
368
|
-
);
|
|
369
|
-
SidebarSeparator.displayName = 'SidebarSeparator';
|
|
370
|
-
|
|
371
|
-
export const ShadcnSidebarContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
372
|
-
({ className, ...props }, ref) => (
|
|
373
|
-
<div
|
|
374
|
-
ref={ref}
|
|
375
|
-
data-slot="sidebar-content"
|
|
376
|
-
data-sidebar="content"
|
|
377
|
-
className={cn(
|
|
378
|
-
'no-scrollbar gap-0 flex min-h-0 flex-1 flex-col overflow-auto group-data-[collapsible=icon]:overflow-hidden',
|
|
379
|
-
className
|
|
380
|
-
)}
|
|
381
|
-
{...props}
|
|
382
|
-
/>
|
|
383
|
-
)
|
|
384
|
-
);
|
|
385
|
-
SidebarContent.displayName = 'SidebarContent';
|
|
386
|
-
|
|
387
|
-
export const ShadcnSidebarGroup = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
388
|
-
({ className, ...props }, ref) => (
|
|
389
|
-
<div
|
|
390
|
-
ref={ref}
|
|
391
|
-
data-slot="sidebar-group"
|
|
392
|
-
data-sidebar="group"
|
|
393
|
-
className={cn('p-2 relative flex w-full min-w-0 flex-col', className)}
|
|
394
|
-
{...props}
|
|
395
|
-
/>
|
|
396
|
-
)
|
|
397
|
-
);
|
|
398
|
-
SidebarGroup.displayName = 'SidebarGroup';
|
|
399
|
-
|
|
400
|
-
export const SidebarGroupLabel = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
401
|
-
({ className, ...props }, ref) => (
|
|
402
|
-
<div
|
|
403
|
-
ref={ref}
|
|
404
|
-
data-slot="sidebar-group-label"
|
|
405
|
-
data-sidebar="group-label"
|
|
406
|
-
className={cn(
|
|
407
|
-
'h-8 rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 flex shrink-0 items-center outline-hidden [&>svg]:size-4 [&>svg]:shrink-0',
|
|
408
|
-
className
|
|
409
|
-
)}
|
|
410
|
-
{...props}
|
|
411
|
-
/>
|
|
412
|
-
)
|
|
413
|
-
);
|
|
414
|
-
SidebarGroupLabel.displayName = 'SidebarGroupLabel';
|
|
415
|
-
|
|
416
|
-
export const SidebarGroupAction = React.forwardRef<
|
|
417
|
-
HTMLButtonElement,
|
|
418
|
-
React.ComponentProps<'button'>
|
|
419
|
-
>(({ className, ...props }, ref) => (
|
|
420
|
-
<button
|
|
421
|
-
ref={ref}
|
|
422
|
-
type="button"
|
|
423
|
-
data-slot="sidebar-group-action"
|
|
424
|
-
data-sidebar="group-action"
|
|
425
|
-
className={cn(
|
|
426
|
-
'absolute top-3.5 right-3 w-5 rounded-md p-0 text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 flex aspect-square items-center justify-center outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
|
|
427
|
-
className
|
|
428
|
-
)}
|
|
429
|
-
{...props}
|
|
430
|
-
/>
|
|
431
|
-
));
|
|
432
|
-
SidebarGroupAction.displayName = 'SidebarGroupAction';
|
|
433
|
-
|
|
434
|
-
export const SidebarGroupContent = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
435
|
-
({ className, ...props }, ref) => (
|
|
436
|
-
<div
|
|
437
|
-
ref={ref}
|
|
438
|
-
data-slot="sidebar-group-content"
|
|
439
|
-
data-sidebar="group-content"
|
|
440
|
-
className={cn('text-sm w-full', className)}
|
|
441
|
-
{...props}
|
|
442
|
-
/>
|
|
443
|
-
)
|
|
444
|
-
);
|
|
445
|
-
SidebarGroupContent.displayName = 'SidebarGroupContent';
|
|
446
|
-
|
|
447
|
-
export const SidebarMenu = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(
|
|
448
|
-
({ className, ...props }, ref) => (
|
|
449
|
-
<ul
|
|
450
|
-
ref={ref}
|
|
451
|
-
data-slot="sidebar-menu"
|
|
452
|
-
data-sidebar="menu"
|
|
453
|
-
className={cn('gap-0 flex w-full min-w-0 flex-col list-none p-0 m-0', className)}
|
|
454
|
-
{...props}
|
|
455
|
-
/>
|
|
456
|
-
)
|
|
457
|
-
);
|
|
458
|
-
SidebarMenu.displayName = 'SidebarMenu';
|
|
459
|
-
|
|
460
|
-
export const SidebarMenuItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(
|
|
461
|
-
({ className, ...props }, ref) => (
|
|
462
|
-
<li
|
|
463
|
-
ref={ref}
|
|
464
|
-
data-slot="sidebar-menu-item"
|
|
465
|
-
data-sidebar="menu-item"
|
|
466
|
-
className={cn('group/menu-item relative list-none', className)}
|
|
467
|
-
{...props}
|
|
468
|
-
/>
|
|
469
|
-
)
|
|
470
|
-
);
|
|
471
|
-
SidebarMenuItem.displayName = 'SidebarMenuItem';
|
|
472
|
-
|
|
473
|
-
export const sidebarMenuButtonVariants = cva(
|
|
474
|
-
'gap-2 rounded-md p-2 text-left text-sm ring-sidebar-ring transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground peer/menu-button group/menu-button flex w-full items-center overflow-hidden outline-hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate',
|
|
475
|
-
{
|
|
476
|
-
variants: {
|
|
477
|
-
variant: {
|
|
478
|
-
default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
|
479
|
-
outline:
|
|
480
|
-
'bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]'
|
|
481
|
-
},
|
|
482
|
-
size: {
|
|
483
|
-
default: 'h-8 text-sm',
|
|
484
|
-
sm: 'h-7 text-xs',
|
|
485
|
-
lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'
|
|
486
|
-
}
|
|
487
|
-
},
|
|
488
|
-
defaultVariants: {
|
|
489
|
-
variant: 'default',
|
|
490
|
-
size: 'default'
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
);
|
|
494
|
-
|
|
495
|
-
export interface SidebarMenuButtonProps
|
|
496
|
-
extends React.ComponentProps<'button'>, VariantProps<typeof sidebarMenuButtonVariants> {
|
|
497
|
-
isActive?: boolean;
|
|
498
|
-
tooltip?: string;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
export const SidebarMenuButton = React.forwardRef<HTMLButtonElement, SidebarMenuButtonProps>(
|
|
502
|
-
(
|
|
503
|
-
{ className, variant = 'default', size = 'default', isActive = false, tooltip, ...props },
|
|
504
|
-
ref
|
|
505
|
-
) => {
|
|
506
|
-
return (
|
|
507
|
-
<button
|
|
508
|
-
ref={ref}
|
|
509
|
-
type="button"
|
|
510
|
-
data-slot="sidebar-menu-button"
|
|
511
|
-
data-sidebar="menu-button"
|
|
512
|
-
data-size={size}
|
|
513
|
-
data-active={isActive}
|
|
514
|
-
title={tooltip}
|
|
515
|
-
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
516
|
-
{...props}
|
|
517
|
-
/>
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
);
|
|
521
|
-
SidebarMenuButton.displayName = 'SidebarMenuButton';
|
|
522
|
-
|
|
523
|
-
export interface SidebarMenuActionProps extends React.ComponentProps<'button'> {
|
|
524
|
-
showOnHover?: boolean;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
export const SidebarMenuAction = React.forwardRef<HTMLButtonElement, SidebarMenuActionProps>(
|
|
528
|
-
({ className, showOnHover = false, ...props }, ref) => (
|
|
529
|
-
<button
|
|
530
|
-
ref={ref}
|
|
531
|
-
type="button"
|
|
532
|
-
data-slot="sidebar-menu-action"
|
|
533
|
-
data-sidebar="menu-action"
|
|
534
|
-
className={cn(
|
|
535
|
-
'absolute top-1.5 right-1 aspect-square w-5 rounded-md p-0 text-sidebar-foreground ring-sidebar-ring peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 flex items-center justify-center outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
|
|
536
|
-
showOnHover &&
|
|
537
|
-
'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground md:opacity-0 data-open:opacity-100',
|
|
538
|
-
className
|
|
539
|
-
)}
|
|
540
|
-
{...props}
|
|
541
|
-
/>
|
|
542
|
-
)
|
|
543
|
-
);
|
|
544
|
-
SidebarMenuAction.displayName = 'SidebarMenuAction';
|
|
545
|
-
|
|
546
|
-
export const SidebarMenuBadge = React.forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
547
|
-
({ className, ...props }, ref) => (
|
|
548
|
-
<div
|
|
549
|
-
ref={ref}
|
|
550
|
-
data-slot="sidebar-menu-badge"
|
|
551
|
-
data-sidebar="menu-badge"
|
|
552
|
-
className={cn(
|
|
553
|
-
'pointer-events-none absolute right-1 flex h-5 min-w-5 rounded-md px-1 text-xs font-medium text-sidebar-foreground peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground items-center justify-center tabular-nums select-none group-data-[collapsible=icon]:hidden',
|
|
554
|
-
className
|
|
555
|
-
)}
|
|
556
|
-
{...props}
|
|
557
|
-
/>
|
|
558
|
-
)
|
|
559
|
-
);
|
|
560
|
-
SidebarMenuBadge.displayName = 'SidebarMenuBadge';
|
|
561
|
-
|
|
562
|
-
export const SidebarMenuSub = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(
|
|
563
|
-
({ className, ...props }, ref) => (
|
|
564
|
-
<ul
|
|
565
|
-
ref={ref}
|
|
566
|
-
data-slot="sidebar-menu-sub"
|
|
567
|
-
data-sidebar="menu-sub"
|
|
568
|
-
className={cn(
|
|
569
|
-
'mx-3.5 translate-x-px gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden flex min-w-0 flex-col list-none',
|
|
570
|
-
className
|
|
571
|
-
)}
|
|
572
|
-
{...props}
|
|
573
|
-
/>
|
|
574
|
-
)
|
|
575
|
-
);
|
|
576
|
-
SidebarMenuSub.displayName = 'SidebarMenuSub';
|
|
577
|
-
|
|
578
|
-
export const SidebarMenuSubItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(
|
|
579
|
-
({ className, ...props }, ref) => (
|
|
580
|
-
<li
|
|
581
|
-
ref={ref}
|
|
582
|
-
data-slot="sidebar-menu-sub-item"
|
|
583
|
-
data-sidebar="menu-sub-item"
|
|
584
|
-
className={cn('group/menu-sub-item relative list-none', className)}
|
|
585
|
-
{...props}
|
|
586
|
-
/>
|
|
587
|
-
)
|
|
588
|
-
);
|
|
589
|
-
SidebarMenuSubItem.displayName = 'SidebarMenuSubItem';
|
|
590
|
-
|
|
591
|
-
export interface SidebarMenuSubButtonProps extends React.ComponentProps<'a'> {
|
|
592
|
-
size?: 'sm' | 'md';
|
|
593
|
-
isActive?: boolean;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
export const SidebarMenuSubButton = React.forwardRef<HTMLAnchorElement, SidebarMenuSubButtonProps>(
|
|
597
|
-
({ className, size = 'md', isActive = false, ...props }, ref) => (
|
|
598
|
-
<a
|
|
599
|
-
ref={ref}
|
|
600
|
-
data-slot="sidebar-menu-sub-button"
|
|
601
|
-
data-sidebar="menu-sub-button"
|
|
602
|
-
data-size={size}
|
|
603
|
-
data-active={isActive}
|
|
604
|
-
className={cn(
|
|
605
|
-
'h-7 gap-2 rounded-md px-2 text-sidebar-foreground 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 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:text-sidebar-accent-foreground flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0 no-underline',
|
|
606
|
-
className
|
|
607
|
-
)}
|
|
608
|
-
{...props}
|
|
609
|
-
/>
|
|
610
|
-
)
|
|
611
|
-
);
|
|
612
|
-
SidebarMenuSubButton.displayName = 'SidebarMenuSubButton';
|
|
613
|
-
|
|
614
|
-
export interface SidebarMenuSkeletonProps extends React.ComponentProps<'div'> {
|
|
615
|
-
showIcon?: boolean;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
export const SidebarMenuSkeleton = React.forwardRef<HTMLDivElement, SidebarMenuSkeletonProps>(
|
|
619
|
-
({ className, showIcon = false, ...props }, ref) => (
|
|
620
|
-
<div
|
|
621
|
-
ref={ref}
|
|
622
|
-
data-slot="sidebar-menu-skeleton"
|
|
623
|
-
data-sidebar="menu-skeleton"
|
|
624
|
-
className={cn('h-8 gap-2 rounded-md px-2 flex items-center animate-pulse', className)}
|
|
625
|
-
{...props}
|
|
626
|
-
>
|
|
627
|
-
{showIcon && (
|
|
628
|
-
<div className="size-4 rounded-md bg-sidebar-accent" data-sidebar="menu-skeleton-icon" />
|
|
629
|
-
)}
|
|
630
|
-
<div className="h-4 w-3/4 rounded-md bg-sidebar-accent" data-sidebar="menu-skeleton-text" />
|
|
631
|
-
</div>
|
|
632
|
-
)
|
|
633
|
-
);
|
|
634
|
-
SidebarMenuSkeleton.displayName = 'SidebarMenuSkeleton';
|
|
635
|
-
|
|
636
|
-
export { SidebarProvider as Root, ShadcnSidebar as ContentRoot };
|
|
637
|
-
|
|
638
|
-
export default ShadcnSidebar;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export interface ShadcnSkeletonProps extends React.ComponentProps<'div'> {}
|
|
5
|
-
|
|
6
|
-
export function ShadcnSkeleton({ className, ...props }: SkeletonProps) {
|
|
7
|
-
return (
|
|
8
|
-
<div
|
|
9
|
-
data-slot="skeleton"
|
|
10
|
-
className={cn('rounded-md bg-muted animate-pulse', className)}
|
|
11
|
-
{...props}
|
|
12
|
-
/>
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default ShadcnSkeleton;
|