@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,276 @@
1
+ // @ts-nocheck
2
+ import * as React from "react";
3
+ import { Toast as BaseToast } from "@base-ui-components/react/toast";
4
+ import { cn } from "@/lib/utils";
5
+ import { type VariantProps, cva } from "class-variance-authority";
6
+
7
+ // Toast Provider
8
+ const ToastProvider = BaseToast.Provider;
9
+
10
+ // Toast Viewport
11
+ const ToastViewport = React.forwardRef<
12
+ HTMLDivElement,
13
+ React.ComponentProps<typeof BaseToast.Viewport>
14
+ >(({ className, ...props }, ref) => (
15
+ <BaseToast.Viewport
16
+ ref={ref}
17
+ className={cn(
18
+ "fixed top-auto right-[1rem] bottom-[1rem] mx-auto flex w-[250px] sm:right-[2rem] sm:bottom-[2rem] sm:w-[300px]",
19
+ className
20
+ )}
21
+ {...props}
22
+ />
23
+ ));
24
+ ToastViewport.displayName = "ToastViewport";
25
+
26
+ // Toast Portal
27
+ const ToastPortal = BaseToast.Portal;
28
+
29
+ // Toast variants for different types
30
+ const toastVariants = cva(
31
+ [
32
+ "absolute right-0 bottom-0 left-auto z-[calc(1000-var(--toast-index))] mr-0 w-full",
33
+ "[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)+calc(min(var(--toast-index),10)*-15px)))_scale(calc(max(0,1-(var(--toast-index)*0.1))))]",
34
+ "rounded-lg border bg-background p-4 shadow-lg transition-all [transition-property:opacity,transform] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] select-none",
35
+ "after:absolute after:bottom-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
36
+ "data-[ending-style]:opacity-0",
37
+ "data-[expanded]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y)))]",
38
+ "data-[limited]:opacity-0",
39
+ "data-[starting-style]:[transform:translateY(150%)]",
40
+ "data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
41
+ "data-[expanded]:data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
42
+ "data-[ending-style]:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
43
+ "data-[expanded]:data-[ending-style]:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
44
+ "data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
45
+ "data-[expanded]:data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
46
+ "data-[ending-style]:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
47
+ "data-[expanded]:data-[ending-style]:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
48
+ "data-[ending-style]:[&:not([data-limited])]:[transform:translateY(150%)]",
49
+ ],
50
+ {
51
+ variants: {
52
+ variant: {
53
+ default: "border-border bg-background text-foreground",
54
+ destructive:
55
+ "border-destructive/50 bg-destructive text-destructive-foreground",
56
+ success: "border-success bg-success text-success-foreground",
57
+ warning: "border-warning bg-warning text-warning-foreground",
58
+ loading:
59
+ "border-primary/50 border-dashed bg-secondary text-secondary-foreground",
60
+ },
61
+ },
62
+ defaultVariants: {
63
+ variant: "default",
64
+ },
65
+ }
66
+ );
67
+
68
+ export interface ToastProps
69
+ extends React.ComponentPropsWithoutRef<typeof BaseToast.Root>,
70
+ VariantProps<typeof toastVariants> {}
71
+
72
+ // Toast Root
73
+ const ToastRoot = React.forwardRef<HTMLDivElement, ToastProps>(
74
+ ({ className, variant, ...props }, ref) => (
75
+ <BaseToast.Root
76
+ ref={ref}
77
+ className={cn(toastVariants({ variant }), className)}
78
+ style={{
79
+ ["--gap" as string]: "1rem",
80
+ ["--offset-y" as string]:
81
+ "calc(var(--toast-offset-y) * -1 + (var(--toast-index) * var(--gap) * -1) + var(--toast-swipe-movement-y))",
82
+ }}
83
+ {...props}
84
+ />
85
+ )
86
+ );
87
+ ToastRoot.displayName = "ToastRoot";
88
+
89
+ // Toast Title
90
+ const ToastTitle = React.forwardRef<
91
+ HTMLHeadingElement,
92
+ React.ComponentProps<typeof BaseToast.Title>
93
+ >(({ className, ...props }, ref) => (
94
+ <BaseToast.Title
95
+ ref={ref}
96
+ className={cn("text-[0.975rem] leading-5 font-medium", className)}
97
+ {...props}
98
+ />
99
+ ));
100
+ ToastTitle.displayName = "ToastTitle";
101
+
102
+ // Toast Description
103
+ const ToastDescription = React.forwardRef<
104
+ HTMLParagraphElement,
105
+ React.ComponentProps<typeof BaseToast.Description>
106
+ >(({ className, ...props }, ref) => (
107
+ <BaseToast.Description
108
+ ref={ref}
109
+ className={cn("text-[0.925rem] leading-5 opacity-90", className)}
110
+ {...props}
111
+ />
112
+ ));
113
+ ToastDescription.displayName = "ToastDescription";
114
+
115
+ // Toast Action
116
+ const ToastAction = React.forwardRef<
117
+ HTMLButtonElement,
118
+ React.ComponentProps<typeof BaseToast.Action>
119
+ >(({ className, ...props }, ref) => (
120
+ <BaseToast.Action
121
+ ref={ref}
122
+ className={cn(
123
+ "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors",
124
+ "hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring",
125
+ "disabled:pointer-events-none disabled:opacity-50",
126
+ "group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
127
+ className
128
+ )}
129
+ {...props}
130
+ />
131
+ ));
132
+ ToastAction.displayName = "ToastAction";
133
+
134
+ // Toast Close
135
+ const ToastClose = React.forwardRef<
136
+ HTMLButtonElement,
137
+ React.ComponentProps<typeof BaseToast.Close>
138
+ >(({ className, ...props }, ref) => (
139
+ <BaseToast.Close
140
+ ref={ref}
141
+ className={cn(
142
+ "absolute top-2 right-2 flex h-5 w-5 items-center justify-center rounded border-none bg-transparent opacity-60 transition-opacity",
143
+ "hover:opacity-100 focus:outline-none focus:ring-1 focus:ring-ring",
144
+ "disabled:pointer-events-none",
145
+ className
146
+ )}
147
+ {...props}
148
+ />
149
+ ));
150
+ ToastClose.displayName = "ToastClose";
151
+
152
+ // Hook for using toast manager
153
+ const useToastManager = BaseToast.useToastManager;
154
+
155
+ // Create toast manager for global usage
156
+ const createToastManager = BaseToast.createToastManager;
157
+
158
+ // Helper function to get variant from toast type
159
+ function getVariantFromType(
160
+ type?: string
161
+ ): VariantProps<typeof toastVariants>["variant"] {
162
+ switch (type) {
163
+ case "success":
164
+ return "success";
165
+ case "error":
166
+ return "destructive";
167
+ case "warning":
168
+ return "warning";
169
+ case "loading":
170
+ return "loading";
171
+ default:
172
+ return "default";
173
+ }
174
+ }
175
+
176
+ // Default ToastList component for easy usage
177
+ interface ToastListProps {
178
+ className?: string;
179
+ }
180
+
181
+ const ToastList = React.forwardRef<HTMLDivElement, ToastListProps>(
182
+ ({ className }, ref) => {
183
+ const { toasts } = useToastManager();
184
+
185
+ return (
186
+ <div ref={ref} className={className}>
187
+ {toasts.map((toast) => (
188
+ <ToastRoot
189
+ key={toast.id}
190
+ toast={toast}
191
+ variant={getVariantFromType(toast.type)}
192
+ swipeDirection={["down", "right"]}
193
+ >
194
+ <div className="grid gap-1">
195
+ {toast.title && <ToastTitle>{toast.title}</ToastTitle>}
196
+ {toast.description && (
197
+ <ToastDescription>{toast.description}</ToastDescription>
198
+ )}
199
+ </div>
200
+ {toast.actionProps && <ToastAction {...toast.actionProps} />}
201
+ <ToastClose aria-label="Close">
202
+ <X className="h-4 w-4" />
203
+ </ToastClose>
204
+ </ToastRoot>
205
+ ))}
206
+ </div>
207
+ );
208
+ }
209
+ );
210
+ ToastList.displayName = "ToastList";
211
+
212
+ // X Icon component
213
+ const X = React.forwardRef<SVGSVGElement, React.ComponentProps<"svg">>(
214
+ (props, ref) => (
215
+ <svg
216
+ ref={ref}
217
+ xmlns="http://www.w3.org/2000/svg"
218
+ width="24"
219
+ height="24"
220
+ viewBox="0 0 24 24"
221
+ fill="none"
222
+ stroke="currentColor"
223
+ strokeWidth="2"
224
+ strokeLinecap="round"
225
+ strokeLinejoin="round"
226
+ {...props}
227
+ >
228
+ <path d="M18 6 6 18" />
229
+ <path d="m6 6 12 12" />
230
+ </svg>
231
+ )
232
+ );
233
+ X.displayName = "X";
234
+
235
+ // Complete Toast component for easy setup
236
+ interface ToastComponentProps {
237
+ children?: React.ReactNode;
238
+ className?: string;
239
+ limit?: number;
240
+ timeout?: number;
241
+ toastManager?: ReturnType<typeof createToastManager>;
242
+ }
243
+
244
+ const Toast = React.forwardRef<HTMLDivElement, ToastComponentProps>(
245
+ (
246
+ { children, className, limit = 3, timeout = 5000, toastManager, ...props },
247
+ ref
248
+ ) => (
249
+ <ToastProvider limit={limit} timeout={timeout} toastManager={toastManager}>
250
+ {children}
251
+ <ToastPortal>
252
+ <ToastViewport ref={ref} className={className} {...props}>
253
+ <ToastList />
254
+ </ToastViewport>
255
+ </ToastPortal>
256
+ </ToastProvider>
257
+ )
258
+ );
259
+ Toast.displayName = "Toast";
260
+
261
+ export {
262
+ Toast,
263
+ ToastProvider,
264
+ ToastViewport,
265
+ ToastPortal,
266
+ ToastRoot,
267
+ ToastTitle,
268
+ ToastDescription,
269
+ ToastAction,
270
+ ToastClose,
271
+ ToastList,
272
+ useToastManager,
273
+ createToastManager,
274
+ toastVariants,
275
+ getVariantFromType,
276
+ };
@@ -0,0 +1 @@
1
+ export * from "./toggle"
@@ -0,0 +1,83 @@
1
+ // @ts-nocheck
2
+ "use client"
3
+
4
+ import * as React from "react"
5
+ import { Toggle as TogglePrimitive } from "@base-ui-components/react/toggle"
6
+ import { type VariantProps, cva } from "class-variance-authority"
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const toggleVariants = cva(
10
+ // Base styles with improved state handling
11
+ [
12
+ "inline-flex items-center justify-center rounded-md text-sm font-medium",
13
+ "ring-offset-background transition-all duration-200 ease-in-out",
14
+ // Focus styles
15
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
16
+ // Disabled styles
17
+ "disabled:pointer-events-none disabled:opacity-50",
18
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
19
+ // Pressed/Active state styles using Base UI data attributes
20
+ "data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
21
+ "data-[pressed]:bg-accent data-[pressed]:text-accent-foreground",
22
+ ],
23
+ {
24
+ variants: {
25
+ variant: {
26
+ default: [
27
+ "bg-transparent",
28
+ // Hover states
29
+ "hover:bg-muted hover:text-muted-foreground",
30
+ // Pressed hover states
31
+ "data-[state=on]:hover:bg-accent/90",
32
+ "data-[pressed]:hover:bg-accent/90",
33
+ // Disabled pressed state
34
+ "data-[state=on]:data-[disabled]:bg-accent/50",
35
+ "data-[pressed]:data-[disabled]:bg-accent/50",
36
+ ],
37
+ outline: [
38
+ "border border-input bg-transparent",
39
+ // Hover states
40
+ "hover:bg-accent hover:text-accent-foreground hover:border-accent",
41
+ // Pressed states for outline variant
42
+ "data-[state=on]:bg-accent data-[state=on]:text-accent-foreground data-[state=on]:border-accent",
43
+ "data-[pressed]:bg-accent data-[pressed]:text-accent-foreground data-[pressed]:border-accent",
44
+ // Pressed hover states
45
+ "data-[state=on]:hover:bg-accent/90",
46
+ "data-[pressed]:hover:bg-accent/90",
47
+ // Disabled states
48
+ "data-[disabled]:border-input/50",
49
+ "data-[state=on]:data-[disabled]:bg-accent/50 data-[state=on]:data-[disabled]:border-accent/50",
50
+ "data-[pressed]:data-[disabled]:bg-accent/50 data-[pressed]:data-[disabled]:border-accent/50",
51
+ ],
52
+ },
53
+ size: {
54
+ default: "h-10 px-3",
55
+ sm: "h-9 px-2.5 text-xs",
56
+ lg: "h-11 px-5",
57
+ },
58
+ },
59
+ defaultVariants: {
60
+ variant: "default",
61
+ size: "default",
62
+ },
63
+ }
64
+ )
65
+
66
+ export interface ToggleProps
67
+ extends React.ComponentPropsWithoutRef<typeof TogglePrimitive>,
68
+ VariantProps<typeof toggleVariants> {}
69
+
70
+ const Toggle = React.forwardRef<
71
+ React.ElementRef<typeof TogglePrimitive>,
72
+ ToggleProps
73
+ >(({ className, variant, size, ...props }, ref) => (
74
+ <TogglePrimitive
75
+ ref={ref}
76
+ className={cn(toggleVariants({ variant, size }), className)}
77
+ {...props}
78
+ />
79
+ ))
80
+
81
+ Toggle.displayName = "Toggle"
82
+
83
+ export { Toggle, toggleVariants }
@@ -0,0 +1 @@
1
+ export * from "./toolbar";
@@ -0,0 +1,124 @@
1
+ // @ts-nocheck
2
+ import * as React from "react";
3
+ import { Toolbar as BaseToolbar } from "@base-ui-components/react/toolbar";
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const ToolbarRoot = React.forwardRef<
7
+ React.ElementRef<typeof BaseToolbar.Root>,
8
+ React.ComponentProps<typeof BaseToolbar.Root>
9
+ >(({ className, ...props }, ref) => (
10
+ <BaseToolbar.Root
11
+ ref={ref}
12
+ className={cn(
13
+ "flex items-center gap-1 rounded-md border bg-background p-1",
14
+ className
15
+ )}
16
+ {...props}
17
+ />
18
+ ));
19
+ ToolbarRoot.displayName = "ToolbarRoot";
20
+
21
+ const ToolbarButton = React.forwardRef<
22
+ React.ElementRef<typeof BaseToolbar.Button>,
23
+ React.ComponentProps<typeof BaseToolbar.Button>
24
+ >(({ className, ...props }, ref) => (
25
+ <BaseToolbar.Button
26
+ ref={ref}
27
+ className={cn(
28
+ "inline-flex items-center justify-center rounded-sm px-3 py-2 text-sm font-medium transition-colors",
29
+ "hover:bg-accent hover:text-accent-foreground",
30
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
31
+ "disabled:pointer-events-none disabled:opacity-50",
32
+ "data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
33
+ className
34
+ )}
35
+ {...props}
36
+ />
37
+ ));
38
+ ToolbarButton.displayName = "ToolbarButton";
39
+
40
+ const ToolbarLink = React.forwardRef<
41
+ React.ElementRef<typeof BaseToolbar.Link>,
42
+ React.ComponentProps<typeof BaseToolbar.Link>
43
+ >(({ className, ...props }, ref) => (
44
+ <BaseToolbar.Link
45
+ ref={ref}
46
+ className={cn(
47
+ "inline-flex items-center justify-center rounded-sm px-3 py-2 text-sm font-medium transition-colors",
48
+ "text-primary hover:text-primary/80 hover:underline",
49
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
50
+ "data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
51
+ className
52
+ )}
53
+ {...props}
54
+ />
55
+ ));
56
+ ToolbarLink.displayName = "ToolbarLink";
57
+
58
+ const ToolbarSeparator = React.forwardRef<
59
+ React.ElementRef<typeof BaseToolbar.Separator>,
60
+ React.ComponentProps<typeof BaseToolbar.Separator>
61
+ >(({ className, orientation = "vertical", ...props }, ref) => (
62
+ <BaseToolbar.Separator
63
+ ref={ref}
64
+ orientation={orientation}
65
+ className={cn(
66
+ "shrink-0 bg-border",
67
+ orientation === "horizontal" ? "h-px w-full" : "h-4 w-px",
68
+ className
69
+ )}
70
+ {...props}
71
+ />
72
+ ));
73
+ ToolbarSeparator.displayName = "ToolbarSeparator";
74
+
75
+ const ToolbarGroup = React.forwardRef<
76
+ React.ElementRef<typeof BaseToolbar.Group>,
77
+ React.ComponentProps<typeof BaseToolbar.Group>
78
+ >(({ className, ...props }, ref) => (
79
+ <BaseToolbar.Group
80
+ ref={ref}
81
+ className={cn("flex items-center gap-1", className)}
82
+ {...props}
83
+ />
84
+ ));
85
+ ToolbarGroup.displayName = "ToolbarGroup";
86
+
87
+ const ToolbarInput = React.forwardRef<
88
+ React.ElementRef<typeof BaseToolbar.Input>,
89
+ React.ComponentProps<typeof BaseToolbar.Input>
90
+ >(({ className, ...props }, ref) => (
91
+ <BaseToolbar.Input
92
+ ref={ref}
93
+ className={cn(
94
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors",
95
+ "file:border-0 file:bg-transparent file:text-sm file:font-medium",
96
+ "placeholder:text-muted-foreground",
97
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
98
+ "disabled:cursor-not-allowed disabled:opacity-50",
99
+ "data-[highlighted]:ring-2 data-[highlighted]:ring-ring data-[highlighted]:ring-offset-2",
100
+ className
101
+ )}
102
+ {...props}
103
+ />
104
+ ));
105
+ ToolbarInput.displayName = "ToolbarInput";
106
+
107
+ const Toolbar = Object.assign(ToolbarRoot, {
108
+ Root: ToolbarRoot,
109
+ Button: ToolbarButton,
110
+ Link: ToolbarLink,
111
+ Separator: ToolbarSeparator,
112
+ Group: ToolbarGroup,
113
+ Input: ToolbarInput,
114
+ });
115
+
116
+ export {
117
+ Toolbar,
118
+ ToolbarRoot,
119
+ ToolbarButton,
120
+ ToolbarLink,
121
+ ToolbarSeparator,
122
+ ToolbarGroup,
123
+ ToolbarInput,
124
+ };
@@ -0,0 +1 @@
1
+ export * from "./tooltip"