dropdown-menu.tsx
This file
Path
apps/web/src/components/ui/dropdown-menu.tsx
269 lines · 8.5 KiB · TypeScript
Last changed by
Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–41why, one step back1import { Menu as MenuPrimitive } from "@base-ui/react/menu";2import { cn } from "cn";3import { ChevronRightIcon, CheckIcon } from "lucide-react";4import * as React from "react";56function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {7 return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />;8}910function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {11 return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />;12}1314function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {15 return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;16}1718function DropdownMenuContent({19 align = "start",20 alignOffset = 0,21 side = "bottom",22 sideOffset = 4,23 className,24 ...props25}: MenuPrimitive.Popup.Props &26 Pick<27 MenuPrimitive.Positioner.Props,28 "align" | "alignOffset" | "side" | "sideOffset"29 >) {30 return (31 <MenuPrimitive.Portal>32 <MenuPrimitive.Positioner33 className="isolate z-50 outline-none"34 align={align}35 alignOffset={alignOffset}36 side={side}37 sideOffset={sideOffset}38 >39 <MenuPrimitive.Popup40 data-slot="dropdown-menu-content"41 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 42why, one step back42 "bg-popover text-popover-foreground ring-input 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 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-none ring-1 duration-100 outline-none data-closed:overflow-hidden",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 43–67why, one step back43 className44 )}45 {...props}46 />47 </MenuPrimitive.Positioner>48 </MenuPrimitive.Portal>49 );50}5152function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {53 return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />;54}5556function DropdownMenuLabel({57 className,58 inset,59 ...props60}: MenuPrimitive.GroupLabel.Props & {61 inset?: boolean;62}) {63 return (64 <MenuPrimitive.GroupLabel65 data-slot="dropdown-menu-label"66 data-inset={inset}67 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 68why, one step back68 "text-muted-foreground text-label px-2 py-2 data-inset:pl-7",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 69–90why, one step back69 className70 )}71 {...props}72 />73 );74}7576function DropdownMenuItem({77 className,78 inset,79 variant = "default",80 ...props81}: MenuPrimitive.Item.Props & {82 inset?: boolean;83 variant?: "default" | "destructive";84}) {85 return (86 <MenuPrimitive.Item87 data-slot="dropdown-menu-item"88 data-inset={inset}89 data-variant={variant}90 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 91why, one step back91 "group/dropdown-menu-item focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground 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-[variant=destructive]:*:[svg]:text-destructive text-ui relative flex cursor-default items-center gap-2 rounded-none px-2 py-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 92–115why, one step back92 className93 )}94 {...props}95 />96 );97}9899function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {100 return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />;101}102103function DropdownMenuSubTrigger({104 className,105 inset,106 children,107 ...props108}: MenuPrimitive.SubmenuTrigger.Props & {109 inset?: boolean;110}) {111 return (112 <MenuPrimitive.SubmenuTrigger113 data-slot="dropdown-menu-sub-trigger"114 data-inset={inset}115 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 116why, one step back116 "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground text-ui flex cursor-default items-center gap-2 rounded-none px-2 py-2 outline-hidden select-none data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 117–138why, one step back117 className118 )}119 {...props}120 >121 {children}122 <ChevronRightIcon className="ml-auto" />123 </MenuPrimitive.SubmenuTrigger>124 );125}126127function DropdownMenuSubContent({128 align = "start",129 alignOffset = -3,130 side = "right",131 sideOffset = 0,132 className,133 ...props134}: React.ComponentProps<typeof DropdownMenuContent>) {135 return (136 <DropdownMenuContent137 data-slot="dropdown-menu-sub-content"138 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 139why, one step back139 "bg-popover text-popover-foreground ring-input 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 w-auto min-w-[96px] rounded-none ring-1 duration-100",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 140–164why, one step back140 className141 )}142 align={align}143 alignOffset={alignOffset}144 side={side}145 sideOffset={sideOffset}146 {...props}147 />148 );149}150151function DropdownMenuCheckboxItem({152 className,153 children,154 checked,155 inset,156 ...props157}: MenuPrimitive.CheckboxItem.Props & {158 inset?: boolean;159}) {160 return (161 <MenuPrimitive.CheckboxItem162 data-slot="dropdown-menu-checkbox-item"163 data-inset={inset}164 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 165why, one step back165 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground text-ui relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 166–205why, one step back166 className167 )}168 checked={checked}169 {...props}170 >171 <span172 className="pointer-events-none absolute right-2 flex items-center justify-center"173 data-slot="dropdown-menu-checkbox-item-indicator"174 >175 <MenuPrimitive.CheckboxItemIndicator>176 <CheckIcon />177 </MenuPrimitive.CheckboxItemIndicator>178 </span>179 {children}180 </MenuPrimitive.CheckboxItem>181 );182}183184function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {185 return (186 <MenuPrimitive.RadioGroup187 data-slot="dropdown-menu-radio-group"188 {...props}189 />190 );191}192193function DropdownMenuRadioItem({194 className,195 children,196 inset,197 ...props198}: MenuPrimitive.RadioItem.Props & {199 inset?: boolean;200}) {201 return (202 <MenuPrimitive.RadioItem203 data-slot="dropdown-menu-radio-item"204 data-inset={inset}205 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 206why, one step back206 "focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground text-ui relative flex cursor-default items-center gap-2 rounded-none py-2 pr-8 pl-2 outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 207–244why, one step back207 className208 )}209 {...props}210 >211 <span212 className="pointer-events-none absolute right-2 flex items-center justify-center"213 data-slot="dropdown-menu-radio-item-indicator"214 >215 <MenuPrimitive.RadioItemIndicator>216 <CheckIcon />217 </MenuPrimitive.RadioItemIndicator>218 </span>219 {children}220 </MenuPrimitive.RadioItem>221 );222}223224function DropdownMenuSeparator({225 className,226 ...props227}: MenuPrimitive.Separator.Props) {228 return (229 <MenuPrimitive.Separator230 data-slot="dropdown-menu-separator"231 className={cn("bg-border -mx-1 h-px", className)}232 {...props}233 />234 );235}236237function DropdownMenuShortcut({238 className,239 ...props240}: React.ComponentProps<"span">) {241 return (242 <span243 data-slot="dropdown-menu-shortcut"244 className={cn(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 245why, one step back245 "text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground text-label ml-auto",Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 246–269why, one step back246 className247 )}248 {...props}249 />250 );251}252253export {254 DropdownMenu,255 DropdownMenuPortal,256 DropdownMenuTrigger,257 DropdownMenuContent,258 DropdownMenuGroup,259 DropdownMenuLabel,260 DropdownMenuItem,261 DropdownMenuCheckboxItem,262 DropdownMenuRadioGroup,263 DropdownMenuRadioItem,264 DropdownMenuSeparator,265 DropdownMenuShortcut,266 DropdownMenuSub,267 DropdownMenuSubTrigger,268 DropdownMenuSubContent,269};