@lark-apaas/coding-templates 0.1.5 → 0.1.6

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 (82) hide show
  1. package/package.json +1 -1
  2. package/template-vite-react/README.md +175 -0
  3. package/template-vite-react/client/index.html +2 -1
  4. package/template-vite-react/client/src/components/layout.tsx +0 -2
  5. package/template-vite-react/client/src/components/ui/README.md +134 -0
  6. package/template-vite-react/client/src/components/ui/accordion.tsx +22 -28
  7. package/template-vite-react/client/src/components/ui/alert-dialog.tsx +34 -64
  8. package/template-vite-react/client/src/components/ui/alert.tsx +10 -15
  9. package/template-vite-react/client/src/components/ui/aspect-ratio.tsx +5 -16
  10. package/template-vite-react/client/src/components/ui/avatar.tsx +11 -67
  11. package/template-vite-react/client/src/components/ui/badge.tsx +21 -31
  12. package/template-vite-react/client/src/components/ui/breadcrumb.tsx +23 -39
  13. package/template-vite-react/client/src/components/ui/button.tsx +36 -25
  14. package/template-vite-react/client/src/components/ui/calendar.tsx +37 -43
  15. package/template-vite-react/client/src/components/ui/card.tsx +73 -94
  16. package/template-vite-react/client/src/components/ui/carousel.tsx +7 -8
  17. package/template-vite-react/client/src/components/ui/chart.tsx +35 -49
  18. package/template-vite-react/client/src/components/ui/checkbox.tsx +10 -7
  19. package/template-vite-react/client/src/components/ui/collapsible.tsx +20 -6
  20. package/template-vite-react/client/src/components/ui/command.tsx +52 -40
  21. package/template-vite-react/client/src/components/ui/context-menu.tsx +170 -117
  22. package/template-vite-react/client/src/components/ui/dialog.tsx +37 -52
  23. package/template-vite-react/client/src/components/ui/drawer.tsx +12 -9
  24. package/template-vite-react/client/src/components/ui/dropdown-menu.tsx +194 -133
  25. package/template-vite-react/client/src/components/ui/hover-card.tsx +24 -29
  26. package/template-vite-react/client/src/components/ui/input-group.tsx +39 -29
  27. package/template-vite-react/client/src/components/ui/input-otp.tsx +7 -17
  28. package/template-vite-react/client/src/components/ui/input.tsx +4 -3
  29. package/template-vite-react/client/src/components/ui/label.tsx +9 -3
  30. package/template-vite-react/client/src/components/ui/menubar.tsx +160 -92
  31. package/template-vite-react/client/src/components/ui/navigation-menu.tsx +45 -45
  32. package/template-vite-react/client/src/components/ui/pagination.tsx +32 -35
  33. package/template-vite-react/client/src/components/ui/popover.tsx +20 -62
  34. package/template-vite-react/client/src/components/ui/progress.tsx +14 -64
  35. package/template-vite-react/client/src/components/ui/radio-group.tsx +20 -13
  36. package/template-vite-react/client/src/components/ui/resizable.tsx +18 -10
  37. package/template-vite-react/client/src/components/ui/scroll-area.tsx +13 -10
  38. package/template-vite-react/client/src/components/ui/select.tsx +122 -78
  39. package/template-vite-react/client/src/components/ui/separator.tsx +7 -4
  40. package/template-vite-react/client/src/components/ui/sheet.tsx +42 -41
  41. package/template-vite-react/client/src/components/ui/sidebar.tsx +162 -156
  42. package/template-vite-react/client/src/components/ui/skeleton.tsx +1 -1
  43. package/template-vite-react/client/src/components/ui/slider.tsx +52 -22
  44. package/template-vite-react/client/src/components/ui/sonner.tsx +44 -26
  45. package/template-vite-react/client/src/components/ui/switch.tsx +9 -8
  46. package/template-vite-react/client/src/components/ui/table.tsx +5 -5
  47. package/template-vite-react/client/src/components/ui/tabs.tsx +24 -38
  48. package/template-vite-react/client/src/components/ui/textarea.tsx +1 -1
  49. package/template-vite-react/client/src/components/ui/toggle-group.tsx +14 -20
  50. package/template-vite-react/client/src/components/ui/toggle.tsx +13 -10
  51. package/template-vite-react/client/src/components/ui/tooltip.tsx +30 -33
  52. package/template-vite-react/client/src/index.css +130 -0
  53. package/template-vite-react/client/src/main.tsx +1 -4
  54. package/template-vite-react/components.json +2 -6
  55. package/template-vite-react/eslint.config.js +11 -0
  56. package/template-vite-react/package.json +27 -2
  57. package/template-vite-react/client/src/components/header.tsx +0 -22
  58. package/template-vite-react/client/src/components/theme-provider.tsx +0 -45
  59. package/template-vite-react/client/src/components/ui/icons/file-ae-colorful-icon.tsx +0 -21
  60. package/template-vite-react/client/src/components/ui/icons/file-ai-colorful-icon.tsx +0 -36
  61. package/template-vite-react/client/src/components/ui/icons/file-android-colorful-icon.tsx +0 -33
  62. package/template-vite-react/client/src/components/ui/icons/file-audio-colorful-icon.tsx +0 -21
  63. package/template-vite-react/client/src/components/ui/icons/file-code-colorful-icon.tsx +0 -28
  64. package/template-vite-react/client/src/components/ui/icons/file-csv-colorful-icon.tsx +0 -21
  65. package/template-vite-react/client/src/components/ui/icons/file-eml-colorful-icon.tsx +0 -29
  66. package/template-vite-react/client/src/components/ui/icons/file-ios-colorful-icon.tsx +0 -25
  67. package/template-vite-react/client/src/components/ui/icons/file-keynote-colorful-icon.tsx +0 -29
  68. package/template-vite-react/client/src/components/ui/icons/file-pages-colorful-icon.tsx +0 -29
  69. package/template-vite-react/client/src/components/ui/icons/file-ps-colorful-icon.tsx +0 -21
  70. package/template-vite-react/client/src/components/ui/icons/file-sketch-colorful-icon.tsx +0 -21
  71. package/template-vite-react/client/src/components/ui/icons/file-slide-colorful-icon.tsx +0 -21
  72. package/template-vite-react/client/src/components/ui/icons/file-vcf-colorful-icon.tsx +0 -29
  73. package/template-vite-react/client/src/components/ui/icons/file-wiki-excel-colorful-icon.tsx +0 -23
  74. package/template-vite-react/client/src/components/ui/icons/file-wiki-image-colorful-icon.tsx +0 -27
  75. package/template-vite-react/client/src/components/ui/icons/file-wiki-pdf-colorful-icon.tsx +0 -20
  76. package/template-vite-react/client/src/components/ui/icons/file-wiki-ppt-colorful-icon.tsx +0 -21
  77. package/template-vite-react/client/src/components/ui/icons/file-wiki-text-colorful-icon.tsx +0 -12
  78. package/template-vite-react/client/src/components/ui/icons/file-wiki-unknown-colorful-icon.tsx +0 -14
  79. package/template-vite-react/client/src/components/ui/icons/file-wiki-video-colorful-icon.tsx +0 -23
  80. package/template-vite-react/client/src/components/ui/icons/file-wiki-word-colorful-icon.tsx +0 -38
  81. package/template-vite-react/client/src/components/ui/icons/file-wiki-zip-colorful-icon.tsx +0 -21
  82. package/template-vite-react/client/src/types/index.ts +0 -1
@@ -1,33 +1,20 @@
1
1
  "use client"
2
2
 
3
3
  import * as React from "react"
4
- import { Menu as MenuPrimitive } from "@base-ui/react/menu"
5
- import { Menubar as MenubarPrimitive } from "@base-ui/react/menubar"
4
+ import * as MenubarPrimitive from "@radix-ui/react-menubar"
5
+ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react"
6
6
 
7
7
  import { cn } from "@/lib/utils"
8
- import {
9
- DropdownMenu,
10
- DropdownMenuContent,
11
- DropdownMenuGroup,
12
- DropdownMenuItem,
13
- DropdownMenuLabel,
14
- DropdownMenuPortal,
15
- DropdownMenuRadioGroup,
16
- DropdownMenuSeparator,
17
- DropdownMenuShortcut,
18
- DropdownMenuSub,
19
- DropdownMenuSubContent,
20
- DropdownMenuSubTrigger,
21
- DropdownMenuTrigger,
22
- } from "@/components/ui/dropdown-menu"
23
- import { CheckIcon } from "lucide-react"
24
8
 
25
- function Menubar({ className, ...props }: MenubarPrimitive.Props) {
9
+ function Menubar({
10
+ className,
11
+ ...props
12
+ }: React.ComponentProps<typeof MenubarPrimitive.Root>) {
26
13
  return (
27
- <MenubarPrimitive
14
+ <MenubarPrimitive.Root
28
15
  data-slot="menubar"
29
16
  className={cn(
30
- "flex h-8 items-center gap-0.5 rounded-lg border p-[3px]",
17
+ "bg-background flex h-9 items-center gap-1 rounded-md border p-1 shadow-xs",
31
18
  className
32
19
  )}
33
20
  {...props}
@@ -35,31 +22,41 @@ function Menubar({ className, ...props }: MenubarPrimitive.Props) {
35
22
  )
36
23
  }
37
24
 
38
- function MenubarMenu({ ...props }: React.ComponentProps<typeof DropdownMenu>) {
39
- return <DropdownMenu data-slot="menubar-menu" {...props} />
25
+ function MenubarMenu({
26
+ ...props
27
+ }: React.ComponentProps<typeof MenubarPrimitive.Menu>) {
28
+ return <MenubarPrimitive.Menu data-slot="menubar-menu" {...props} />
40
29
  }
41
30
 
42
31
  function MenubarGroup({
43
32
  ...props
44
- }: React.ComponentProps<typeof DropdownMenuGroup>) {
45
- return <DropdownMenuGroup data-slot="menubar-group" {...props} />
33
+ }: React.ComponentProps<typeof MenubarPrimitive.Group>) {
34
+ return <MenubarPrimitive.Group data-slot="menubar-group" {...props} />
46
35
  }
47
36
 
48
37
  function MenubarPortal({
49
38
  ...props
50
- }: React.ComponentProps<typeof DropdownMenuPortal>) {
51
- return <DropdownMenuPortal data-slot="menubar-portal" {...props} />
39
+ }: React.ComponentProps<typeof MenubarPrimitive.Portal>) {
40
+ return <MenubarPrimitive.Portal data-slot="menubar-portal" {...props} />
41
+ }
42
+
43
+ function MenubarRadioGroup({
44
+ ...props
45
+ }: React.ComponentProps<typeof MenubarPrimitive.RadioGroup>) {
46
+ return (
47
+ <MenubarPrimitive.RadioGroup data-slot="menubar-radio-group" {...props} />
48
+ )
52
49
  }
53
50
 
54
51
  function MenubarTrigger({
55
52
  className,
56
53
  ...props
57
- }: React.ComponentProps<typeof DropdownMenuTrigger>) {
54
+ }: React.ComponentProps<typeof MenubarPrimitive.Trigger>) {
58
55
  return (
59
- <DropdownMenuTrigger
56
+ <MenubarPrimitive.Trigger
60
57
  data-slot="menubar-trigger"
61
58
  className={cn(
62
- "flex items-center rounded-sm px-1.5 py-[2px] text-sm font-medium outline-hidden select-none hover:bg-muted aria-expanded:bg-muted",
59
+ "focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex items-center rounded-sm px-2 py-1 text-sm font-medium outline-hidden select-none",
63
60
  className
64
61
  )}
65
62
  {...props}
@@ -73,16 +70,21 @@ function MenubarContent({
73
70
  alignOffset = -4,
74
71
  sideOffset = 8,
75
72
  ...props
76
- }: React.ComponentProps<typeof DropdownMenuContent>) {
73
+ }: React.ComponentProps<typeof MenubarPrimitive.Content>) {
77
74
  return (
78
- <DropdownMenuContent
79
- data-slot="menubar-content"
80
- align={align}
81
- alignOffset={alignOffset}
82
- sideOffset={sideOffset}
83
- className={cn("min-w-36 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=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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", className )}
84
- {...props}
85
- />
75
+ <MenubarPortal>
76
+ <MenubarPrimitive.Content
77
+ data-slot="menubar-content"
78
+ align={align}
79
+ alignOffset={alignOffset}
80
+ sideOffset={sideOffset}
81
+ className={cn(
82
+ "bg-popover text-popover-foreground data-[state=open]:animate-in 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 z-50 min-w-[12rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-md",
83
+ className
84
+ )}
85
+ {...props}
86
+ />
87
+ </MenubarPortal>
86
88
  )
87
89
  }
88
90
 
@@ -90,17 +92,44 @@ function MenubarItem({
90
92
  className,
91
93
  inset,
92
94
  variant = "default",
95
+ disabled,
96
+ onClick,
97
+ onMouseDown,
98
+ onKeyDown,
99
+ onKeyUp,
100
+ onPointerDown,
93
101
  ...props
94
- }: React.ComponentProps<typeof DropdownMenuItem>) {
102
+ }: React.ComponentProps<typeof MenubarPrimitive.Item> & {
103
+ inset?: boolean
104
+ variant?: "default" | "destructive"
105
+ }) {
95
106
  return (
96
- <DropdownMenuItem
107
+ <MenubarPrimitive.Item
97
108
  data-slot="menubar-item"
98
109
  data-inset={inset}
99
110
  data-variant={variant}
100
111
  className={cn(
101
- "group/menubar-item gap-1.5 rounded-md px-1.5 py-1 text-sm 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:opacity-50 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive!",
112
+ "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 relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
102
113
  className
103
114
  )}
115
+ disabled={disabled}
116
+ onClick={(event) => {
117
+ if (disabled) {
118
+ event.preventDefault()
119
+ return
120
+ }
121
+ onClick?.(event)
122
+ }}
123
+ onMouseDown={disabled ? undefined : onMouseDown}
124
+ onKeyDown={disabled ? undefined : onKeyDown}
125
+ onKeyUp={disabled ? undefined : onKeyUp}
126
+ onPointerDown={(event) => {
127
+ if (disabled) {
128
+ event.preventDefault()
129
+ return
130
+ }
131
+ onPointerDown?.(event)
132
+ }}
104
133
  {...props}
105
134
  />
106
135
  )
@@ -110,65 +139,97 @@ function MenubarCheckboxItem({
110
139
  className,
111
140
  children,
112
141
  checked,
113
- inset,
142
+ disabled,
143
+ onClick,
144
+ onMouseDown,
145
+ onKeyDown,
146
+ onKeyUp,
147
+ onPointerDown,
114
148
  ...props
115
- }: MenuPrimitive.CheckboxItem.Props & {
116
- inset?: boolean
117
- }) {
149
+ }: React.ComponentProps<typeof MenubarPrimitive.CheckboxItem>) {
118
150
  return (
119
- <MenuPrimitive.CheckboxItem
151
+ <MenubarPrimitive.CheckboxItem
120
152
  data-slot="menubar-checkbox-item"
121
- data-inset={inset}
122
153
  className={cn(
123
- "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-1.5 pl-7 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",
154
+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
124
155
  className
125
156
  )}
126
157
  checked={checked}
158
+ disabled={disabled}
159
+ onClick={(event) => {
160
+ if (disabled) {
161
+ event.preventDefault()
162
+ return
163
+ }
164
+ onClick?.(event)
165
+ }}
166
+ onMouseDown={disabled ? undefined : onMouseDown}
167
+ onKeyDown={disabled ? undefined : onKeyDown}
168
+ onKeyUp={disabled ? undefined : onKeyUp}
169
+ onPointerDown={(event) => {
170
+ if (disabled) {
171
+ event.preventDefault()
172
+ return
173
+ }
174
+ onPointerDown?.(event)
175
+ }}
127
176
  {...props}
128
177
  >
129
- <span className="pointer-events-none absolute left-1.5 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
130
- <MenuPrimitive.CheckboxItemIndicator>
131
- <CheckIcon
132
- />
133
- </MenuPrimitive.CheckboxItemIndicator>
178
+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
179
+ <MenubarPrimitive.ItemIndicator>
180
+ <CheckIcon className="size-4" />
181
+ </MenubarPrimitive.ItemIndicator>
134
182
  </span>
135
183
  {children}
136
- </MenuPrimitive.CheckboxItem>
184
+ </MenubarPrimitive.CheckboxItem>
137
185
  )
138
186
  }
139
187
 
140
- function MenubarRadioGroup({
141
- ...props
142
- }: React.ComponentProps<typeof DropdownMenuRadioGroup>) {
143
- return <DropdownMenuRadioGroup data-slot="menubar-radio-group" {...props} />
144
- }
145
-
146
188
  function MenubarRadioItem({
147
189
  className,
148
190
  children,
149
- inset,
191
+ disabled,
192
+ onClick,
193
+ onMouseDown,
194
+ onKeyDown,
195
+ onKeyUp,
196
+ onPointerDown,
150
197
  ...props
151
- }: MenuPrimitive.RadioItem.Props & {
152
- inset?: boolean
153
- }) {
198
+ }: React.ComponentProps<typeof MenubarPrimitive.RadioItem>) {
154
199
  return (
155
- <MenuPrimitive.RadioItem
200
+ <MenubarPrimitive.RadioItem
156
201
  data-slot="menubar-radio-item"
157
- data-inset={inset}
158
202
  className={cn(
159
- "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-1.5 pl-7 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",
203
+ "focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
160
204
  className
161
205
  )}
206
+ disabled={disabled}
207
+ onClick={(event) => {
208
+ if (disabled) {
209
+ event.preventDefault()
210
+ return
211
+ }
212
+ onClick?.(event)
213
+ }}
214
+ onMouseDown={disabled ? undefined : onMouseDown}
215
+ onKeyDown={disabled ? undefined : onKeyDown}
216
+ onKeyUp={disabled ? undefined : onKeyUp}
217
+ onPointerDown={(event) => {
218
+ if (disabled) {
219
+ event.preventDefault()
220
+ return
221
+ }
222
+ onPointerDown?.(event)
223
+ }}
162
224
  {...props}
163
225
  >
164
- <span className="pointer-events-none absolute left-1.5 flex size-4 items-center justify-center [&_svg:not([class*='size-'])]:size-4">
165
- <MenuPrimitive.RadioItemIndicator>
166
- <CheckIcon
167
- />
168
- </MenuPrimitive.RadioItemIndicator>
226
+ <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
227
+ <MenubarPrimitive.ItemIndicator>
228
+ <CircleIcon className="size-2 fill-current" />
229
+ </MenubarPrimitive.ItemIndicator>
169
230
  </span>
170
231
  {children}
171
- </MenuPrimitive.RadioItem>
232
+ </MenubarPrimitive.RadioItem>
172
233
  )
173
234
  }
174
235
 
@@ -176,15 +237,15 @@ function MenubarLabel({
176
237
  className,
177
238
  inset,
178
239
  ...props
179
- }: React.ComponentProps<typeof DropdownMenuLabel> & {
240
+ }: React.ComponentProps<typeof MenubarPrimitive.Label> & {
180
241
  inset?: boolean
181
242
  }) {
182
243
  return (
183
- <DropdownMenuLabel
244
+ <MenubarPrimitive.Label
184
245
  data-slot="menubar-label"
185
246
  data-inset={inset}
186
247
  className={cn(
187
- "px-1.5 py-1 text-sm font-medium data-inset:pl-7",
248
+ "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
188
249
  className
189
250
  )}
190
251
  {...props}
@@ -195,11 +256,11 @@ function MenubarLabel({
195
256
  function MenubarSeparator({
196
257
  className,
197
258
  ...props
198
- }: React.ComponentProps<typeof DropdownMenuSeparator>) {
259
+ }: React.ComponentProps<typeof MenubarPrimitive.Separator>) {
199
260
  return (
200
- <DropdownMenuSeparator
261
+ <MenubarPrimitive.Separator
201
262
  data-slot="menubar-separator"
202
- className={cn("-mx-1 my-1 h-px bg-border", className)}
263
+ className={cn("bg-border -mx-1 my-1 h-px", className)}
203
264
  {...props}
204
265
  />
205
266
  )
@@ -208,12 +269,12 @@ function MenubarSeparator({
208
269
  function MenubarShortcut({
209
270
  className,
210
271
  ...props
211
- }: React.ComponentProps<typeof DropdownMenuShortcut>) {
272
+ }: React.ComponentProps<"span">) {
212
273
  return (
213
- <DropdownMenuShortcut
274
+ <span
214
275
  data-slot="menubar-shortcut"
215
276
  className={cn(
216
- "ml-auto text-xs tracking-widest text-muted-foreground group-focus/menubar-item:text-accent-foreground",
277
+ "text-muted-foreground ml-auto text-xs tracking-widest",
217
278
  className
218
279
  )}
219
280
  {...props}
@@ -223,38 +284,45 @@ function MenubarShortcut({
223
284
 
224
285
  function MenubarSub({
225
286
  ...props
226
- }: React.ComponentProps<typeof DropdownMenuSub>) {
227
- return <DropdownMenuSub data-slot="menubar-sub" {...props} />
287
+ }: React.ComponentProps<typeof MenubarPrimitive.Sub>) {
288
+ return <MenubarPrimitive.Sub data-slot="menubar-sub" {...props} />
228
289
  }
229
290
 
230
291
  function MenubarSubTrigger({
231
292
  className,
232
293
  inset,
294
+ children,
233
295
  ...props
234
- }: React.ComponentProps<typeof DropdownMenuSubTrigger> & {
296
+ }: React.ComponentProps<typeof MenubarPrimitive.SubTrigger> & {
235
297
  inset?: boolean
236
298
  }) {
237
299
  return (
238
- <DropdownMenuSubTrigger
300
+ <MenubarPrimitive.SubTrigger
239
301
  data-slot="menubar-sub-trigger"
240
302
  data-inset={inset}
241
303
  className={cn(
242
- "gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg:not([class*='size-'])]:size-4",
304
+ "focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[inset]:pl-8",
243
305
  className
244
306
  )}
245
307
  {...props}
246
- />
308
+ >
309
+ {children}
310
+ <ChevronRightIcon className="ml-auto h-4 w-4" />
311
+ </MenubarPrimitive.SubTrigger>
247
312
  )
248
313
  }
249
314
 
250
315
  function MenubarSubContent({
251
316
  className,
252
317
  ...props
253
- }: React.ComponentProps<typeof DropdownMenuSubContent>) {
318
+ }: React.ComponentProps<typeof MenubarPrimitive.SubContent>) {
254
319
  return (
255
- <DropdownMenuSubContent
320
+ <MenubarPrimitive.SubContent
256
321
  data-slot="menubar-sub-content"
257
- className={cn("min-w-32 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 )}
322
+ className={cn(
323
+ "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 z-50 min-w-[8rem] origin-(--radix-menubar-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
324
+ className
325
+ )}
258
326
  {...props}
259
327
  />
260
328
  )
@@ -1,19 +1,22 @@
1
- import { NavigationMenu as NavigationMenuPrimitive } from "@base-ui/react/navigation-menu"
1
+ import * as React from "react"
2
+ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu"
2
3
  import { cva } from "class-variance-authority"
4
+ import { ChevronDownIcon } from "lucide-react"
3
5
 
4
6
  import { cn } from "@/lib/utils"
5
- import { ChevronDownIcon } from "lucide-react"
6
7
 
7
8
  function NavigationMenu({
8
- align = "start",
9
9
  className,
10
10
  children,
11
+ viewport = true,
11
12
  ...props
12
- }: NavigationMenuPrimitive.Root.Props &
13
- Pick<NavigationMenuPrimitive.Positioner.Props, "align">) {
13
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {
14
+ viewport?: boolean
15
+ }) {
14
16
  return (
15
17
  <NavigationMenuPrimitive.Root
16
18
  data-slot="navigation-menu"
19
+ data-viewport={viewport}
17
20
  className={cn(
18
21
  "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center",
19
22
  className
@@ -21,7 +24,7 @@ function NavigationMenu({
21
24
  {...props}
22
25
  >
23
26
  {children}
24
- <NavigationMenuPositioner align={align} />
27
+ {viewport && <NavigationMenuViewport />}
25
28
  </NavigationMenuPrimitive.Root>
26
29
  )
27
30
  }
@@ -29,12 +32,12 @@ function NavigationMenu({
29
32
  function NavigationMenuList({
30
33
  className,
31
34
  ...props
32
- }: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.List>) {
35
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.List>) {
33
36
  return (
34
37
  <NavigationMenuPrimitive.List
35
38
  data-slot="navigation-menu-list"
36
39
  className={cn(
37
- "group flex flex-1 list-none items-center justify-center gap-0",
40
+ "group flex flex-1 list-none items-center justify-center gap-1",
38
41
  className
39
42
  )}
40
43
  {...props}
@@ -45,7 +48,7 @@ function NavigationMenuList({
45
48
  function NavigationMenuItem({
46
49
  className,
47
50
  ...props
48
- }: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.Item>) {
51
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) {
49
52
  return (
50
53
  <NavigationMenuPrimitive.Item
51
54
  data-slot="navigation-menu-item"
@@ -56,14 +59,14 @@ function NavigationMenuItem({
56
59
  }
57
60
 
58
61
  const navigationMenuTriggerStyle = cva(
59
- "group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all outline-none hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted"
62
+ "group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium enabled:hover:bg-accent enabled:hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-50 enabled:data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 focus-visible:ring-ring/20 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1"
60
63
  )
61
64
 
62
65
  function NavigationMenuTrigger({
63
66
  className,
64
67
  children,
65
68
  ...props
66
- }: NavigationMenuPrimitive.Trigger.Props) {
69
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
67
70
  return (
68
71
  <NavigationMenuPrimitive.Trigger
69
72
  data-slot="navigation-menu-trigger"
@@ -71,7 +74,10 @@ function NavigationMenuTrigger({
71
74
  {...props}
72
75
  >
73
76
  {children}{" "}
74
- <ChevronDownIcon className="relative top-px ml-1 size-3 transition duration-300 group-data-popup-open/navigation-menu-trigger:rotate-180 group-data-open/navigation-menu-trigger:rotate-180" aria-hidden="true" />
77
+ <ChevronDownIcon
78
+ className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
79
+ aria-hidden="true"
80
+ />
75
81
  </NavigationMenuPrimitive.Trigger>
76
82
  )
77
83
  }
@@ -79,12 +85,13 @@ function NavigationMenuTrigger({
79
85
  function NavigationMenuContent({
80
86
  className,
81
87
  ...props
82
- }: NavigationMenuPrimitive.Content.Props) {
88
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) {
83
89
  return (
84
90
  <NavigationMenuPrimitive.Content
85
91
  data-slot="navigation-menu-content"
86
92
  className={cn(
87
- "data-ending-style:data-activation-direction=left:translate-x-[50%] data-ending-style:data-activation-direction=right:translate-x-[-50%] data-starting-style:data-activation-direction=left:translate-x-[-50%] data-starting-style:data-activation-direction=right:translate-x-[50%] h-full w-auto p-1 transition-[opacity,transform,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[viewport=false]/navigation-menu:rounded-lg group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:ring-1 group-data-[viewport=false]/navigation-menu:ring-foreground/10 group-data-[viewport=false]/navigation-menu:duration-300 data-ending-style:opacity-0 data-starting-style:opacity-0 data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 data-[motion^=from-]:animate-in data-[motion^=from-]:fade-in data-[motion^=to-]:animate-out data-[motion^=to-]:fade-out **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none group-data-[viewport=false]/navigation-menu:data-open:animate-in group-data-[viewport=false]/navigation-menu:data-open:fade-in-0 group-data-[viewport=false]/navigation-menu:data-open:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-closed:animate-out group-data-[viewport=false]/navigation-menu:data-closed:fade-out-0 group-data-[viewport=false]/navigation-menu:data-closed:zoom-out-95",
93
+ "data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 top-0 left-0 w-full p-2 pr-2.5 md:absolute md:w-auto",
94
+ "group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-in group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-out group-data-[viewport=false]/navigation-menu:data-[state=closed]:zoom-out-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:zoom-in-95 group-data-[viewport=false]/navigation-menu:data-[state=open]:fade-in-0 group-data-[viewport=false]/navigation-menu:data-[state=closed]:fade-out-0 group-data-[viewport=false]/navigation-menu:top-full group-data-[viewport=false]/navigation-menu:mt-1.5 group-data-[viewport=false]/navigation-menu:overflow-hidden group-data-[viewport=false]/navigation-menu:rounded-md group-data-[viewport=false]/navigation-menu:border group-data-[viewport=false]/navigation-menu:shadow group-data-[viewport=false]/navigation-menu:duration-200 **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none",
88
95
  className
89
96
  )}
90
97
  {...props}
@@ -92,44 +99,37 @@ function NavigationMenuContent({
92
99
  )
93
100
  }
94
101
 
95
- function NavigationMenuPositioner({
102
+ function NavigationMenuViewport({
96
103
  className,
97
- side = "bottom",
98
- sideOffset = 8,
99
- align = "start",
100
- alignOffset = 0,
101
104
  ...props
102
- }: NavigationMenuPrimitive.Positioner.Props) {
105
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) {
103
106
  return (
104
- <NavigationMenuPrimitive.Portal>
105
- <NavigationMenuPrimitive.Positioner
106
- side={side}
107
- sideOffset={sideOffset}
108
- align={align}
109
- alignOffset={alignOffset}
107
+ <div
108
+ className={cn(
109
+ "absolute top-full left-0 isolate z-50 flex justify-center"
110
+ )}
111
+ >
112
+ <NavigationMenuPrimitive.Viewport
113
+ data-slot="navigation-menu-viewport"
110
114
  className={cn(
111
- "isolate z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] data-instant:transition-none data-[side=bottom]:before:top-[-10px] data-[side=bottom]:before:right-0 data-[side=bottom]:before:left-0",
115
+ "origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--radix-navigation-menu-viewport-width)]",
112
116
  className
113
117
  )}
114
118
  {...props}
115
- >
116
- <NavigationMenuPrimitive.Popup className="data-[ending-style]:easing-[ease] xs:w-(--popup-width) relative h-(--popup-height) w-(--popup-width) origin-(--transform-origin) rounded-lg bg-popover text-popover-foreground shadow ring-1 ring-foreground/10 transition-[opacity,transform,width,height,scale,translate] duration-[0.35s] ease-[cubic-bezier(0.22,1,0.36,1)] outline-none data-ending-style:scale-90 data-ending-style:opacity-0 data-ending-style:duration-150 data-starting-style:scale-90 data-starting-style:opacity-0">
117
- <NavigationMenuPrimitive.Viewport className="relative size-full overflow-hidden" />
118
- </NavigationMenuPrimitive.Popup>
119
- </NavigationMenuPrimitive.Positioner>
120
- </NavigationMenuPrimitive.Portal>
119
+ />
120
+ </div>
121
121
  )
122
122
  }
123
123
 
124
124
  function NavigationMenuLink({
125
125
  className,
126
126
  ...props
127
- }: NavigationMenuPrimitive.Link.Props) {
127
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) {
128
128
  return (
129
129
  <NavigationMenuPrimitive.Link
130
130
  data-slot="navigation-menu-link"
131
131
  className={cn(
132
- "flex items-center gap-2 rounded-lg p-2 text-sm transition-all outline-none hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 in-data-[slot=navigation-menu-content]:rounded-md data-active:bg-muted/50 data-active:hover:bg-muted data-active:focus:bg-muted [&_svg:not([class*='size-'])]:size-4",
132
+ "data-[active=true]:focus:bg-accent data-[active=true]:hover:bg-accent data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-ring/20 [&_svg:not([class*='text-'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&_svg:not([class*='size-'])]:size-4",
133
133
  className
134
134
  )}
135
135
  {...props}
@@ -140,29 +140,29 @@ function NavigationMenuLink({
140
140
  function NavigationMenuIndicator({
141
141
  className,
142
142
  ...props
143
- }: React.ComponentPropsWithRef<typeof NavigationMenuPrimitive.Icon>) {
143
+ }: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) {
144
144
  return (
145
- <NavigationMenuPrimitive.Icon
145
+ <NavigationMenuPrimitive.Indicator
146
146
  data-slot="navigation-menu-indicator"
147
147
  className={cn(
148
- "top-full z-1 flex h-1.5 items-end justify-center overflow-hidden data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:animate-in data-[state=visible]:fade-in",
148
+ "data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden",
149
149
  className
150
150
  )}
151
151
  {...props}
152
152
  >
153
- <div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
154
- </NavigationMenuPrimitive.Icon>
153
+ <div className="bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" />
154
+ </NavigationMenuPrimitive.Indicator>
155
155
  )
156
156
  }
157
157
 
158
158
  export {
159
159
  NavigationMenu,
160
- NavigationMenuContent,
161
- NavigationMenuIndicator,
162
- NavigationMenuItem,
163
- NavigationMenuLink,
164
160
  NavigationMenuList,
161
+ NavigationMenuItem,
162
+ NavigationMenuContent,
165
163
  NavigationMenuTrigger,
164
+ NavigationMenuLink,
165
+ NavigationMenuIndicator,
166
+ NavigationMenuViewport,
166
167
  navigationMenuTriggerStyle,
167
- NavigationMenuPositioner,
168
168
  }