@dinachi/cli 0.3.2 → 0.5.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/README.md +14 -0
- package/dist/index.js +392 -344
- package/package.json +5 -5
- package/templates/accordion/accordion.tsx +1 -1
- package/templates/alert-dialog/alert-dialog.tsx +1 -1
- package/templates/autocomplete/autocomplete.tsx +197 -0
- package/templates/autocomplete/index.ts +17 -0
- package/templates/avatar/avatar.tsx +4 -4
- package/templates/checkbox/checkbox.tsx +2 -2
- package/templates/checkbox-group/checkbox-group.tsx +2 -2
- package/templates/collapsible/collapsible.tsx +4 -4
- package/templates/combobox/combobox.tsx +202 -0
- package/templates/combobox/index.ts +17 -0
- package/templates/context-menu/context-menu.tsx +119 -54
- package/templates/dialog/dialog.tsx +1 -1
- package/templates/drawer/drawer.tsx +109 -0
- package/templates/drawer/index.ts +12 -0
- package/templates/field/field.tsx +1 -1
- package/templates/fieldset/fieldset.tsx +32 -0
- package/templates/fieldset/index.ts +1 -0
- package/templates/form/form.tsx +3 -3
- package/templates/input/input.tsx +23 -15
- package/templates/menu/index.ts +17 -0
- package/templates/menu/menu.tsx +282 -0
- package/templates/menubar/menubar.tsx +22 -22
- package/templates/meter/index.ts +1 -0
- package/templates/meter/meter.tsx +64 -0
- package/templates/navigation-menu/navigation-menu.tsx +13 -13
- package/templates/number-field/index.ts +9 -0
- package/templates/number-field/number-field.tsx +114 -0
- package/templates/popover/index.ts +12 -0
- package/templates/popover/popover.tsx +137 -0
- package/templates/preview-card/preview-card.tsx +10 -11
- package/templates/progress/index.ts +7 -0
- package/templates/progress/progress.tsx +64 -0
- package/templates/radio/index.ts +1 -0
- package/templates/radio/radio.tsx +39 -0
- package/templates/scroll-area/index.ts +8 -0
- package/templates/scroll-area/scroll-area.tsx +94 -0
- package/templates/select/select.tsx +8 -8
- package/templates/separator/index.ts +1 -0
- package/templates/separator/separator.tsx +25 -0
- package/templates/slider/slider.tsx +10 -10
- package/templates/switch/index.ts +1 -0
- package/templates/switch/switch.tsx +42 -0
- package/templates/tabs/tabs.tsx +6 -6
- package/templates/toast/toast.tsx +1 -1
- package/templates/toggle/toggle.tsx +2 -2
- package/templates/toggle-group/index.ts +1 -0
- package/templates/toggle-group/toggle-group.tsx +67 -0
- package/templates/toolbar/toolbar.tsx +7 -7
- package/templates/tooltip/tooltip.tsx +38 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinachi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "CLI for adding Dinachi UI components to your project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"templates"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"commander": "^
|
|
30
|
+
"commander": "^14.0.2",
|
|
31
31
|
"chalk": "^5.3.0",
|
|
32
|
-
"ora": "^
|
|
32
|
+
"ora": "^9.0.0",
|
|
33
33
|
"prompts": "^2.4.2",
|
|
34
34
|
"fs-extra": "^11.2.0",
|
|
35
35
|
"node-fetch": "^3.3.2",
|
|
36
|
-
"execa": "^
|
|
37
|
-
"ts-morph": "^
|
|
36
|
+
"execa": "^9.6.1",
|
|
37
|
+
"ts-morph": "^27.0.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Accordion as BaseAccordion } from "@base-ui
|
|
3
|
+
import { Accordion as BaseAccordion } from "@base-ui/react/accordion";
|
|
4
4
|
import { cn } from "@/lib/utils"
|
|
5
5
|
import { ChevronDown } from "lucide-react";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as React from "react"
|
|
3
|
-
import { AlertDialog as BaseAlertDialog } from "@base-ui
|
|
3
|
+
import { AlertDialog as BaseAlertDialog } from "@base-ui/react"
|
|
4
4
|
import { cn } from "@/lib/utils"
|
|
5
5
|
|
|
6
6
|
const AlertDialog = BaseAlertDialog.Root
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
"use client"
|
|
3
|
+
|
|
4
|
+
import * as React from "react"
|
|
5
|
+
import { Autocomplete as AutocompletePrimitive } from "@base-ui/react/autocomplete"
|
|
6
|
+
import { ChevronDown, X } from "lucide-react"
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
const Autocomplete = AutocompletePrimitive.Root
|
|
10
|
+
const AutocompleteValue = AutocompletePrimitive.Value
|
|
11
|
+
const AutocompleteCollection = AutocompletePrimitive.Collection
|
|
12
|
+
const AutocompletePortal = AutocompletePrimitive.Portal
|
|
13
|
+
|
|
14
|
+
const AutocompleteInput = React.forwardRef<
|
|
15
|
+
React.ComponentRef<typeof AutocompletePrimitive.Input>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Input>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<AutocompletePrimitive.Input
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(
|
|
21
|
+
"flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm",
|
|
22
|
+
"placeholder:text-muted-foreground",
|
|
23
|
+
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
24
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
AutocompleteInput.displayName = "AutocompleteInput"
|
|
31
|
+
|
|
32
|
+
const AutocompleteTrigger = React.forwardRef<
|
|
33
|
+
React.ComponentRef<typeof AutocompletePrimitive.Trigger>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Trigger>
|
|
35
|
+
>(({ className, children, ...props }, ref) => (
|
|
36
|
+
<AutocompletePrimitive.Trigger
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-3",
|
|
40
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
41
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children ?? (
|
|
47
|
+
<AutocompletePrimitive.Icon>
|
|
48
|
+
<ChevronDown className="h-4 w-4 text-muted-foreground" />
|
|
49
|
+
</AutocompletePrimitive.Icon>
|
|
50
|
+
)}
|
|
51
|
+
</AutocompletePrimitive.Trigger>
|
|
52
|
+
))
|
|
53
|
+
AutocompleteTrigger.displayName = "AutocompleteTrigger"
|
|
54
|
+
|
|
55
|
+
const AutocompleteClear = React.forwardRef<
|
|
56
|
+
React.ComponentRef<typeof AutocompletePrimitive.Clear>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Clear>
|
|
58
|
+
>(({ className, children, ...props }, ref) => (
|
|
59
|
+
<AutocompletePrimitive.Clear
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
"inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground",
|
|
63
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children ?? <X className="h-4 w-4" />}
|
|
69
|
+
</AutocompletePrimitive.Clear>
|
|
70
|
+
))
|
|
71
|
+
AutocompleteClear.displayName = "AutocompleteClear"
|
|
72
|
+
|
|
73
|
+
const AutocompleteContent = React.forwardRef<
|
|
74
|
+
React.ComponentRef<typeof AutocompletePrimitive.Popup>,
|
|
75
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Popup>
|
|
76
|
+
>(({ className, ...props }, ref) => (
|
|
77
|
+
<AutocompletePortal>
|
|
78
|
+
<AutocompletePrimitive.Positioner sideOffset={4}>
|
|
79
|
+
<AutocompletePrimitive.Popup
|
|
80
|
+
ref={ref}
|
|
81
|
+
className={cn(
|
|
82
|
+
"relative z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
83
|
+
"origin-[var(--transform-origin)] outline-none",
|
|
84
|
+
"data-[starting-style]:animate-in data-[starting-style]:fade-in-0 data-[starting-style]:zoom-in-95",
|
|
85
|
+
"data-[ending-style]:animate-out data-[ending-style]:fade-out-0 data-[ending-style]:zoom-out-95",
|
|
86
|
+
className
|
|
87
|
+
)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
</AutocompletePrimitive.Positioner>
|
|
91
|
+
</AutocompletePortal>
|
|
92
|
+
))
|
|
93
|
+
AutocompleteContent.displayName = "AutocompleteContent"
|
|
94
|
+
|
|
95
|
+
const AutocompleteList = React.forwardRef<
|
|
96
|
+
React.ComponentRef<typeof AutocompletePrimitive.List>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.List>
|
|
98
|
+
>(({ className, ...props }, ref) => (
|
|
99
|
+
<AutocompletePrimitive.List
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn("max-h-80 overflow-y-auto p-1", className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
))
|
|
105
|
+
AutocompleteList.displayName = "AutocompleteList"
|
|
106
|
+
|
|
107
|
+
const AutocompleteItem = React.forwardRef<
|
|
108
|
+
React.ComponentRef<typeof AutocompletePrimitive.Item>,
|
|
109
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Item> & {
|
|
110
|
+
inset?: boolean
|
|
111
|
+
}
|
|
112
|
+
>(({ className, children, inset, ...props }, ref) => (
|
|
113
|
+
<AutocompletePrimitive.Item
|
|
114
|
+
ref={ref}
|
|
115
|
+
className={cn(
|
|
116
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
117
|
+
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
|
|
118
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
119
|
+
inset && "pl-8",
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</AutocompletePrimitive.Item>
|
|
126
|
+
))
|
|
127
|
+
AutocompleteItem.displayName = "AutocompleteItem"
|
|
128
|
+
|
|
129
|
+
const AutocompleteGroup = React.forwardRef<
|
|
130
|
+
React.ComponentRef<typeof AutocompletePrimitive.Group>,
|
|
131
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Group>
|
|
132
|
+
>(({ className, ...props }, ref) => (
|
|
133
|
+
<AutocompletePrimitive.Group ref={ref} className={cn(className)} {...props} />
|
|
134
|
+
))
|
|
135
|
+
AutocompleteGroup.displayName = "AutocompleteGroup"
|
|
136
|
+
|
|
137
|
+
const AutocompleteGroupLabel = React.forwardRef<
|
|
138
|
+
React.ComponentRef<typeof AutocompletePrimitive.GroupLabel>,
|
|
139
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.GroupLabel>
|
|
140
|
+
>(({ className, ...props }, ref) => (
|
|
141
|
+
<AutocompletePrimitive.GroupLabel
|
|
142
|
+
ref={ref}
|
|
143
|
+
className={cn("px-2 py-1.5 text-xs font-medium text-muted-foreground", className)}
|
|
144
|
+
{...props}
|
|
145
|
+
/>
|
|
146
|
+
))
|
|
147
|
+
AutocompleteGroupLabel.displayName = "AutocompleteGroupLabel"
|
|
148
|
+
|
|
149
|
+
const AutocompleteEmpty = React.forwardRef<
|
|
150
|
+
React.ComponentRef<typeof AutocompletePrimitive.Empty>,
|
|
151
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Empty>
|
|
152
|
+
>(({ className, ...props }, ref) => (
|
|
153
|
+
<AutocompletePrimitive.Empty
|
|
154
|
+
ref={ref}
|
|
155
|
+
className={cn("px-2 py-6 text-center text-sm text-muted-foreground", className)}
|
|
156
|
+
{...props}
|
|
157
|
+
/>
|
|
158
|
+
))
|
|
159
|
+
AutocompleteEmpty.displayName = "AutocompleteEmpty"
|
|
160
|
+
|
|
161
|
+
const AutocompleteStatus = React.forwardRef<
|
|
162
|
+
React.ComponentRef<typeof AutocompletePrimitive.Status>,
|
|
163
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Status>
|
|
164
|
+
>(({ className, ...props }, ref) => (
|
|
165
|
+
<AutocompletePrimitive.Status ref={ref} className={cn("sr-only", className)} {...props} />
|
|
166
|
+
))
|
|
167
|
+
AutocompleteStatus.displayName = "AutocompleteStatus"
|
|
168
|
+
|
|
169
|
+
const AutocompleteSeparator = React.forwardRef<
|
|
170
|
+
React.ComponentRef<typeof AutocompletePrimitive.Separator>,
|
|
171
|
+
React.ComponentPropsWithoutRef<typeof AutocompletePrimitive.Separator>
|
|
172
|
+
>(({ className, ...props }, ref) => (
|
|
173
|
+
<AutocompletePrimitive.Separator
|
|
174
|
+
ref={ref}
|
|
175
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
176
|
+
{...props}
|
|
177
|
+
/>
|
|
178
|
+
))
|
|
179
|
+
AutocompleteSeparator.displayName = "AutocompleteSeparator"
|
|
180
|
+
|
|
181
|
+
export {
|
|
182
|
+
Autocomplete,
|
|
183
|
+
AutocompleteValue,
|
|
184
|
+
AutocompleteCollection,
|
|
185
|
+
AutocompletePortal,
|
|
186
|
+
AutocompleteInput,
|
|
187
|
+
AutocompleteTrigger,
|
|
188
|
+
AutocompleteClear,
|
|
189
|
+
AutocompleteContent,
|
|
190
|
+
AutocompleteList,
|
|
191
|
+
AutocompleteItem,
|
|
192
|
+
AutocompleteGroup,
|
|
193
|
+
AutocompleteGroupLabel,
|
|
194
|
+
AutocompleteEmpty,
|
|
195
|
+
AutocompleteStatus,
|
|
196
|
+
AutocompleteSeparator,
|
|
197
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Autocomplete,
|
|
3
|
+
AutocompleteValue,
|
|
4
|
+
AutocompleteCollection,
|
|
5
|
+
AutocompletePortal,
|
|
6
|
+
AutocompleteInput,
|
|
7
|
+
AutocompleteTrigger,
|
|
8
|
+
AutocompleteClear,
|
|
9
|
+
AutocompleteContent,
|
|
10
|
+
AutocompleteList,
|
|
11
|
+
AutocompleteItem,
|
|
12
|
+
AutocompleteGroup,
|
|
13
|
+
AutocompleteGroupLabel,
|
|
14
|
+
AutocompleteEmpty,
|
|
15
|
+
AutocompleteStatus,
|
|
16
|
+
AutocompleteSeparator,
|
|
17
|
+
} from "./autocomplete"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Avatar as BaseAvatar } from "@base-ui
|
|
3
|
+
import { Avatar as BaseAvatar } from "@base-ui/react";
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
5
|
import { cn } from "@/lib/utils"
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ const avatarVariants = cva(
|
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
const Avatar = React.forwardRef<
|
|
25
|
-
React.
|
|
25
|
+
React.ComponentRef<typeof BaseAvatar.Root>,
|
|
26
26
|
React.ComponentPropsWithoutRef<typeof BaseAvatar.Root> &
|
|
27
27
|
VariantProps<typeof avatarVariants>
|
|
28
28
|
>(({ className, size, ...props }, ref) => (
|
|
@@ -35,7 +35,7 @@ const Avatar = React.forwardRef<
|
|
|
35
35
|
Avatar.displayName = "Avatar";
|
|
36
36
|
|
|
37
37
|
const AvatarImage = React.forwardRef<
|
|
38
|
-
React.
|
|
38
|
+
React.ComponentRef<typeof BaseAvatar.Image>,
|
|
39
39
|
React.ComponentPropsWithoutRef<typeof BaseAvatar.Image>
|
|
40
40
|
>(({ className, ...props }, ref) => (
|
|
41
41
|
<BaseAvatar.Image
|
|
@@ -47,7 +47,7 @@ const AvatarImage = React.forwardRef<
|
|
|
47
47
|
AvatarImage.displayName = "AvatarImage";
|
|
48
48
|
|
|
49
49
|
const AvatarFallback = React.forwardRef<
|
|
50
|
-
React.
|
|
50
|
+
React.ComponentRef<typeof BaseAvatar.Fallback>,
|
|
51
51
|
React.ComponentPropsWithoutRef<typeof BaseAvatar.Fallback>
|
|
52
52
|
>(({ className, ...props }, ref) => (
|
|
53
53
|
<BaseAvatar.Fallback
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Checkbox as BaseCheckbox } from "@base-ui
|
|
3
|
+
import { Checkbox as BaseCheckbox } from "@base-ui/react";
|
|
4
4
|
import { cn } from "@/lib/utils"
|
|
5
5
|
import { Check } from "lucide-react";
|
|
6
6
|
|
|
7
7
|
const Checkbox = React.forwardRef<
|
|
8
|
-
React.
|
|
8
|
+
React.ComponentRef<typeof BaseCheckbox.Root>,
|
|
9
9
|
React.ComponentPropsWithoutRef<typeof BaseCheckbox.Root>
|
|
10
10
|
>(({ className, ...props }, ref) => (
|
|
11
11
|
<BaseCheckbox.Root
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { CheckboxGroup as BaseCheckboxGroup } from "@base-ui
|
|
3
|
+
import { CheckboxGroup as BaseCheckboxGroup } from "@base-ui/react/checkbox-group";
|
|
4
4
|
import { cn } from "@/lib/utils"
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const CheckboxGroup = React.forwardRef<
|
|
8
|
-
React.
|
|
8
|
+
React.ComponentRef<typeof BaseCheckboxGroup>,
|
|
9
9
|
React.ComponentPropsWithoutRef<typeof BaseCheckboxGroup>
|
|
10
10
|
>(({ className, ...props }, ref) => (
|
|
11
11
|
<BaseCheckboxGroup
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
"use client"
|
|
4
4
|
import * as React from "react"
|
|
5
|
-
import { Collapsible as BaseCollapsible } from "@base-ui
|
|
5
|
+
import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible"
|
|
6
6
|
import { cn } from "@/lib/utils"
|
|
7
7
|
|
|
8
8
|
const Collapsible = React.forwardRef<
|
|
9
|
-
React.
|
|
9
|
+
React.ComponentRef<typeof BaseCollapsible.Root>,
|
|
10
10
|
React.ComponentPropsWithoutRef<typeof BaseCollapsible.Root>
|
|
11
11
|
>(({ className, ...props }, ref) => (
|
|
12
12
|
<BaseCollapsible.Root ref={ref} className={cn("w-full", className)} {...props} />
|
|
@@ -14,7 +14,7 @@ const Collapsible = React.forwardRef<
|
|
|
14
14
|
Collapsible.displayName = "Collapsible"
|
|
15
15
|
|
|
16
16
|
const CollapsibleTrigger = React.forwardRef<
|
|
17
|
-
React.
|
|
17
|
+
React.ComponentRef<typeof BaseCollapsible.Trigger>,
|
|
18
18
|
React.ComponentPropsWithoutRef<typeof BaseCollapsible.Trigger>
|
|
19
19
|
>(({ className, ...props }, ref) => (
|
|
20
20
|
<BaseCollapsible.Trigger
|
|
@@ -33,7 +33,7 @@ const CollapsibleTrigger = React.forwardRef<
|
|
|
33
33
|
CollapsibleTrigger.displayName = "CollapsibleTrigger"
|
|
34
34
|
|
|
35
35
|
const CollapsiblePanel = React.forwardRef<
|
|
36
|
-
React.
|
|
36
|
+
React.ComponentRef<typeof BaseCollapsible.Panel>,
|
|
37
37
|
React.ComponentPropsWithoutRef<typeof BaseCollapsible.Panel>
|
|
38
38
|
>(({ className, ...props }, ref) => (
|
|
39
39
|
<BaseCollapsible.Panel
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
"use client"
|
|
3
|
+
|
|
4
|
+
import * as React from "react"
|
|
5
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox"
|
|
6
|
+
import { Check, ChevronDown, X } from "lucide-react"
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
const Combobox = ComboboxPrimitive.Root
|
|
10
|
+
const ComboboxValue = ComboboxPrimitive.Value
|
|
11
|
+
const ComboboxCollection = ComboboxPrimitive.Collection
|
|
12
|
+
const ComboboxPortal = ComboboxPrimitive.Portal
|
|
13
|
+
|
|
14
|
+
const ComboboxInput = React.forwardRef<
|
|
15
|
+
React.ComponentRef<typeof ComboboxPrimitive.Input>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Input>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<ComboboxPrimitive.Input
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(
|
|
21
|
+
"flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm",
|
|
22
|
+
"placeholder:text-muted-foreground",
|
|
23
|
+
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
24
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
))
|
|
30
|
+
ComboboxInput.displayName = "ComboboxInput"
|
|
31
|
+
|
|
32
|
+
const ComboboxTrigger = React.forwardRef<
|
|
33
|
+
React.ComponentRef<typeof ComboboxPrimitive.Trigger>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Trigger>
|
|
35
|
+
>(({ className, children, ...props }, ref) => (
|
|
36
|
+
<ComboboxPrimitive.Trigger
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-3",
|
|
40
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
41
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children ?? (
|
|
47
|
+
<ComboboxPrimitive.Icon>
|
|
48
|
+
<ChevronDown className="h-4 w-4 text-muted-foreground" />
|
|
49
|
+
</ComboboxPrimitive.Icon>
|
|
50
|
+
)}
|
|
51
|
+
</ComboboxPrimitive.Trigger>
|
|
52
|
+
))
|
|
53
|
+
ComboboxTrigger.displayName = "ComboboxTrigger"
|
|
54
|
+
|
|
55
|
+
const ComboboxClear = React.forwardRef<
|
|
56
|
+
React.ComponentRef<typeof ComboboxPrimitive.Clear>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Clear>
|
|
58
|
+
>(({ className, children, ...props }, ref) => (
|
|
59
|
+
<ComboboxPrimitive.Clear
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
"inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground",
|
|
63
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children ?? <X className="h-4 w-4" />}
|
|
69
|
+
</ComboboxPrimitive.Clear>
|
|
70
|
+
))
|
|
71
|
+
ComboboxClear.displayName = "ComboboxClear"
|
|
72
|
+
|
|
73
|
+
const ComboboxContent = React.forwardRef<
|
|
74
|
+
React.ComponentRef<typeof ComboboxPrimitive.Popup>,
|
|
75
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Popup>
|
|
76
|
+
>(({ className, ...props }, ref) => (
|
|
77
|
+
<ComboboxPortal>
|
|
78
|
+
<ComboboxPrimitive.Positioner sideOffset={4}>
|
|
79
|
+
<ComboboxPrimitive.Popup
|
|
80
|
+
ref={ref}
|
|
81
|
+
className={cn(
|
|
82
|
+
"relative z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
83
|
+
"origin-[var(--transform-origin)] outline-none",
|
|
84
|
+
"data-[starting-style]:animate-in data-[starting-style]:fade-in-0 data-[starting-style]:zoom-in-95",
|
|
85
|
+
"data-[ending-style]:animate-out data-[ending-style]:fade-out-0 data-[ending-style]:zoom-out-95",
|
|
86
|
+
className
|
|
87
|
+
)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
</ComboboxPrimitive.Positioner>
|
|
91
|
+
</ComboboxPortal>
|
|
92
|
+
))
|
|
93
|
+
ComboboxContent.displayName = "ComboboxContent"
|
|
94
|
+
|
|
95
|
+
const ComboboxList = React.forwardRef<
|
|
96
|
+
React.ComponentRef<typeof ComboboxPrimitive.List>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.List>
|
|
98
|
+
>(({ className, ...props }, ref) => (
|
|
99
|
+
<ComboboxPrimitive.List
|
|
100
|
+
ref={ref}
|
|
101
|
+
className={cn("max-h-80 overflow-y-auto p-1", className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
))
|
|
105
|
+
ComboboxList.displayName = "ComboboxList"
|
|
106
|
+
|
|
107
|
+
const ComboboxItem = React.forwardRef<
|
|
108
|
+
React.ComponentRef<typeof ComboboxPrimitive.Item>,
|
|
109
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Item> & {
|
|
110
|
+
inset?: boolean
|
|
111
|
+
}
|
|
112
|
+
>(({ className, children, inset, ...props }, ref) => (
|
|
113
|
+
<ComboboxPrimitive.Item
|
|
114
|
+
ref={ref}
|
|
115
|
+
className={cn(
|
|
116
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none",
|
|
117
|
+
"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",
|
|
118
|
+
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
119
|
+
inset && "pl-10",
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
125
|
+
<ComboboxPrimitive.ItemIndicator>
|
|
126
|
+
<Check className="h-4 w-4" />
|
|
127
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
128
|
+
</span>
|
|
129
|
+
{children}
|
|
130
|
+
</ComboboxPrimitive.Item>
|
|
131
|
+
))
|
|
132
|
+
ComboboxItem.displayName = "ComboboxItem"
|
|
133
|
+
|
|
134
|
+
const ComboboxGroup = React.forwardRef<
|
|
135
|
+
React.ComponentRef<typeof ComboboxPrimitive.Group>,
|
|
136
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Group>
|
|
137
|
+
>(({ className, ...props }, ref) => (
|
|
138
|
+
<ComboboxPrimitive.Group ref={ref} className={cn(className)} {...props} />
|
|
139
|
+
))
|
|
140
|
+
ComboboxGroup.displayName = "ComboboxGroup"
|
|
141
|
+
|
|
142
|
+
const ComboboxGroupLabel = React.forwardRef<
|
|
143
|
+
React.ComponentRef<typeof ComboboxPrimitive.GroupLabel>,
|
|
144
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.GroupLabel>
|
|
145
|
+
>(({ className, ...props }, ref) => (
|
|
146
|
+
<ComboboxPrimitive.GroupLabel
|
|
147
|
+
ref={ref}
|
|
148
|
+
className={cn("px-2 py-1.5 text-xs font-medium text-muted-foreground", className)}
|
|
149
|
+
{...props}
|
|
150
|
+
/>
|
|
151
|
+
))
|
|
152
|
+
ComboboxGroupLabel.displayName = "ComboboxGroupLabel"
|
|
153
|
+
|
|
154
|
+
const ComboboxEmpty = React.forwardRef<
|
|
155
|
+
React.ComponentRef<typeof ComboboxPrimitive.Empty>,
|
|
156
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Empty>
|
|
157
|
+
>(({ className, ...props }, ref) => (
|
|
158
|
+
<ComboboxPrimitive.Empty
|
|
159
|
+
ref={ref}
|
|
160
|
+
className={cn("px-2 py-6 text-center text-sm text-muted-foreground", className)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
))
|
|
164
|
+
ComboboxEmpty.displayName = "ComboboxEmpty"
|
|
165
|
+
|
|
166
|
+
const ComboboxStatus = React.forwardRef<
|
|
167
|
+
React.ComponentRef<typeof ComboboxPrimitive.Status>,
|
|
168
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Status>
|
|
169
|
+
>(({ className, ...props }, ref) => (
|
|
170
|
+
<ComboboxPrimitive.Status ref={ref} className={cn("sr-only", className)} {...props} />
|
|
171
|
+
))
|
|
172
|
+
ComboboxStatus.displayName = "ComboboxStatus"
|
|
173
|
+
|
|
174
|
+
const ComboboxSeparator = React.forwardRef<
|
|
175
|
+
React.ComponentRef<typeof ComboboxPrimitive.Separator>,
|
|
176
|
+
React.ComponentPropsWithoutRef<typeof ComboboxPrimitive.Separator>
|
|
177
|
+
>(({ className, ...props }, ref) => (
|
|
178
|
+
<ComboboxPrimitive.Separator
|
|
179
|
+
ref={ref}
|
|
180
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
181
|
+
{...props}
|
|
182
|
+
/>
|
|
183
|
+
))
|
|
184
|
+
ComboboxSeparator.displayName = "ComboboxSeparator"
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
Combobox,
|
|
188
|
+
ComboboxValue,
|
|
189
|
+
ComboboxCollection,
|
|
190
|
+
ComboboxPortal,
|
|
191
|
+
ComboboxInput,
|
|
192
|
+
ComboboxTrigger,
|
|
193
|
+
ComboboxClear,
|
|
194
|
+
ComboboxContent,
|
|
195
|
+
ComboboxList,
|
|
196
|
+
ComboboxItem,
|
|
197
|
+
ComboboxGroup,
|
|
198
|
+
ComboboxGroupLabel,
|
|
199
|
+
ComboboxEmpty,
|
|
200
|
+
ComboboxStatus,
|
|
201
|
+
ComboboxSeparator,
|
|
202
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Combobox,
|
|
3
|
+
ComboboxValue,
|
|
4
|
+
ComboboxCollection,
|
|
5
|
+
ComboboxPortal,
|
|
6
|
+
ComboboxInput,
|
|
7
|
+
ComboboxTrigger,
|
|
8
|
+
ComboboxClear,
|
|
9
|
+
ComboboxContent,
|
|
10
|
+
ComboboxList,
|
|
11
|
+
ComboboxItem,
|
|
12
|
+
ComboboxGroup,
|
|
13
|
+
ComboboxGroupLabel,
|
|
14
|
+
ComboboxEmpty,
|
|
15
|
+
ComboboxStatus,
|
|
16
|
+
ComboboxSeparator,
|
|
17
|
+
} from "./combobox"
|