@zabuti/components-mcp 0.0.0-stage → 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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -2
  3. package/dist/index.js +527 -0
  4. package/dist/project-setup.js +424 -0
  5. package/dist/registry.js +73 -0
  6. package/dist/source.js +19 -0
  7. package/package.json +41 -4
  8. package/payload/registry.json +801 -0
  9. package/payload/src/components/ui/accordion.tsx +75 -0
  10. package/payload/src/components/ui/alert-dialog.tsx +151 -0
  11. package/payload/src/components/ui/alert.tsx +69 -0
  12. package/payload/src/components/ui/avatar.tsx +59 -0
  13. package/payload/src/components/ui/badge.tsx +57 -0
  14. package/payload/src/components/ui/breadcrumb.tsx +109 -0
  15. package/payload/src/components/ui/button.tsx +76 -0
  16. package/payload/src/components/ui/calendar.tsx +117 -0
  17. package/payload/src/components/ui/card.tsx +120 -0
  18. package/payload/src/components/ui/chart.tsx +249 -0
  19. package/payload/src/components/ui/checkbox.tsx +38 -0
  20. package/payload/src/components/ui/collapsible.tsx +30 -0
  21. package/payload/src/components/ui/combobox.tsx +127 -0
  22. package/payload/src/components/ui/command.tsx +186 -0
  23. package/payload/src/components/ui/context-menu.tsx +261 -0
  24. package/payload/src/components/ui/date-picker.tsx +140 -0
  25. package/payload/src/components/ui/dialog.tsx +176 -0
  26. package/payload/src/components/ui/dropdown-menu.tsx +277 -0
  27. package/payload/src/components/ui/form.tsx +151 -0
  28. package/payload/src/components/ui/hover-card.tsx +46 -0
  29. package/payload/src/components/ui/input-group.tsx +127 -0
  30. package/payload/src/components/ui/input.tsx +25 -0
  31. package/payload/src/components/ui/label.tsx +28 -0
  32. package/payload/src/components/ui/pagination.tsx +130 -0
  33. package/payload/src/components/ui/popover.tsx +97 -0
  34. package/payload/src/components/ui/progress.tsx +35 -0
  35. package/payload/src/components/ui/radio-group.tsx +49 -0
  36. package/payload/src/components/ui/scroll-area.tsx +67 -0
  37. package/payload/src/components/ui/select.tsx +199 -0
  38. package/payload/src/components/ui/separator.tsx +32 -0
  39. package/payload/src/components/ui/sheet.tsx +155 -0
  40. package/payload/src/components/ui/skeleton.tsx +21 -0
  41. package/payload/src/components/ui/slider.tsx +61 -0
  42. package/payload/src/components/ui/sonner.tsx +31 -0
  43. package/payload/src/components/ui/switch.tsx +40 -0
  44. package/payload/src/components/ui/table.tsx +108 -0
  45. package/payload/src/components/ui/tabs.tsx +98 -0
  46. package/payload/src/components/ui/textarea.tsx +24 -0
  47. package/payload/src/components/ui/toggle-group.tsx +72 -0
  48. package/payload/src/components/ui/toggle.tsx +54 -0
  49. package/payload/src/components/ui/tooltip.tsx +65 -0
  50. package/payload/src/lib/utils.ts +1 -0
  51. package/payload/src/themes/manifest.json +12 -0
  52. package/payload/src/themes/zabuti-ui-sky.css +14 -0
  53. package/payload/src/themes/zabuti-ui-teal.css +14 -0
  54. package/payload/src/zabuti-ui.css +272 -0
@@ -0,0 +1,176 @@
1
+ "use client"
2
+
3
+ /**
4
+ * Dialog — Zabuti UI primitive.
5
+ *
6
+ * Radix Dialog + Tailwind over the `zabuti-ui.css` token layer. Zabuti-owned, no
7
+ * shadcn dependency; Radix is the behavioural base only. Composes the Button
8
+ * primitive for the close affordance.
9
+ *
10
+ * Local surface: `showCloseButton` on `DialogContent` and `DialogFooter`.
11
+ */
12
+ import * as React from "react"
13
+ import { cn } from "cn"
14
+ import { Dialog as DialogPrimitive } from "radix-ui"
15
+
16
+ import { Button } from "@/components/ui/button"
17
+ import { XIcon } from "lucide-react"
18
+
19
+ function Dialog({
20
+ ...props
21
+ }: React.ComponentProps<typeof DialogPrimitive.Root>) {
22
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />
23
+ }
24
+
25
+ function DialogTrigger({
26
+ ...props
27
+ }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
28
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
29
+ }
30
+
31
+ function DialogPortal({
32
+ ...props
33
+ }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
34
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
35
+ }
36
+
37
+ function DialogClose({
38
+ ...props
39
+ }: React.ComponentProps<typeof DialogPrimitive.Close>) {
40
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
41
+ }
42
+
43
+ function DialogOverlay({
44
+ className,
45
+ ...props
46
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
47
+ return (
48
+ <DialogPrimitive.Overlay
49
+ data-slot="dialog-overlay"
50
+ className={cn(
51
+ "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
52
+ className
53
+ )}
54
+ {...props}
55
+ />
56
+ )
57
+ }
58
+
59
+ function DialogContent({
60
+ className,
61
+ children,
62
+ showCloseButton = true,
63
+ ...props
64
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
65
+ showCloseButton?: boolean
66
+ }) {
67
+ return (
68
+ <DialogPortal>
69
+ <DialogOverlay />
70
+ <DialogPrimitive.Content
71
+ data-slot="dialog-content"
72
+ className={cn(
73
+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
74
+ className
75
+ )}
76
+ {...props}
77
+ >
78
+ {children}
79
+ {showCloseButton && (
80
+ <DialogPrimitive.Close data-slot="dialog-close" asChild>
81
+ <Button
82
+ variant="ghost"
83
+ className="absolute top-2 right-2"
84
+ size="icon-sm"
85
+ >
86
+ <XIcon />
87
+ <span className="sr-only">Close</span>
88
+ </Button>
89
+ </DialogPrimitive.Close>
90
+ )}
91
+ </DialogPrimitive.Content>
92
+ </DialogPortal>
93
+ )
94
+ }
95
+
96
+ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
97
+ return (
98
+ <div
99
+ data-slot="dialog-header"
100
+ className={cn("flex flex-col gap-2", className)}
101
+ {...props}
102
+ />
103
+ )
104
+ }
105
+
106
+ function DialogFooter({
107
+ className,
108
+ showCloseButton = false,
109
+ children,
110
+ ...props
111
+ }: React.ComponentProps<"div"> & {
112
+ showCloseButton?: boolean
113
+ }) {
114
+ return (
115
+ <div
116
+ data-slot="dialog-footer"
117
+ className={cn(
118
+ "-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
119
+ className
120
+ )}
121
+ {...props}
122
+ >
123
+ {children}
124
+ {showCloseButton && (
125
+ <DialogPrimitive.Close asChild>
126
+ <Button variant="outline">Close</Button>
127
+ </DialogPrimitive.Close>
128
+ )}
129
+ </div>
130
+ )
131
+ }
132
+
133
+ function DialogTitle({
134
+ className,
135
+ ...props
136
+ }: React.ComponentProps<typeof DialogPrimitive.Title>) {
137
+ return (
138
+ <DialogPrimitive.Title
139
+ data-slot="dialog-title"
140
+ className={cn(
141
+ "font-heading text-base leading-none font-medium",
142
+ className
143
+ )}
144
+ {...props}
145
+ />
146
+ )
147
+ }
148
+
149
+ function DialogDescription({
150
+ className,
151
+ ...props
152
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) {
153
+ return (
154
+ <DialogPrimitive.Description
155
+ data-slot="dialog-description"
156
+ className={cn(
157
+ "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
158
+ className
159
+ )}
160
+ {...props}
161
+ />
162
+ )
163
+ }
164
+
165
+ export {
166
+ Dialog,
167
+ DialogClose,
168
+ DialogContent,
169
+ DialogDescription,
170
+ DialogFooter,
171
+ DialogHeader,
172
+ DialogOverlay,
173
+ DialogPortal,
174
+ DialogTitle,
175
+ DialogTrigger,
176
+ }
@@ -0,0 +1,277 @@
1
+ "use client"
2
+
3
+ /**
4
+ * Dropdown Menu — Zabuti UI primitive.
5
+ *
6
+ * Radix DropdownMenu + Tailwind over the `zabuti-ui.css` token layer. Zabuti-
7
+ * owned, no shadcn dependency; Radix is the behavioural base only.
8
+ *
9
+ * Local surface: `inset` and `variant="destructive"` on items,
10
+ * `DropdownMenuShortcut`.
11
+ */
12
+ import * as React from "react"
13
+ import { cn } from "cn"
14
+ import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
15
+ import { CheckIcon, ChevronRightIcon } from "lucide-react"
16
+
17
+ function DropdownMenu({
18
+ ...props
19
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
20
+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
21
+ }
22
+
23
+ function DropdownMenuPortal({
24
+ ...props
25
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
26
+ return (
27
+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
28
+ )
29
+ }
30
+
31
+ function DropdownMenuTrigger({
32
+ ...props
33
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
34
+ return (
35
+ <DropdownMenuPrimitive.Trigger
36
+ data-slot="dropdown-menu-trigger"
37
+ {...props}
38
+ />
39
+ )
40
+ }
41
+
42
+ function DropdownMenuContent({
43
+ className,
44
+ align = "start",
45
+ sideOffset = 4,
46
+ ...props
47
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
48
+ return (
49
+ <DropdownMenuPrimitive.Portal>
50
+ <DropdownMenuPrimitive.Content
51
+ data-slot="dropdown-menu-content"
52
+ sideOffset={sideOffset}
53
+ align={align}
54
+ className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
55
+ {...props}
56
+ />
57
+ </DropdownMenuPrimitive.Portal>
58
+ )
59
+ }
60
+
61
+ function DropdownMenuGroup({
62
+ ...props
63
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
64
+ return (
65
+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
66
+ )
67
+ }
68
+
69
+ function DropdownMenuItem({
70
+ className,
71
+ inset,
72
+ variant = "default",
73
+ ...props
74
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
75
+ inset?: boolean
76
+ variant?: "default" | "destructive"
77
+ }) {
78
+ return (
79
+ <DropdownMenuPrimitive.Item
80
+ data-slot="dropdown-menu-item"
81
+ data-inset={inset}
82
+ data-variant={variant}
83
+ className={cn(
84
+ "group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
85
+ className
86
+ )}
87
+ {...props}
88
+ />
89
+ )
90
+ }
91
+
92
+ function DropdownMenuCheckboxItem({
93
+ className,
94
+ children,
95
+ checked,
96
+ inset,
97
+ ...props
98
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {
99
+ inset?: boolean
100
+ }) {
101
+ return (
102
+ <DropdownMenuPrimitive.CheckboxItem
103
+ data-slot="dropdown-menu-checkbox-item"
104
+ data-inset={inset}
105
+ className={cn(
106
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
107
+ className
108
+ )}
109
+ checked={checked}
110
+ {...props}
111
+ >
112
+ <span
113
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
114
+ data-slot="dropdown-menu-checkbox-item-indicator"
115
+ >
116
+ <DropdownMenuPrimitive.ItemIndicator>
117
+ <CheckIcon
118
+ />
119
+ </DropdownMenuPrimitive.ItemIndicator>
120
+ </span>
121
+ {children}
122
+ </DropdownMenuPrimitive.CheckboxItem>
123
+ )
124
+ }
125
+
126
+ function DropdownMenuRadioGroup({
127
+ ...props
128
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
129
+ return (
130
+ <DropdownMenuPrimitive.RadioGroup
131
+ data-slot="dropdown-menu-radio-group"
132
+ {...props}
133
+ />
134
+ )
135
+ }
136
+
137
+ function DropdownMenuRadioItem({
138
+ className,
139
+ children,
140
+ inset,
141
+ ...props
142
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {
143
+ inset?: boolean
144
+ }) {
145
+ return (
146
+ <DropdownMenuPrimitive.RadioItem
147
+ data-slot="dropdown-menu-radio-item"
148
+ data-inset={inset}
149
+ className={cn(
150
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
151
+ className
152
+ )}
153
+ {...props}
154
+ >
155
+ <span
156
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
157
+ data-slot="dropdown-menu-radio-item-indicator"
158
+ >
159
+ <DropdownMenuPrimitive.ItemIndicator>
160
+ <CheckIcon
161
+ />
162
+ </DropdownMenuPrimitive.ItemIndicator>
163
+ </span>
164
+ {children}
165
+ </DropdownMenuPrimitive.RadioItem>
166
+ )
167
+ }
168
+
169
+ function DropdownMenuLabel({
170
+ className,
171
+ inset,
172
+ ...props
173
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
174
+ inset?: boolean
175
+ }) {
176
+ return (
177
+ <DropdownMenuPrimitive.Label
178
+ data-slot="dropdown-menu-label"
179
+ data-inset={inset}
180
+ className={cn(
181
+ "px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
182
+ className
183
+ )}
184
+ {...props}
185
+ />
186
+ )
187
+ }
188
+
189
+ function DropdownMenuSeparator({
190
+ className,
191
+ ...props
192
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
193
+ return (
194
+ <DropdownMenuPrimitive.Separator
195
+ data-slot="dropdown-menu-separator"
196
+ className={cn("-mx-1 my-1 h-px bg-border", className)}
197
+ {...props}
198
+ />
199
+ )
200
+ }
201
+
202
+ function DropdownMenuShortcut({
203
+ className,
204
+ ...props
205
+ }: React.ComponentProps<"span">) {
206
+ return (
207
+ <span
208
+ data-slot="dropdown-menu-shortcut"
209
+ className={cn(
210
+ "ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
211
+ className
212
+ )}
213
+ {...props}
214
+ />
215
+ )
216
+ }
217
+
218
+ function DropdownMenuSub({
219
+ ...props
220
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
221
+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
222
+ }
223
+
224
+ function DropdownMenuSubTrigger({
225
+ className,
226
+ inset,
227
+ children,
228
+ ...props
229
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
230
+ inset?: boolean
231
+ }) {
232
+ return (
233
+ <DropdownMenuPrimitive.SubTrigger
234
+ data-slot="dropdown-menu-sub-trigger"
235
+ data-inset={inset}
236
+ className={cn(
237
+ "flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
238
+ className
239
+ )}
240
+ {...props}
241
+ >
242
+ {children}
243
+ <ChevronRightIcon className="ml-auto" />
244
+ </DropdownMenuPrimitive.SubTrigger>
245
+ )
246
+ }
247
+
248
+ function DropdownMenuSubContent({
249
+ className,
250
+ ...props
251
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
252
+ return (
253
+ <DropdownMenuPrimitive.SubContent
254
+ data-slot="dropdown-menu-sub-content"
255
+ className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
256
+ {...props}
257
+ />
258
+ )
259
+ }
260
+
261
+ export {
262
+ DropdownMenu,
263
+ DropdownMenuPortal,
264
+ DropdownMenuTrigger,
265
+ DropdownMenuContent,
266
+ DropdownMenuGroup,
267
+ DropdownMenuLabel,
268
+ DropdownMenuItem,
269
+ DropdownMenuCheckboxItem,
270
+ DropdownMenuRadioGroup,
271
+ DropdownMenuRadioItem,
272
+ DropdownMenuSeparator,
273
+ DropdownMenuShortcut,
274
+ DropdownMenuSub,
275
+ DropdownMenuSubTrigger,
276
+ DropdownMenuSubContent,
277
+ }
@@ -0,0 +1,151 @@
1
+ "use client"
2
+
3
+ /**
4
+ * Form — Zabuti UI primitive.
5
+ *
6
+ * The react-hook-form binding layer: `Form` (= `FormProvider`), `FormField`
7
+ * (a `Controller` + name context), `FormItem` / `FormLabel` / `FormControl` /
8
+ * `FormDescription` / `FormMessage`, and the `useFormField` hook that wires
9
+ * `id` / `aria-describedby` / `aria-invalid` / error text together.
10
+ *
11
+ * Zabuti-owned, no shadcn dependency. Composes the Label primitive and Radix
12
+ * `Slot`; `react-hook-form` is a peer dependency.
13
+ */
14
+ import * as React from "react"
15
+ import { Slot } from "radix-ui"
16
+ import {
17
+ Controller,
18
+ FormProvider,
19
+ useFormContext,
20
+ useFormState,
21
+ type ControllerProps,
22
+ type FieldPath,
23
+ type FieldValues,
24
+ } from "react-hook-form"
25
+ import { cn } from "cn"
26
+
27
+ import { Label } from "@/components/ui/label"
28
+
29
+ const Form = FormProvider
30
+
31
+ type FormFieldContextValue<
32
+ TFieldValues extends FieldValues = FieldValues,
33
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
34
+ > = {
35
+ name: TName
36
+ }
37
+
38
+ const FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)
39
+
40
+ function FormField<
41
+ TFieldValues extends FieldValues = FieldValues,
42
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
43
+ >(props: ControllerProps<TFieldValues, TName>) {
44
+ return (
45
+ <FormFieldContext.Provider value={{ name: props.name }}>
46
+ <Controller {...props} />
47
+ </FormFieldContext.Provider>
48
+ )
49
+ }
50
+
51
+ type FormItemContextValue = {
52
+ id: string
53
+ }
54
+
55
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)
56
+
57
+ function useFormField() {
58
+ const fieldContext = React.useContext(FormFieldContext)
59
+ const itemContext = React.useContext(FormItemContext)
60
+ const { getFieldState } = useFormContext()
61
+ const formState = useFormState({ name: fieldContext.name })
62
+ const fieldState = getFieldState(fieldContext.name, formState)
63
+
64
+ if (!fieldContext) {
65
+ throw new Error("useFormField should be used within <FormField>")
66
+ }
67
+
68
+ const { id } = itemContext
69
+ return {
70
+ id,
71
+ name: fieldContext.name,
72
+ formItemId: `${id}-form-item`,
73
+ formDescriptionId: `${id}-form-item-description`,
74
+ formMessageId: `${id}-form-item-message`,
75
+ ...fieldState,
76
+ }
77
+ }
78
+
79
+ function FormItem({ className, ...props }: React.ComponentProps<"div">) {
80
+ const id = React.useId()
81
+ return (
82
+ <FormItemContext.Provider value={{ id }}>
83
+ <div data-slot="form-item" className={cn("grid gap-2", className)} {...props} />
84
+ </FormItemContext.Provider>
85
+ )
86
+ }
87
+
88
+ function FormLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
89
+ const { error, formItemId } = useFormField()
90
+ return (
91
+ <Label
92
+ data-slot="form-label"
93
+ data-error={Boolean(error)}
94
+ className={cn("data-[error=true]:text-destructive", className)}
95
+ htmlFor={formItemId}
96
+ {...props}
97
+ />
98
+ )
99
+ }
100
+
101
+ function FormControl({ ...props }: React.ComponentProps<typeof Slot.Root>) {
102
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
103
+ return (
104
+ <Slot.Root
105
+ data-slot="form-control"
106
+ id={formItemId}
107
+ aria-describedby={error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId}
108
+ aria-invalid={Boolean(error)}
109
+ {...props}
110
+ />
111
+ )
112
+ }
113
+
114
+ function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
115
+ const { formDescriptionId } = useFormField()
116
+ return (
117
+ <p
118
+ data-slot="form-description"
119
+ id={formDescriptionId}
120
+ className={cn("text-sm text-muted-foreground", className)}
121
+ {...props}
122
+ />
123
+ )
124
+ }
125
+
126
+ function FormMessage({ className, children, ...props }: React.ComponentProps<"p">) {
127
+ const { error, formMessageId } = useFormField()
128
+ const body = error ? String(error.message ?? "") : children
129
+ if (!body) return null
130
+ return (
131
+ <p
132
+ data-slot="form-message"
133
+ id={formMessageId}
134
+ className={cn("text-sm text-destructive", className)}
135
+ {...props}
136
+ >
137
+ {body}
138
+ </p>
139
+ )
140
+ }
141
+
142
+ export {
143
+ useFormField,
144
+ Form,
145
+ FormItem,
146
+ FormLabel,
147
+ FormControl,
148
+ FormDescription,
149
+ FormMessage,
150
+ FormField,
151
+ }
@@ -0,0 +1,46 @@
1
+ "use client"
2
+
3
+ /**
4
+ * Hover Card — Zabuti UI primitive.
5
+ *
6
+ * Radix HoverCard + Tailwind over the `zabuti-ui.css` token layer — a preview
7
+ * panel that opens on pointer hover / keyboard focus of its trigger. Zabuti-
8
+ * owned, no shadcn dependency; Radix is the behavioural base only.
9
+ */
10
+ import * as React from "react"
11
+ import { cn } from "cn"
12
+ import { HoverCard as HoverCardPrimitive } from "radix-ui"
13
+
14
+ function HoverCard({ ...props }: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
15
+ return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
16
+ }
17
+
18
+ function HoverCardTrigger({
19
+ ...props
20
+ }: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
21
+ return <HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
22
+ }
23
+
24
+ function HoverCardContent({
25
+ className,
26
+ align = "center",
27
+ sideOffset = 4,
28
+ ...props
29
+ }: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
30
+ return (
31
+ <HoverCardPrimitive.Portal data-slot="hover-card-portal">
32
+ <HoverCardPrimitive.Content
33
+ data-slot="hover-card-content"
34
+ align={align}
35
+ sideOffset={sideOffset}
36
+ className={cn(
37
+ "z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-lg bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
38
+ className
39
+ )}
40
+ {...props}
41
+ />
42
+ </HoverCardPrimitive.Portal>
43
+ )
44
+ }
45
+
46
+ export { HoverCard, HoverCardTrigger, HoverCardContent }