@dinachi/cli 0.1.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 (50) hide show
  1. package/README.md +131 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +643 -0
  4. package/package.json +56 -0
  5. package/templates/accordion/accordion.tsx +85 -0
  6. package/templates/accordion/index.ts +1 -0
  7. package/templates/alert-dialog/alert-dialog.tsx +162 -0
  8. package/templates/alert-dialog/index.ts +13 -0
  9. package/templates/avatar/avatar.tsx +64 -0
  10. package/templates/avatar/index.ts +1 -0
  11. package/templates/button/button.tsx +54 -0
  12. package/templates/button/index.ts +2 -0
  13. package/templates/checkbox/checkbox.tsx +29 -0
  14. package/templates/checkbox/index.ts +1 -0
  15. package/templates/checkbox-group/checkbox-group.tsx +19 -0
  16. package/templates/checkbox-group/index.ts +1 -0
  17. package/templates/collapsible/collapsible.tsx +65 -0
  18. package/templates/collapsible/index.ts +1 -0
  19. package/templates/context-menu/context-menu.tsx +278 -0
  20. package/templates/context-menu/index.ts +17 -0
  21. package/templates/dialog/dialog.tsx +158 -0
  22. package/templates/dialog/index.ts +1 -0
  23. package/templates/field/field.tsx +119 -0
  24. package/templates/field/index.ts +1 -0
  25. package/templates/form/form.tsx +71 -0
  26. package/templates/form/index.ts +1 -0
  27. package/templates/input/index.ts +2 -0
  28. package/templates/input/input.tsx +17 -0
  29. package/templates/menubar/index.ts +18 -0
  30. package/templates/menubar/menubar.tsx +303 -0
  31. package/templates/navigation-menu/index.ts +13 -0
  32. package/templates/navigation-menu/navigation-menu.tsx +205 -0
  33. package/templates/preview-card/index.ts +1 -0
  34. package/templates/preview-card/preview-card.tsx +142 -0
  35. package/templates/select/index.ts +1 -0
  36. package/templates/select/select.tsx +208 -0
  37. package/templates/slider/index.ts +9 -0
  38. package/templates/slider/slider.tsx +121 -0
  39. package/templates/tabs/index.ts +7 -0
  40. package/templates/tabs/tabs.tsx +89 -0
  41. package/templates/toast/index.ts +1 -0
  42. package/templates/toast/toast.tsx +276 -0
  43. package/templates/toggle/index.ts +1 -0
  44. package/templates/toggle/toggle.tsx +83 -0
  45. package/templates/toolbar/index.ts +1 -0
  46. package/templates/toolbar/toolbar.tsx +124 -0
  47. package/templates/tooltip/index.ts +1 -0
  48. package/templates/tooltip/tooltip.tsx +217 -0
  49. package/templates/utils/utils.ts +7 -0
  50. package/templates/utils/variants.ts +7 -0
@@ -0,0 +1,208 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Select as SelectPrimitive } from "@base-ui-components/react/select"
5
+ import { cn } from "@dinachi/core"
6
+ import { Check, ChevronDown } from "lucide-react"
7
+
8
+
9
+
10
+ // Re-export root components for better tree-shaking
11
+ const Select = SelectPrimitive.Root
12
+ const SelectGroup = SelectPrimitive.Group
13
+ const SelectValue = SelectPrimitive.Value
14
+
15
+ // Optimized SelectTrigger with better type safety and performance
16
+ const SelectTrigger = React.forwardRef<
17
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
18
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
19
+ readonly children?: React.ReactNode
20
+ }
21
+ >(({ className, children, ...props }, ref) => (
22
+ <SelectPrimitive.Trigger
23
+ ref={ref}
24
+ className={cn(
25
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
26
+ className
27
+ )}
28
+ {...props}
29
+ >
30
+ {children}
31
+ <SelectPrimitive.Icon>
32
+ <ChevronDown className="h-4 w-4 opacity-50" />
33
+ </SelectPrimitive.Icon>
34
+ </SelectPrimitive.Trigger>
35
+ ))
36
+ SelectTrigger.displayName = "SelectTrigger"
37
+
38
+ // Optimized SelectContent with better positioning and performance
39
+ const SelectContent = React.forwardRef<
40
+ React.ElementRef<typeof SelectPrimitive.Popup>,
41
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Popup> & {
42
+ readonly position?: "item-aligned" | "popper"
43
+ readonly sideOffset?: number
44
+ }
45
+ >(({ className, children, position = "popper", sideOffset = 4, ...props }, ref) => (
46
+ <SelectPrimitive.Portal>
47
+ <SelectPrimitive.Positioner
48
+ sideOffset={sideOffset}
49
+ alignItemWithTrigger={position === "item-aligned"}
50
+ >
51
+ <SelectPrimitive.Popup
52
+ ref={ref}
53
+ className={cn(
54
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
55
+ "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",
56
+ "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",
57
+ position === "popper" &&
58
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
59
+ className
60
+ )}
61
+ {...props}
62
+ >
63
+ <SelectScrollUpArrow />
64
+ <div className="overflow-y-auto p-1">
65
+ {children}
66
+ </div>
67
+ <SelectScrollDownArrow />
68
+ </SelectPrimitive.Popup>
69
+ </SelectPrimitive.Positioner>
70
+ </SelectPrimitive.Portal>
71
+ ))
72
+ SelectContent.displayName = "SelectContent"
73
+
74
+ // Add scroll arrows for better UX with large lists
75
+ const SelectScrollUpArrow = React.forwardRef<
76
+ React.ElementRef<typeof SelectPrimitive.ScrollUpArrow>,
77
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpArrow>
78
+ >(({ className, ...props }, ref) => (
79
+ <SelectPrimitive.ScrollUpArrow
80
+ ref={ref}
81
+ className={cn(
82
+ "flex cursor-default items-center justify-center py-1",
83
+ className
84
+ )}
85
+ {...props}
86
+ >
87
+ <ChevronDown className="h-4 w-4 rotate-180" />
88
+ </SelectPrimitive.ScrollUpArrow>
89
+ ))
90
+ SelectScrollUpArrow.displayName = "SelectScrollUpArrow"
91
+
92
+ const SelectScrollDownArrow = React.forwardRef<
93
+ React.ElementRef<typeof SelectPrimitive.ScrollDownArrow>,
94
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownArrow>
95
+ >(({ className, ...props }, ref) => (
96
+ <SelectPrimitive.ScrollDownArrow
97
+ ref={ref}
98
+ className={cn(
99
+ "flex cursor-default items-center justify-center py-1",
100
+ className
101
+ )}
102
+ {...props}
103
+ >
104
+ <ChevronDown className="h-4 w-4" />
105
+ </SelectPrimitive.ScrollDownArrow>
106
+ ))
107
+ SelectScrollDownArrow.displayName = "SelectScrollDownArrow"
108
+
109
+ // Optimized SelectLabel with better accessibility
110
+ const SelectLabel = React.forwardRef<
111
+ React.ElementRef<typeof SelectPrimitive.GroupLabel>,
112
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.GroupLabel>
113
+ >(({ className, ...props }, ref) => (
114
+ <SelectPrimitive.GroupLabel
115
+ ref={ref}
116
+ className={cn("py-1.5 pl-2 pr-2 text-sm font-semibold", className)}
117
+ {...props}
118
+ />
119
+ ))
120
+ SelectLabel.displayName = "SelectLabel"
121
+
122
+ // Optimized SelectItem with conditional indicator and better type safety
123
+ const SelectItem = React.forwardRef<
124
+ React.ElementRef<typeof SelectPrimitive.Item>,
125
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & {
126
+ readonly inset?: boolean
127
+ readonly showIndicator?: boolean
128
+ readonly indicatorIcon?: React.ReactNode
129
+ readonly indicatorPosition?: "left" | "right"
130
+ }
131
+ >(({
132
+ className,
133
+ children,
134
+ inset,
135
+ showIndicator = false,
136
+ indicatorIcon = <Check className="h-4 w-4" />,
137
+ indicatorPosition = "left",
138
+ ...props
139
+ }, ref) => {
140
+ const isLeftIndicator = indicatorPosition === "left"
141
+ const isRightIndicator = indicatorPosition === "right"
142
+
143
+ return (
144
+ <SelectPrimitive.Item
145
+ ref={ref}
146
+ className={cn(
147
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-2 text-sm outline-none",
148
+ "focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
149
+ // Dynamic padding based on indicator presence and position
150
+ showIndicator && isLeftIndicator && "pl-8",
151
+ showIndicator && isRightIndicator && "pr-8",
152
+ !showIndicator && "px-2",
153
+ inset && !showIndicator && "pl-8",
154
+ inset && showIndicator && isLeftIndicator && "pl-8",
155
+ !inset && !showIndicator && "pl-2",
156
+ className
157
+ )}
158
+ {...props}
159
+ >
160
+ {/* Left indicator */}
161
+ {showIndicator && isLeftIndicator && (
162
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
163
+ <SelectPrimitive.ItemIndicator>
164
+ {indicatorIcon}
165
+ </SelectPrimitive.ItemIndicator>
166
+ </span>
167
+ )}
168
+
169
+ <SelectPrimitive.ItemText className="flex-1">
170
+ {children}
171
+ </SelectPrimitive.ItemText>
172
+
173
+ {/* Right indicator */}
174
+ {showIndicator && isRightIndicator && (
175
+ <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
176
+ <SelectPrimitive.ItemIndicator>
177
+ {indicatorIcon}
178
+ </SelectPrimitive.ItemIndicator>
179
+ </span>
180
+ )}
181
+ </SelectPrimitive.Item>
182
+ )
183
+ })
184
+ SelectItem.displayName = "SelectItem"
185
+
186
+ // Optimized SelectSeparator
187
+ const SelectSeparator = React.forwardRef<
188
+ React.ElementRef<typeof SelectPrimitive.Separator>,
189
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
190
+ >(({ className, ...props }, ref) => (
191
+ <SelectPrimitive.Separator
192
+ ref={ref}
193
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
194
+ {...props}
195
+ />
196
+ ))
197
+ SelectSeparator.displayName = "SelectSeparator"
198
+
199
+ export {
200
+ Select,
201
+ SelectGroup,
202
+ SelectValue,
203
+ SelectTrigger,
204
+ SelectContent,
205
+ SelectLabel,
206
+ SelectItem,
207
+ SelectSeparator,
208
+ }
@@ -0,0 +1,9 @@
1
+ export {
2
+ Slider,
3
+ SliderValue,
4
+ SliderControl,
5
+ SliderTrack,
6
+ SliderRange,
7
+ SliderThumb,
8
+ SliderDirectionProvider,
9
+ } from './slider'
@@ -0,0 +1,121 @@
1
+ // @ts-nocheck
2
+ import * as React from "react";
3
+ import { Slider as BaseSlider } from "@base-ui-components/react/slider";
4
+ import { DirectionProvider } from "@base-ui-components/react/direction-provider";
5
+ import { cn } from "@/lib/utils"
6
+
7
+
8
+ const Slider = React.forwardRef<
9
+ React.ElementRef<typeof BaseSlider.Root>,
10
+ React.ComponentProps<typeof BaseSlider.Root>
11
+ >(({ className, ...props }, ref) => {
12
+ const internalRef = React.useRef<HTMLDivElement>(null);
13
+
14
+ React.useImperativeHandle(ref, () => internalRef.current!, []);
15
+
16
+ return (
17
+ <BaseSlider.Root
18
+ ref={internalRef}
19
+ className={cn("relative flex w-full touch-none select-none items-center", className)}
20
+ {...props}
21
+ />
22
+ );
23
+ });
24
+ Slider.displayName = "Slider";
25
+
26
+ const SliderValue = React.forwardRef<
27
+ React.ElementRef<typeof BaseSlider.Value>,
28
+ React.ComponentProps<typeof BaseSlider.Value>
29
+ >(({ className, ...props }, ref) => (
30
+ <BaseSlider.Value
31
+ ref={ref}
32
+ className={cn("text-sm font-medium", className)}
33
+ {...props}
34
+ />
35
+ ));
36
+ SliderValue.displayName = "SliderValue";
37
+
38
+ const SliderControl = React.forwardRef<
39
+ React.ElementRef<typeof BaseSlider.Control>,
40
+ React.ComponentProps<typeof BaseSlider.Control>
41
+ >(({ className, ...props }, ref) => (
42
+ <BaseSlider.Control
43
+ ref={ref}
44
+ className={cn("relative flex w-full touch-none select-none items-center", className)}
45
+ {...props}
46
+ />
47
+ ));
48
+ SliderControl.displayName = "SliderControl";
49
+
50
+ const SliderTrack = React.forwardRef<
51
+ React.ElementRef<typeof BaseSlider.Track>,
52
+ React.ComponentProps<typeof BaseSlider.Track>
53
+ >(({ className, ...props }, ref) => (
54
+ <BaseSlider.Track
55
+ ref={ref}
56
+ className={cn(
57
+ "relative h-2 w-full grow rounded-full bg-secondary shadow-[inset_0_0_0_1px] shadow-secondary-foreground/5",
58
+ className
59
+ )}
60
+ {...props}
61
+ />
62
+ ));
63
+ SliderTrack.displayName = "SliderTrack";
64
+
65
+ const SliderRange = React.forwardRef<
66
+ React.ElementRef<typeof BaseSlider.Indicator>,
67
+ React.ComponentProps<typeof BaseSlider.Indicator>
68
+ >(({ className, ...props }, ref) => (
69
+ <BaseSlider.Indicator
70
+ ref={ref}
71
+ className={cn("absolute h-full bg-primary rounded", className)}
72
+ {...props}
73
+ />
74
+ ));
75
+ SliderRange.displayName = "SliderRange";
76
+
77
+ const SliderThumb = React.forwardRef<
78
+ React.ElementRef<typeof BaseSlider.Thumb>,
79
+ React.ComponentProps<typeof BaseSlider.Thumb>
80
+ >(({ className, ...props }, ref) => (
81
+ <BaseSlider.Thumb
82
+ ref={ref}
83
+ className={cn(
84
+ "block h-5 w-5 z-10 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors",
85
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
86
+ "disabled:pointer-events-none disabled:opacity-50",
87
+ "data-[dragging]:scale-110",
88
+ className
89
+ )}
90
+ {...props}
91
+ />
92
+ ));
93
+ SliderThumb.displayName = "SliderThumb";
94
+
95
+ const SliderDirectionProvider: React.FC<React.ComponentProps<typeof DirectionProvider>> = ({
96
+ children,
97
+ ...props
98
+ }) => (
99
+ <DirectionProvider {...props}>
100
+ {children}
101
+ </DirectionProvider>
102
+ );
103
+ SliderDirectionProvider.displayName = "SliderDirectionProvider";
104
+
105
+ export type SliderProps = React.ComponentProps<typeof BaseSlider.Root>;
106
+ export type SliderValueProps = React.ComponentProps<typeof BaseSlider.Value>;
107
+ export type SliderControlProps = React.ComponentProps<typeof BaseSlider.Control>;
108
+ export type SliderTrackProps = React.ComponentProps<typeof BaseSlider.Track>;
109
+ export type SliderRangeProps = React.ComponentProps<typeof BaseSlider.Indicator>;
110
+ export type SliderThumbProps = React.ComponentProps<typeof BaseSlider.Thumb>;
111
+ export type SliderDirectionProviderProps = React.ComponentProps<typeof DirectionProvider>;
112
+
113
+ export {
114
+ Slider,
115
+ SliderValue,
116
+ SliderControl,
117
+ SliderTrack,
118
+ SliderRange,
119
+ SliderThumb,
120
+ SliderDirectionProvider,
121
+ };
@@ -0,0 +1,7 @@
1
+ export {
2
+ Tabs,
3
+ TabsList,
4
+ TabsTrigger,
5
+ TabsContent,
6
+ TabsIndicator,
7
+ } from './tabs'
@@ -0,0 +1,89 @@
1
+ // @ts-nocheck
2
+ import * as React from "react";
3
+ import { Tabs as BaseTabs } from "@base-ui-components/react/tabs";
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const Tabs = React.forwardRef<
7
+ React.ElementRef<typeof BaseTabs.Root>,
8
+ React.ComponentProps<typeof BaseTabs.Root>
9
+ >(({ className, ...props }, ref) => (
10
+ <BaseTabs.Root
11
+ ref={ref}
12
+ className={cn("w-full", className)}
13
+ {...props}
14
+ />
15
+ ));
16
+ Tabs.displayName = "Tabs";
17
+
18
+ const TabsList = React.forwardRef<
19
+ React.ElementRef<typeof BaseTabs.List>,
20
+ React.ComponentProps<typeof BaseTabs.List>
21
+ >(({ className, ...props }, ref) => (
22
+ <BaseTabs.List
23
+ ref={ref}
24
+ className={cn(
25
+ "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
26
+ className
27
+ )}
28
+ {...props}
29
+ />
30
+ ));
31
+ TabsList.displayName = "TabsList";
32
+
33
+ const TabsTrigger = React.forwardRef<
34
+ React.ElementRef<typeof BaseTabs.Tab>,
35
+ React.ComponentProps<typeof BaseTabs.Tab>
36
+ >(({ className, ...props }, ref) => (
37
+ <BaseTabs.Tab
38
+ ref={ref}
39
+ className={cn(
40
+ "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all",
41
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
42
+ "disabled:pointer-events-none disabled:opacity-50",
43
+ "data-[selected]:bg-background data-[selected]:text-foreground data-[selected]:shadow-sm",
44
+ "hover:text-foreground",
45
+ className
46
+ )}
47
+ {...props}
48
+ />
49
+ ));
50
+ TabsTrigger.displayName = "TabsTrigger";
51
+
52
+ const TabsContent = React.forwardRef<
53
+ React.ElementRef<typeof BaseTabs.Panel>,
54
+ React.ComponentProps<typeof BaseTabs.Panel>
55
+ >(({ className, ...props }, ref) => (
56
+ <BaseTabs.Panel
57
+ ref={ref}
58
+ className={cn(
59
+ "mt-2 ring-offset-background",
60
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
61
+ className
62
+ )}
63
+ {...props}
64
+ />
65
+ ));
66
+ TabsContent.displayName = "TabsContent";
67
+
68
+ const TabsIndicator = React.forwardRef<
69
+ React.ElementRef<typeof BaseTabs.Indicator>,
70
+ React.ComponentProps<typeof BaseTabs.Indicator>
71
+ >(({ className, ...props }, ref) => (
72
+ <BaseTabs.Indicator
73
+ ref={ref}
74
+ className={cn(
75
+ "absolute bottom-0 left-0 z-10 h-1 w-[var(--active-tab-width)] -translate-y-1/2 translate-x-[var(--active-tab-left)] rounded-sm bg-muted-foreground transition-all duration-200 ease-in-out",
76
+ className
77
+ )}
78
+ {...props}
79
+ />
80
+ ));
81
+ TabsIndicator.displayName = "TabsIndicator";
82
+
83
+ export {
84
+ Tabs,
85
+ TabsList,
86
+ TabsTrigger,
87
+ TabsContent,
88
+ TabsIndicator,
89
+ };
@@ -0,0 +1 @@
1
+ export * from "./toast"