@lark-apaas/coding-templates 0.1.5 → 0.1.7

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.
Files changed (82) hide show
  1. package/package.json +1 -1
  2. package/template-vite-react/README.md +175 -0
  3. package/template-vite-react/client/index.html +2 -1
  4. package/template-vite-react/client/src/components/layout.tsx +0 -2
  5. package/template-vite-react/client/src/components/ui/README.md +134 -0
  6. package/template-vite-react/client/src/components/ui/accordion.tsx +22 -28
  7. package/template-vite-react/client/src/components/ui/alert-dialog.tsx +34 -64
  8. package/template-vite-react/client/src/components/ui/alert.tsx +10 -15
  9. package/template-vite-react/client/src/components/ui/aspect-ratio.tsx +5 -16
  10. package/template-vite-react/client/src/components/ui/avatar.tsx +11 -67
  11. package/template-vite-react/client/src/components/ui/badge.tsx +21 -31
  12. package/template-vite-react/client/src/components/ui/breadcrumb.tsx +23 -39
  13. package/template-vite-react/client/src/components/ui/button.tsx +36 -25
  14. package/template-vite-react/client/src/components/ui/calendar.tsx +37 -43
  15. package/template-vite-react/client/src/components/ui/card.tsx +73 -94
  16. package/template-vite-react/client/src/components/ui/carousel.tsx +7 -8
  17. package/template-vite-react/client/src/components/ui/chart.tsx +35 -49
  18. package/template-vite-react/client/src/components/ui/checkbox.tsx +10 -7
  19. package/template-vite-react/client/src/components/ui/collapsible.tsx +20 -6
  20. package/template-vite-react/client/src/components/ui/command.tsx +52 -40
  21. package/template-vite-react/client/src/components/ui/context-menu.tsx +170 -117
  22. package/template-vite-react/client/src/components/ui/dialog.tsx +37 -52
  23. package/template-vite-react/client/src/components/ui/drawer.tsx +12 -9
  24. package/template-vite-react/client/src/components/ui/dropdown-menu.tsx +194 -133
  25. package/template-vite-react/client/src/components/ui/hover-card.tsx +24 -29
  26. package/template-vite-react/client/src/components/ui/input-group.tsx +39 -29
  27. package/template-vite-react/client/src/components/ui/input-otp.tsx +7 -17
  28. package/template-vite-react/client/src/components/ui/input.tsx +4 -3
  29. package/template-vite-react/client/src/components/ui/label.tsx +9 -3
  30. package/template-vite-react/client/src/components/ui/menubar.tsx +160 -92
  31. package/template-vite-react/client/src/components/ui/navigation-menu.tsx +45 -45
  32. package/template-vite-react/client/src/components/ui/pagination.tsx +32 -35
  33. package/template-vite-react/client/src/components/ui/popover.tsx +20 -62
  34. package/template-vite-react/client/src/components/ui/progress.tsx +14 -64
  35. package/template-vite-react/client/src/components/ui/radio-group.tsx +20 -13
  36. package/template-vite-react/client/src/components/ui/resizable.tsx +18 -10
  37. package/template-vite-react/client/src/components/ui/scroll-area.tsx +13 -10
  38. package/template-vite-react/client/src/components/ui/select.tsx +122 -78
  39. package/template-vite-react/client/src/components/ui/separator.tsx +7 -4
  40. package/template-vite-react/client/src/components/ui/sheet.tsx +42 -41
  41. package/template-vite-react/client/src/components/ui/sidebar.tsx +162 -156
  42. package/template-vite-react/client/src/components/ui/skeleton.tsx +1 -1
  43. package/template-vite-react/client/src/components/ui/slider.tsx +52 -22
  44. package/template-vite-react/client/src/components/ui/sonner.tsx +44 -26
  45. package/template-vite-react/client/src/components/ui/switch.tsx +9 -8
  46. package/template-vite-react/client/src/components/ui/table.tsx +5 -5
  47. package/template-vite-react/client/src/components/ui/tabs.tsx +24 -38
  48. package/template-vite-react/client/src/components/ui/textarea.tsx +1 -1
  49. package/template-vite-react/client/src/components/ui/toggle-group.tsx +14 -20
  50. package/template-vite-react/client/src/components/ui/toggle.tsx +13 -10
  51. package/template-vite-react/client/src/components/ui/tooltip.tsx +30 -33
  52. package/template-vite-react/client/src/index.css +130 -0
  53. package/template-vite-react/client/src/main.tsx +1 -4
  54. package/template-vite-react/components.json +2 -6
  55. package/template-vite-react/eslint.config.js +11 -0
  56. package/template-vite-react/package.json +29 -2
  57. package/template-vite-react/client/src/components/header.tsx +0 -22
  58. package/template-vite-react/client/src/components/theme-provider.tsx +0 -45
  59. package/template-vite-react/client/src/components/ui/icons/file-ae-colorful-icon.tsx +0 -21
  60. package/template-vite-react/client/src/components/ui/icons/file-ai-colorful-icon.tsx +0 -36
  61. package/template-vite-react/client/src/components/ui/icons/file-android-colorful-icon.tsx +0 -33
  62. package/template-vite-react/client/src/components/ui/icons/file-audio-colorful-icon.tsx +0 -21
  63. package/template-vite-react/client/src/components/ui/icons/file-code-colorful-icon.tsx +0 -28
  64. package/template-vite-react/client/src/components/ui/icons/file-csv-colorful-icon.tsx +0 -21
  65. package/template-vite-react/client/src/components/ui/icons/file-eml-colorful-icon.tsx +0 -29
  66. package/template-vite-react/client/src/components/ui/icons/file-ios-colorful-icon.tsx +0 -25
  67. package/template-vite-react/client/src/components/ui/icons/file-keynote-colorful-icon.tsx +0 -29
  68. package/template-vite-react/client/src/components/ui/icons/file-pages-colorful-icon.tsx +0 -29
  69. package/template-vite-react/client/src/components/ui/icons/file-ps-colorful-icon.tsx +0 -21
  70. package/template-vite-react/client/src/components/ui/icons/file-sketch-colorful-icon.tsx +0 -21
  71. package/template-vite-react/client/src/components/ui/icons/file-slide-colorful-icon.tsx +0 -21
  72. package/template-vite-react/client/src/components/ui/icons/file-vcf-colorful-icon.tsx +0 -29
  73. package/template-vite-react/client/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +0 -23
  74. package/template-vite-react/client/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +0 -27
  75. package/template-vite-react/client/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +0 -20
  76. package/template-vite-react/client/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +0 -21
  77. package/template-vite-react/client/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +0 -12
  78. package/template-vite-react/client/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +0 -14
  79. package/template-vite-react/client/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +0 -23
  80. package/template-vite-react/client/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +0 -38
  81. package/template-vite-react/client/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +0 -21
  82. package/template-vite-react/client/src/types/index.ts +0 -1
@@ -1,10 +1,12 @@
1
+ "use client"
2
+
1
3
  import * as React from "react"
2
- import { mergeProps } from "@base-ui/react/merge-props"
3
- import { useRender } from "@base-ui/react/use-render"
4
+ import { Slot } from "@radix-ui/react-slot"
4
5
  import { cva, type VariantProps } from "class-variance-authority"
6
+ import { PanelLeftIcon } from "lucide-react"
5
7
 
6
- import { useIsMobile } from "@/hooks/use-mobile"
7
8
  import { cn } from "@/lib/utils"
9
+ import { useIsMobile } from "@/hooks/use-mobile"
8
10
  import { Button } from "@/components/ui/button"
9
11
  import { Input } from "@/components/ui/input"
10
12
  import { Separator } from "@/components/ui/separator"
@@ -19,9 +21,9 @@ import { Skeleton } from "@/components/ui/skeleton"
19
21
  import {
20
22
  Tooltip,
21
23
  TooltipContent,
24
+ TooltipProvider,
22
25
  TooltipTrigger,
23
26
  } from "@/components/ui/tooltip"
24
- import { PanelLeftIcon } from "lucide-react"
25
27
 
26
28
  const SIDEBAR_COOKIE_NAME = "sidebar_state"
27
29
  const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
@@ -126,23 +128,25 @@ function SidebarProvider({
126
128
 
127
129
  return (
128
130
  <SidebarContext.Provider value={contextValue}>
129
- <div
130
- data-slot="sidebar-wrapper"
131
- style={
132
- {
133
- "--sidebar-width": SIDEBAR_WIDTH,
134
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
135
- ...style,
136
- } as React.CSSProperties
137
- }
138
- className={cn(
139
- "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
140
- className
141
- )}
142
- {...props}
143
- >
144
- {children}
145
- </div>
131
+ <TooltipProvider delayDuration={0}>
132
+ <div
133
+ data-slot="sidebar-wrapper"
134
+ style={
135
+ {
136
+ "--sidebar-width": SIDEBAR_WIDTH,
137
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
138
+ ...style,
139
+ } as React.CSSProperties
140
+ }
141
+ className={cn(
142
+ "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
143
+ className
144
+ )}
145
+ {...props}
146
+ >
147
+ {children}
148
+ </div>
149
+ </TooltipProvider>
146
150
  </SidebarContext.Provider>
147
151
  )
148
152
  }
@@ -153,7 +157,6 @@ function Sidebar({
153
157
  collapsible = "offcanvas",
154
158
  className,
155
159
  children,
156
- dir,
157
160
  ...props
158
161
  }: React.ComponentProps<"div"> & {
159
162
  side?: "left" | "right"
@@ -167,7 +170,7 @@ function Sidebar({
167
170
  <div
168
171
  data-slot="sidebar"
169
172
  className={cn(
170
- "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
173
+ "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
171
174
  className
172
175
  )}
173
176
  {...props}
@@ -181,11 +184,10 @@ function Sidebar({
181
184
  return (
182
185
  <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
183
186
  <SheetContent
184
- dir={dir}
185
187
  data-sidebar="sidebar"
186
188
  data-slot="sidebar"
187
189
  data-mobile="true"
188
- className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
190
+ className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
189
191
  style={
190
192
  {
191
193
  "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
@@ -205,7 +207,7 @@ function Sidebar({
205
207
 
206
208
  return (
207
209
  <div
208
- className="group peer hidden text-sidebar-foreground md:block"
210
+ className="group peer text-sidebar-foreground hidden md:block"
209
211
  data-state={state}
210
212
  data-collapsible={state === "collapsed" ? collapsible : ""}
211
213
  data-variant={variant}
@@ -226,9 +228,11 @@ function Sidebar({
226
228
  />
227
229
  <div
228
230
  data-slot="sidebar-container"
229
- data-side={side}
230
231
  className={cn(
231
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
232
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
233
+ side === "left"
234
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
235
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
232
236
  // Adjust the padding for floating and inset variants.
233
237
  variant === "floating" || variant === "inset"
234
238
  ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
@@ -240,7 +244,7 @@ function Sidebar({
240
244
  <div
241
245
  data-sidebar="sidebar"
242
246
  data-slot="sidebar-inner"
243
- className="flex size-full flex-col 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"
247
+ className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
244
248
  >
245
249
  {children}
246
250
  </div>
@@ -261,8 +265,8 @@ function SidebarTrigger({
261
265
  data-sidebar="trigger"
262
266
  data-slot="sidebar-trigger"
263
267
  variant="ghost"
264
- size="icon-sm"
265
- className={cn(className)}
268
+ size="icon"
269
+ className={cn("size-7", className)}
266
270
  onClick={(event) => {
267
271
  onClick?.(event)
268
272
  toggleSidebar()
@@ -287,10 +291,10 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
287
291
  onClick={toggleSidebar}
288
292
  title="Toggle Sidebar"
289
293
  className={cn(
290
- "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
294
+ "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",
291
295
  "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
292
296
  "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
293
- "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
297
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
294
298
  "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
295
299
  "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
296
300
  className
@@ -305,7 +309,8 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
305
309
  <main
306
310
  data-slot="sidebar-inset"
307
311
  className={cn(
308
- "relative flex w-full flex-1 flex-col 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",
312
+ "bg-background relative flex w-full flex-1 flex-col",
313
+ "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",
309
314
  className
310
315
  )}
311
316
  {...props}
@@ -321,7 +326,7 @@ function SidebarInput({
321
326
  <Input
322
327
  data-slot="sidebar-input"
323
328
  data-sidebar="input"
324
- className={cn("h-8 w-full bg-background shadow-none", className)}
329
+ className={cn("bg-background h-8 w-full shadow-none", className)}
325
330
  {...props}
326
331
  />
327
332
  )
@@ -357,7 +362,7 @@ function SidebarSeparator({
357
362
  <Separator
358
363
  data-slot="sidebar-separator"
359
364
  data-sidebar="separator"
360
- className={cn("mx-2 w-auto bg-sidebar-border", className)}
365
+ className={cn("bg-sidebar-border mx-2 w-auto", className)}
361
366
  {...props}
362
367
  />
363
368
  )
@@ -369,7 +374,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
369
374
  data-slot="sidebar-content"
370
375
  data-sidebar="content"
371
376
  className={cn(
372
- "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
377
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
373
378
  className
374
379
  )}
375
380
  {...props}
@@ -390,50 +395,46 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
390
395
 
391
396
  function SidebarGroupLabel({
392
397
  className,
393
- render,
398
+ asChild = false,
394
399
  ...props
395
- }: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
396
- return useRender({
397
- defaultTagName: "div",
398
- props: mergeProps<"div">(
399
- {
400
- className: cn(
401
- "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden 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 [&>svg]:shrink-0",
402
- className
403
- ),
404
- },
405
- props
406
- ),
407
- render,
408
- state: {
409
- slot: "sidebar-group-label",
410
- sidebar: "group-label",
411
- },
412
- })
400
+ }: React.ComponentProps<"div"> & { asChild?: boolean }) {
401
+ const Comp = asChild ? Slot : "div"
402
+
403
+ return (
404
+ <Comp
405
+ data-slot="sidebar-group-label"
406
+ data-sidebar="group-label"
407
+ className={cn(
408
+ "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
409
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
410
+ className
411
+ )}
412
+ {...props}
413
+ />
414
+ )
413
415
  }
414
416
 
415
417
  function SidebarGroupAction({
416
418
  className,
417
- render,
419
+ asChild = false,
418
420
  ...props
419
- }: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
420
- return useRender({
421
- defaultTagName: "button",
422
- props: mergeProps<"button">(
423
- {
424
- className: cn(
425
- "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
426
- className
427
- ),
428
- },
429
- props
430
- ),
431
- render,
432
- state: {
433
- slot: "sidebar-group-action",
434
- sidebar: "group-action",
435
- },
436
- })
421
+ }: React.ComponentProps<"button"> & { asChild?: boolean }) {
422
+ const Comp = asChild ? Slot : "button"
423
+
424
+ return (
425
+ <Comp
426
+ data-slot="sidebar-group-action"
427
+ data-sidebar="group-action"
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 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
430
+ // Increases the hit area of the button on mobile.
431
+ "after:absolute after:-inset-2 md:after:hidden",
432
+ "group-data-[collapsible=icon]:hidden",
433
+ className
434
+ )}
435
+ {...props}
436
+ />
437
+ )
437
438
  }
438
439
 
439
440
  function SidebarGroupContent({
@@ -455,7 +456,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
455
456
  <ul
456
457
  data-slot="sidebar-menu"
457
458
  data-sidebar="menu"
458
- className={cn("flex w-full min-w-0 flex-col gap-0", className)}
459
+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}
459
460
  {...props}
460
461
  />
461
462
  )
@@ -473,13 +474,14 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
473
474
  }
474
475
 
475
476
  const sidebarMenuButtonVariants = cva(
476
- "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden 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 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 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 [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
477
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] not-disabled:hover:bg-sidebar-accent not-disabled:hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground not-disabled:data-[state=open]:hover:bg-sidebar-accent not-disabled: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",
477
478
  {
478
479
  variants: {
479
480
  variant: {
480
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
481
+ default:
482
+ "not-disabled:hover:bg-sidebar-accent not-disabled:hover:text-sidebar-accent-foreground",
481
483
  outline:
482
- "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))]",
484
+ "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] not-disabled:hover:bg-sidebar-accent not-disabled:hover:text-sidebar-accent-foreground not-disabled:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
483
485
  },
484
486
  size: {
485
487
  default: "h-8 text-sm",
@@ -495,38 +497,34 @@ const sidebarMenuButtonVariants = cva(
495
497
  )
496
498
 
497
499
  function SidebarMenuButton({
498
- render,
500
+ asChild = false,
499
501
  isActive = false,
500
502
  variant = "default",
501
503
  size = "default",
502
504
  tooltip,
503
505
  className,
504
506
  ...props
505
- }: useRender.ComponentProps<"button"> &
506
- React.ComponentProps<"button"> & {
507
- isActive?: boolean
508
- tooltip?: string | React.ComponentProps<typeof TooltipContent>
509
- } & VariantProps<typeof sidebarMenuButtonVariants>) {
507
+ }: React.ComponentProps<"button"> & {
508
+ asChild?: boolean
509
+ isActive?: boolean
510
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
511
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
512
+ const Comp = asChild ? Slot : "button"
510
513
  const { isMobile, state } = useSidebar()
511
- const comp = useRender({
512
- defaultTagName: "button",
513
- props: mergeProps<"button">(
514
- {
515
- className: cn(sidebarMenuButtonVariants({ variant, size }), className),
516
- },
517
- props
518
- ),
519
- render: !tooltip ? render : <TooltipTrigger render={render} />,
520
- state: {
521
- slot: "sidebar-menu-button",
522
- sidebar: "menu-button",
523
- size,
524
- active: isActive,
525
- },
526
- })
514
+
515
+ const button = (
516
+ <Comp
517
+ data-slot="sidebar-menu-button"
518
+ data-sidebar="menu-button"
519
+ data-size={size}
520
+ data-active={isActive}
521
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
522
+ {...props}
523
+ />
524
+ )
527
525
 
528
526
  if (!tooltip) {
529
- return comp
527
+ return button
530
528
  }
531
529
 
532
530
  if (typeof tooltip === "string") {
@@ -537,7 +535,7 @@ function SidebarMenuButton({
537
535
 
538
536
  return (
539
537
  <Tooltip>
540
- {comp}
538
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
541
539
  <TooltipContent
542
540
  side="right"
543
541
  align="center"
@@ -550,32 +548,34 @@ function SidebarMenuButton({
550
548
 
551
549
  function SidebarMenuAction({
552
550
  className,
553
- render,
551
+ asChild = false,
554
552
  showOnHover = false,
555
553
  ...props
556
- }: useRender.ComponentProps<"button"> &
557
- React.ComponentProps<"button"> & {
558
- showOnHover?: boolean
559
- }) {
560
- return useRender({
561
- defaultTagName: "button",
562
- props: mergeProps<"button">(
563
- {
564
- className: cn(
565
- "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden 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 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
566
- showOnHover &&
567
- "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
568
- className
569
- ),
570
- },
571
- props
572
- ),
573
- render,
574
- state: {
575
- slot: "sidebar-menu-action",
576
- sidebar: "menu-action",
577
- },
578
- })
554
+ }: React.ComponentProps<"button"> & {
555
+ asChild?: boolean
556
+ showOnHover?: boolean
557
+ }) {
558
+ const Comp = asChild ? Slot : "button"
559
+
560
+ return (
561
+ <Comp
562
+ data-slot="sidebar-menu-action"
563
+ data-sidebar="menu-action"
564
+ className={cn(
565
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
566
+ // Increases the hit area of the button on mobile.
567
+ "after:absolute after:-inset-2 md:after:hidden",
568
+ "peer-data-[size=sm]/menu-button:top-1",
569
+ "peer-data-[size=default]/menu-button:top-1.5",
570
+ "peer-data-[size=lg]/menu-button:top-2.5",
571
+ "group-data-[collapsible=icon]:hidden",
572
+ showOnHover &&
573
+ "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
574
+ className
575
+ )}
576
+ {...props}
577
+ />
578
+ )
579
579
  }
580
580
 
581
581
  function SidebarMenuBadge({
@@ -587,7 +587,12 @@ function SidebarMenuBadge({
587
587
  data-slot="sidebar-menu-badge"
588
588
  data-sidebar="menu-badge"
589
589
  className={cn(
590
- "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden 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",
590
+ "text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
591
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
592
+ "peer-data-[size=sm]/menu-button:top-1",
593
+ "peer-data-[size=default]/menu-button:top-1.5",
594
+ "peer-data-[size=lg]/menu-button:top-2.5",
595
+ "group-data-[collapsible=icon]:hidden",
591
596
  className
592
597
  )}
593
598
  {...props}
@@ -603,9 +608,9 @@ function SidebarMenuSkeleton({
603
608
  showIcon?: boolean
604
609
  }) {
605
610
  // Random width between 50 to 90%.
606
- const [width] = React.useState(() => {
611
+ const width = React.useMemo(() => {
607
612
  return `${Math.floor(Math.random() * 40) + 50}%`
608
- })
613
+ }, [])
609
614
 
610
615
  return (
611
616
  <div
@@ -639,7 +644,8 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
639
644
  data-slot="sidebar-menu-sub"
640
645
  data-sidebar="menu-sub"
641
646
  className={cn(
642
- "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 group-data-[collapsible=icon]:hidden",
647
+ "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
648
+ "group-data-[collapsible=icon]:hidden",
643
649
  className
644
650
  )}
645
651
  {...props}
@@ -662,35 +668,35 @@ function SidebarMenuSubItem({
662
668
  }
663
669
 
664
670
  function SidebarMenuSubButton({
665
- render,
671
+ asChild = false,
666
672
  size = "md",
667
673
  isActive = false,
668
674
  className,
669
675
  ...props
670
- }: useRender.ComponentProps<"a"> &
671
- React.ComponentProps<"a"> & {
672
- size?: "sm" | "md"
673
- isActive?: boolean
674
- }) {
675
- return useRender({
676
- defaultTagName: "a",
677
- props: mergeProps<"a">(
678
- {
679
- className: cn(
680
- "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden 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 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
681
- className
682
- ),
683
- },
684
- props
685
- ),
686
- render,
687
- state: {
688
- slot: "sidebar-menu-sub-button",
689
- sidebar: "menu-sub-button",
690
- size,
691
- active: isActive,
692
- },
693
- })
676
+ }: React.ComponentProps<"a"> & {
677
+ asChild?: boolean
678
+ size?: "sm" | "md"
679
+ isActive?: boolean
680
+ }) {
681
+ const Comp = asChild ? Slot : "a"
682
+
683
+ return (
684
+ <Comp
685
+ data-slot="sidebar-menu-sub-button"
686
+ data-sidebar="menu-sub-button"
687
+ data-size={size}
688
+ data-active={isActive}
689
+ className={cn(
690
+ "text-sidebar-foreground ring-sidebar-ring not-disabled:hover:bg-sidebar-accent not-disabled:hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
691
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
692
+ size === "sm" && "text-xs",
693
+ size === "md" && "text-sm",
694
+ "group-data-[collapsible=icon]:hidden",
695
+ className
696
+ )}
697
+ {...props}
698
+ />
699
+ )
694
700
  }
695
701
 
696
702
  export {
@@ -4,7 +4,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
4
  return (
5
5
  <div
6
6
  data-slot="skeleton"
7
- className={cn("animate-pulse rounded-md bg-muted", className)}
7
+ className={cn("bg-accent animate-pulse rounded-md", className)}
8
8
  {...props}
9
9
  />
10
10
  )
@@ -1,5 +1,7 @@
1
+ "use client"
2
+
1
3
  import * as React from "react"
2
- import { Slider as SliderPrimitive } from "@base-ui/react/slider"
4
+ import * as SliderPrimitive from "@radix-ui/react-slider"
3
5
 
4
6
  import { cn } from "@/lib/utils"
5
7
 
@@ -9,8 +11,14 @@ function Slider({
9
11
  value,
10
12
  min = 0,
11
13
  max = 100,
14
+ disabled,
15
+ onClick,
16
+ onMouseDown,
17
+ onKeyDown,
18
+ onKeyUp,
19
+ onPointerDown,
12
20
  ...props
13
- }: SliderPrimitive.Root.Props) {
21
+ }: React.ComponentProps<typeof SliderPrimitive.Root>) {
14
22
  const _values = React.useMemo(
15
23
  () =>
16
24
  Array.isArray(value)
@@ -23,33 +31,55 @@ function Slider({
23
31
 
24
32
  return (
25
33
  <SliderPrimitive.Root
26
- className={cn("data-horizontal:w-full data-vertical:h-full", className)}
27
34
  data-slot="slider"
28
35
  defaultValue={defaultValue}
29
36
  value={value}
30
37
  min={min}
31
38
  max={max}
32
- thumbAlignment="edge"
39
+ className={cn(
40
+ "relative flex w-full touch-none items-center select-none cursor-pointer data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
41
+ className
42
+ )}
43
+ disabled={disabled}
44
+ onClick={(event) => {
45
+ if (disabled) {
46
+ event.preventDefault()
47
+ return
48
+ }
49
+ onClick?.(event)
50
+ }}
51
+ onMouseDown={disabled ? undefined : onMouseDown}
52
+ onKeyDown={disabled ? undefined : onKeyDown}
53
+ onKeyUp={disabled ? undefined : onKeyUp}
54
+ onPointerDown={(event) => {
55
+ if (disabled) {
56
+ event.preventDefault()
57
+ return
58
+ }
59
+ onPointerDown?.(event)
60
+ }}
33
61
  {...props}
34
62
  >
35
- <SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
36
- <SliderPrimitive.Track
37
- data-slot="slider-track"
38
- className="relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
39
- >
40
- <SliderPrimitive.Indicator
41
- data-slot="slider-range"
42
- className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
43
- />
44
- </SliderPrimitive.Track>
45
- {Array.from({ length: _values.length }, (_, index) => (
46
- <SliderPrimitive.Thumb
47
- data-slot="slider-thumb"
48
- key={index}
49
- className="relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"
50
- />
51
- ))}
52
- </SliderPrimitive.Control>
63
+ <SliderPrimitive.Track
64
+ data-slot="slider-track"
65
+ className={cn(
66
+ "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
67
+ )}
68
+ >
69
+ <SliderPrimitive.Range
70
+ data-slot="slider-range"
71
+ className={cn(
72
+ "bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
73
+ )}
74
+ />
75
+ </SliderPrimitive.Track>
76
+ {Array.from({ length: _values.length }, (_, index) => (
77
+ <SliderPrimitive.Thumb
78
+ data-slot="slider-thumb"
79
+ key={index}
80
+ className="border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] not-data-disabled:hover:ring-4 not-data-disabled:focus-visible:ring-4 not-data-disabled:focus-visible:outline-hidden disabled:cursor-not-allowed data-[disabled]:cursor-not-allowed disabled:opacity-50"
81
+ />
82
+ ))}
53
83
  </SliderPrimitive.Root>
54
84
  )
55
85
  }