@weaverclub/render 0.0.2 → 0.0.3
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/entrypoint +0 -0
- package/package.json +6 -2
- package/.github/workflows/publish.yml +0 -44
- package/biome.json +0 -42
- package/build.ts +0 -62
- package/bun.lock +0 -733
- package/bunfig.toml +0 -3
- package/ideas.md +0 -11
- package/publish.ts +0 -62
- package/src/cli/command/renderCommand.ts +0 -112
- package/src/cli/entrypoint.ts +0 -25
- package/src/core/bundler.ts +0 -180
- package/src/core/control/arrayControl.ts +0 -15
- package/src/core/control/booleanControl.ts +0 -15
- package/src/core/control/control.ts +0 -7
- package/src/core/control/controlBuilder.ts +0 -87
- package/src/core/control/numberControl.ts +0 -15
- package/src/core/control/stringControl.ts +0 -15
- package/src/core/control/variantControl.ts +0 -18
- package/src/core/css/css.ts +0 -50
- package/src/core/css/tailwind.ts +0 -172
- package/src/core/html.ts +0 -63
- package/src/core/pkg.ts +0 -92
- package/src/core/story.ts +0 -52
- package/src/core/tsconfig.ts +0 -46
- package/src/react/react.ts +0 -2
- package/src/react/reactControlBuilder.ts +0 -130
- package/src/react/reactStory.ts +0 -36
- package/src/server/api/getStories.ts +0 -44
- package/src/server/api/renderIframe.ts +0 -66
- package/src/server/backend.ts +0 -104
- package/src/server/streaming.ts +0 -16
- package/src/ui/api.ts +0 -16
- package/src/ui/app.tsx +0 -23
- package/src/ui/cn.ts +0 -6
- package/src/ui/components/appSidebar.tsx +0 -76
- package/src/ui/components/button.stories.tsx +0 -32
- package/src/ui/components/button.tsx +0 -55
- package/src/ui/components/command.tsx +0 -187
- package/src/ui/components/contextMenu.tsx +0 -261
- package/src/ui/components/dialog.tsx +0 -153
- package/src/ui/components/input.tsx +0 -23
- package/src/ui/components/inputGroup.tsx +0 -157
- package/src/ui/components/kdb.tsx +0 -26
- package/src/ui/components/searchCommand.tsx +0 -5
- package/src/ui/components/separator.tsx +0 -22
- package/src/ui/components/sheet.tsx +0 -131
- package/src/ui/components/sidebar.tsx +0 -725
- package/src/ui/components/skeleton.tsx +0 -13
- package/src/ui/components/spinner.tsx +0 -15
- package/src/ui/components/tabButton.tsx +0 -80
- package/src/ui/components/tabContent.tsx +0 -20
- package/src/ui/components/tabList.tsx +0 -53
- package/src/ui/components/textarea.tsx +0 -17
- package/src/ui/components/tooltip.tsx +0 -67
- package/src/ui/frontend.tsx +0 -68
- package/src/ui/hooks/useMobile.ts +0 -23
- package/src/ui/index.html +0 -12
- package/src/ui/routeTree.gen.ts +0 -35
- package/src/ui/routes/__root.tsx +0 -9
- package/src/ui/styles.css +0 -123
- package/src/ui/tabs.tsx +0 -89
- package/tsconfig.json +0 -25
- package/tsr.config.json +0 -6
|
@@ -1,725 +0,0 @@
|
|
|
1
|
-
import { mergeProps } from '@base-ui/react/merge-props'
|
|
2
|
-
import { useRender } from '@base-ui/react/use-render'
|
|
3
|
-
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
-
import { PanelLeftIcon } from 'lucide-react'
|
|
5
|
-
import * as React from 'react'
|
|
6
|
-
import { cn } from '../cn'
|
|
7
|
-
import { useIsMobile } from '../hooks/useMobile'
|
|
8
|
-
import { Button } from './button'
|
|
9
|
-
import { Input } from './input'
|
|
10
|
-
import { Separator } from './separator'
|
|
11
|
-
import {
|
|
12
|
-
Sheet,
|
|
13
|
-
SheetContent,
|
|
14
|
-
SheetDescription,
|
|
15
|
-
SheetHeader,
|
|
16
|
-
SheetTitle
|
|
17
|
-
} from './sheet'
|
|
18
|
-
import { Skeleton } from './skeleton'
|
|
19
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip'
|
|
20
|
-
|
|
21
|
-
const SIDEBAR_COOKIE_NAME = 'sidebar_state'
|
|
22
|
-
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
|
23
|
-
const SIDEBAR_WIDTH = '16rem'
|
|
24
|
-
const SIDEBAR_WIDTH_MOBILE = '18rem'
|
|
25
|
-
const SIDEBAR_WIDTH_ICON = '3rem'
|
|
26
|
-
const SIDEBAR_KEYBOARD_SHORTCUT = 'b'
|
|
27
|
-
|
|
28
|
-
type SidebarContextProps = {
|
|
29
|
-
state: 'expanded' | 'collapsed'
|
|
30
|
-
open: boolean
|
|
31
|
-
setOpen: (open: boolean) => void
|
|
32
|
-
openMobile: boolean
|
|
33
|
-
setOpenMobile: (open: boolean) => void
|
|
34
|
-
isMobile: boolean
|
|
35
|
-
toggleSidebar: () => void
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
|
|
39
|
-
|
|
40
|
-
function useSidebar() {
|
|
41
|
-
const context = React.useContext(SidebarContext)
|
|
42
|
-
if (!context) {
|
|
43
|
-
throw new Error('useSidebar must be used within a SidebarProvider.')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return context
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function SidebarProvider({
|
|
50
|
-
defaultOpen = true,
|
|
51
|
-
open: openProp,
|
|
52
|
-
onOpenChange: setOpenProp,
|
|
53
|
-
className,
|
|
54
|
-
style,
|
|
55
|
-
children,
|
|
56
|
-
...props
|
|
57
|
-
}: React.ComponentProps<'div'> & {
|
|
58
|
-
defaultOpen?: boolean
|
|
59
|
-
open?: boolean
|
|
60
|
-
onOpenChange?: (open: boolean) => void
|
|
61
|
-
}) {
|
|
62
|
-
const isMobile = useIsMobile()
|
|
63
|
-
const [openMobile, setOpenMobile] = React.useState(false)
|
|
64
|
-
|
|
65
|
-
// This is the internal state of the sidebar.
|
|
66
|
-
// We use openProp and setOpenProp for control from outside the component.
|
|
67
|
-
const [_open, _setOpen] = React.useState(defaultOpen)
|
|
68
|
-
const open = openProp ?? _open
|
|
69
|
-
const setOpen = React.useCallback(
|
|
70
|
-
(value: boolean | ((value: boolean) => boolean)) => {
|
|
71
|
-
const openState = typeof value === 'function' ? value(open) : value
|
|
72
|
-
if (setOpenProp) {
|
|
73
|
-
setOpenProp(openState)
|
|
74
|
-
} else {
|
|
75
|
-
_setOpen(openState)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// This sets the cookie to keep the sidebar state.
|
|
79
|
-
// biome-ignore lint/suspicious/noDocumentCookie: Intended use of document.cookie
|
|
80
|
-
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
|
|
81
|
-
},
|
|
82
|
-
[setOpenProp, open]
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
// Helper to toggle the sidebar.
|
|
86
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: The dependencies are correct.
|
|
87
|
-
const toggleSidebar = React.useCallback(() => {
|
|
88
|
-
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
|
|
89
|
-
}, [isMobile, setOpen, setOpenMobile])
|
|
90
|
-
|
|
91
|
-
// Adds a keyboard shortcut to toggle the sidebar.
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
94
|
-
if (
|
|
95
|
-
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
96
|
-
(event.metaKey || event.ctrlKey)
|
|
97
|
-
) {
|
|
98
|
-
event.preventDefault()
|
|
99
|
-
toggleSidebar()
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
window.addEventListener('keydown', handleKeyDown)
|
|
104
|
-
return () => window.removeEventListener('keydown', handleKeyDown)
|
|
105
|
-
}, [toggleSidebar])
|
|
106
|
-
|
|
107
|
-
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
108
|
-
// This makes it easier to style the sidebar with Tailwind classes.
|
|
109
|
-
const state = open ? 'expanded' : 'collapsed'
|
|
110
|
-
|
|
111
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: The dependencies are correct.
|
|
112
|
-
const contextValue = React.useMemo<SidebarContextProps>(
|
|
113
|
-
() => ({
|
|
114
|
-
state,
|
|
115
|
-
open,
|
|
116
|
-
setOpen,
|
|
117
|
-
isMobile,
|
|
118
|
-
openMobile,
|
|
119
|
-
setOpenMobile,
|
|
120
|
-
toggleSidebar
|
|
121
|
-
}),
|
|
122
|
-
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<SidebarContext.Provider value={contextValue}>
|
|
127
|
-
<div
|
|
128
|
-
data-slot="sidebar-wrapper"
|
|
129
|
-
style={
|
|
130
|
-
{
|
|
131
|
-
'--sidebar-width': SIDEBAR_WIDTH,
|
|
132
|
-
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
133
|
-
...style
|
|
134
|
-
} as React.CSSProperties
|
|
135
|
-
}
|
|
136
|
-
className={cn(
|
|
137
|
-
'group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full',
|
|
138
|
-
className
|
|
139
|
-
)}
|
|
140
|
-
{...props}
|
|
141
|
-
>
|
|
142
|
-
{children}
|
|
143
|
-
</div>
|
|
144
|
-
</SidebarContext.Provider>
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function Sidebar({
|
|
149
|
-
side = 'left',
|
|
150
|
-
variant = 'sidebar',
|
|
151
|
-
collapsible = 'offExamples',
|
|
152
|
-
className,
|
|
153
|
-
children,
|
|
154
|
-
...props
|
|
155
|
-
}: React.ComponentProps<'div'> & {
|
|
156
|
-
side?: 'left' | 'right'
|
|
157
|
-
variant?: 'sidebar' | 'floating' | 'inset'
|
|
158
|
-
collapsible?: 'offExamples' | 'icon' | 'none'
|
|
159
|
-
}) {
|
|
160
|
-
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
|
161
|
-
|
|
162
|
-
if (collapsible === 'none') {
|
|
163
|
-
return (
|
|
164
|
-
<div
|
|
165
|
-
data-slot="sidebar"
|
|
166
|
-
className={cn(
|
|
167
|
-
'bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col',
|
|
168
|
-
className
|
|
169
|
-
)}
|
|
170
|
-
{...props}
|
|
171
|
-
>
|
|
172
|
-
{children}
|
|
173
|
-
</div>
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (isMobile) {
|
|
178
|
-
return (
|
|
179
|
-
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
180
|
-
<SheetContent
|
|
181
|
-
data-sidebar="sidebar"
|
|
182
|
-
data-slot="sidebar"
|
|
183
|
-
data-mobile="true"
|
|
184
|
-
className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
185
|
-
style={
|
|
186
|
-
{
|
|
187
|
-
'--sidebar-width': SIDEBAR_WIDTH_MOBILE
|
|
188
|
-
} as React.CSSProperties
|
|
189
|
-
}
|
|
190
|
-
side={side}
|
|
191
|
-
>
|
|
192
|
-
<SheetHeader className="sr-only">
|
|
193
|
-
<SheetTitle>Sidebar</SheetTitle>
|
|
194
|
-
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
195
|
-
</SheetHeader>
|
|
196
|
-
<div className="flex h-full w-full flex-col">{children}</div>
|
|
197
|
-
</SheetContent>
|
|
198
|
-
</Sheet>
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return (
|
|
203
|
-
<div
|
|
204
|
-
className="group peer text-sidebar-foreground hidden md:block"
|
|
205
|
-
data-state={state}
|
|
206
|
-
data-collapsible={state === 'collapsed' ? collapsible : ''}
|
|
207
|
-
data-variant={variant}
|
|
208
|
-
data-side={side}
|
|
209
|
-
data-slot="sidebar"
|
|
210
|
-
>
|
|
211
|
-
{/* This is what handles the sidebar gap on desktop */}
|
|
212
|
-
<div
|
|
213
|
-
data-slot="sidebar-gap"
|
|
214
|
-
className={cn(
|
|
215
|
-
'transition-[width] duration-200 ease-linear relative w-(--sidebar-width) bg-transparent',
|
|
216
|
-
'group-data-[collapsible=offExamples]:w-0',
|
|
217
|
-
'group-data-[side=right]:rotate-180',
|
|
218
|
-
variant === 'floating' || variant === 'inset'
|
|
219
|
-
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
|
|
220
|
-
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)'
|
|
221
|
-
)}
|
|
222
|
-
/>
|
|
223
|
-
<div
|
|
224
|
-
data-slot="sidebar-container"
|
|
225
|
-
className={cn(
|
|
226
|
-
'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',
|
|
227
|
-
side === 'left'
|
|
228
|
-
? 'left-0 group-data-[collapsible=offExamples]:left-[calc(var(--sidebar-width)*-1)]'
|
|
229
|
-
: 'right-0 group-data-[collapsible=offExamples]:right-[calc(var(--sidebar-width)*-1)]',
|
|
230
|
-
// Adjust the padding for floating and inset variants.
|
|
231
|
-
variant === 'floating' || variant === 'inset'
|
|
232
|
-
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
|
|
233
|
-
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
|
|
234
|
-
className
|
|
235
|
-
)}
|
|
236
|
-
{...props}
|
|
237
|
-
>
|
|
238
|
-
<div
|
|
239
|
-
data-sidebar="sidebar"
|
|
240
|
-
data-slot="sidebar-inner"
|
|
241
|
-
className="bg-sidebar group-data-[variant=floating]:ring-sidebar-border group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 flex size-full flex-col"
|
|
242
|
-
>
|
|
243
|
-
{children}
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function SidebarTrigger({
|
|
251
|
-
className,
|
|
252
|
-
onClick,
|
|
253
|
-
...props
|
|
254
|
-
}: React.ComponentProps<typeof Button>) {
|
|
255
|
-
const { toggleSidebar } = useSidebar()
|
|
256
|
-
|
|
257
|
-
return (
|
|
258
|
-
<Button
|
|
259
|
-
data-sidebar="trigger"
|
|
260
|
-
data-slot="sidebar-trigger"
|
|
261
|
-
variant="ghost"
|
|
262
|
-
size="icon-sm"
|
|
263
|
-
className={cn(className)}
|
|
264
|
-
onClick={(event) => {
|
|
265
|
-
onClick?.(event)
|
|
266
|
-
toggleSidebar()
|
|
267
|
-
}}
|
|
268
|
-
{...props}
|
|
269
|
-
>
|
|
270
|
-
<PanelLeftIcon />
|
|
271
|
-
<span className="sr-only">Toggle Sidebar</span>
|
|
272
|
-
</Button>
|
|
273
|
-
)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
|
277
|
-
const { toggleSidebar } = useSidebar()
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<button
|
|
281
|
-
data-sidebar="rail"
|
|
282
|
-
data-slot="sidebar-rail"
|
|
283
|
-
aria-label="Toggle Sidebar"
|
|
284
|
-
tabIndex={-1}
|
|
285
|
-
onClick={toggleSidebar}
|
|
286
|
-
title="Toggle Sidebar"
|
|
287
|
-
className={cn(
|
|
288
|
-
'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-0.5 sm:flex',
|
|
289
|
-
'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
|
|
290
|
-
'[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
|
|
291
|
-
'hover:group-data-[collapsible=offExamples]:bg-sidebar group-data-[collapsible=offExamples]:translate-x-0 group-data-[collapsible=offExamples]:after:left-full',
|
|
292
|
-
'[[data-side=left][data-collapsible=offExamples]_&]:-right-2',
|
|
293
|
-
'[[data-side=right][data-collapsible=offExamples]_&]:-left-2',
|
|
294
|
-
className
|
|
295
|
-
)}
|
|
296
|
-
{...props}
|
|
297
|
-
/>
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
|
|
302
|
-
return (
|
|
303
|
-
<main
|
|
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
|
-
|
|
314
|
-
function SidebarInput({
|
|
315
|
-
className,
|
|
316
|
-
...props
|
|
317
|
-
}: React.ComponentProps<typeof Input>) {
|
|
318
|
-
return (
|
|
319
|
-
<Input
|
|
320
|
-
data-slot="sidebar-input"
|
|
321
|
-
data-sidebar="input"
|
|
322
|
-
className={cn(
|
|
323
|
-
'bg-muted/20 dark:bg-muted/30 border-input h-8 w-full',
|
|
324
|
-
className
|
|
325
|
-
)}
|
|
326
|
-
{...props}
|
|
327
|
-
/>
|
|
328
|
-
)
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
332
|
-
return (
|
|
333
|
-
<div
|
|
334
|
-
data-slot="sidebar-header"
|
|
335
|
-
data-sidebar="header"
|
|
336
|
-
className={cn('gap-2 p-2 flex flex-col', className)}
|
|
337
|
-
{...props}
|
|
338
|
-
/>
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
343
|
-
return (
|
|
344
|
-
<div
|
|
345
|
-
data-slot="sidebar-footer"
|
|
346
|
-
data-sidebar="footer"
|
|
347
|
-
className={cn('gap-2 p-2 flex flex-col', className)}
|
|
348
|
-
{...props}
|
|
349
|
-
/>
|
|
350
|
-
)
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
function SidebarSeparator({
|
|
354
|
-
className,
|
|
355
|
-
...props
|
|
356
|
-
}: React.ComponentProps<typeof Separator>) {
|
|
357
|
-
return (
|
|
358
|
-
<Separator
|
|
359
|
-
data-slot="sidebar-separator"
|
|
360
|
-
data-sidebar="separator"
|
|
361
|
-
className={cn('bg-sidebar-border mx-2 w-auto', className)}
|
|
362
|
-
{...props}
|
|
363
|
-
/>
|
|
364
|
-
)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
368
|
-
return (
|
|
369
|
-
<div
|
|
370
|
-
data-slot="sidebar-content"
|
|
371
|
-
data-sidebar="content"
|
|
372
|
-
className={cn(
|
|
373
|
-
'no-scrollbar gap-0 flex min-h-0 flex-1 flex-col overflow-auto group-data-[collapsible=icon]:overflow-hidden',
|
|
374
|
-
className
|
|
375
|
-
)}
|
|
376
|
-
{...props}
|
|
377
|
-
/>
|
|
378
|
-
)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
382
|
-
return (
|
|
383
|
-
<div
|
|
384
|
-
data-slot="sidebar-group"
|
|
385
|
-
data-sidebar="group"
|
|
386
|
-
className={cn(
|
|
387
|
-
'px-2 py-1 relative flex w-full min-w-0 flex-col',
|
|
388
|
-
className
|
|
389
|
-
)}
|
|
390
|
-
{...props}
|
|
391
|
-
/>
|
|
392
|
-
)
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function SidebarGroupLabel({
|
|
396
|
-
className,
|
|
397
|
-
render,
|
|
398
|
-
...props
|
|
399
|
-
}: useRender.ComponentProps<'div'> & React.ComponentProps<'div'>) {
|
|
400
|
-
return useRender({
|
|
401
|
-
defaultTagName: 'div',
|
|
402
|
-
props: mergeProps<'div'>(
|
|
403
|
-
{
|
|
404
|
-
className: cn(
|
|
405
|
-
'text-sidebar-foreground/70 ring-sidebar-ring h-8 rounded-md px-2 text-xs transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 flex shrink-0 items-center outline-hidden [&>svg]:shrink-0',
|
|
406
|
-
className
|
|
407
|
-
)
|
|
408
|
-
},
|
|
409
|
-
props
|
|
410
|
-
),
|
|
411
|
-
render,
|
|
412
|
-
state: {
|
|
413
|
-
slot: 'sidebar-group-label',
|
|
414
|
-
sidebar: 'group-label'
|
|
415
|
-
}
|
|
416
|
-
})
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function SidebarGroupAction({
|
|
420
|
-
className,
|
|
421
|
-
render,
|
|
422
|
-
...props
|
|
423
|
-
}: useRender.ComponentProps<'button'> & React.ComponentProps<'button'>) {
|
|
424
|
-
return useRender({
|
|
425
|
-
defaultTagName: 'button',
|
|
426
|
-
props: mergeProps<'button'>(
|
|
427
|
-
{
|
|
428
|
-
className: cn(
|
|
429
|
-
'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 w-5 rounded-md p-0 focus-visible:ring-2 [&>svg]:size-4 flex aspect-square items-center justify-center outline-hidden transition-transform [&>svg]:shrink-0 after:absolute after:-inset-2 md:after:hidden group-data-[collapsible=icon]:hidden',
|
|
430
|
-
className
|
|
431
|
-
)
|
|
432
|
-
},
|
|
433
|
-
props
|
|
434
|
-
),
|
|
435
|
-
render,
|
|
436
|
-
state: {
|
|
437
|
-
slot: 'sidebar-group-action',
|
|
438
|
-
sidebar: 'group-action'
|
|
439
|
-
}
|
|
440
|
-
})
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function SidebarGroupContent({
|
|
444
|
-
className,
|
|
445
|
-
...props
|
|
446
|
-
}: React.ComponentProps<'div'>) {
|
|
447
|
-
return (
|
|
448
|
-
<div
|
|
449
|
-
data-slot="sidebar-group-content"
|
|
450
|
-
data-sidebar="group-content"
|
|
451
|
-
className={cn('text-xs w-full', className)}
|
|
452
|
-
{...props}
|
|
453
|
-
/>
|
|
454
|
-
)
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
|
|
458
|
-
return (
|
|
459
|
-
<ul
|
|
460
|
-
data-slot="sidebar-menu"
|
|
461
|
-
data-sidebar="menu"
|
|
462
|
-
className={cn('gap-px flex w-full min-w-0 flex-col', className)}
|
|
463
|
-
{...props}
|
|
464
|
-
/>
|
|
465
|
-
)
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
469
|
-
return (
|
|
470
|
-
<li
|
|
471
|
-
data-slot="sidebar-menu-item"
|
|
472
|
-
data-sidebar="menu-item"
|
|
473
|
-
className={cn('group/menu-item relative', className)}
|
|
474
|
-
{...props}
|
|
475
|
-
/>
|
|
476
|
-
)
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
const sidebarMenuButtonVariants = cva(
|
|
480
|
-
'ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-[calc(var(--radius-sm)+2px)] p-2 text-left text-xs 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! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button 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',
|
|
481
|
-
{
|
|
482
|
-
variants: {
|
|
483
|
-
variant: {
|
|
484
|
-
default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
|
485
|
-
outline:
|
|
486
|
-
'bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]'
|
|
487
|
-
},
|
|
488
|
-
size: {
|
|
489
|
-
default: 'h-8 text-xs',
|
|
490
|
-
sm: 'h-7 text-xs',
|
|
491
|
-
lg: 'h-12 text-xs group-data-[collapsible=icon]:p-0!'
|
|
492
|
-
}
|
|
493
|
-
},
|
|
494
|
-
defaultVariants: {
|
|
495
|
-
variant: 'default',
|
|
496
|
-
size: 'default'
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
)
|
|
500
|
-
|
|
501
|
-
function SidebarMenuButton({
|
|
502
|
-
render,
|
|
503
|
-
isActive = false,
|
|
504
|
-
variant = 'default',
|
|
505
|
-
size = 'default',
|
|
506
|
-
tooltip,
|
|
507
|
-
className,
|
|
508
|
-
...props
|
|
509
|
-
}: useRender.ComponentProps<'button'> &
|
|
510
|
-
React.ComponentProps<'button'> & {
|
|
511
|
-
isActive?: boolean
|
|
512
|
-
tooltip?: string | React.ComponentProps<typeof TooltipContent>
|
|
513
|
-
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
514
|
-
const { isMobile, state } = useSidebar()
|
|
515
|
-
const comp = useRender({
|
|
516
|
-
defaultTagName: 'button',
|
|
517
|
-
props: mergeProps<'button'>(
|
|
518
|
-
{
|
|
519
|
-
className: cn(sidebarMenuButtonVariants({ variant, size }), className)
|
|
520
|
-
},
|
|
521
|
-
props
|
|
522
|
-
),
|
|
523
|
-
render: !tooltip ? render : TooltipTrigger,
|
|
524
|
-
state: {
|
|
525
|
-
slot: 'sidebar-menu-button',
|
|
526
|
-
sidebar: 'menu-button',
|
|
527
|
-
size,
|
|
528
|
-
active: isActive
|
|
529
|
-
}
|
|
530
|
-
})
|
|
531
|
-
|
|
532
|
-
if (!tooltip) {
|
|
533
|
-
return comp
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if (typeof tooltip === 'string') {
|
|
537
|
-
tooltip = {
|
|
538
|
-
children: tooltip
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return (
|
|
543
|
-
<Tooltip>
|
|
544
|
-
{comp}
|
|
545
|
-
<TooltipContent
|
|
546
|
-
side="right"
|
|
547
|
-
align="center"
|
|
548
|
-
hidden={state !== 'collapsed' || isMobile}
|
|
549
|
-
{...tooltip}
|
|
550
|
-
/>
|
|
551
|
-
</Tooltip>
|
|
552
|
-
)
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
function SidebarMenuAction({
|
|
556
|
-
className,
|
|
557
|
-
render,
|
|
558
|
-
showOnHover = false,
|
|
559
|
-
...props
|
|
560
|
-
}: useRender.ComponentProps<'button'> &
|
|
561
|
-
React.ComponentProps<'button'> & {
|
|
562
|
-
showOnHover?: boolean
|
|
563
|
-
}) {
|
|
564
|
-
return useRender({
|
|
565
|
-
defaultTagName: 'button',
|
|
566
|
-
props: mergeProps<'button'>(
|
|
567
|
-
{
|
|
568
|
-
className: cn(
|
|
569
|
-
'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 aspect-square w-5 rounded-[calc(var(--radius-sm)-2px)] p-0 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 focus-visible:ring-2 [&>svg]:size-4 flex items-center justify-center outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden [&>svg]:shrink-0',
|
|
570
|
-
showOnHover &&
|
|
571
|
-
'peer-data-active/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-open:opacity-100 md:opacity-0',
|
|
572
|
-
className
|
|
573
|
-
)
|
|
574
|
-
},
|
|
575
|
-
props
|
|
576
|
-
),
|
|
577
|
-
render,
|
|
578
|
-
state: {
|
|
579
|
-
slot: 'sidebar-menu-action',
|
|
580
|
-
sidebar: 'menu-action'
|
|
581
|
-
}
|
|
582
|
-
})
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
function SidebarMenuBadge({
|
|
586
|
-
className,
|
|
587
|
-
...props
|
|
588
|
-
}: React.ComponentProps<'div'>) {
|
|
589
|
-
return (
|
|
590
|
-
<div
|
|
591
|
-
data-slot="sidebar-menu-badge"
|
|
592
|
-
data-sidebar="menu-badge"
|
|
593
|
-
className={cn(
|
|
594
|
-
'text-sidebar-foreground peer-hover/menu-button:text-sidebar-accent-foreground peer-data-active/menu-button:text-sidebar-accent-foreground pointer-events-none absolute right-1 h-5 min-w-5 rounded-[calc(var(--radius-sm)-2px)] px-1 text-xs font-medium 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 flex items-center justify-center tabular-nums select-none group-data-[collapsible=icon]:hidden',
|
|
595
|
-
className
|
|
596
|
-
)}
|
|
597
|
-
{...props}
|
|
598
|
-
/>
|
|
599
|
-
)
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
function SidebarMenuSkeleton({
|
|
603
|
-
className,
|
|
604
|
-
showIcon = false,
|
|
605
|
-
...props
|
|
606
|
-
}: React.ComponentProps<'div'> & {
|
|
607
|
-
showIcon?: boolean
|
|
608
|
-
}) {
|
|
609
|
-
// Random width between 50 to 90%.
|
|
610
|
-
const [width] = React.useState(() => {
|
|
611
|
-
return `${Math.floor(Math.random() * 40) + 50}%`
|
|
612
|
-
})
|
|
613
|
-
|
|
614
|
-
return (
|
|
615
|
-
<div
|
|
616
|
-
data-slot="sidebar-menu-skeleton"
|
|
617
|
-
data-sidebar="menu-skeleton"
|
|
618
|
-
className={cn('h-8 gap-2 rounded-md px-2 flex items-center', className)}
|
|
619
|
-
{...props}
|
|
620
|
-
>
|
|
621
|
-
{showIcon && (
|
|
622
|
-
<Skeleton
|
|
623
|
-
className="size-4 rounded-md"
|
|
624
|
-
data-sidebar="menu-skeleton-icon"
|
|
625
|
-
/>
|
|
626
|
-
)}
|
|
627
|
-
<Skeleton
|
|
628
|
-
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
629
|
-
data-sidebar="menu-skeleton-text"
|
|
630
|
-
style={
|
|
631
|
-
{
|
|
632
|
-
'--skeleton-width': width
|
|
633
|
-
} as React.CSSProperties
|
|
634
|
-
}
|
|
635
|
-
/>
|
|
636
|
-
</div>
|
|
637
|
-
)
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
|
|
641
|
-
return (
|
|
642
|
-
<ul
|
|
643
|
-
data-slot="sidebar-menu-sub"
|
|
644
|
-
data-sidebar="menu-sub"
|
|
645
|
-
className={cn(
|
|
646
|
-
'border-sidebar-border mx-3.5 translate-x-px gap-1 border-l px-2.5 py-0.5 group-data-[collapsible=icon]:hidden flex min-w-0 flex-col',
|
|
647
|
-
className
|
|
648
|
-
)}
|
|
649
|
-
{...props}
|
|
650
|
-
/>
|
|
651
|
-
)
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
function SidebarMenuSubItem({
|
|
655
|
-
className,
|
|
656
|
-
...props
|
|
657
|
-
}: React.ComponentProps<'li'>) {
|
|
658
|
-
return (
|
|
659
|
-
<li
|
|
660
|
-
data-slot="sidebar-menu-sub-item"
|
|
661
|
-
data-sidebar="menu-sub-item"
|
|
662
|
-
className={cn('group/menu-sub-item relative', className)}
|
|
663
|
-
{...props}
|
|
664
|
-
/>
|
|
665
|
-
)
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
function SidebarMenuSubButton({
|
|
669
|
-
render,
|
|
670
|
-
size = 'md',
|
|
671
|
-
isActive = false,
|
|
672
|
-
className,
|
|
673
|
-
...props
|
|
674
|
-
}: useRender.ComponentProps<'a'> &
|
|
675
|
-
React.ComponentProps<'a'> & {
|
|
676
|
-
size?: 'sm' | 'md'
|
|
677
|
-
isActive?: boolean
|
|
678
|
-
}) {
|
|
679
|
-
return useRender({
|
|
680
|
-
defaultTagName: 'a',
|
|
681
|
-
props: mergeProps<'a'>(
|
|
682
|
-
{
|
|
683
|
-
className: cn(
|
|
684
|
-
'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 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-xs data-[size=sm]:text-xs [&>svg]:size-4 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',
|
|
685
|
-
className
|
|
686
|
-
)
|
|
687
|
-
},
|
|
688
|
-
props
|
|
689
|
-
),
|
|
690
|
-
render,
|
|
691
|
-
state: {
|
|
692
|
-
slot: 'sidebar-menu-sub-button',
|
|
693
|
-
sidebar: 'menu-sub-button',
|
|
694
|
-
size,
|
|
695
|
-
active: isActive
|
|
696
|
-
}
|
|
697
|
-
})
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
export {
|
|
701
|
-
Sidebar,
|
|
702
|
-
SidebarContent,
|
|
703
|
-
SidebarFooter,
|
|
704
|
-
SidebarGroup,
|
|
705
|
-
SidebarGroupAction,
|
|
706
|
-
SidebarGroupContent,
|
|
707
|
-
SidebarGroupLabel,
|
|
708
|
-
SidebarHeader,
|
|
709
|
-
SidebarInput,
|
|
710
|
-
SidebarInset,
|
|
711
|
-
SidebarMenu,
|
|
712
|
-
SidebarMenuAction,
|
|
713
|
-
SidebarMenuBadge,
|
|
714
|
-
SidebarMenuButton,
|
|
715
|
-
SidebarMenuItem,
|
|
716
|
-
SidebarMenuSkeleton,
|
|
717
|
-
SidebarMenuSub,
|
|
718
|
-
SidebarMenuSubButton,
|
|
719
|
-
SidebarMenuSubItem,
|
|
720
|
-
SidebarProvider,
|
|
721
|
-
SidebarRail,
|
|
722
|
-
SidebarSeparator,
|
|
723
|
-
SidebarTrigger,
|
|
724
|
-
useSidebar
|
|
725
|
-
}
|