@saena-io/create 0.1.0 → 0.2.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 (100) hide show
  1. package/dist/index.js +9 -9
  2. package/package.json +1 -1
  3. package/template/base/package.json +44 -2
  4. package/template/base/scripts/ui-update.ts +83 -0
  5. package/template/base/src/components/ui/accordion.tsx +75 -0
  6. package/template/base/src/components/ui/alert-dialog.tsx +162 -0
  7. package/template/base/src/components/ui/alert.tsx +73 -0
  8. package/template/base/src/components/ui/app-sidebar.tsx +183 -0
  9. package/template/base/src/components/ui/aspect-ratio.tsx +22 -0
  10. package/template/base/src/components/ui/asset-input.tsx +211 -0
  11. package/template/base/src/components/ui/avatar.tsx +91 -0
  12. package/template/base/src/components/ui/badge.tsx +50 -0
  13. package/template/base/src/components/ui/breadcrumb.tsx +104 -0
  14. package/template/base/src/components/ui/button-group.tsx +78 -0
  15. package/template/base/src/components/ui/button.tsx +56 -0
  16. package/template/base/src/components/ui/calendar.tsx +205 -0
  17. package/template/base/src/components/ui/card.tsx +85 -0
  18. package/template/base/src/components/ui/carousel.tsx +232 -0
  19. package/template/base/src/components/ui/chart.tsx +337 -0
  20. package/template/base/src/components/ui/checkbox.tsx +29 -0
  21. package/template/base/src/components/ui/collapsible.tsx +15 -0
  22. package/template/base/src/components/ui/combobox.tsx +276 -0
  23. package/template/base/src/components/ui/command.tsx +190 -0
  24. package/template/base/src/components/ui/context-menu.tsx +243 -0
  25. package/template/base/src/components/ui/dialog.tsx +134 -0
  26. package/template/base/src/components/ui/direction.tsx +4 -0
  27. package/template/base/src/components/ui/drawer.tsx +120 -0
  28. package/template/base/src/components/ui/dropdown-menu.tsx +254 -0
  29. package/template/base/src/components/ui/empty.tsx +94 -0
  30. package/template/base/src/components/ui/field.tsx +222 -0
  31. package/template/base/src/components/ui/focal-point-picker.tsx +175 -0
  32. package/template/base/src/components/ui/hover-card.tsx +46 -0
  33. package/template/base/src/components/ui/input-group.tsx +149 -0
  34. package/template/base/src/components/ui/input-otp.tsx +85 -0
  35. package/template/base/src/components/ui/input.tsx +20 -0
  36. package/template/base/src/components/ui/item.tsx +188 -0
  37. package/template/base/src/components/ui/kbd.tsx +26 -0
  38. package/template/base/src/components/ui/label.tsx +20 -0
  39. package/template/base/src/components/ui/menubar.tsx +268 -0
  40. package/template/base/src/components/ui/native-select.tsx +58 -0
  41. package/template/base/src/components/ui/nav-main.tsx +70 -0
  42. package/template/base/src/components/ui/nav-projects.tsx +97 -0
  43. package/template/base/src/components/ui/nav-secondary.tsx +37 -0
  44. package/template/base/src/components/ui/nav-user.tsx +108 -0
  45. package/template/base/src/components/ui/navigation-menu.tsx +164 -0
  46. package/template/base/src/components/ui/pagination.tsx +123 -0
  47. package/template/base/src/components/ui/popover.tsx +80 -0
  48. package/template/base/src/components/ui/progress.tsx +66 -0
  49. package/template/base/src/components/ui/radio-group.tsx +36 -0
  50. package/template/base/src/components/ui/resizable.tsx +42 -0
  51. package/template/base/src/components/ui/rich-text/ai-chat-editor.tsx +20 -0
  52. package/template/base/src/components/ui/rich-text/ai-command.tsx +90 -0
  53. package/template/base/src/components/ui/rich-text/ai-copilot.tsx +67 -0
  54. package/template/base/src/components/ui/rich-text/ai-menu.tsx +456 -0
  55. package/template/base/src/components/ui/rich-text/ai-node.tsx +42 -0
  56. package/template/base/src/components/ui/rich-text/ai-toolbar-button.tsx +29 -0
  57. package/template/base/src/components/ui/rich-text/block-draggable.tsx +187 -0
  58. package/template/base/src/components/ui/rich-text/block-selection.tsx +17 -0
  59. package/template/base/src/components/ui/rich-text/code-block-node.tsx +204 -0
  60. package/template/base/src/components/ui/rich-text/codec.ts +63 -0
  61. package/template/base/src/components/ui/rich-text/extension.ts +53 -0
  62. package/template/base/src/components/ui/rich-text/ghost-text.tsx +23 -0
  63. package/template/base/src/components/ui/rich-text/import-export-toolbar.tsx +103 -0
  64. package/template/base/src/components/ui/rich-text/link.tsx +18 -0
  65. package/template/base/src/components/ui/rich-text/list-node.tsx +65 -0
  66. package/template/base/src/components/ui/rich-text/nodes.tsx +44 -0
  67. package/template/base/src/components/ui/rich-text/plugins.ts +233 -0
  68. package/template/base/src/components/ui/rich-text/rich-text-editor.tsx +82 -0
  69. package/template/base/src/components/ui/rich-text/static.tsx +117 -0
  70. package/template/base/src/components/ui/rich-text/table-node.tsx +934 -0
  71. package/template/base/src/components/ui/rich-text/table-toolbar.tsx +232 -0
  72. package/template/base/src/components/ui/rich-text/toggle-node.tsx +36 -0
  73. package/template/base/src/components/ui/rich-text/toolbar-slots.ts +41 -0
  74. package/template/base/src/components/ui/rich-text/toolbar.tsx +668 -0
  75. package/template/base/src/components/ui/rich-text/use-ai-chat.ts +35 -0
  76. package/template/base/src/components/ui/rich-text/variable-type.ts +4 -0
  77. package/template/base/src/components/ui/rich-text/variable.tsx +97 -0
  78. package/template/base/src/components/ui/scroll-area.tsx +49 -0
  79. package/template/base/src/components/ui/select.tsx +202 -0
  80. package/template/base/src/components/ui/separator.tsx +19 -0
  81. package/template/base/src/components/ui/sheet.tsx +126 -0
  82. package/template/base/src/components/ui/sidebar.tsx +695 -0
  83. package/template/base/src/components/ui/skeleton.tsx +13 -0
  84. package/template/base/src/components/ui/slider.tsx +52 -0
  85. package/template/base/src/components/ui/sonner.tsx +50 -0
  86. package/template/base/src/components/ui/spinner.tsx +18 -0
  87. package/template/base/src/components/ui/switch.tsx +30 -0
  88. package/template/base/src/components/ui/table.tsx +89 -0
  89. package/template/base/src/components/ui/tabs.tsx +73 -0
  90. package/template/base/src/components/ui/textarea.tsx +18 -0
  91. package/template/base/src/components/ui/toggle-group.tsx +85 -0
  92. package/template/base/src/components/ui/toggle.tsx +45 -0
  93. package/template/base/src/components/ui/toolbar.tsx +451 -0
  94. package/template/base/src/components/ui/tooltip.tsx +52 -0
  95. package/template/base/src/hooks/use-mobile.ts +19 -0
  96. package/template/base/src/lib/utils.ts +6 -0
  97. package/template/base/src/routes/__root.tsx +1 -1
  98. package/template/base/src/server/auth.ts +2 -2
  99. package/template/base/src/styles/globals.css +230 -0
  100. package/template/base/vite.config.ts +15 -1
@@ -0,0 +1,52 @@
1
+ import { Slider as SliderPrimitive } from '@base-ui/react/slider';
2
+
3
+ import { cn } from '@saena-io/ui/lib/utils';
4
+
5
+ function Slider({
6
+ className,
7
+ defaultValue,
8
+ value,
9
+ min = 0,
10
+ max = 100,
11
+ ...props
12
+ }: SliderPrimitive.Root.Props) {
13
+ const _values = Array.isArray(value)
14
+ ? value
15
+ : Array.isArray(defaultValue)
16
+ ? defaultValue
17
+ : [min, max];
18
+
19
+ return (
20
+ <SliderPrimitive.Root
21
+ className={cn('data-horizontal:w-full data-vertical:h-full', className)}
22
+ data-slot="slider"
23
+ defaultValue={defaultValue}
24
+ value={value}
25
+ min={min}
26
+ max={max}
27
+ thumbAlignment="edge"
28
+ {...props}
29
+ >
30
+ <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">
31
+ <SliderPrimitive.Track
32
+ data-slot="slider-track"
33
+ className="relative grow overflow-hidden rounded-md bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
34
+ >
35
+ <SliderPrimitive.Indicator
36
+ data-slot="slider-range"
37
+ className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
38
+ />
39
+ </SliderPrimitive.Track>
40
+ {Array.from({ length: _values.length }, (_, index) => (
41
+ <SliderPrimitive.Thumb
42
+ data-slot="slider-thumb"
43
+ key={index}
44
+ className="relative block size-3 shrink-0 rounded-md border border-ring bg-white ring-ring/30 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-2 focus-visible:ring-2 focus-visible:outline-hidden active:ring-2 disabled:pointer-events-none disabled:opacity-50"
45
+ />
46
+ ))}
47
+ </SliderPrimitive.Control>
48
+ </SliderPrimitive.Root>
49
+ );
50
+ }
51
+
52
+ export { Slider };
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+
3
+ import {
4
+ Alert02Icon,
5
+ CheckmarkCircle02Icon,
6
+ InformationCircleIcon,
7
+ Loading03Icon,
8
+ MultiplicationSignCircleIcon,
9
+ } from '@hugeicons/core-free-icons';
10
+ import { HugeiconsIcon } from '@hugeicons/react';
11
+ import { useTheme } from 'next-themes';
12
+ import { Toaster as Sonner, type ToasterProps } from 'sonner';
13
+
14
+ const Toaster = ({ ...props }: ToasterProps) => {
15
+ const { theme = 'system' } = useTheme();
16
+
17
+ return (
18
+ <Sonner
19
+ theme={theme as ToasterProps['theme']}
20
+ className="toaster group"
21
+ icons={{
22
+ success: <HugeiconsIcon icon={CheckmarkCircle02Icon} strokeWidth={2} className="size-4" />,
23
+ info: <HugeiconsIcon icon={InformationCircleIcon} strokeWidth={2} className="size-4" />,
24
+ warning: <HugeiconsIcon icon={Alert02Icon} strokeWidth={2} className="size-4" />,
25
+ error: (
26
+ <HugeiconsIcon icon={MultiplicationSignCircleIcon} strokeWidth={2} className="size-4" />
27
+ ),
28
+ loading: (
29
+ <HugeiconsIcon icon={Loading03Icon} strokeWidth={2} className="size-4 animate-spin" />
30
+ ),
31
+ }}
32
+ style={
33
+ {
34
+ '--normal-bg': 'var(--popover)',
35
+ '--normal-text': 'var(--popover-foreground)',
36
+ '--normal-border': 'var(--border)',
37
+ '--border-radius': 'var(--radius)',
38
+ } as React.CSSProperties
39
+ }
40
+ toastOptions={{
41
+ classNames: {
42
+ toast: 'cn-toast',
43
+ },
44
+ }}
45
+ {...props}
46
+ />
47
+ );
48
+ };
49
+
50
+ export { Toaster };
@@ -0,0 +1,18 @@
1
+ import { Loading03Icon } from '@hugeicons/core-free-icons';
2
+ import { HugeiconsIcon } from '@hugeicons/react';
3
+ import { cn } from '@saena-io/ui/lib/utils';
4
+
5
+ function Spinner({ className, strokeWidth = 2, ...props }: React.ComponentProps<'svg'>) {
6
+ return (
7
+ <HugeiconsIcon
8
+ icon={Loading03Icon}
9
+ strokeWidth={Number(strokeWidth)}
10
+ role="status"
11
+ aria-label="Loading"
12
+ className={cn('size-4 animate-spin', className)}
13
+ {...props}
14
+ />
15
+ );
16
+ }
17
+
18
+ export { Spinner };
@@ -0,0 +1,30 @@
1
+ import { Switch as SwitchPrimitive } from '@base-ui/react/switch';
2
+
3
+ import { cn } from '@saena-io/ui/lib/utils';
4
+
5
+ function Switch({
6
+ className,
7
+ size = 'default',
8
+ ...props
9
+ }: SwitchPrimitive.Root.Props & {
10
+ size?: 'sm' | 'default';
11
+ }) {
12
+ return (
13
+ <SwitchPrimitive.Root
14
+ data-slot="switch"
15
+ data-size={size}
16
+ className={cn(
17
+ '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-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=default]:h-[16.6px] data-[size=default]:w-[28px] 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',
18
+ className,
19
+ )}
20
+ {...props}
21
+ >
22
+ <SwitchPrimitive.Thumb
23
+ data-slot="switch-thumb"
24
+ className="pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3.5 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"
25
+ />
26
+ </SwitchPrimitive.Root>
27
+ );
28
+ }
29
+
30
+ export { Switch };
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+
3
+ import type * as React from 'react';
4
+
5
+ import { cn } from '@saena-io/ui/lib/utils';
6
+
7
+ function Table({ className, ...props }: React.ComponentProps<'table'>) {
8
+ return (
9
+ <div data-slot="table-container" className="relative w-full overflow-x-auto">
10
+ <table
11
+ data-slot="table"
12
+ className={cn('w-full caption-bottom text-xs', className)}
13
+ {...props}
14
+ />
15
+ </div>
16
+ );
17
+ }
18
+
19
+ function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
20
+ return <thead data-slot="table-header" className={cn('[&_tr]:border-b', className)} {...props} />;
21
+ }
22
+
23
+ function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
24
+ return (
25
+ <tbody
26
+ data-slot="table-body"
27
+ className={cn('[&_tr:last-child]:border-0', className)}
28
+ {...props}
29
+ />
30
+ );
31
+ }
32
+
33
+ function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
34
+ return (
35
+ <tfoot
36
+ data-slot="table-footer"
37
+ className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}
38
+ {...props}
39
+ />
40
+ );
41
+ }
42
+
43
+ function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
44
+ return (
45
+ <tr
46
+ data-slot="table-row"
47
+ className={cn(
48
+ 'border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted',
49
+ className,
50
+ )}
51
+ {...props}
52
+ />
53
+ );
54
+ }
55
+
56
+ function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
57
+ return (
58
+ <th
59
+ data-slot="table-head"
60
+ className={cn(
61
+ 'h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0',
62
+ className,
63
+ )}
64
+ {...props}
65
+ />
66
+ );
67
+ }
68
+
69
+ function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
70
+ return (
71
+ <td
72
+ data-slot="table-cell"
73
+ className={cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0', className)}
74
+ {...props}
75
+ />
76
+ );
77
+ }
78
+
79
+ function TableCaption({ className, ...props }: React.ComponentProps<'caption'>) {
80
+ return (
81
+ <caption
82
+ data-slot="table-caption"
83
+ className={cn('mt-4 text-xs text-muted-foreground', className)}
84
+ {...props}
85
+ />
86
+ );
87
+ }
88
+
89
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
@@ -0,0 +1,73 @@
1
+ import { Tabs as TabsPrimitive } from '@base-ui/react/tabs';
2
+ import { type VariantProps, cva } from 'class-variance-authority';
3
+
4
+ import { cn } from '@saena-io/ui/lib/utils';
5
+
6
+ function Tabs({ className, orientation = 'horizontal', ...props }: TabsPrimitive.Root.Props) {
7
+ return (
8
+ <TabsPrimitive.Root
9
+ data-slot="tabs"
10
+ data-orientation={orientation}
11
+ className={cn('group/tabs flex gap-2 data-horizontal:flex-col', className)}
12
+ {...props}
13
+ />
14
+ );
15
+ }
16
+
17
+ const tabsListVariants = cva(
18
+ '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',
19
+ {
20
+ variants: {
21
+ variant: {
22
+ default: 'bg-muted',
23
+ line: 'gap-1 bg-transparent',
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ variant: 'default',
28
+ },
29
+ },
30
+ );
31
+
32
+ function TabsList({
33
+ className,
34
+ variant = 'default',
35
+ ...props
36
+ }: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
37
+ return (
38
+ <TabsPrimitive.List
39
+ data-slot="tabs-list"
40
+ data-variant={variant}
41
+ className={cn(tabsListVariants({ variant }), className)}
42
+ {...props}
43
+ />
44
+ );
45
+ }
46
+
47
+ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
48
+ return (
49
+ <TabsPrimitive.Tab
50
+ data-slot="tabs-trigger"
51
+ className={cn(
52
+ "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-xs font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:py-[calc(--spacing(1.25))] 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 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
53
+ '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',
54
+ 'data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground',
55
+ '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',
56
+ className,
57
+ )}
58
+ {...props}
59
+ />
60
+ );
61
+ }
62
+
63
+ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
64
+ return (
65
+ <TabsPrimitive.Panel
66
+ data-slot="tabs-content"
67
+ className={cn('flex-1 text-xs/relaxed outline-none', className)}
68
+ {...props}
69
+ />
70
+ );
71
+ }
72
+
73
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
@@ -0,0 +1,18 @@
1
+ import type * as React from 'react';
2
+
3
+ import { cn } from '@saena-io/ui/lib/utils';
4
+
5
+ function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
6
+ return (
7
+ <textarea
8
+ data-slot="textarea"
9
+ className={cn(
10
+ 'flex field-sizing-content min-h-16 w-full resize-none rounded-md border border-input bg-input/20 px-2 py-2 text-sm transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
11
+ className,
12
+ )}
13
+ {...props}
14
+ />
15
+ );
16
+ }
17
+
18
+ export { Textarea };
@@ -0,0 +1,85 @@
1
+ import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
2
+ import { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group';
3
+ import type { VariantProps } from 'class-variance-authority';
4
+ import * as React from 'react';
5
+
6
+ import { toggleVariants } from '@saena-io/ui/components/toggle';
7
+ import { cn } from '@saena-io/ui/lib/utils';
8
+
9
+ const ToggleGroupContext = React.createContext<
10
+ VariantProps<typeof toggleVariants> & {
11
+ spacing?: number;
12
+ orientation?: 'horizontal' | 'vertical';
13
+ }
14
+ >({
15
+ size: 'default',
16
+ variant: 'default',
17
+ spacing: 2,
18
+ orientation: 'horizontal',
19
+ });
20
+
21
+ function ToggleGroup({
22
+ className,
23
+ variant,
24
+ size,
25
+ spacing = 2,
26
+ orientation = 'horizontal',
27
+ children,
28
+ ...props
29
+ }: ToggleGroupPrimitive.Props &
30
+ VariantProps<typeof toggleVariants> & {
31
+ spacing?: number;
32
+ orientation?: 'horizontal' | 'vertical';
33
+ }) {
34
+ return (
35
+ <ToggleGroupPrimitive
36
+ data-slot="toggle-group"
37
+ data-variant={variant}
38
+ data-size={size}
39
+ data-spacing={spacing}
40
+ data-orientation={orientation}
41
+ style={{ '--gap': spacing } as React.CSSProperties}
42
+ className={cn(
43
+ 'group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-md data-[size=sm]:rounded-[min(var(--radius-md),8px)] data-vertical:flex-col data-vertical:items-stretch',
44
+ className,
45
+ )}
46
+ {...props}
47
+ >
48
+ <ToggleGroupContext.Provider value={{ variant, size, spacing, orientation }}>
49
+ {children}
50
+ </ToggleGroupContext.Provider>
51
+ </ToggleGroupPrimitive>
52
+ );
53
+ }
54
+
55
+ function ToggleGroupItem({
56
+ className,
57
+ children,
58
+ variant = 'default',
59
+ size = 'default',
60
+ ...props
61
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
62
+ const context = React.useContext(ToggleGroupContext);
63
+
64
+ return (
65
+ <TogglePrimitive
66
+ data-slot="toggle-group-item"
67
+ data-variant={context.variant || variant}
68
+ data-size={context.size || size}
69
+ data-spacing={context.spacing}
70
+ className={cn(
71
+ '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-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md 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',
72
+ toggleVariants({
73
+ variant: context.variant || variant,
74
+ size: context.size || size,
75
+ }),
76
+ className,
77
+ )}
78
+ {...props}
79
+ >
80
+ {children}
81
+ </TogglePrimitive>
82
+ );
83
+ }
84
+
85
+ export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,45 @@
1
+ 'use client';
2
+
3
+ import { Toggle as TogglePrimitive } from '@base-ui/react/toggle';
4
+ import { type VariantProps, cva } from 'class-variance-authority';
5
+
6
+ import { cn } from '@saena-io/ui/lib/utils';
7
+
8
+ const toggleVariants = cva(
9
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs 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",
10
+ {
11
+ variants: {
12
+ variant: {
13
+ default: 'bg-transparent',
14
+ outline: 'border border-input bg-transparent hover:bg-muted',
15
+ },
16
+ size: {
17
+ default:
18
+ 'h-7 min-w-7 px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5',
19
+ sm: "h-6 min-w-6 rounded-[min(var(--radius-md),8px)] px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
20
+ lg: 'h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
21
+ },
22
+ },
23
+ defaultVariants: {
24
+ variant: 'default',
25
+ size: 'default',
26
+ },
27
+ },
28
+ );
29
+
30
+ function Toggle({
31
+ className,
32
+ variant = 'default',
33
+ size = 'default',
34
+ ...props
35
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
36
+ return (
37
+ <TogglePrimitive
38
+ data-slot="toggle"
39
+ className={cn(toggleVariants({ variant, size, className }))}
40
+ {...props}
41
+ />
42
+ );
43
+ }
44
+
45
+ export { Toggle, toggleVariants };