@cryptlex/web-components 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/components/data-table/data-table-filter.d.ts +27 -0
  2. package/dist/components/data-table/data-table-filter.js +112 -0
  3. package/dist/components/data-table/data-table.d.ts +73 -0
  4. package/dist/components/data-table/data-table.js +265 -0
  5. package/dist/components/data-table/table-commons.d.ts +56 -0
  6. package/dist/components/data-table/table-commons.js +137 -0
  7. package/dist/components/inputs/checkbox.d.ts +8 -0
  8. package/dist/components/inputs/checkbox.js +25 -0
  9. package/dist/components/inputs/date-picker.d.ts +11 -0
  10. package/dist/components/inputs/date-picker.js +22 -0
  11. package/dist/components/inputs/datefield.d.ts +14 -0
  12. package/dist/components/inputs/datefield.js +25 -0
  13. package/dist/components/inputs/field.d.ts +21 -0
  14. package/dist/components/inputs/field.js +48 -0
  15. package/dist/components/inputs/id-search.d.ts +20 -0
  16. package/dist/components/inputs/id-search.js +40 -0
  17. package/dist/components/inputs/input-otp.d.ts +8 -0
  18. package/dist/components/inputs/input-otp.js +19 -0
  19. package/dist/components/inputs/multi-select.d.ts +17 -0
  20. package/dist/components/inputs/multi-select.js +18 -0
  21. package/dist/components/inputs/numberfield.d.ts +7 -0
  22. package/dist/components/inputs/numberfield.js +25 -0
  23. package/dist/components/inputs/searchfield.d.ts +5 -0
  24. package/dist/components/inputs/searchfield.js +24 -0
  25. package/dist/components/inputs/select-options.d.ts +8 -0
  26. package/dist/components/inputs/select-options.js +286 -0
  27. package/dist/components/inputs/select.d.ts +17 -0
  28. package/dist/components/inputs/select.js +34 -0
  29. package/dist/components/inputs/textfield.d.ts +7 -0
  30. package/dist/components/inputs/textfield.js +28 -0
  31. package/dist/components/key-value-card/key-value-card.d.ts +17 -0
  32. package/dist/components/key-value-card/key-value-card.js +40 -0
  33. package/dist/components/ui/alert.d.ts +8 -0
  34. package/dist/components/ui/alert.js +18 -0
  35. package/dist/components/ui/avatar.d.ts +8 -0
  36. package/dist/components/ui/avatar.js +5 -0
  37. package/dist/components/ui/badge.d.ts +2 -0
  38. package/dist/components/ui/badge.js +5 -0
  39. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  40. package/dist/components/ui/breadcrumbs.js +28 -0
  41. package/dist/components/ui/button.d.ts +11 -0
  42. package/dist/components/ui/button.js +34 -0
  43. package/dist/components/ui/calendar.d.ts +17 -0
  44. package/dist/components/ui/calendar.js +63 -0
  45. package/dist/components/ui/card.d.ts +7 -0
  46. package/dist/components/ui/card.js +20 -0
  47. package/dist/components/ui/dialog.d.ts +19 -0
  48. package/dist/components/ui/dialog.js +42 -0
  49. package/dist/components/ui/disclosure.d.ts +19 -0
  50. package/dist/components/ui/disclosure.js +20 -0
  51. package/dist/components/ui/list-box.d.ts +5 -0
  52. package/dist/components/ui/list-box.js +24 -0
  53. package/dist/components/ui/loader.d.ts +5 -0
  54. package/dist/components/ui/loader.js +6 -0
  55. package/dist/components/ui/menu.d.ts +25 -0
  56. package/dist/components/ui/menu.js +38 -0
  57. package/dist/components/ui/popover.d.ts +4 -0
  58. package/dist/components/ui/popover.js +14 -0
  59. package/dist/components/ui/sidebar.d.ts +53 -0
  60. package/dist/components/ui/sidebar.js +177 -0
  61. package/dist/components/ui/skeleton.d.ts +1 -0
  62. package/dist/components/ui/skeleton.js +5 -0
  63. package/dist/components/ui/sonner.d.ts +4 -0
  64. package/dist/components/ui/sonner.js +14 -0
  65. package/dist/components/ui/table.d.ts +9 -0
  66. package/dist/components/ui/table.js +26 -0
  67. package/dist/components/ui/tabs.d.ts +5 -0
  68. package/dist/components/ui/tabs.js +25 -0
  69. package/dist/components/ui/timeline.d.ts +15 -0
  70. package/dist/components/ui/timeline.js +31 -0
  71. package/dist/components/ui/tooltip.d.ts +4 -0
  72. package/dist/components/ui/tooltip.js +12 -0
  73. package/dist/utils/form-context.d.ts +4 -0
  74. package/{lib/utils/form-context.tsx → dist/utils/form-context.js} +1 -3
  75. package/dist/utils/form-hook.d.ts +25 -0
  76. package/{lib/utils/form-hook.tsx → dist/utils/form-hook.js} +15 -18
  77. package/dist/utils/primitives.d.ts +30 -0
  78. package/{lib/utils/primitives.ts → dist/utils/primitives.js} +8 -37
  79. package/dist/utils/resource-names.d.ts +23 -0
  80. package/{lib/utils/resource-names.tsx → dist/utils/resource-names.js} +42 -75
  81. package/dist/utils/use-mobile.d.ts +1 -0
  82. package/dist/utils/use-mobile.js +15 -0
  83. package/package.json +10 -5
  84. package/lib/components/data-table/data-table-filter.tsx +0 -220
  85. package/lib/components/data-table/data-table.tsx +0 -593
  86. package/lib/components/data-table/table-commons.tsx +0 -233
  87. package/lib/components/inputs/checkbox.tsx +0 -72
  88. package/lib/components/inputs/date-picker.tsx +0 -130
  89. package/lib/components/inputs/datefield.tsx +0 -109
  90. package/lib/components/inputs/field.tsx +0 -106
  91. package/lib/components/inputs/id-search.tsx +0 -83
  92. package/lib/components/inputs/input-otp.tsx +0 -63
  93. package/lib/components/inputs/multi-select.tsx +0 -62
  94. package/lib/components/inputs/numberfield.tsx +0 -110
  95. package/lib/components/inputs/searchfield.tsx +0 -87
  96. package/lib/components/inputs/select-options.tsx +0 -303
  97. package/lib/components/inputs/select.tsx +0 -140
  98. package/lib/components/inputs/textfield.tsx +0 -96
  99. package/lib/components/key-value-card/key-value-card.tsx +0 -115
  100. package/lib/components/ui/alert.tsx +0 -32
  101. package/lib/components/ui/avatar.tsx +0 -22
  102. package/lib/components/ui/badge.tsx +0 -19
  103. package/lib/components/ui/breadcrumbs.tsx +0 -104
  104. package/lib/components/ui/button.tsx +0 -66
  105. package/lib/components/ui/calendar.tsx +0 -220
  106. package/lib/components/ui/card.tsx +0 -58
  107. package/lib/components/ui/dialog.tsx +0 -172
  108. package/lib/components/ui/disclosure.tsx +0 -113
  109. package/lib/components/ui/list-box.tsx +0 -86
  110. package/lib/components/ui/loader.tsx +0 -10
  111. package/lib/components/ui/menu.tsx +0 -168
  112. package/lib/components/ui/popover.tsx +0 -37
  113. package/lib/components/ui/sidebar.tsx +0 -552
  114. package/lib/components/ui/skeleton.tsx +0 -7
  115. package/lib/components/ui/sonner.tsx +0 -26
  116. package/lib/components/ui/table.tsx +0 -79
  117. package/lib/components/ui/tabs.tsx +0 -82
  118. package/lib/components/ui/timeline.tsx +0 -52
  119. package/lib/components/ui/tooltip.tsx +0 -30
  120. package/lib/tokens.scss +0 -89
  121. package/lib/utils/use-mobile.tsx +0 -21
@@ -1,552 +0,0 @@
1
- "use client"
2
- import { PanelLeftClose, PanelLeftOpen } from "lucide-react"
3
- import * as React from "react"
4
-
5
- import { Button } from "lib/components/ui/button"
6
- import { DialogContent, DialogOverlay, DialogTrigger } from "lib/components/ui/dialog"
7
- import { Skeleton } from "lib/components/ui/skeleton"
8
- import { Tooltip, TooltipTrigger } from "lib/components/ui/tooltip"
9
- import { cn } from "lib/utils/primitives"
10
- import { useIsMobile } from "lib/utils/use-mobile"
11
-
12
- // TODO use tailwind variables
13
- const SIDEBAR_WIDTH = "16rem"
14
- const SIDEBAR_WIDTH_MOBILE = "18rem"
15
- const SIDEBAR_WIDTH_ICON = "3rem"
16
- const SIDEBAR_KEYBOARD_SHORTCUT = "b"
17
-
18
- type SidebarContextProps = {
19
- state: "expanded" | "collapsed"
20
- open: boolean
21
- setOpen: (open: boolean) => void
22
- openMobile: boolean
23
- setOpenMobile: (open: boolean) => void
24
- isMobile: boolean
25
- toggleSidebar: () => void
26
- }
27
-
28
- export const SidebarContext = React.createContext<SidebarContextProps | null>(null)
29
-
30
- export function useSidebar() {
31
- const context = React.useContext(SidebarContext)
32
- if (!context) {
33
- throw new Error("useSidebar must be used within a SidebarProvider.")
34
- }
35
-
36
- return context
37
- }
38
-
39
- export function SidebarProvider(
40
- {
41
- defaultOpen = true,
42
- open: openProp,
43
- onOpenChange: setOpenProp,
44
- className,
45
- style,
46
- children,
47
- ...props
48
- }: React.ComponentProps<'div'> & {
49
- defaultOpen?: boolean
50
- open?: boolean
51
- onOpenChange?: (open: boolean) => void
52
- }) {
53
- const isMobile = useIsMobile()
54
- const [openMobile, setOpenMobile] = React.useState(false)
55
-
56
- // This is the internal state of the sidebar.
57
- // We use openProp and setOpenProp for control from outside the component.
58
- const [_open, _setOpen] = React.useState(defaultOpen)
59
- const open = openProp ?? _open
60
- const setOpen = React.useCallback(
61
- (value: boolean | ((value: boolean) => boolean)) => {
62
- const openState = typeof value === "function" ? value(open) : value
63
- if (setOpenProp) {
64
- setOpenProp(openState)
65
- } else {
66
- _setOpen(openState)
67
- }
68
-
69
- // TODO, use different model for persistence
70
- // This sets the cookie to keep the sidebar state.
71
- // document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
72
- },
73
- [setOpenProp, open]
74
- )
75
-
76
- // Helper to toggle the sidebar.
77
- const toggleSidebar = React.useCallback(() => {
78
- return isMobile
79
- ? setOpenMobile((open) => !open)
80
- : setOpen((open) => !open)
81
- }, [isMobile, setOpen, setOpenMobile])
82
-
83
- // Adds a keyboard shortcut to toggle the sidebar.
84
- React.useEffect(() => {
85
- const handleKeyDown = (event: KeyboardEvent) => {
86
- if (
87
- event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
88
- (event.metaKey || event.ctrlKey)
89
- ) {
90
- event.preventDefault()
91
- toggleSidebar()
92
- }
93
- }
94
-
95
- window.addEventListener("keydown", handleKeyDown)
96
- return () => window.removeEventListener("keydown", handleKeyDown)
97
- }, [toggleSidebar])
98
-
99
- // We add a state so that we can do data-state="expanded" or "collapsed".
100
- // This makes it easier to style the sidebar with Tailwind classes.
101
- const state = open ? "expanded" : "collapsed"
102
-
103
- const contextValue = React.useMemo<SidebarContextProps>(
104
- () => ({
105
- state,
106
- open,
107
- setOpen,
108
- isMobile,
109
- openMobile,
110
- setOpenMobile,
111
- toggleSidebar,
112
- }),
113
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
114
- )
115
-
116
- return (
117
- <SidebarContext.Provider value={contextValue}>
118
- <div
119
- style={
120
- {
121
- "--sidebar-width": SIDEBAR_WIDTH,
122
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
123
- ...style,
124
- } as React.CSSProperties
125
- }
126
- className={cn(
127
- "group/sidebar-wrapper flex w-full has-[[data-variant=inset]]:bg-sidebar-background",
128
- className
129
- )}
130
- {...props}
131
- >
132
- {children}
133
- </div>
134
- </SidebarContext.Provider>
135
- )
136
- }
137
-
138
-
139
- export function Sidebar(
140
- {
141
- side = "left",
142
- variant = "sidebar",
143
- collapsible = "offcanvas",
144
- className,
145
- children,
146
- ...props
147
- }: React.ComponentProps<"div"> & {
148
- side?: "left" | "right"
149
- variant?: "sidebar" | "floating" | "inset"
150
- collapsible?: "offcanvas" | "icon" | "none"
151
- }
152
- ) {
153
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
154
-
155
- if (collapsible === "none") {
156
- return (
157
- <div
158
- className={cn(
159
- "flex h-full w-[--sidebar-width] flex-col bg-sidebar-background text-sidebar-foreground",
160
- className
161
- )}
162
- {...props}
163
- >
164
- {children}
165
- </div>
166
- )
167
- }
168
-
169
- if (isMobile) {
170
- return (
171
- <DialogTrigger style={{ "--sidebar-width": SIDEBAR_WIDTH_MOBILE, } as React.CSSProperties} isOpen={openMobile} onOpenChange={setOpenMobile} {...props} >
172
- <DialogOverlay>
173
- <DialogContent
174
- data-sidebar="sidebar"
175
- data-mobile="true"
176
- className="w-[--sidebar-width] p-0 [&>button]:hidden" side="right">
177
- {() => (
178
- <>
179
- {children}
180
- </>
181
- )}
182
- </DialogContent>
183
- </DialogOverlay>
184
- </DialogTrigger>
185
- )
186
- }
187
-
188
- return (
189
- <div
190
- className="group peer hidden text-sidebar-foreground md:block"
191
- data-state={state}
192
- data-collapsible={state === "collapsed" ? collapsible : ""}
193
- data-variant={variant}
194
- data-side={side}
195
- >
196
- {/* This is what handles the sidebar gap on desktop */}
197
- <div
198
- className={cn(
199
- "relative w-(--sidebar-width) bg-sidebar-background transition-[width] duration-200 ease-linear",
200
- "group-data-[collapsible=offcanvas]:w-0",
201
- "group-data-[side=right]:rotate-180",
202
- variant === "floating" || variant === "inset"
203
- ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
204
- : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
205
- )}
206
- />
207
- <div
208
- className={cn(
209
- "absolute z-10 hidden w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
210
- side === "left"
211
- ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
212
- : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
213
- // Adjust the padding for floating and inset variants.
214
- variant === "floating" || variant === "inset"
215
- ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
216
- : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
217
- className
218
- )}
219
- {...props}
220
- >
221
- <div
222
- data-sidebar="sidebar"
223
- className="flex h-full w-full flex-col bg-sidebar-background group-data-[variant=floating]:border group-data-[variant=floating]:border-border group-data-[variant=floating]:shadow"
224
- >
225
- {children}
226
- </div>
227
- </div>
228
- </div>
229
- )
230
- }
231
-
232
-
233
-
234
- export function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
235
- const { toggleSidebar, open } = useSidebar()
236
-
237
- return (
238
- <Button
239
- data-sidebar="trigger"
240
- variant="neutral"
241
- size="icon"
242
- onClick={(event) => {
243
- onClick?.(event)
244
- toggleSidebar()
245
- }}
246
- {...props}
247
- >{open ? <PanelLeftClose /> : <PanelLeftOpen />}</Button>
248
- )
249
- }
250
-
251
- // TODO, evaluate if we need this??
252
- export const SidebarRail = React.forwardRef<
253
- HTMLButtonElement,
254
- React.ComponentProps<"button">
255
- >(({ className, ...props }, ref) => {
256
- const { toggleSidebar } = useSidebar()
257
-
258
- return (
259
- <button
260
- ref={ref}
261
- data-sidebar="rail"
262
- aria-label="Toggle Sidebar"
263
- tabIndex={-1}
264
- onClick={toggleSidebar}
265
- title="Toggle Sidebar"
266
- className={cn(
267
- "absolute inset-y-0 z-20 hidden w-icon -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-border group-data-[side=left]:-right-icon group-data-[side=right]:left-0 sm:flex",
268
- "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
269
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
270
- "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar-background",
271
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
272
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
273
- className
274
- )}
275
- {...props}
276
- />
277
- )
278
- })
279
- SidebarRail.displayName = "SidebarRail"
280
-
281
- export function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
282
- return (
283
- <main
284
- className={cn(
285
- "relative flex w-full flex-1 flex-col bg-background",
286
- "md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
287
- className
288
- )}
289
- {...props}
290
- />
291
- )
292
- }
293
-
294
-
295
- export function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
296
- return (
297
- <div
298
-
299
- data-sidebar="header"
300
- className={cn("flex flex-col gap-2 p-2", className)}
301
- {...props}
302
- />
303
- )
304
- }
305
-
306
- export function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
307
- return (
308
- <div
309
- data-sidebar="footer"
310
- className={cn("flex flex-col gap-2 p-2", className)}
311
- {...props}
312
- />
313
- )
314
- }
315
-
316
- export function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
317
- return (
318
- <div
319
- data-sidebar="content"
320
- className={cn(
321
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
322
- className
323
- )}
324
- {...props}
325
- />
326
- )
327
- }
328
-
329
- export function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
330
- return (
331
- <div
332
- data-sidebar="group"
333
- className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
334
- {...props}
335
- />
336
- )
337
- }
338
-
339
-
340
- export function SidebarGroupLabel({ className, ...props }: React.ComponentProps<"div">) {
341
- return (
342
- <div
343
- data-sidebar="group-label"
344
- className={cn(
345
- "flex h-input shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-icon [&>svg]:shrink-0",
346
- "group-data-[collapsible=icon]:-mt-input group-data-[collapsible=icon]:opacity-0",
347
- className
348
- )}
349
- {...props}
350
- />
351
- )
352
- }
353
- export function SidebarGroupAction({ className, ...props }: React.ComponentProps<"button">) {
354
- return (
355
- <button
356
- data-sidebar="group-action"
357
- className={cn(
358
- "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-ring transition-transform hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 [&>svg]:size-icon [&>svg]:shrink-0",
359
- // Increases the hit area of the button on mobile.
360
- "after:absolute after:-inset-2 after:md:hidden",
361
- "group-data-[collapsible=icon]:hidden",
362
- className
363
- )}
364
- {...props}
365
- />
366
- )
367
- }
368
-
369
- export function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
370
- return (
371
- <div
372
- data-sidebar="group-content"
373
- className={cn("w-full text-sm", className)}
374
- {...props}
375
- />
376
- )
377
- }
378
-
379
- export function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
380
- return (
381
- <ul
382
- data-sidebar="menu"
383
- className={cn("flex w-full min-w-0 flex-col gap-1", className)}
384
- {...props}
385
- />
386
- )
387
- }
388
-
389
- export function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
390
- return (
391
- <li
392
- data-sidebar="menu-item"
393
- className={cn("group/menu-item relative list-none", className)}
394
- {...props}
395
- />
396
- )
397
- }
398
-
399
- /// TODO fix positioning
400
- export function SidebarMenuAction({ className, showOnHover = false, ...props }: React.ComponentProps<"button"> & {
401
- showOnHover?: boolean
402
- }) {
403
-
404
- return (
405
- <button
406
- data-sidebar="menu-action"
407
- className={cn(
408
- "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-ring transition-transform hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-accent-foreground [&>svg]:size-icon [&>svg]:shrink-0",
409
- // Increases the hit area of the button on mobile.
410
- "after:absolute after:-inset-2 after:md:hidden",
411
- "peer-data-[size=sm]/menu-button:top-1",
412
- "peer-data-[size=default]/menu-button:top-1.5",
413
- "peer-data-[size=lg]/menu-button:top-2.5",
414
- "group-data-[collapsible=icon]:hidden",
415
- showOnHover &&
416
- "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-accent-foreground md:opacity-0",
417
- className
418
- )}
419
- {...props}
420
- />
421
- )
422
- }
423
-
424
- export function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
425
- return (
426
- <div
427
- data-sidebar="menu-badge"
428
- className={cn(
429
- "pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground",
430
- "peer-hover/menu-button:text-accent-foreground peer-data-[active=true]/menu-button:text-accent-foreground",
431
- "peer-data-[size=sm]/menu-button:top-1",
432
- "peer-data-[size=default]/menu-button:top-1.5",
433
- "peer-data-[size=lg]/menu-button:top-2.5",
434
- "group-data-[collapsible=icon]:hidden",
435
- className
436
- )}
437
- {...props}
438
- />
439
- )
440
- }
441
-
442
- export function SidebarMenuSkeleton({ className, showIcon = false, ...props }: React.ComponentProps<"div"> & {
443
- showIcon?: boolean
444
- }) {
445
- // Random width between 50 to 90%.
446
- const width = React.useMemo(() => {
447
- return `${Math.floor(Math.random() * 40) + 50}%`
448
- }, [])
449
-
450
- return (
451
- <div
452
- data-sidebar="menu-skeleton"
453
- className={cn("flex h-input items-center gap-2 px-2", className)}
454
- {...props}
455
- >
456
- {showIcon && (
457
- <Skeleton
458
- className="size-icon"
459
- data-sidebar="menu-skeleton-icon"
460
- />
461
- )}
462
- <Skeleton
463
- className="h-icon max-w-[--skeleton-width] flex-1"
464
- data-sidebar="menu-skeleton-text"
465
- style={
466
- {
467
- "--skeleton-width": width,
468
- } as React.CSSProperties
469
- }
470
- />
471
- </div>
472
- )
473
- }
474
-
475
- export function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
476
- return (
477
- <ul
478
- data-sidebar="menu-sub"
479
- className={cn(
480
- "mx-2 flex min-w-0 translate-x-px flex-col gap-1 border-l border-border px-2",
481
- "group-data-[collapsible=icon]:hidden",
482
- className
483
- )}
484
- {...props}
485
- />
486
- )
487
- }
488
-
489
- export function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) { return <li className={cn("list-none ms-0", className)} {...props} /> }
490
-
491
- // Common interaction logic for SidebarMenuButton and SidebarMenuSubButton
492
- const Cs_SidebarButton = "flex w-full items-center gap-2 truncate p-2 text-sm btn btn-ghost h-input text-accent data-[active=true]:bg-primary/20 data-[active=true]:font-medium data-[active=true]:text-primary [&>span:last-child]:truncate [&>svg]:size-icon [&>svg]:shrink-0";
493
- export function SidebarMenuButton
494
- (
495
- {
496
- isActive = false,
497
- tooltip,
498
- className,
499
- ...props
500
- }: React.ComponentProps<"button"> & {
501
- isActive?: boolean
502
- tooltip?: React.ComponentProps<typeof Tooltip>
503
- }
504
- ) {
505
- const { isMobile, state } = useSidebar()
506
-
507
- const button = (
508
- <button
509
- data-sidebar="menu-button"
510
- data-active={isActive}
511
- className={cn(
512
- "peer/menu-button group-has-[[data-sidebar=menu-action]]/menu-item:pr-input group-data-[collapsible=icon]:!size-icon group-data-[collapsible=icon]:!p-2 ",
513
- Cs_SidebarButton,
514
- className)}
515
- {...props}
516
- />
517
- )
518
-
519
- if (!tooltip) {
520
- return button
521
- }
522
-
523
- return (
524
- <TooltipTrigger>
525
- {button}
526
- <Tooltip
527
- hidden={state !== "collapsed" || isMobile}
528
- {...tooltip}
529
- />
530
- </TooltipTrigger>
531
- )
532
- }
533
-
534
- export function SidebarMenuSubButton({ isActive, className, ...props }: React.ComponentProps<'a'> & {
535
- isActive?: boolean
536
- }) {
537
-
538
- return (
539
- <a
540
- data-sidebar="menu-sub-button"
541
- data-active={isActive}
542
- className={cn(
543
- "-translate-x-px [&>svg]:text-accent-foreground",
544
- "group-data-[collapsible=icon]:hidden",
545
- Cs_SidebarButton,
546
- className
547
- )}
548
- {...props}
549
- />
550
- )
551
- }
552
- // TODO, standardize heights here
@@ -1,7 +0,0 @@
1
- import { cn } from "lib/utils/primitives";
2
-
3
- export function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
- return (
5
- <div className={cn("animate-pulse bg-primary/10", className)} {...props} />
6
- );
7
- }
@@ -1,26 +0,0 @@
1
- "use client";
2
- import { Toaster as Sonner } from "sonner";
3
-
4
- type ToasterProps = React.ComponentProps<typeof Sonner>;
5
-
6
- export function Toaster({ ...props }: ToasterProps) {
7
- return (
8
- <Sonner
9
- className="toaster group"
10
- toastOptions={{
11
- classNames: {
12
- toast:
13
- "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
14
- description: "group-[.toast]:text-muted-foreground",
15
- actionButton:
16
- "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
17
- cancelButton:
18
- "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
19
- },
20
- }}
21
- {...props}
22
- />
23
- );
24
- };
25
-
26
-
@@ -1,79 +0,0 @@
1
- import { cn } from "lib/utils/primitives";
2
- import type * as React from "react";
3
-
4
- export function Table({ className, ...props }: React.ComponentProps<"table">) {
5
- return (
6
- <table
7
- className={cn(
8
- "caption-bottom text-sm [&_tr:last-child]:border-0 my-0 whitespace-nowrap",
9
- className,
10
- )}
11
- {...props}
12
- />
13
- );
14
- }
15
-
16
- export function TableHeader({
17
- className,
18
- ...props
19
- }: React.ComponentProps<"thead">) {
20
- return (
21
- <thead
22
- className={cn("[&_tr]:border-b border-b", className)} // Added border-b to apply a bottom border
23
- {...props}
24
- />
25
- );
26
- }
27
-
28
- export function TableBody({
29
- className,
30
- ...props
31
- }: React.ComponentProps<"tbody">) {
32
- return <tbody className={cn(className)} {...props} />;
33
- }
34
-
35
- export function TableFooter({
36
- className,
37
- ...props
38
- }: React.ComponentProps<"tfoot">) {
39
- return (
40
- <tfoot
41
- className={cn("border-t font-medium last:[&>tr]:border-b-0", className)}
42
- {...props}
43
- />
44
- );
45
- }
46
-
47
- export function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
48
- return <tr className={cn("border-b border-border", className)} {...props} />;
49
- }
50
-
51
- export function TableHead({ className, ...props }: React.ComponentProps<"th">) {
52
- return (
53
- <th
54
- className={cn("text-left align-middle font-medium", className)}
55
- {...props}
56
- />
57
- );
58
- }
59
-
60
- export function TableCell({ className, ...props }: React.ComponentProps<"td">) {
61
- return (
62
- <td
63
- className={cn("[&_tr:last-child]:border-dotted", className)}
64
- {...props}
65
- />
66
- );
67
- }
68
-
69
- export function TableCaption({
70
- className,
71
- ...props
72
- }: React.ComponentProps<"caption">) {
73
- return (
74
- <caption
75
- className={cn("mt-icon text-sm text-muted-foreground", className)}
76
- {...props}
77
- />
78
- );
79
- }