@bupple/vss-ui 1.0.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 (65) hide show
  1. package/.turbo/turbo-lint.log +4 -0
  2. package/components.json +21 -0
  3. package/eslint.config.js +4 -0
  4. package/index.ts +2 -0
  5. package/package.json +67 -0
  6. package/postcss.config.mjs +6 -0
  7. package/src/components/accordion.tsx +84 -0
  8. package/src/components/alert-dialog.tsx +198 -0
  9. package/src/components/alert.tsx +77 -0
  10. package/src/components/aspect-ratio.tsx +11 -0
  11. package/src/components/avatar.tsx +109 -0
  12. package/src/components/badge.tsx +50 -0
  13. package/src/components/breadcrumb.tsx +118 -0
  14. package/src/components/button-group.tsx +84 -0
  15. package/src/components/button.tsx +68 -0
  16. package/src/components/calendar.tsx +223 -0
  17. package/src/components/card.tsx +102 -0
  18. package/src/components/carousel.tsx +241 -0
  19. package/src/components/chart.tsx +373 -0
  20. package/src/components/checkbox.tsx +32 -0
  21. package/src/components/collapsible.tsx +33 -0
  22. package/src/components/combobox.tsx +299 -0
  23. package/src/components/command.tsx +194 -0
  24. package/src/components/context-menu.tsx +272 -0
  25. package/src/components/dialog.tsx +171 -0
  26. package/src/components/direction.tsx +20 -0
  27. package/src/components/drawer.tsx +130 -0
  28. package/src/components/dropdown-menu.tsx +278 -0
  29. package/src/components/empty.tsx +102 -0
  30. package/src/components/field.tsx +237 -0
  31. package/src/components/hover-card.tsx +43 -0
  32. package/src/components/input-group.tsx +157 -0
  33. package/src/components/input.tsx +18 -0
  34. package/src/components/item.tsx +197 -0
  35. package/src/components/kbd.tsx +26 -0
  36. package/src/components/label.tsx +21 -0
  37. package/src/components/menubar.tsx +283 -0
  38. package/src/components/native-select.tsx +64 -0
  39. package/src/components/navigation-menu.tsx +166 -0
  40. package/src/components/pagination.tsx +131 -0
  41. package/src/components/popover.tsx +88 -0
  42. package/src/components/progress.tsx +30 -0
  43. package/src/components/radio-group.tsx +46 -0
  44. package/src/components/resizable.tsx +49 -0
  45. package/src/components/scroll-area.tsx +52 -0
  46. package/src/components/select.tsx +209 -0
  47. package/src/components/separator.tsx +25 -0
  48. package/src/components/sheet.tsx +152 -0
  49. package/src/components/sidebar.tsx +703 -0
  50. package/src/components/skeleton.tsx +13 -0
  51. package/src/components/slider.tsx +58 -0
  52. package/src/components/sonner.tsx +45 -0
  53. package/src/components/spinner.tsx +15 -0
  54. package/src/components/switch.tsx +32 -0
  55. package/src/components/table.tsx +115 -0
  56. package/src/components/tabs.tsx +89 -0
  57. package/src/components/textarea.tsx +17 -0
  58. package/src/components/toggle-group.tsx +86 -0
  59. package/src/components/toggle.tsx +48 -0
  60. package/src/components/tooltip.tsx +56 -0
  61. package/src/hooks/use-mobile.ts +19 -0
  62. package/src/lib/portal-container.ts +11 -0
  63. package/src/lib/utils.ts +8 -0
  64. package/src/theme.css +125 -0
  65. package/tsconfig.json +15 -0
@@ -0,0 +1,58 @@
1
+ 'use client'
2
+
3
+ import { cn } from '@bupple/vss-ui/lib/utils'
4
+ import { Slider as SliderPrimitive } from 'radix-ui'
5
+ import * as React from 'react'
6
+
7
+ function Slider({
8
+ className,
9
+ defaultValue,
10
+ value,
11
+ min = 0,
12
+ max = 100,
13
+ ...props
14
+ }: React.ComponentProps<typeof SliderPrimitive.Root>) {
15
+ const _values = React.useMemo(
16
+ () =>
17
+ Array.isArray(value)
18
+ ? value
19
+ : Array.isArray(defaultValue)
20
+ ? defaultValue
21
+ : [min, max],
22
+ [value, defaultValue, min, max],
23
+ )
24
+
25
+ return (
26
+ <SliderPrimitive.Root
27
+ data-slot='slider'
28
+ defaultValue={defaultValue}
29
+ value={value}
30
+ min={min}
31
+ max={max}
32
+ className={cn(
33
+ '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',
34
+ className,
35
+ )}
36
+ {...props}
37
+ >
38
+ <SliderPrimitive.Track
39
+ data-slot='slider-track'
40
+ className='relative grow overflow-hidden rounded-full bg-muted data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1'
41
+ >
42
+ <SliderPrimitive.Range
43
+ data-slot='slider-range'
44
+ className='absolute bg-primary select-none data-horizontal:h-full data-vertical:w-full'
45
+ />
46
+ </SliderPrimitive.Track>
47
+ {Array.from({ length: _values.length }, (_, index) => (
48
+ <SliderPrimitive.Thumb
49
+ data-slot='slider-thumb'
50
+ key={index}
51
+ 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'
52
+ />
53
+ ))}
54
+ </SliderPrimitive.Root>
55
+ )
56
+ }
57
+
58
+ export { Slider }
@@ -0,0 +1,45 @@
1
+ import type { ToasterProps } from 'sonner'
2
+
3
+ import {
4
+ CircleCheckIcon,
5
+ InfoIcon,
6
+ Loader2Icon,
7
+ OctagonXIcon,
8
+ TriangleAlertIcon,
9
+ } from 'lucide-react'
10
+ import { useTheme } from 'next-themes'
11
+ import { Toaster as Sonner } from 'sonner'
12
+
13
+ const Toaster = ({ ...props }: ToasterProps) => {
14
+ const { theme = 'system' } = useTheme()
15
+
16
+ return (
17
+ <Sonner
18
+ theme={theme as ToasterProps['theme']}
19
+ className='toaster group'
20
+ icons={{
21
+ success: <CircleCheckIcon className='size-4' />,
22
+ info: <InfoIcon className='size-4' />,
23
+ warning: <TriangleAlertIcon className='size-4' />,
24
+ error: <OctagonXIcon className='size-4' />,
25
+ loading: <Loader2Icon className='size-4 animate-spin' />,
26
+ }}
27
+ style={
28
+ {
29
+ '--normal-bg': 'var(--popover)',
30
+ '--normal-text': 'var(--popover-foreground)',
31
+ '--normal-border': 'var(--border)',
32
+ '--border-radius': 'var(--radius)',
33
+ } as React.CSSProperties
34
+ }
35
+ toastOptions={{
36
+ classNames: {
37
+ toast: 'cn-toast',
38
+ },
39
+ }}
40
+ {...props}
41
+ />
42
+ )
43
+ }
44
+
45
+ export { Toaster }
@@ -0,0 +1,15 @@
1
+ import { cn } from '@bupple/vss-ui/lib/utils'
2
+ import { Loader2Icon } from 'lucide-react'
3
+
4
+ function Spinner({ className, ...props }: React.ComponentProps<'svg'>) {
5
+ return (
6
+ <Loader2Icon
7
+ role='status'
8
+ aria-label='Loading'
9
+ className={cn('size-4 animate-spin', className)}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ export { Spinner }
@@ -0,0 +1,32 @@
1
+ 'use client'
2
+
3
+ import { cn } from '@bupple/vss-ui/lib/utils'
4
+ import { Switch as SwitchPrimitive } from 'radix-ui'
5
+ import * as React from 'react'
6
+
7
+ function Switch({
8
+ className,
9
+ size = 'default',
10
+ ...props
11
+ }: React.ComponentProps<typeof SwitchPrimitive.Root> & {
12
+ size?: 'sm' | 'default'
13
+ }) {
14
+ return (
15
+ <SwitchPrimitive.Root
16
+ data-slot='switch'
17
+ data-size={size}
18
+ className={cn(
19
+ 'peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50',
20
+ className,
21
+ )}
22
+ {...props}
23
+ >
24
+ <SwitchPrimitive.Thumb
25
+ data-slot='switch-thumb'
26
+ className='pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground'
27
+ />
28
+ </SwitchPrimitive.Root>
29
+ )
30
+ }
31
+
32
+ export { Switch }
@@ -0,0 +1,115 @@
1
+ 'use client'
2
+
3
+ import { cn } from '@bupple/vss-ui/lib/utils'
4
+ import * as React from 'react'
5
+
6
+ function Table({ className, ...props }: React.ComponentProps<'table'>) {
7
+ return (
8
+ <div
9
+ data-slot='table-container'
10
+ className='relative w-full overflow-x-auto'
11
+ >
12
+ <table
13
+ data-slot='table'
14
+ className={cn('w-full caption-bottom text-sm', className)}
15
+ {...props}
16
+ />
17
+ </div>
18
+ )
19
+ }
20
+
21
+ function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
22
+ return (
23
+ <thead
24
+ data-slot='table-header'
25
+ className={cn('[&_tr]:border-b', className)}
26
+ {...props}
27
+ />
28
+ )
29
+ }
30
+
31
+ function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
32
+ return (
33
+ <tbody
34
+ data-slot='table-body'
35
+ className={cn('[&_tr:last-child]:border-0', className)}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
42
+ return (
43
+ <tfoot
44
+ data-slot='table-footer'
45
+ className={cn(
46
+ 'border-t bg-muted/50 font-medium [&>tr]:last:border-b-0',
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ )
52
+ }
53
+
54
+ function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
55
+ return (
56
+ <tr
57
+ data-slot='table-row'
58
+ className={cn(
59
+ 'border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted',
60
+ className,
61
+ )}
62
+ {...props}
63
+ />
64
+ )
65
+ }
66
+
67
+ function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
68
+ return (
69
+ <th
70
+ data-slot='table-head'
71
+ className={cn(
72
+ 'h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0',
73
+ className,
74
+ )}
75
+ {...props}
76
+ />
77
+ )
78
+ }
79
+
80
+ function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
81
+ return (
82
+ <td
83
+ data-slot='table-cell'
84
+ className={cn(
85
+ 'p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0',
86
+ className,
87
+ )}
88
+ {...props}
89
+ />
90
+ )
91
+ }
92
+
93
+ function TableCaption({
94
+ className,
95
+ ...props
96
+ }: React.ComponentProps<'caption'>) {
97
+ return (
98
+ <caption
99
+ data-slot='table-caption'
100
+ className={cn('mt-4 text-sm text-muted-foreground', className)}
101
+ {...props}
102
+ />
103
+ )
104
+ }
105
+
106
+ export {
107
+ Table,
108
+ TableHeader,
109
+ TableBody,
110
+ TableFooter,
111
+ TableHead,
112
+ TableRow,
113
+ TableCell,
114
+ TableCaption,
115
+ }
@@ -0,0 +1,89 @@
1
+ import type { VariantProps } from 'class-variance-authority'
2
+
3
+ import { cn } from '@bupple/vss-ui/lib/utils'
4
+ import { cva } from 'class-variance-authority'
5
+ import { Tabs as TabsPrimitive } from 'radix-ui'
6
+ import * as React from 'react'
7
+
8
+ function Tabs({
9
+ className,
10
+ orientation = 'horizontal',
11
+ ...props
12
+ }: React.ComponentProps<typeof TabsPrimitive.Root>) {
13
+ return (
14
+ <TabsPrimitive.Root
15
+ data-slot='tabs'
16
+ data-orientation={orientation}
17
+ className={cn(
18
+ 'group/tabs flex gap-2 data-horizontal:flex-col',
19
+ className,
20
+ )}
21
+ {...props}
22
+ />
23
+ )
24
+ }
25
+
26
+ const tabsListVariants = cva(
27
+ 'group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none',
28
+ {
29
+ variants: {
30
+ variant: {
31
+ default: 'bg-muted',
32
+ line: 'gap-1 bg-transparent',
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: 'default',
37
+ },
38
+ },
39
+ )
40
+
41
+ function TabsList({
42
+ className,
43
+ variant = 'default',
44
+ ...props
45
+ }: React.ComponentProps<typeof TabsPrimitive.List> &
46
+ VariantProps<typeof tabsListVariants>) {
47
+ return (
48
+ <TabsPrimitive.List
49
+ data-slot='tabs-list'
50
+ data-variant={variant}
51
+ className={cn(tabsListVariants({ variant }), className)}
52
+ {...props}
53
+ />
54
+ )
55
+ }
56
+
57
+ function TabsTrigger({
58
+ className,
59
+ ...props
60
+ }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
61
+ return (
62
+ <TabsPrimitive.Trigger
63
+ data-slot='tabs-trigger'
64
+ className={cn(
65
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
66
+ 'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent',
67
+ 'data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground',
68
+ 'after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100',
69
+ className,
70
+ )}
71
+ {...props}
72
+ />
73
+ )
74
+ }
75
+
76
+ function TabsContent({
77
+ className,
78
+ ...props
79
+ }: React.ComponentProps<typeof TabsPrimitive.Content>) {
80
+ return (
81
+ <TabsPrimitive.Content
82
+ data-slot='tabs-content'
83
+ className={cn('flex-1 text-sm outline-none', className)}
84
+ {...props}
85
+ />
86
+ )
87
+ }
88
+
89
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
@@ -0,0 +1,17 @@
1
+ import { cn } from '@bupple/vss-ui/lib/utils'
2
+ import * as React from 'react'
3
+
4
+ function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
5
+ return (
6
+ <textarea
7
+ data-slot='textarea'
8
+ className={cn(
9
+ 'flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
10
+ className,
11
+ )}
12
+ {...props}
13
+ />
14
+ )
15
+ }
16
+
17
+ export { Textarea }
@@ -0,0 +1,86 @@
1
+ import { toggleVariants } from '@bupple/vss-ui/components/toggle'
2
+ import { cn } from '@bupple/vss-ui/lib/utils'
3
+ import { type VariantProps } from 'class-variance-authority'
4
+ import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui'
5
+ import * as React from 'react'
6
+
7
+ const ToggleGroupContext = React.createContext<
8
+ VariantProps<typeof toggleVariants> & {
9
+ spacing?: number
10
+ orientation?: 'horizontal' | 'vertical'
11
+ }
12
+ >({
13
+ size: 'default',
14
+ variant: 'default',
15
+ spacing: 0,
16
+ orientation: 'horizontal',
17
+ })
18
+
19
+ function ToggleGroup({
20
+ className,
21
+ variant,
22
+ size,
23
+ spacing = 0,
24
+ orientation = 'horizontal',
25
+ children,
26
+ ...props
27
+ }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
28
+ VariantProps<typeof toggleVariants> & {
29
+ spacing?: number
30
+ orientation?: 'horizontal' | 'vertical'
31
+ }) {
32
+ return (
33
+ <ToggleGroupPrimitive.Root
34
+ data-slot='toggle-group'
35
+ data-variant={variant}
36
+ data-size={size}
37
+ data-spacing={spacing}
38
+ data-orientation={orientation}
39
+ style={{ '--gap': spacing } as React.CSSProperties}
40
+ className={cn(
41
+ 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch',
42
+ className,
43
+ )}
44
+ {...props}
45
+ >
46
+ <ToggleGroupContext.Provider
47
+ value={{ variant, size, spacing, orientation }}
48
+ >
49
+ {children}
50
+ </ToggleGroupContext.Provider>
51
+ </ToggleGroupPrimitive.Root>
52
+ )
53
+ }
54
+
55
+ function ToggleGroupItem({
56
+ className,
57
+ children,
58
+ variant = 'default',
59
+ size = 'default',
60
+ ...props
61
+ }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
62
+ VariantProps<typeof toggleVariants>) {
63
+ const context = React.useContext(ToggleGroupContext)
64
+
65
+ return (
66
+ <ToggleGroupPrimitive.Item
67
+ data-slot='toggle-group-item'
68
+ data-variant={context.variant || variant}
69
+ data-size={context.size || size}
70
+ data-spacing={context.spacing}
71
+ className={cn(
72
+ 'shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t',
73
+ toggleVariants({
74
+ variant: context.variant || variant,
75
+ size: context.size || size,
76
+ }),
77
+ className,
78
+ )}
79
+ {...props}
80
+ >
81
+ {children}
82
+ </ToggleGroupPrimitive.Item>
83
+ )
84
+ }
85
+
86
+ export { ToggleGroup, ToggleGroupItem }
@@ -0,0 +1,48 @@
1
+ 'use client'
2
+
3
+ import type { VariantProps } from 'class-variance-authority'
4
+
5
+ import { cn } from '@bupple/vss-ui/lib/utils'
6
+ import { cva } from 'class-variance-authority'
7
+ import { Toggle as TogglePrimitive } from 'radix-ui'
8
+ import * as React from 'react'
9
+
10
+ const toggleVariants = cva(
11
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
12
+ {
13
+ variants: {
14
+ variant: {
15
+ default: 'bg-transparent',
16
+ outline: 'border border-input bg-transparent hover:bg-muted',
17
+ },
18
+ size: {
19
+ default:
20
+ 'h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
21
+ sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
22
+ lg: 'h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ variant: 'default',
27
+ size: 'default',
28
+ },
29
+ },
30
+ )
31
+
32
+ function Toggle({
33
+ className,
34
+ variant = 'default',
35
+ size = 'default',
36
+ ...props
37
+ }: React.ComponentProps<typeof TogglePrimitive.Root> &
38
+ VariantProps<typeof toggleVariants>) {
39
+ return (
40
+ <TogglePrimitive.Root
41
+ data-slot='toggle'
42
+ className={cn(toggleVariants({ variant, size, className }))}
43
+ {...props}
44
+ />
45
+ )
46
+ }
47
+
48
+ export { Toggle, toggleVariants }
@@ -0,0 +1,56 @@
1
+ import { usePortalContainer } from '@bupple/vss-ui/lib/portal-container'
2
+ import { cn } from '@bupple/vss-ui/lib/utils'
3
+ import { Tooltip as TooltipPrimitive } from 'radix-ui'
4
+ import * as React from 'react'
5
+
6
+ function TooltipProvider({
7
+ delayDuration = 0,
8
+ ...props
9
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
10
+ return (
11
+ <TooltipPrimitive.Provider
12
+ data-slot='tooltip-provider'
13
+ delayDuration={delayDuration}
14
+ {...props}
15
+ />
16
+ )
17
+ }
18
+
19
+ function Tooltip({
20
+ ...props
21
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
22
+ return <TooltipPrimitive.Root data-slot='tooltip' {...props} />
23
+ }
24
+
25
+ function TooltipTrigger({
26
+ ...props
27
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
28
+ return <TooltipPrimitive.Trigger data-slot='tooltip-trigger' {...props} />
29
+ }
30
+
31
+ function TooltipContent({
32
+ className,
33
+ sideOffset = 0,
34
+ children,
35
+ ...props
36
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
37
+ const container = usePortalContainer()
38
+ return (
39
+ <TooltipPrimitive.Portal container={container ?? undefined}>
40
+ <TooltipPrimitive.Content
41
+ data-slot='tooltip-content'
42
+ sideOffset={sideOffset}
43
+ className={cn(
44
+ 'z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
45
+ className,
46
+ )}
47
+ {...props}
48
+ >
49
+ {children}
50
+ <TooltipPrimitive.Arrow className='z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground' />
51
+ </TooltipPrimitive.Content>
52
+ </TooltipPrimitive.Portal>
53
+ )
54
+ }
55
+
56
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
@@ -0,0 +1,19 @@
1
+ import * as React from 'react'
2
+
3
+ const MOBILE_BREAKPOINT = 768
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7
+
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10
+ const onChange = () => {
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12
+ }
13
+ mql.addEventListener('change', onChange)
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15
+ return () => mql.removeEventListener('change', onChange)
16
+ }, [])
17
+
18
+ return !!isMobile
19
+ }
@@ -0,0 +1,11 @@
1
+ 'use client'
2
+
3
+ import { createContext, useContext } from 'react'
4
+
5
+ const PortalContainerContext = createContext<HTMLElement | null>(null)
6
+
7
+ function usePortalContainer(): HTMLElement | null {
8
+ return useContext(PortalContainerContext)
9
+ }
10
+
11
+ export { PortalContainerContext, usePortalContainer }
@@ -0,0 +1,8 @@
1
+ import type { ClassValue } from 'clsx'
2
+
3
+ import { clsx } from 'clsx'
4
+ import { twMerge } from 'tailwind-merge'
5
+
6
+ export function cn(...inputs: ClassValue[]) {
7
+ return twMerge(clsx(inputs))
8
+ }