@blocknote/shadcn 0.36.1 → 0.38.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 (66) hide show
  1. package/dist/blocknote-shadcn.cjs +1 -1
  2. package/dist/blocknote-shadcn.cjs.map +1 -1
  3. package/dist/blocknote-shadcn.js +1237 -1187
  4. package/dist/blocknote-shadcn.js.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/webpack-stats.json +1 -1
  7. package/package.json +17 -19
  8. package/src/BlockNoteView.tsx +2 -0
  9. package/src/badge/Badge.tsx +3 -6
  10. package/src/comments/Card.tsx +7 -9
  11. package/src/comments/Comment.tsx +10 -27
  12. package/src/components/ui/avatar.tsx +44 -39
  13. package/src/components/ui/badge.tsx +22 -12
  14. package/src/components/ui/button.tsx +33 -32
  15. package/src/components/ui/card.tsx +78 -72
  16. package/src/components/ui/dropdown-menu.tsx +230 -176
  17. package/src/components/ui/form.tsx +40 -51
  18. package/src/components/ui/input.tsx +16 -20
  19. package/src/components/ui/label.tsx +19 -19
  20. package/src/components/ui/popover.tsx +40 -23
  21. package/src/components/ui/select.tsx +153 -133
  22. package/src/components/ui/skeleton.tsx +3 -5
  23. package/src/components/ui/tabs.tsx +59 -46
  24. package/src/components/ui/toggle.tsx +23 -21
  25. package/src/components/ui/tooltip.tsx +50 -21
  26. package/src/components.ts +0 -1
  27. package/src/form/TextInput.tsx +4 -4
  28. package/src/index.tsx +1 -2
  29. package/src/lib/utils.ts +2 -8
  30. package/src/menu/Button.tsx +1 -1
  31. package/src/menu/Menu.tsx +2 -2
  32. package/src/panel/Panel.tsx +2 -2
  33. package/src/panel/PanelTab.tsx +1 -1
  34. package/src/panel/PanelTextInput.tsx +1 -1
  35. package/src/popover/popover.tsx +2 -2
  36. package/src/sideMenu/SideMenuButton.tsx +1 -1
  37. package/src/style.css +6 -127
  38. package/src/suggestionMenu/SuggestionMenu.tsx +1 -1
  39. package/src/suggestionMenu/SuggestionMenuEmptyItem.tsx +3 -1
  40. package/src/suggestionMenu/SuggestionMenuItem.tsx +13 -10
  41. package/src/suggestionMenu/SuggestionMenuLabel.tsx +4 -1
  42. package/src/suggestionMenu/SuggestionMenuLoader.tsx +3 -2
  43. package/src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenu.tsx +8 -1
  44. package/src/suggestionMenu/gridSuggestionMenu/GridSuggestionMenuItem.tsx +10 -1
  45. package/src/tableHandle/ExtendButton.tsx +6 -6
  46. package/src/tableHandle/TableHandle.tsx +1 -1
  47. package/src/toolbar/Toolbar.tsx +7 -9
  48. package/types/src/BlockNoteView.d.ts +1 -0
  49. package/types/src/ShadCNComponentsContext.d.ts +116 -132
  50. package/types/src/components/ui/avatar.d.ts +3 -3
  51. package/types/src/components/ui/badge.d.ts +5 -5
  52. package/types/src/components/ui/button.d.ts +4 -5
  53. package/types/src/components/ui/card.d.ts +8 -7
  54. package/types/src/components/ui/dropdown-menu.d.ts +21 -23
  55. package/types/src/components/ui/form.d.ts +10 -9
  56. package/types/src/components/ui/input.d.ts +1 -3
  57. package/types/src/components/ui/label.d.ts +2 -3
  58. package/types/src/components/ui/popover.d.ts +6 -5
  59. package/types/src/components/ui/select.d.ts +13 -11
  60. package/types/src/components/ui/skeleton.d.ts +1 -1
  61. package/types/src/components/ui/tabs.d.ts +6 -6
  62. package/types/src/components/ui/toggle.d.ts +3 -6
  63. package/types/src/components/ui/tooltip.d.ts +6 -6
  64. package/types/src/components.d.ts +0 -1
  65. package/types/src/index.d.ts +1 -1
  66. package/src/tailwindStyles.css +0 -421
@@ -1,201 +1,255 @@
1
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
2
- import { Check, ChevronRight, Circle } from "lucide-react";
1
+ "use client";
2
+
3
3
  import * as React from "react";
4
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
5
+ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
6
+
7
+ import { cn } from "../../lib/utils";
4
8
 
5
- import { cn } from "../../lib/utils.js";
6
-
7
- const DropdownMenu = DropdownMenuPrimitive.Root;
8
-
9
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
10
-
11
- const DropdownMenuGroup = DropdownMenuPrimitive.Group;
12
-
13
- const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
14
-
15
- const DropdownMenuSub = DropdownMenuPrimitive.Sub;
16
-
17
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
18
-
19
- const DropdownMenuSubTrigger = React.forwardRef<
20
- React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
21
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
22
- inset?: boolean;
23
- }
24
- >(({ className, inset, children, ...props }, ref) => (
25
- <DropdownMenuPrimitive.SubTrigger
26
- ref={ref}
27
- className={cn(
28
- "bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none focus:bn-bg-accent data-[state=open]:bn-bg-accent",
29
- inset && "bn-pl-8",
30
- className,
31
- )}
32
- {...props}
33
- >
34
- {children}
35
- <ChevronRight className="bn-ml-auto bn-h-4 bn-w-4" />
36
- </DropdownMenuPrimitive.SubTrigger>
37
- ));
38
- DropdownMenuSubTrigger.displayName =
39
- DropdownMenuPrimitive.SubTrigger.displayName;
40
-
41
- const DropdownMenuSubContent = React.forwardRef<
42
- React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
43
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
44
- >(({ className, ...props }, ref) => (
45
- <DropdownMenuPrimitive.SubContent
46
- ref={ref}
47
- className={cn(
48
- "bn-z-50 bn-min-w-[8rem] bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-p-1 bn-text-popover-foreground bn-shadow-lg data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",
49
- className,
50
- )}
51
- {...props}
52
- />
53
- ));
54
- DropdownMenuSubContent.displayName =
55
- DropdownMenuPrimitive.SubContent.displayName;
56
-
57
- const DropdownMenuContent = React.forwardRef<
58
- React.ElementRef<typeof DropdownMenuPrimitive.Content>,
59
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
60
- >(({ className, sideOffset = 4, ...props }, ref) => (
61
- // <DropdownMenuPrimitive.Portal>
62
- <DropdownMenuPrimitive.Content
63
- ref={ref}
64
- sideOffset={sideOffset}
65
- className={cn(
66
- "bn-z-50 bn-min-w-[8rem] bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-p-1 bn-text-popover-foreground bn-shadow-md data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",
67
- className,
68
- )}
69
- {...props}
70
- />
71
- // </DropdownMenuPrimitive.Portal>
72
- ));
73
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
74
-
75
- const DropdownMenuItem = React.forwardRef<
76
- React.ElementRef<typeof DropdownMenuPrimitive.Item>,
77
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
78
- inset?: boolean;
79
- }
80
- >(({ className, inset, ...props }, ref) => (
81
- <DropdownMenuPrimitive.Item
82
- ref={ref}
83
- className={cn(
84
- "bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",
85
- inset && "bn-pl-8",
86
- className,
87
- )}
88
- {...props}
89
- />
90
- ));
91
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
92
-
93
- const DropdownMenuCheckboxItem = React.forwardRef<
94
- React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
95
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
96
- >(({ className, children, checked, ...props }, ref) => (
97
- <DropdownMenuPrimitive.CheckboxItem
98
- ref={ref}
99
- className={cn(
100
- "bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",
101
- className,
102
- )}
103
- checked={checked}
104
- {...props}
105
- >
106
- <span className="bn-absolute bn-left-2 bn-flex bn-h-3.5 bn-w-3.5 bn-items-center bn-justify-center">
107
- <DropdownMenuPrimitive.ItemIndicator>
108
- <Check className="bn-h-4 bn-w-4" />
109
- </DropdownMenuPrimitive.ItemIndicator>
110
- </span>
111
- {children}
112
- </DropdownMenuPrimitive.CheckboxItem>
113
- ));
114
- DropdownMenuCheckboxItem.displayName =
115
- DropdownMenuPrimitive.CheckboxItem.displayName;
116
-
117
- const DropdownMenuRadioItem = React.forwardRef<
118
- React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
119
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
120
- >(({ className, children, ...props }, ref) => (
121
- <DropdownMenuPrimitive.RadioItem
122
- ref={ref}
123
- className={cn(
124
- "bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",
125
- className,
126
- )}
127
- {...props}
128
- >
129
- <span className="bn-absolute bn-left-2 bn-flex bn-h-3.5 bn-w-3.5 bn-items-center bn-justify-center">
130
- <DropdownMenuPrimitive.ItemIndicator>
131
- <Circle className="bn-h-2 bn-w-2 bn-fill-current" />
132
- </DropdownMenuPrimitive.ItemIndicator>
133
- </span>
134
- {children}
135
- </DropdownMenuPrimitive.RadioItem>
136
- ));
137
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
138
-
139
- const DropdownMenuLabel = React.forwardRef<
140
- React.ElementRef<typeof DropdownMenuPrimitive.Label>,
141
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
142
- inset?: boolean;
143
- }
144
- >(({ className, inset, ...props }, ref) => (
145
- <DropdownMenuPrimitive.Label
146
- ref={ref}
147
- className={cn(
148
- "bn-px-2 bn-py-1.5 bn-text-sm bn-font-semibold",
149
- inset && "bn-pl-8",
150
- className,
151
- )}
152
- {...props}
153
- />
154
- ));
155
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
156
-
157
- const DropdownMenuSeparator = React.forwardRef<
158
- React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
159
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
160
- >(({ className, ...props }, ref) => (
161
- <DropdownMenuPrimitive.Separator
162
- ref={ref}
163
- className={cn("bn--mx-1 bn-my-1 bn-h-px bn-bg-muted", className)}
164
- {...props}
165
- />
166
- ));
167
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
168
-
169
- const DropdownMenuShortcut = ({
9
+ function DropdownMenu({
10
+ ...props
11
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
12
+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
13
+ }
14
+
15
+ function DropdownMenuPortal({
16
+ ...props
17
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
18
+ return (
19
+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
20
+ );
21
+ }
22
+
23
+ function DropdownMenuTrigger({
24
+ ...props
25
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
26
+ return (
27
+ <DropdownMenuPrimitive.Trigger
28
+ data-slot="dropdown-menu-trigger"
29
+ {...props}
30
+ />
31
+ );
32
+ }
33
+
34
+ function DropdownMenuContent({
170
35
  className,
36
+ sideOffset = 4,
37
+ ...props
38
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
39
+ return (
40
+ <DropdownMenuPrimitive.Content
41
+ data-slot="dropdown-menu-content"
42
+ sideOffset={sideOffset}
43
+ className={cn(
44
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md",
45
+ className,
46
+ )}
47
+ {...props}
48
+ />
49
+ );
50
+ }
51
+
52
+ function DropdownMenuGroup({
171
53
  ...props
172
- }: React.HTMLAttributes<HTMLSpanElement>) => {
54
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
55
+ return (
56
+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
57
+ );
58
+ }
59
+
60
+ function DropdownMenuItem({
61
+ className,
62
+ inset,
63
+ variant = "default",
64
+ ...props
65
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
66
+ inset?: boolean;
67
+ variant?: "default" | "destructive";
68
+ }) {
69
+ return (
70
+ <DropdownMenuPrimitive.Item
71
+ data-slot="dropdown-menu-item"
72
+ data-inset={inset}
73
+ data-variant={variant}
74
+ className={cn(
75
+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
76
+ className,
77
+ )}
78
+ {...props}
79
+ />
80
+ );
81
+ }
82
+
83
+ function DropdownMenuCheckboxItem({
84
+ className,
85
+ children,
86
+ checked,
87
+ ...props
88
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
89
+ return (
90
+ <DropdownMenuPrimitive.CheckboxItem
91
+ data-slot="dropdown-menu-checkbox-item"
92
+ className={cn(
93
+ "focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
94
+ className,
95
+ )}
96
+ checked={checked}
97
+ {...props}
98
+ >
99
+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
100
+ <DropdownMenuPrimitive.ItemIndicator>
101
+ <CheckIcon className="size-4" />
102
+ </DropdownMenuPrimitive.ItemIndicator>
103
+ </span>
104
+ {children}
105
+ </DropdownMenuPrimitive.CheckboxItem>
106
+ );
107
+ }
108
+
109
+ function DropdownMenuRadioGroup({
110
+ ...props
111
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
112
+ return (
113
+ <DropdownMenuPrimitive.RadioGroup
114
+ data-slot="dropdown-menu-radio-group"
115
+ {...props}
116
+ />
117
+ );
118
+ }
119
+
120
+ function DropdownMenuRadioItem({
121
+ className,
122
+ children,
123
+ ...props
124
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
125
+ return (
126
+ <DropdownMenuPrimitive.RadioItem
127
+ data-slot="dropdown-menu-radio-item"
128
+ className={cn(
129
+ "focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
130
+ className,
131
+ )}
132
+ {...props}
133
+ >
134
+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
135
+ <DropdownMenuPrimitive.ItemIndicator>
136
+ <CircleIcon className="size-2 fill-current" />
137
+ </DropdownMenuPrimitive.ItemIndicator>
138
+ </span>
139
+ {children}
140
+ </DropdownMenuPrimitive.RadioItem>
141
+ );
142
+ }
143
+
144
+ function DropdownMenuLabel({
145
+ className,
146
+ inset,
147
+ ...props
148
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
149
+ inset?: boolean;
150
+ }) {
151
+ return (
152
+ <DropdownMenuPrimitive.Label
153
+ data-slot="dropdown-menu-label"
154
+ data-inset={inset}
155
+ className={cn(
156
+ "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
157
+ className,
158
+ )}
159
+ {...props}
160
+ />
161
+ );
162
+ }
163
+
164
+ function DropdownMenuSeparator({
165
+ className,
166
+ ...props
167
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
168
+ return (
169
+ <DropdownMenuPrimitive.Separator
170
+ data-slot="dropdown-menu-separator"
171
+ className={cn("bg-border -mx-1 my-1 h-px", className)}
172
+ {...props}
173
+ />
174
+ );
175
+ }
176
+
177
+ function DropdownMenuShortcut({
178
+ className,
179
+ ...props
180
+ }: React.ComponentProps<"span">) {
173
181
  return (
174
182
  <span
183
+ data-slot="dropdown-menu-shortcut"
175
184
  className={cn(
176
- "bn-ml-auto bn-text-xs bn-tracking-widest bn-opacity-60",
185
+ "text-muted-foreground ml-auto text-xs tracking-widest",
177
186
  className,
178
187
  )}
179
188
  {...props}
180
189
  />
181
190
  );
182
- };
183
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
191
+ }
192
+
193
+ function DropdownMenuSub({
194
+ ...props
195
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
196
+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
197
+ }
198
+
199
+ function DropdownMenuSubTrigger({
200
+ className,
201
+ inset,
202
+ children,
203
+ ...props
204
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
205
+ inset?: boolean;
206
+ }) {
207
+ return (
208
+ <DropdownMenuPrimitive.SubTrigger
209
+ data-slot="dropdown-menu-sub-trigger"
210
+ data-inset={inset}
211
+ className={cn(
212
+ "focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground outline-hidden flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm data-[inset]:pl-8",
213
+ className,
214
+ )}
215
+ {...props}
216
+ >
217
+ {children}
218
+ <ChevronRightIcon className="ml-auto size-4" />
219
+ </DropdownMenuPrimitive.SubTrigger>
220
+ );
221
+ }
222
+
223
+ function DropdownMenuSubContent({
224
+ className,
225
+ ...props
226
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
227
+ return (
228
+ <DropdownMenuPrimitive.SubContent
229
+ data-slot="dropdown-menu-sub-content"
230
+ className={cn(
231
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",
232
+ className,
233
+ )}
234
+ {...props}
235
+ />
236
+ );
237
+ }
184
238
 
185
239
  export {
186
240
  DropdownMenu,
187
- DropdownMenuCheckboxItem,
241
+ DropdownMenuPortal,
242
+ DropdownMenuTrigger,
188
243
  DropdownMenuContent,
189
244
  DropdownMenuGroup,
190
- DropdownMenuItem,
191
245
  DropdownMenuLabel,
192
- DropdownMenuPortal,
246
+ DropdownMenuItem,
247
+ DropdownMenuCheckboxItem,
193
248
  DropdownMenuRadioGroup,
194
249
  DropdownMenuRadioItem,
195
250
  DropdownMenuSeparator,
196
251
  DropdownMenuShortcut,
197
252
  DropdownMenuSub,
198
- DropdownMenuSubContent,
199
253
  DropdownMenuSubTrigger,
200
- DropdownMenuTrigger,
254
+ DropdownMenuSubContent,
201
255
  };
@@ -1,17 +1,18 @@
1
+ import * as React from "react";
1
2
  import * as LabelPrimitive from "@radix-ui/react-label";
2
3
  import { Slot } from "@radix-ui/react-slot";
3
- import * as React from "react";
4
4
  import {
5
5
  Controller,
6
- ControllerProps,
7
- FieldPath,
8
- FieldValues,
9
6
  FormProvider,
10
7
  useFormContext,
8
+ useFormState,
9
+ type ControllerProps,
10
+ type FieldPath,
11
+ type FieldValues,
11
12
  } from "react-hook-form";
12
13
 
13
- import { cn } from "../../lib/utils.js";
14
- import { Label } from "./label.js";
14
+ import { cn } from "../../lib/utils";
15
+ import { Label } from "./label";
15
16
 
16
17
  const Form = FormProvider;
17
18
 
@@ -42,8 +43,8 @@ const FormField = <
42
43
  const useFormField = () => {
43
44
  const fieldContext = React.useContext(FormFieldContext);
44
45
  const itemContext = React.useContext(FormItemContext);
45
- const { getFieldState, formState } = useFormContext();
46
-
46
+ const { getFieldState } = useFormContext();
47
+ const formState = useFormState({ name: fieldContext.name });
47
48
  const fieldState = getFieldState(fieldContext.name, formState);
48
49
 
49
50
  if (!fieldContext) {
@@ -70,47 +71,44 @@ const FormItemContext = React.createContext<FormItemContextValue>(
70
71
  {} as FormItemContextValue,
71
72
  );
72
73
 
73
- const FormItem = React.forwardRef<
74
- HTMLDivElement,
75
- React.HTMLAttributes<HTMLDivElement>
76
- >(({ className, ...props }, ref) => {
74
+ function FormItem({ className, ...props }: React.ComponentProps<"div">) {
77
75
  const id = React.useId();
78
76
 
79
77
  return (
80
78
  <FormItemContext.Provider value={{ id }}>
81
- <div ref={ref} className={cn("bn-space-y-2", className)} {...props} />
79
+ <div
80
+ data-slot="form-item"
81
+ className={cn("grid gap-2", className)}
82
+ {...props}
83
+ />
82
84
  </FormItemContext.Provider>
83
85
  );
84
- });
85
- FormItem.displayName = "FormItem";
86
+ }
86
87
 
87
- const FormLabel = React.forwardRef<
88
- React.ElementRef<typeof LabelPrimitive.Root>,
89
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
90
- >(({ className, ...props }, ref) => {
88
+ function FormLabel({
89
+ className,
90
+ ...props
91
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) {
91
92
  const { error, formItemId } = useFormField();
92
93
 
93
94
  return (
94
95
  <Label
95
- ref={ref}
96
- className={cn(error && "bn-text-destructive", className)}
96
+ data-slot="form-label"
97
+ data-error={!!error}
98
+ className={cn("data-[error=true]:text-destructive", className)}
97
99
  htmlFor={formItemId}
98
100
  {...props}
99
101
  />
100
102
  );
101
- });
102
- FormLabel.displayName = "FormLabel";
103
+ }
103
104
 
104
- const FormControl = React.forwardRef<
105
- React.ElementRef<typeof Slot>,
106
- React.ComponentPropsWithoutRef<typeof Slot>
107
- >(({ ...props }, ref) => {
105
+ function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
108
106
  const { error, formItemId, formDescriptionId, formMessageId } =
109
107
  useFormField();
110
108
 
111
109
  return (
112
110
  <Slot
113
- ref={ref}
111
+ data-slot="form-control"
114
112
  id={formItemId}
115
113
  aria-describedby={
116
114
  !error
@@ -121,32 +119,24 @@ const FormControl = React.forwardRef<
121
119
  {...props}
122
120
  />
123
121
  );
124
- });
125
- FormControl.displayName = "FormControl";
122
+ }
126
123
 
127
- const FormDescription = React.forwardRef<
128
- HTMLParagraphElement,
129
- React.HTMLAttributes<HTMLParagraphElement>
130
- >(({ className, ...props }, ref) => {
124
+ function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
131
125
  const { formDescriptionId } = useFormField();
132
126
 
133
127
  return (
134
128
  <p
135
- ref={ref}
129
+ data-slot="form-description"
136
130
  id={formDescriptionId}
137
- className={cn("bn-text-sm bn-text-muted-foreground", className)}
131
+ className={cn("text-muted-foreground text-sm", className)}
138
132
  {...props}
139
133
  />
140
134
  );
141
- });
142
- FormDescription.displayName = "FormDescription";
135
+ }
143
136
 
144
- const FormMessage = React.forwardRef<
145
- HTMLParagraphElement,
146
- React.HTMLAttributes<HTMLParagraphElement>
147
- >(({ className, children, ...props }, ref) => {
137
+ function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
148
138
  const { error, formMessageId } = useFormField();
149
- const body = error ? String(error?.message) : children;
139
+ const body = error ? String(error?.message ?? "") : props.children;
150
140
 
151
141
  if (!body) {
152
142
  return null;
@@ -154,24 +144,23 @@ const FormMessage = React.forwardRef<
154
144
 
155
145
  return (
156
146
  <p
157
- ref={ref}
147
+ data-slot="form-message"
158
148
  id={formMessageId}
159
- className={cn("bn-text-sm bn-font-medium bn-text-destructive", className)}
149
+ className={cn("text-destructive text-sm", className)}
160
150
  {...props}
161
151
  >
162
152
  {body}
163
153
  </p>
164
154
  );
165
- });
166
- FormMessage.displayName = "FormMessage";
155
+ }
167
156
 
168
157
  export {
158
+ useFormField,
169
159
  Form,
170
- FormControl,
171
- FormDescription,
172
- FormField,
173
160
  FormItem,
174
161
  FormLabel,
162
+ FormControl,
163
+ FormDescription,
175
164
  FormMessage,
176
- useFormField,
165
+ FormField,
177
166
  };
@@ -1,25 +1,21 @@
1
1
  import * as React from "react";
2
2
 
3
- import { cn } from "../../lib/utils.js";
3
+ import { cn } from "../../lib/utils";
4
4
 
5
- export interface InputProps
6
- extends React.InputHTMLAttributes<HTMLInputElement> {}
7
-
8
- const Input = React.forwardRef<HTMLInputElement, InputProps>(
9
- ({ className, type, ...props }, ref) => {
10
- return (
11
- <input
12
- type={type}
13
- className={cn(
14
- "bn-flex bn-h-10 bn-w-full bn-rounded-md bn-border bn-border-input bn-bg-background bn-px-3 bn-py-2 bn-text-sm bn-ring-offset-background file:bn-border-0 file:bn-bg-transparent file:bn-text-sm file:bn-font-medium placeholder:bn-text-muted-foreground focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2 disabled:bn-cursor-not-allowed disabled:bn-opacity-50",
15
- className,
16
- )}
17
- ref={ref}
18
- {...props}
19
- />
20
- );
21
- },
22
- );
23
- Input.displayName = "Input";
5
+ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6
+ return (
7
+ <input
8
+ type={type}
9
+ data-slot="input"
10
+ className={cn(
11
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input shadow-xs flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
13
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
14
+ className,
15
+ )}
16
+ {...props}
17
+ />
18
+ );
19
+ }
24
20
 
25
21
  export { Input };