@turtleclub/ui 0.7.0-beta.33 → 0.7.0-beta.35

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