@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
@@ -1,28 +1,27 @@
1
- 'use client';
1
+ "use client"
2
2
 
3
3
  import * as React from "react"
4
4
  import { cva, type VariantProps } from "class-variance-authority"
5
- import { useRender } from '@base-ui/react/use-render'
6
5
  import { cn } from "@/lib/utils"
7
6
 
8
7
  const badgeVariants = cva(
9
- "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8
+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
10
9
  {
11
10
  variants: {
12
11
  variant: {
13
12
  default:
14
- "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
13
+ "border-transparent bg-primary text-primary-foreground",
15
14
  secondary:
16
- "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
15
+ "border-transparent bg-secondary text-secondary-foreground",
17
16
  destructive:
18
- "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
17
+ "border-transparent bg-destructive text-destructive-foreground",
19
18
  outline: "text-foreground",
20
- success:
21
- "border-transparent bg-green-500 text-white hover:bg-green-600",
19
+ success:
20
+ "border-transparent bg-green-500 text-white",
22
21
  warning:
23
- "border-transparent bg-yellow-500 text-yellow-900 hover:bg-yellow-600",
22
+ "border-transparent bg-yellow-500 text-yellow-900",
24
23
  info:
25
- "border-transparent bg-blue-500 text-white hover:bg-blue-600",
24
+ "border-transparent bg-blue-500 text-white",
26
25
  },
27
26
  size: {
28
27
  sm: "px-2 py-0.5 text-xs",
@@ -35,7 +34,7 @@ const badgeVariants = cva(
35
34
  md: "rounded-md",
36
35
  lg: "rounded-lg",
37
36
  none: "rounded-none",
38
- }
37
+ },
39
38
  },
40
39
  defaultVariants: {
41
40
  variant: "default",
@@ -45,123 +44,63 @@ const badgeVariants = cva(
45
44
  }
46
45
  )
47
46
 
48
- type BadgeElement = React.ComponentRef<"div">
49
-
50
47
  export interface BadgeProps
51
- extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>,
48
+ extends React.HTMLAttributes<HTMLDivElement>,
52
49
  VariantProps<typeof badgeVariants> {
53
- /**
54
- * The content of the badge
55
- */
56
- children?: React.ReactNode
57
- /**
58
- * Custom render prop for composition
59
- */
60
- render?: React.ReactElement
61
- /**
62
- * Whether the badge should be interactive (clickable)
63
- */
64
- interactive?: boolean
65
- /**
66
- * Icon to display before the content
67
- */
68
50
  icon?: React.ReactNode
69
- /**
70
- * Whether to show a close button
71
- */
72
51
  dismissible?: boolean
73
- /**
74
- * Callback when close button is clicked
75
- */
76
52
  onDismiss?: () => void
77
53
  }
78
54
 
79
- const Badge = React.forwardRef<BadgeElement, BadgeProps>(
80
- ({
81
- className,
82
- variant,
83
- size,
84
- rounded,
85
- children,
86
- render = <div />,
87
- interactive = false,
88
- icon,
89
- dismissible = false,
90
- onDismiss,
91
- onClick,
92
- ...props
93
- }, ref) => {
94
- // Handle keyboard interaction for dismissible badges
95
- const handleKeyDown = React.useCallback((event: React.KeyboardEvent) => {
96
- if (dismissible && onDismiss && (event.key === 'Delete' || event.key === 'Backspace')) {
97
- event.preventDefault()
98
- onDismiss()
99
- }
100
- }, [dismissible, onDismiss])
101
-
102
- // Handle click for interactive badges
103
- const handleClick = React.useCallback((event: React.MouseEvent<HTMLDivElement>) => {
104
- if (interactive && onClick) {
105
- onClick(event)
106
- }
107
- }, [interactive, onClick])
108
-
109
- // Compute classes once
110
- const badgeClasses = React.useMemo(() =>
111
- cn(
112
- badgeVariants({ variant, size, rounded }),
113
- {
114
- 'cursor-pointer hover:opacity-80': interactive,
115
- 'focus:ring-2 focus:ring-offset-2': interactive || dismissible,
116
- },
117
- className
118
- ),
119
- [variant, size, rounded, interactive, dismissible, className]
120
- )
121
-
122
- const content = (
123
- <>
124
- {icon && <span className="mr-1 shrink-0">{icon}</span>}
125
- {children}
126
- {dismissible && (
127
- <button
128
- type="button"
129
- onClick={onDismiss}
130
- className="ml-1 shrink-0 rounded-full p-0.5 hover:bg-black/10 focus:outline-none focus:ring-1 focus:ring-black/20"
131
- aria-label="Remove badge"
55
+ const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(
56
+ (
57
+ {
58
+ className,
59
+ variant,
60
+ size,
61
+ rounded,
62
+ children,
63
+ icon,
64
+ dismissible = false,
65
+ onDismiss,
66
+ ...props
67
+ },
68
+ ref
69
+ ) => (
70
+ <div
71
+ ref={ref}
72
+ className={cn(badgeVariants({ variant, size, rounded }), className)}
73
+ {...props}
74
+ >
75
+ {icon && <span className="mr-1 shrink-0">{icon}</span>}
76
+ {children}
77
+ {dismissible && (
78
+ <button
79
+ type="button"
80
+ onClick={onDismiss}
81
+ className="ml-1 shrink-0 rounded-full p-0.5 hover:bg-black/10 focus:outline-none focus:ring-1 focus:ring-black/20"
82
+ aria-label="Remove"
83
+ >
84
+ <svg
85
+ className="h-3 w-3"
86
+ fill="none"
87
+ stroke="currentColor"
88
+ viewBox="0 0 24 24"
89
+ aria-hidden="true"
132
90
  >
133
- <svg
134
- className="h-3 w-3"
135
- fill="none"
136
- stroke="currentColor"
137
- viewBox="0 0 24 24"
138
- aria-hidden="true"
139
- >
140
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
141
- </svg>
142
- </button>
143
- )}
144
- </>
145
- )
146
-
147
- return useRender({
148
- render: React.cloneElement(render, {
149
- ref,
150
- className: badgeClasses,
151
- onClick: handleClick,
152
- onKeyDown: handleKeyDown,
153
- tabIndex: interactive || dismissible ? 0 : undefined,
154
- role: interactive ? 'button' : dismissible ? 'button' : undefined,
155
- 'aria-label': interactive ? 'Interactive badge' : dismissible ? 'Dismissible badge' : undefined,
156
- ...props,
157
- }),
158
- props: {
159
- children: content,
160
- },
161
- })
162
- }
91
+ <path
92
+ strokeLinecap="round"
93
+ strokeLinejoin="round"
94
+ strokeWidth={2}
95
+ d="M6 18L18 6M6 6l12 12"
96
+ />
97
+ </svg>
98
+ </button>
99
+ )}
100
+ </div>
101
+ )
163
102
  )
164
103
 
165
104
  Badge.displayName = "Badge"
166
105
 
167
- export { Badge, badgeVariants }
106
+ export { Badge, badgeVariants }
@@ -35,7 +35,7 @@ const CardTitle = React.forwardRef<
35
35
  <h3
36
36
  ref={ref}
37
37
  className={cn(
38
- "text-2xl font-semibold leading-none tracking-tight",
38
+ "text-2xl font-medium leading-none tracking-tight",
39
39
  className
40
40
  )}
41
41
  {...props}
@@ -7,21 +7,23 @@ const Checkbox = React.forwardRef<
7
7
  React.ComponentRef<typeof BaseCheckbox.Root>,
8
8
  React.ComponentPropsWithoutRef<typeof BaseCheckbox.Root>
9
9
  >(({ className, ...props }, ref) => (
10
- <BaseCheckbox.Root
11
- ref={ref}
12
- className={cn(
13
- "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
14
- "data-[checked]:bg-primary data-[checked]:text-primary-foreground",
15
- className
16
- )}
17
- {...props}
18
- >
19
- <BaseCheckbox.Indicator
20
- className={cn("flex items-center justify-center text-current")}
10
+ <span className="relative inline-flex [&>input]:!absolute">
11
+ <BaseCheckbox.Root
12
+ ref={ref}
13
+ className={cn(
14
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
15
+ "data-[checked]:bg-primary data-[checked]:text-primary-foreground",
16
+ className
17
+ )}
18
+ {...props}
21
19
  >
22
- <Check className="h-4 w-4" />
23
- </BaseCheckbox.Indicator>
24
- </BaseCheckbox.Root>
20
+ <BaseCheckbox.Indicator
21
+ className={cn("flex items-center justify-center text-current")}
22
+ >
23
+ <Check className="h-4 w-4" />
24
+ </BaseCheckbox.Indicator>
25
+ </BaseCheckbox.Root>
26
+ </span>
25
27
  ));
26
28
  Checkbox.displayName = "Checkbox";
27
29
 
@@ -17,9 +17,9 @@ const ComboboxInput = React.forwardRef<
17
17
  <ComboboxPrimitive.Input
18
18
  ref={ref}
19
19
  className={cn(
20
- "flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm",
20
+ "flex h-10 w-full bg-transparent px-3 py-2 text-sm",
21
21
  "placeholder:text-muted-foreground",
22
- "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
22
+ "focus:outline-none",
23
23
  "disabled:cursor-not-allowed disabled:opacity-50",
24
24
  className
25
25
  )}
@@ -35,8 +35,8 @@ const ComboboxTrigger = React.forwardRef<
35
35
  <ComboboxPrimitive.Trigger
36
36
  ref={ref}
37
37
  className={cn(
38
- "inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-3",
39
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
38
+ "inline-flex h-10 items-center justify-center px-3",
39
+ "focus-visible:outline-none",
40
40
  "disabled:pointer-events-none disabled:opacity-50",
41
41
  className
42
42
  )}
@@ -80,7 +80,7 @@ const ComboboxContent = React.forwardRef<
80
80
  <ComboboxPrimitive.Popup
81
81
  ref={ref}
82
82
  className={cn(
83
- "relative z-50 min-w-48 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
83
+ "relative z-50 min-w-(--anchor-width) overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
84
84
  "origin-(--transform-origin) outline-none",
85
85
  "data-starting-style:animate-in data-starting-style:fade-in-0 data-starting-style:zoom-in-95",
86
86
  "data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95",