@dinachi/cli 0.6.2 → 0.7.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.
- package/LICENSE +21 -0
- package/dist/index.js +122 -33
- package/package.json +3 -4
- package/templates/alert-dialog/alert-dialog.tsx +60 -45
- package/templates/autocomplete/autocomplete.tsx +23 -17
- package/templates/badge/badge.tsx +58 -119
- package/templates/card/card.tsx +1 -1
- package/templates/checkbox/checkbox.tsx +16 -14
- package/templates/combobox/combobox.tsx +22 -16
- package/templates/context-menu/context-menu.tsx +124 -186
- package/templates/context-menu/index.ts +3 -1
- package/templates/dialog/dialog.tsx +26 -27
- package/templates/drawer/drawer.tsx +23 -21
- package/templates/field/field.tsx +5 -15
- package/templates/form/form.tsx +9 -66
- package/templates/label/index.ts +1 -0
- package/templates/label/label.tsx +21 -0
- package/templates/menu/index.ts +2 -0
- package/templates/menu/menu.tsx +59 -61
- package/templates/menubar/index.ts +1 -0
- package/templates/menubar/menubar.tsx +52 -71
- package/templates/navigation-menu/navigation-menu.tsx +61 -18
- package/templates/popover/index.ts +4 -1
- package/templates/popover/popover.tsx +89 -34
- package/templates/preview-card/preview-card.tsx +19 -5
- package/templates/radio/index.ts +1 -1
- package/templates/radio/radio.tsx +30 -14
- package/templates/select/select.tsx +83 -76
- package/templates/skeleton/index.ts +1 -0
- package/templates/skeleton/skeleton.tsx +12 -0
- package/templates/slider/slider.tsx +9 -15
- package/templates/switch/switch.tsx +15 -11
- package/templates/tabs/tabs.tsx +2 -2
- package/templates/toast/toast.tsx +76 -48
- package/templates/toggle/toggle.tsx +0 -17
- package/templates/toggle-group/toggle-group.tsx +8 -3
- package/templates/toolbar/toolbar.tsx +5 -4
- package/templates/tooltip/tooltip.tsx +9 -54
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
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-
|
|
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
|
|
13
|
+
"border-transparent bg-primary text-primary-foreground",
|
|
15
14
|
secondary:
|
|
16
|
-
"border-transparent bg-secondary text-secondary-foreground
|
|
15
|
+
"border-transparent bg-secondary text-secondary-foreground",
|
|
17
16
|
destructive:
|
|
18
|
-
"border-transparent bg-destructive text-destructive-foreground
|
|
17
|
+
"border-transparent bg-destructive text-destructive-foreground",
|
|
19
18
|
outline: "text-foreground",
|
|
20
|
-
success:
|
|
21
|
-
"border-transparent bg-green-500 text-white
|
|
19
|
+
success:
|
|
20
|
+
"border-transparent bg-green-500 text-white",
|
|
22
21
|
warning:
|
|
23
|
-
"border-transparent bg-yellow-500 text-yellow-900
|
|
22
|
+
"border-transparent bg-yellow-500 text-yellow-900",
|
|
24
23
|
info:
|
|
25
|
-
"border-transparent bg-blue-500 text-white
|
|
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
|
|
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<
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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 }
|
package/templates/card/card.tsx
CHANGED
|
@@ -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
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
20
|
+
"flex h-10 w-full bg-transparent px-3 py-2 text-sm",
|
|
21
21
|
"placeholder:text-muted-foreground",
|
|
22
|
-
"focus:outline-none
|
|
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
|
|
39
|
-
"focus-visible:outline-none
|
|
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
|
)}
|
|
@@ -71,24 +71,30 @@ ComboboxClear.displayName = "ComboboxClear"
|
|
|
71
71
|
|
|
72
72
|
const ComboboxContent = React.forwardRef<
|
|
73
73
|
React.ComponentRef<typeof ComboboxPrimitive.Popup>,
|
|
74
|
-
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Popup>
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Popup> & {
|
|
75
|
+
readonly portal?: boolean
|
|
76
|
+
}
|
|
77
|
+
>(({ className, portal = true, ...props }, ref) => {
|
|
78
|
+
const content = (
|
|
77
79
|
<ComboboxPrimitive.Positioner sideOffset={4}>
|
|
78
80
|
<ComboboxPrimitive.Popup
|
|
79
81
|
ref={ref}
|
|
80
82
|
className={cn(
|
|
81
|
-
"relative z-50 min-w-
|
|
82
|
-
"origin-
|
|
83
|
-
"data-
|
|
84
|
-
"data-
|
|
83
|
+
"relative z-50 min-w-(--anchor-width) overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
84
|
+
"origin-(--transform-origin) outline-none",
|
|
85
|
+
"data-starting-style:animate-in data-starting-style:fade-in-0 data-starting-style:zoom-in-95",
|
|
86
|
+
"data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95",
|
|
85
87
|
className
|
|
86
88
|
)}
|
|
87
89
|
{...props}
|
|
88
90
|
/>
|
|
89
91
|
</ComboboxPrimitive.Positioner>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if (!portal) return content
|
|
95
|
+
|
|
96
|
+
return <ComboboxPortal>{content}</ComboboxPortal>
|
|
97
|
+
})
|
|
92
98
|
ComboboxContent.displayName = "ComboboxContent"
|
|
93
99
|
|
|
94
100
|
const ComboboxList = React.forwardRef<
|
|
@@ -113,8 +119,8 @@ const ComboboxItem = React.forwardRef<
|
|
|
113
119
|
ref={ref}
|
|
114
120
|
className={cn(
|
|
115
121
|
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none",
|
|
116
|
-
"data-
|
|
117
|
-
"data-
|
|
122
|
+
"data-highlighted:bg-accent data-highlighted:text-accent-foreground",
|
|
123
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
118
124
|
inset && "pl-10",
|
|
119
125
|
className
|
|
120
126
|
)}
|
|
@@ -156,7 +162,7 @@ const ComboboxEmpty = React.forwardRef<
|
|
|
156
162
|
>(({ className, ...props }, ref) => (
|
|
157
163
|
<ComboboxPrimitive.Empty
|
|
158
164
|
ref={ref}
|
|
159
|
-
className={cn("
|
|
165
|
+
className={cn("p-2 text-center text-sm text-muted-foreground", className)}
|
|
160
166
|
{...props}
|
|
161
167
|
/>
|
|
162
168
|
))
|