mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat: init * fix * fix * fix * feat * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: implement icons * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: update init command * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: dialog * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add registry:base item type * feat: rename frame to canva * fix * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fi * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add all colors * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add outfit font * fix * fix * fix * fix * fix * chore: changeset * fix * fix * fix * fix * fix * fix * fix * fix
285 lines
9.1 KiB
TypeScript
285 lines
9.1 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
|
|
|
|
import { cn } from "@/registry/bases/base/lib/utils"
|
|
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"
|
|
|
|
function Picker({ ...props }: MenuPrimitive.Root.Props) {
|
|
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
}
|
|
|
|
function PickerPortal({ ...props }: MenuPrimitive.Portal.Props) {
|
|
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
}
|
|
|
|
function PickerTrigger({ className, ...props }: MenuPrimitive.Trigger.Props) {
|
|
return (
|
|
<MenuPrimitive.Trigger
|
|
data-slot="dropdown-menu-trigger"
|
|
className={cn(
|
|
"hover:bg-muted data-popup-open:bg-muted border-foreground/10 bg-muted/50 relative w-[160px] shrink-0 touch-manipulation rounded-xl border p-2 select-none disabled:opacity-50 md:w-full md:rounded-lg md:border-transparent md:bg-transparent",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerContent({
|
|
align = "start",
|
|
alignOffset = 0,
|
|
side = "bottom",
|
|
sideOffset = 4,
|
|
anchor,
|
|
className,
|
|
...props
|
|
}: MenuPrimitive.Popup.Props &
|
|
Pick<
|
|
MenuPrimitive.Positioner.Props,
|
|
"align" | "alignOffset" | "side" | "sideOffset" | "anchor"
|
|
>) {
|
|
return (
|
|
<MenuPrimitive.Portal>
|
|
<MenuPrimitive.Positioner
|
|
className="isolate z-50 outline-none"
|
|
align={align}
|
|
alignOffset={alignOffset}
|
|
side={side}
|
|
sideOffset={sideOffset}
|
|
anchor={anchor}
|
|
>
|
|
<MenuPrimitive.Popup
|
|
data-slot="dropdown-menu-content"
|
|
className={cn(
|
|
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 bg-popover text-popover-foreground cn-menu-target ring-foreground/10 no-scrollbar z-50 max-h-(--available-height) w-[calc(var(--available-width)-(--spacing(3.5)))] min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl border-0 p-1 shadow-md ring-1 duration-100 outline-none data-closed:overflow-hidden md:w-52",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</MenuPrimitive.Positioner>
|
|
<div className="absolute inset-0 z-40 bg-transparent" />
|
|
</MenuPrimitive.Portal>
|
|
)
|
|
}
|
|
|
|
function PickerGroup({ ...props }: MenuPrimitive.Group.Props) {
|
|
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
}
|
|
|
|
function PickerLabel({
|
|
className,
|
|
inset,
|
|
...props
|
|
}: MenuPrimitive.GroupLabel.Props & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<MenuPrimitive.GroupLabel
|
|
data-slot="dropdown-menu-label"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"text-muted-foreground px-2 py-1.5 text-xs font-medium data-[inset]:pl-8",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerItem({
|
|
className,
|
|
inset,
|
|
variant = "default",
|
|
...props
|
|
}: MenuPrimitive.Item.Props & {
|
|
inset?: boolean
|
|
variant?: "default" | "destructive"
|
|
}) {
|
|
return (
|
|
<MenuPrimitive.Item
|
|
data-slot="dropdown-menu-item"
|
|
data-inset={inset}
|
|
data-variant={variant}
|
|
className={cn(
|
|
"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 not-data-[variant=destructive]:focus:**:text-accent-foreground group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 pointer-coarse:py-2.5 pointer-coarse:pl-3 pointer-coarse:text-base [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
|
|
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
|
|
}
|
|
|
|
function PickerSubTrigger({
|
|
className,
|
|
inset,
|
|
children,
|
|
...props
|
|
}: MenuPrimitive.SubmenuTrigger.Props & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<MenuPrimitive.SubmenuTrigger
|
|
data-slot="dropdown-menu-sub-trigger"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<IconPlaceholder
|
|
lucide="ChevronRightIcon"
|
|
tabler="IconChevronRight"
|
|
hugeicons="ArrowRight01Icon"
|
|
className="ml-auto"
|
|
/>
|
|
</MenuPrimitive.SubmenuTrigger>
|
|
)
|
|
}
|
|
|
|
function PickerSubContent({
|
|
align = "start",
|
|
alignOffset = -3,
|
|
side = "right",
|
|
sideOffset = 0,
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof PickerContent>) {
|
|
return (
|
|
<PickerContent
|
|
data-slot="dropdown-menu-sub-content"
|
|
className={cn(
|
|
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 ring-foreground/10 bg-popover text-popover-foreground w-auto min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100",
|
|
className
|
|
)}
|
|
align={align}
|
|
alignOffset={alignOffset}
|
|
side={side}
|
|
sideOffset={sideOffset}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerCheckboxItem({
|
|
className,
|
|
children,
|
|
checked,
|
|
...props
|
|
}: MenuPrimitive.CheckboxItem.Props) {
|
|
return (
|
|
<MenuPrimitive.CheckboxItem
|
|
data-slot="dropdown-menu-checkbox-item"
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
checked={checked}
|
|
{...props}
|
|
>
|
|
<span className="pointer-events-none absolute right-2 flex items-center justify-center">
|
|
<MenuPrimitive.CheckboxItemIndicator>
|
|
<IconPlaceholder
|
|
lucide="CheckIcon"
|
|
tabler="IconCheck"
|
|
hugeicons="Tick02Icon"
|
|
/>
|
|
</MenuPrimitive.CheckboxItemIndicator>
|
|
</span>
|
|
{children}
|
|
</MenuPrimitive.CheckboxItem>
|
|
)
|
|
}
|
|
|
|
function PickerRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
|
|
return (
|
|
<MenuPrimitive.RadioGroup
|
|
data-slot="dropdown-menu-radio-group"
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerRadioItem({
|
|
className,
|
|
children,
|
|
...props
|
|
}: MenuPrimitive.RadioItem.Props) {
|
|
return (
|
|
<MenuPrimitive.RadioItem
|
|
data-slot="dropdown-menu-radio-item"
|
|
className={cn(
|
|
"focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-lg py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 pointer-coarse:gap-3 pointer-coarse:py-2.5 pointer-coarse:pl-3 pointer-coarse:text-base [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<span
|
|
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
data-slot="dropdown-menu-radio-item-indicator"
|
|
>
|
|
<MenuPrimitive.RadioItemIndicator>
|
|
<IconPlaceholder
|
|
lucide="CheckIcon"
|
|
tabler="IconCheck"
|
|
hugeicons="Tick02Icon"
|
|
className="size-4 pointer-coarse:size-5"
|
|
/>
|
|
</MenuPrimitive.RadioItemIndicator>
|
|
</span>
|
|
{children}
|
|
</MenuPrimitive.RadioItem>
|
|
)
|
|
}
|
|
|
|
function PickerSeparator({
|
|
className,
|
|
...props
|
|
}: MenuPrimitive.Separator.Props) {
|
|
return (
|
|
<MenuPrimitive.Separator
|
|
data-slot="dropdown-menu-separator"
|
|
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function PickerShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
return (
|
|
<span
|
|
data-slot="dropdown-menu-shortcut"
|
|
className={cn(
|
|
"text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {
|
|
Picker,
|
|
PickerPortal,
|
|
PickerTrigger,
|
|
PickerContent,
|
|
PickerGroup,
|
|
PickerLabel,
|
|
PickerItem,
|
|
PickerCheckboxItem,
|
|
PickerRadioGroup,
|
|
PickerRadioItem,
|
|
PickerSeparator,
|
|
PickerShortcut,
|
|
PickerSub,
|
|
PickerSubTrigger,
|
|
PickerSubContent,
|
|
}
|