@dinachi/cli 0.6.3 → 0.7.1

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 (36) hide show
  1. package/dist/index.js +133 -34
  2. package/package.json +2 -3
  3. package/templates/alert-dialog/alert-dialog.tsx +62 -47
  4. package/templates/autocomplete/autocomplete.tsx +7 -7
  5. package/templates/badge/badge.tsx +58 -119
  6. package/templates/card/card.tsx +1 -1
  7. package/templates/checkbox/checkbox.tsx +16 -14
  8. package/templates/combobox/combobox.tsx +5 -5
  9. package/templates/context-menu/context-menu.tsx +124 -186
  10. package/templates/context-menu/index.ts +3 -1
  11. package/templates/dialog/dialog.tsx +26 -27
  12. package/templates/drawer/drawer.tsx +23 -21
  13. package/templates/field/field.tsx +5 -15
  14. package/templates/form/form.tsx +9 -66
  15. package/templates/label/index.ts +1 -0
  16. package/templates/label/label.tsx +21 -0
  17. package/templates/menu/index.ts +2 -0
  18. package/templates/menu/menu.tsx +59 -61
  19. package/templates/menubar/menubar.tsx +44 -72
  20. package/templates/navigation-menu/navigation-menu.tsx +61 -18
  21. package/templates/popover/index.ts +4 -1
  22. package/templates/popover/popover.tsx +80 -30
  23. package/templates/preview-card/preview-card.tsx +19 -5
  24. package/templates/radio/index.ts +1 -1
  25. package/templates/radio/radio.tsx +30 -14
  26. package/templates/select/select.tsx +75 -73
  27. package/templates/skeleton/index.ts +1 -0
  28. package/templates/skeleton/skeleton.tsx +12 -0
  29. package/templates/slider/slider.tsx +9 -15
  30. package/templates/switch/switch.tsx +15 -11
  31. package/templates/tabs/tabs.tsx +2 -2
  32. package/templates/toast/toast.tsx +137 -74
  33. package/templates/toggle/toggle.tsx +0 -17
  34. package/templates/toggle-group/toggle-group.tsx +8 -3
  35. package/templates/toolbar/toolbar.tsx +5 -4
  36. package/templates/tooltip/tooltip.tsx +9 -54
@@ -2,7 +2,6 @@
2
2
 
3
3
  import * as React from "react"
4
4
  import { NavigationMenu as BaseNavigationMenu } from "@base-ui/react/navigation-menu"
5
- import { useRender } from "@base-ui/react/use-render"
6
5
  import { cn } from "@/lib/utils"
7
6
  import { ChevronDown } from "lucide-react"
8
7
 
@@ -44,7 +43,7 @@ const NavigationMenuItem = React.forwardRef<
44
43
  >(({ className, ...props }, ref) => (
45
44
  <BaseNavigationMenu.Item
46
45
  ref={ref}
47
- className={cn("", className)}
46
+ className={className}
48
47
  {...props}
49
48
  />
50
49
  ))
@@ -60,7 +59,7 @@ const NavigationMenuTrigger = React.forwardRef<
60
59
  "group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors",
61
60
  "hover:bg-accent hover:text-accent-foreground",
62
61
  "focus:bg-accent focus:text-accent-foreground focus:outline-none",
63
- "disabled:pointer-events-none disabled:opacity-50",
62
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
64
63
  "data-[popup-open]:bg-accent/50",
65
64
  className
66
65
  )}
@@ -110,17 +109,9 @@ const NavigationMenuLink = React.forwardRef<
110
109
  ))
111
110
  NavigationMenuLink.displayName = "NavigationMenuLink"
112
111
 
113
- const NavigationMenuPortal = React.forwardRef<
114
- React.ComponentRef<typeof BaseNavigationMenu.Portal>,
112
+ const NavigationMenuPortal: React.FC<
115
113
  React.ComponentProps<typeof BaseNavigationMenu.Portal>
116
- >(({ ...props }, ref) => {
117
- const element = useRender({
118
- render: <BaseNavigationMenu.Portal />,
119
- props,
120
- ref,
121
- });
122
- return element;
123
- });
114
+ > = (props) => <BaseNavigationMenu.Portal {...props} />
124
115
  NavigationMenuPortal.displayName = "NavigationMenuPortal"
125
116
 
126
117
  const NavigationMenuPositioner = React.forwardRef<
@@ -129,7 +120,7 @@ const NavigationMenuPositioner = React.forwardRef<
129
120
  >(({ className, ...props }, ref) => (
130
121
  <BaseNavigationMenu.Positioner
131
122
  ref={ref}
132
- className={cn("absolute left-0 top-full flex justify-center", className)}
123
+ className={cn("absolute left-0 top-full z-50 flex justify-center", className)}
133
124
  {...props}
134
125
  />
135
126
  ))
@@ -159,8 +150,6 @@ const NavigationMenuViewport = React.forwardRef<
159
150
  ref={ref}
160
151
  className={cn(
161
152
  "origin-top-center relative mt-1.5 h-auto w-auto overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg",
162
- "data-[state=open]:animate-in data-[state=open]:zoom-in-90 data-[state=open]:fade-in",
163
- "data-[state=closed]:animate-out data-[state=closed]:zoom-out-90 data-[state=closed]:fade-out",
164
153
  className
165
154
  )}
166
155
  style={{
@@ -171,6 +160,58 @@ const NavigationMenuViewport = React.forwardRef<
171
160
  ))
172
161
  NavigationMenuViewport.displayName = "NavigationMenuViewport"
173
162
 
163
+ const NavigationMenuArrow = React.forwardRef<
164
+ React.ComponentRef<typeof BaseNavigationMenu.Arrow>,
165
+ React.ComponentProps<typeof BaseNavigationMenu.Arrow>
166
+ >(({ className, children, ...props }, ref) => (
167
+ <BaseNavigationMenu.Arrow
168
+ ref={ref}
169
+ className={cn(
170
+ "data-[side=bottom]:top-[-8px]",
171
+ "data-[side=left]:right-[-13px] data-[side=left]:rotate-90",
172
+ "data-[side=right]:left-[-13px] data-[side=right]:-rotate-90",
173
+ "data-[side=top]:bottom-[-8px] data-[side=top]:rotate-180",
174
+ className
175
+ )}
176
+ {...props}
177
+ >
178
+ {children || (
179
+ <svg width="20" height="10" viewBox="0 0 20 10" fill="none">
180
+ <path
181
+ d="M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z"
182
+ className="fill-popover"
183
+ />
184
+ <path
185
+ d="M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z"
186
+ className="fill-border"
187
+ />
188
+ <path
189
+ d="M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z"
190
+ className="fill-border"
191
+ />
192
+ </svg>
193
+ )}
194
+ </BaseNavigationMenu.Arrow>
195
+ ))
196
+ NavigationMenuArrow.displayName = "NavigationMenuArrow"
197
+
198
+ const NavigationMenuBackdrop = React.forwardRef<
199
+ React.ComponentRef<typeof BaseNavigationMenu.Backdrop>,
200
+ React.ComponentProps<typeof BaseNavigationMenu.Backdrop>
201
+ >(({ className, ...props }, ref) => (
202
+ <BaseNavigationMenu.Backdrop
203
+ ref={ref}
204
+ className={cn(
205
+ "fixed inset-0 z-40 bg-black/40 pointer-events-none",
206
+ "data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",
207
+ "transition-opacity duration-150",
208
+ className
209
+ )}
210
+ {...props}
211
+ />
212
+ ))
213
+ NavigationMenuBackdrop.displayName = "NavigationMenuBackdrop"
214
+
174
215
  const NavigationMenuIndicator = React.forwardRef<
175
216
  React.ComponentRef<"div">,
176
217
  React.HTMLAttributes<HTMLDivElement>
@@ -178,7 +219,7 @@ const NavigationMenuIndicator = React.forwardRef<
178
219
  <div
179
220
  ref={ref}
180
221
  className={cn(
181
- "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=visible]:fade-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out",
222
+ "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden",
182
223
  className
183
224
  )}
184
225
  {...props}
@@ -200,4 +241,6 @@ export {
200
241
  NavigationMenuPositioner,
201
242
  NavigationMenuPopup,
202
243
  NavigationMenuViewport,
203
- }
244
+ NavigationMenuArrow,
245
+ NavigationMenuBackdrop,
246
+ }
@@ -2,11 +2,14 @@ export {
2
2
  Popover,
3
3
  PopoverTrigger,
4
4
  PopoverContent,
5
+ PopoverPositioner,
6
+ PopoverPopup,
5
7
  PopoverArrow,
8
+ PopoverViewport,
6
9
  PopoverTitle,
7
10
  PopoverDescription,
8
11
  PopoverClose,
9
12
  PopoverPortal,
10
13
  PopoverBackdrop,
14
+ createPopoverHandle,
11
15
  } from "./popover"
12
-
@@ -4,41 +4,80 @@ import * as React from "react"
4
4
  import { Popover as PopoverPrimitive } from "@base-ui/react/popover"
5
5
  import { cn } from "@/lib/utils"
6
6
 
7
- // Re-export root components for better tree-shaking
8
7
  const Popover = PopoverPrimitive.Root
9
8
  const PopoverTrigger = PopoverPrimitive.Trigger
10
9
  const PopoverPortal = PopoverPrimitive.Portal
11
10
  const PopoverClose = PopoverPrimitive.Close
11
+ const createPopoverHandle = PopoverPrimitive.createHandle
12
+
13
+ const PopoverPositioner = React.forwardRef<
14
+ React.ComponentRef<typeof PopoverPrimitive.Positioner>,
15
+ React.ComponentProps<typeof PopoverPrimitive.Positioner>
16
+ >(({ className, sideOffset = 8, ...props }, ref) => (
17
+ <PopoverPrimitive.Positioner
18
+ ref={ref}
19
+ sideOffset={sideOffset}
20
+ className={cn("z-50", className)}
21
+ {...props}
22
+ />
23
+ ))
24
+ PopoverPositioner.displayName = "PopoverPositioner"
25
+
26
+ const PopoverPopup = React.forwardRef<
27
+ React.ComponentRef<typeof PopoverPrimitive.Popup>,
28
+ React.ComponentProps<typeof PopoverPrimitive.Popup>
29
+ >(({ className, ...props }, ref) => (
30
+ <PopoverPrimitive.Popup
31
+ ref={ref}
32
+ className={cn(
33
+ "rounded-lg border bg-popover px-6 py-4 text-popover-foreground shadow-lg outline-none",
34
+ "origin-(--transform-origin)",
35
+ "data-starting-style:scale-90 data-starting-style:opacity-0",
36
+ "data-ending-style:scale-90 data-ending-style:opacity-0",
37
+ "transition-[transform,opacity] duration-150",
38
+ className
39
+ )}
40
+ {...props}
41
+ />
42
+ ))
43
+ PopoverPopup.displayName = "PopoverPopup"
12
44
 
13
- // Optimized PopoverContent with better positioning and animations
14
45
  const PopoverContent = React.forwardRef<
15
46
  React.ComponentRef<typeof PopoverPrimitive.Popup>,
16
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Popup> & {
47
+ React.ComponentProps<typeof PopoverPrimitive.Popup> & {
48
+ readonly side?: React.ComponentProps<typeof PopoverPrimitive.Positioner>["side"]
49
+ readonly align?: React.ComponentProps<typeof PopoverPrimitive.Positioner>["align"]
17
50
  readonly sideOffset?: number
18
- readonly align?: "start" | "center" | "end"
19
- readonly side?: "top" | "bottom" | "left" | "right"
51
+ readonly alignOffset?: number
52
+ readonly collisionBoundary?: React.ComponentProps<typeof PopoverPrimitive.Positioner>["collisionBoundary"]
53
+ readonly collisionPadding?: React.ComponentProps<typeof PopoverPrimitive.Positioner>["collisionPadding"]
54
+ readonly sticky?: boolean
20
55
  readonly portal?: boolean
21
56
  }
22
- >(({ className, align = "center", side = "bottom", sideOffset = 8, portal = true, ...props }, ref) => {
57
+ >(({
58
+ className,
59
+ side = "bottom",
60
+ align = "center",
61
+ sideOffset = 8,
62
+ alignOffset,
63
+ collisionBoundary,
64
+ collisionPadding,
65
+ sticky,
66
+ portal = true,
67
+ ...props
68
+ }, ref) => {
23
69
  const content = (
24
- <PopoverPrimitive.Positioner
25
- align={align}
70
+ <PopoverPositioner
26
71
  side={side}
72
+ align={align}
27
73
  sideOffset={sideOffset}
74
+ alignOffset={alignOffset}
75
+ collisionBoundary={collisionBoundary}
76
+ collisionPadding={collisionPadding}
77
+ sticky={sticky}
28
78
  >
29
- <PopoverPrimitive.Popup
30
- ref={ref}
31
- className={cn(
32
- "z-50 rounded-lg border bg-popover px-6 py-4 text-popover-foreground shadow-lg outline-none",
33
- "origin-(--transform-origin)",
34
- "data-starting-style:scale-90 data-starting-style:opacity-0",
35
- "data-ending-style:scale-90 data-ending-style:opacity-0",
36
- "transition-[transform,opacity] duration-150",
37
- className
38
- )}
39
- {...props}
40
- />
41
- </PopoverPrimitive.Positioner>
79
+ <PopoverPopup ref={ref} className={className} {...props} />
80
+ </PopoverPositioner>
42
81
  )
43
82
 
44
83
  if (!portal) return content
@@ -47,10 +86,9 @@ const PopoverContent = React.forwardRef<
47
86
  })
48
87
  PopoverContent.displayName = "PopoverContent"
49
88
 
50
- // Optimized PopoverArrow
51
89
  const PopoverArrow = React.forwardRef<
52
90
  React.ComponentRef<typeof PopoverPrimitive.Arrow>,
53
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Arrow>
91
+ React.ComponentProps<typeof PopoverPrimitive.Arrow>
54
92
  >(({ className, children, ...props }, ref) => (
55
93
  <PopoverPrimitive.Arrow
56
94
  ref={ref}
@@ -83,10 +121,21 @@ const PopoverArrow = React.forwardRef<
83
121
  ))
84
122
  PopoverArrow.displayName = "PopoverArrow"
85
123
 
86
- // Optimized PopoverTitle
124
+ const PopoverViewport = React.forwardRef<
125
+ React.ComponentRef<typeof PopoverPrimitive.Viewport>,
126
+ React.ComponentProps<typeof PopoverPrimitive.Viewport>
127
+ >(({ className, ...props }, ref) => (
128
+ <PopoverPrimitive.Viewport
129
+ ref={ref}
130
+ className={cn("flex flex-col gap-2", className)}
131
+ {...props}
132
+ />
133
+ ))
134
+ PopoverViewport.displayName = "PopoverViewport"
135
+
87
136
  const PopoverTitle = React.forwardRef<
88
137
  React.ComponentRef<typeof PopoverPrimitive.Title>,
89
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Title>
138
+ React.ComponentProps<typeof PopoverPrimitive.Title>
90
139
  >(({ className, ...props }, ref) => (
91
140
  <PopoverPrimitive.Title
92
141
  ref={ref}
@@ -96,10 +145,9 @@ const PopoverTitle = React.forwardRef<
96
145
  ))
97
146
  PopoverTitle.displayName = "PopoverTitle"
98
147
 
99
- // Optimized PopoverDescription
100
148
  const PopoverDescription = React.forwardRef<
101
149
  React.ComponentRef<typeof PopoverPrimitive.Description>,
102
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Description>
150
+ React.ComponentProps<typeof PopoverPrimitive.Description>
103
151
  >(({ className, ...props }, ref) => (
104
152
  <PopoverPrimitive.Description
105
153
  ref={ref}
@@ -109,10 +157,9 @@ const PopoverDescription = React.forwardRef<
109
157
  ))
110
158
  PopoverDescription.displayName = "PopoverDescription"
111
159
 
112
- // Optimized PopoverBackdrop
113
160
  const PopoverBackdrop = React.forwardRef<
114
161
  React.ComponentRef<typeof PopoverPrimitive.Backdrop>,
115
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Backdrop>
162
+ React.ComponentProps<typeof PopoverPrimitive.Backdrop>
116
163
  >(({ className, ...props }, ref) => (
117
164
  <PopoverPrimitive.Backdrop
118
165
  ref={ref}
@@ -131,11 +178,14 @@ export {
131
178
  Popover,
132
179
  PopoverTrigger,
133
180
  PopoverContent,
181
+ PopoverPositioner,
182
+ PopoverPopup,
134
183
  PopoverArrow,
184
+ PopoverViewport,
135
185
  PopoverTitle,
136
186
  PopoverDescription,
137
187
  PopoverClose,
138
188
  PopoverPortal,
139
189
  PopoverBackdrop,
190
+ createPopoverHandle,
140
191
  }
141
-
@@ -64,10 +64,10 @@ const PreviewCardPopup = React.forwardRef<
64
64
  className={cn(
65
65
  "flex w-[280px] origin-[var(--transform-origin)] flex-col gap-3 rounded-lg bg-secondary/80 p-4 shadow-lg shadow-secondary/20",
66
66
  "outline outline-1 outline-border",
67
- "transition-[transform,scale,opacity] duration-200",
67
+ "transition-[scale,opacity] duration-200",
68
68
  "data-[ending-style]:scale-95 data-[ending-style]:opacity-0",
69
69
  "data-[starting-style]:scale-95 data-[starting-style]:opacity-0",
70
- "bg-secondary/80 backdrop-blur-sm dark:shadow-none dark:-outline-offset-1",
70
+ "backdrop-blur-sm dark:shadow-none dark:-outline-offset-1",
71
71
  className
72
72
  )}
73
73
  {...props}
@@ -77,9 +77,7 @@ PreviewCardPopup.displayName = "PreviewCardPopup"
77
77
 
78
78
  const PreviewCardArrow = React.forwardRef<
79
79
  React.ComponentRef<typeof BasePreviewCard.Arrow>,
80
- React.ComponentProps<typeof BasePreviewCard.Arrow> & {
81
- children?: React.ReactNode
82
- }
80
+ React.ComponentProps<typeof BasePreviewCard.Arrow>
83
81
  >(({ className, children, ...props }, ref) => (
84
82
  <BasePreviewCard.Arrow
85
83
  ref={ref}
@@ -111,6 +109,20 @@ const PreviewCardContent = React.forwardRef<
111
109
  ))
112
110
  PreviewCardContent.displayName = "PreviewCardContent"
113
111
 
112
+ const PreviewCardViewport = React.forwardRef<
113
+ React.ComponentRef<typeof BasePreviewCard.Viewport>,
114
+ React.ComponentProps<typeof BasePreviewCard.Viewport>
115
+ >(({ className, ...props }, ref) => (
116
+ <BasePreviewCard.Viewport
117
+ ref={ref}
118
+ className={cn("flex flex-col gap-3", className)}
119
+ {...props}
120
+ />
121
+ ))
122
+ PreviewCardViewport.displayName = "PreviewCardViewport"
123
+
124
+ const createPreviewCardHandle = BasePreviewCard.createHandle
125
+
114
126
  function PreviewCardArrowSvg(props: React.ComponentProps<'svg'>) {
115
127
  return (
116
128
  <svg width="20" height="10" viewBox="0 0 20 10" fill="none" {...props}>
@@ -136,5 +148,7 @@ export {
136
148
  PreviewCardPopup,
137
149
  PreviewCardArrow,
138
150
  PreviewCardContent,
151
+ PreviewCardViewport,
139
152
  PreviewCardArrowSvg,
153
+ createPreviewCardHandle,
140
154
  }
@@ -1 +1 @@
1
- export { Radio, RadioGroup } from "./radio"
1
+ export { Radio, RadioGroup, RadioIndicator } from "./radio"
@@ -3,7 +3,6 @@
3
3
  import * as React from "react"
4
4
  import { Radio as RadioPrimitive } from "@base-ui/react/radio"
5
5
  import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group"
6
- import { Circle } from "lucide-react"
7
6
  import { cn } from "@/lib/utils"
8
7
 
9
8
  const RadioGroup = React.forwardRef<
@@ -14,25 +13,42 @@ const RadioGroup = React.forwardRef<
14
13
  ))
15
14
  RadioGroup.displayName = "RadioGroup"
16
15
 
17
- const Radio = React.forwardRef<
18
- React.ComponentRef<typeof RadioPrimitive.Root>,
19
- React.ComponentPropsWithoutRef<typeof RadioPrimitive.Root>
16
+ const RadioIndicator = React.forwardRef<
17
+ React.ComponentRef<typeof RadioPrimitive.Indicator>,
18
+ React.ComponentProps<typeof RadioPrimitive.Indicator>
20
19
  >(({ className, ...props }, ref) => (
21
- <RadioPrimitive.Root
20
+ <RadioPrimitive.Indicator
22
21
  ref={ref}
23
22
  className={cn(
24
- "flex items-center justify-center aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background",
25
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
26
- "disabled:cursor-not-allowed disabled:opacity-50",
23
+ "flex items-center justify-center",
24
+ "after:h-2.5 after:w-2.5 after:rounded-full after:bg-current",
27
25
  className
28
26
  )}
29
27
  {...props}
30
- >
31
- <RadioPrimitive.Indicator className="flex items-center justify-center">
32
- <Circle className="h-2.5 w-2.5 fill-current text-current" />
33
- </RadioPrimitive.Indicator>
34
- </RadioPrimitive.Root>
28
+ />
29
+ ))
30
+ RadioIndicator.displayName = "RadioIndicator"
31
+
32
+ const Radio = React.forwardRef<
33
+ React.ComponentRef<typeof RadioPrimitive.Root>,
34
+ React.ComponentPropsWithoutRef<typeof RadioPrimitive.Root>
35
+ >(({ className, ...props }, ref) => (
36
+ <span className="relative inline-flex [&>input]:!absolute">
37
+ <RadioPrimitive.Root
38
+ ref={ref}
39
+ className={cn(
40
+ "flex items-center justify-center aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background",
41
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
42
+ "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50",
43
+ "data-[checked]:border-primary data-[unchecked]:border-muted-foreground",
44
+ className
45
+ )}
46
+ {...props}
47
+ >
48
+ <RadioIndicator />
49
+ </RadioPrimitive.Root>
50
+ </span>
35
51
  ))
36
52
  Radio.displayName = "Radio"
37
53
 
38
- export { Radio, RadioGroup }
54
+ export { Radio, RadioGroup, RadioIndicator }
@@ -5,12 +5,11 @@ import { Select as SelectPrimitive } from "@base-ui/react/select"
5
5
  import { cn } from "@/lib/utils"
6
6
  import { Check, ChevronDown } from "lucide-react"
7
7
 
8
- // Re-export root components for better tree-shaking
8
+ // Direct re-exports
9
9
  const Select = SelectPrimitive.Root
10
10
  const SelectGroup = SelectPrimitive.Group
11
11
  const SelectValue = SelectPrimitive.Value
12
12
 
13
- // Optimized SelectTrigger with better type safety and performance
14
13
  const SelectTrigger = React.forwardRef<
15
14
  React.ComponentRef<typeof SelectPrimitive.Trigger>,
16
15
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
@@ -33,36 +32,35 @@ const SelectTrigger = React.forwardRef<
33
32
  ))
34
33
  SelectTrigger.displayName = "SelectTrigger"
35
34
 
36
- // Optimized SelectContent with better positioning and performance
37
35
  const SelectContent = React.forwardRef<
38
36
  React.ComponentRef<typeof SelectPrimitive.Popup>,
39
37
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.Popup> & {
40
- readonly position?: "item-aligned" | "popper"
38
+ readonly alignItemWithTrigger?: boolean
41
39
  readonly sideOffset?: number
42
40
  readonly portal?: boolean
43
41
  }
44
- >(({ className, children, position = "popper", sideOffset = 4, portal = true, ...props }, ref) => {
42
+ >(({ className, children, alignItemWithTrigger = false, sideOffset = 4, portal = true, ...props }, ref) => {
45
43
  const content = (
46
44
  <SelectPrimitive.Positioner
47
45
  sideOffset={sideOffset}
48
- alignItemWithTrigger={position === "item-aligned"}
46
+ alignItemWithTrigger={alignItemWithTrigger}
49
47
  >
50
48
  <SelectPrimitive.Popup
51
49
  ref={ref}
52
50
  className={cn(
53
- "relative z-50 max-h-96 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
54
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
51
+ "relative z-50 max-h-96 min-w-[var(--anchor-width)] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
52
+ "data-[open]:animate-in data-[closed]:animate-out data-[closed]:fade-out-0 data-[open]:fade-in-0 data-[closed]:zoom-out-95 data-[open]:zoom-in-95",
55
53
  "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",
56
- position === "popper" &&
54
+ !alignItemWithTrigger &&
57
55
  "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
58
56
  className
59
57
  )}
60
58
  {...props}
61
59
  >
62
60
  <SelectScrollUpArrow />
63
- <div className="overflow-y-auto p-1">
61
+ <SelectPrimitive.List className="overflow-y-auto p-1">
64
62
  {children}
65
- </div>
63
+ </SelectPrimitive.List>
66
64
  <SelectScrollDownArrow />
67
65
  </SelectPrimitive.Popup>
68
66
  </SelectPrimitive.Positioner>
@@ -74,7 +72,18 @@ const SelectContent = React.forwardRef<
74
72
  })
75
73
  SelectContent.displayName = "SelectContent"
76
74
 
77
- // Add scroll arrows for better UX with large lists
75
+ const SelectBackdrop = React.forwardRef<
76
+ React.ComponentRef<typeof SelectPrimitive.Backdrop>,
77
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Backdrop>
78
+ >(({ className, ...props }, ref) => (
79
+ <SelectPrimitive.Backdrop
80
+ ref={ref}
81
+ className={cn("fixed inset-0 z-40", className)}
82
+ {...props}
83
+ />
84
+ ))
85
+ SelectBackdrop.displayName = "SelectBackdrop"
86
+
78
87
  const SelectScrollUpArrow = React.forwardRef<
79
88
  React.ComponentRef<typeof SelectPrimitive.ScrollUpArrow>,
80
89
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpArrow>
@@ -109,84 +118,72 @@ const SelectScrollDownArrow = React.forwardRef<
109
118
  ))
110
119
  SelectScrollDownArrow.displayName = "SelectScrollDownArrow"
111
120
 
112
- // Optimized SelectLabel with better accessibility
113
121
  const SelectLabel = React.forwardRef<
114
122
  React.ComponentRef<typeof SelectPrimitive.GroupLabel>,
115
123
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.GroupLabel>
116
124
  >(({ className, ...props }, ref) => (
117
125
  <SelectPrimitive.GroupLabel
118
126
  ref={ref}
119
- className={cn("py-1.5 pl-2 pr-2 text-sm font-semibold", className)}
127
+ className={cn("py-1.5 pl-2 pr-2 text-sm font-medium", className)}
120
128
  {...props}
121
129
  />
122
130
  ))
123
131
  SelectLabel.displayName = "SelectLabel"
124
132
 
125
- // Optimized SelectItem with conditional indicator and better type safety
126
133
  const SelectItem = React.forwardRef<
127
134
  React.ComponentRef<typeof SelectPrimitive.Item>,
128
135
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & {
129
- readonly inset?: boolean
130
136
  readonly showIndicator?: boolean
131
- readonly indicatorIcon?: React.ReactNode
132
- readonly indicatorPosition?: "left" | "right"
133
137
  }
134
- >(({
135
- className,
136
- children,
137
- inset,
138
- showIndicator = false,
139
- indicatorIcon = <Check className="h-4 w-4" />,
140
- indicatorPosition = "left",
141
- ...props
142
- }, ref) => {
143
- const isLeftIndicator = indicatorPosition === "left"
144
- const isRightIndicator = indicatorPosition === "right"
145
-
146
- return (
147
- <SelectPrimitive.Item
148
- ref={ref}
149
- className={cn(
150
- "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-2 text-sm outline-none",
151
- "focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
152
- // Dynamic padding based on indicator presence and position
153
- showIndicator && isLeftIndicator && "pl-8",
154
- showIndicator && isRightIndicator && "pr-8",
155
- !showIndicator && "px-2",
156
- inset && !showIndicator && "pl-8",
157
- inset && showIndicator && isLeftIndicator && "pl-8",
158
- !inset && !showIndicator && "pl-2",
159
- className
160
- )}
161
- {...props}
162
- >
163
- {/* Left indicator */}
164
- {showIndicator && isLeftIndicator && (
165
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
166
- <SelectPrimitive.ItemIndicator>
167
- {indicatorIcon}
168
- </SelectPrimitive.ItemIndicator>
169
- </span>
170
- )}
171
-
172
- <SelectPrimitive.ItemText className="flex-1">
173
- {children}
174
- </SelectPrimitive.ItemText>
175
-
176
- {/* Right indicator */}
177
- {showIndicator && isRightIndicator && (
178
- <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
179
- <SelectPrimitive.ItemIndicator>
180
- {indicatorIcon}
181
- </SelectPrimitive.ItemIndicator>
182
- </span>
183
- )}
184
- </SelectPrimitive.Item>
185
- )
186
- })
138
+ >(({ className, children, showIndicator = false, ...props }, ref) => (
139
+ <SelectPrimitive.Item
140
+ ref={ref}
141
+ className={cn(
142
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 text-sm outline-none",
143
+ "data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
144
+ showIndicator ? "pl-8 pr-2" : "px-2",
145
+ className
146
+ )}
147
+ {...props}
148
+ >
149
+ {showIndicator && (
150
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
151
+ <SelectPrimitive.ItemIndicator>
152
+ <Check className="h-4 w-4" />
153
+ </SelectPrimitive.ItemIndicator>
154
+ </span>
155
+ )}
156
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
157
+ </SelectPrimitive.Item>
158
+ ))
187
159
  SelectItem.displayName = "SelectItem"
188
160
 
189
- // Optimized SelectSeparator
161
+ const SelectItemIndicator = React.forwardRef<
162
+ React.ComponentRef<typeof SelectPrimitive.ItemIndicator>,
163
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ItemIndicator>
164
+ >(({ className, children, ...props }, ref) => (
165
+ <SelectPrimitive.ItemIndicator
166
+ ref={ref}
167
+ className={cn("flex h-3.5 w-3.5 items-center justify-center", className)}
168
+ {...props}
169
+ >
170
+ {children ?? <Check className="h-4 w-4" />}
171
+ </SelectPrimitive.ItemIndicator>
172
+ ))
173
+ SelectItemIndicator.displayName = "SelectItemIndicator"
174
+
175
+ const SelectArrow = React.forwardRef<
176
+ React.ComponentRef<typeof SelectPrimitive.Arrow>,
177
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Arrow>
178
+ >(({ className, ...props }, ref) => (
179
+ <SelectPrimitive.Arrow
180
+ ref={ref}
181
+ className={cn("fill-popover stroke-border", className)}
182
+ {...props}
183
+ />
184
+ ))
185
+ SelectArrow.displayName = "SelectArrow"
186
+
190
187
  const SelectSeparator = React.forwardRef<
191
188
  React.ComponentRef<typeof SelectPrimitive.Separator>,
192
189
  React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
@@ -205,7 +202,12 @@ export {
205
202
  SelectValue,
206
203
  SelectTrigger,
207
204
  SelectContent,
205
+ SelectBackdrop,
208
206
  SelectLabel,
209
207
  SelectItem,
208
+ SelectItemIndicator,
209
+ SelectArrow,
210
+ SelectScrollUpArrow,
211
+ SelectScrollDownArrow,
210
212
  SelectSeparator,
211
- }
213
+ }
@@ -0,0 +1 @@
1
+ export { Skeleton } from "./skeleton"