UNPKG

@loke/design-system

Version:

A design system with individually importable components

3 lines (2 loc) 5.11 kB
"use client"; import{cn}from"@loke/design-system/cn";import{CheckIcon,ChevronDownIcon,ChevronUpIcon}from"@loke/icons";import*as SelectPrimitive from"@loke/ui/select";import{jsx,jsxs}from"react/jsx-runtime";function Select({...props}){return jsx(SelectPrimitive.Root,{"data-slot":"select",...props})}function SelectGroup({className,...props}){return jsx(SelectPrimitive.Group,{className:cn("scroll-my-1 p-1",className),"data-slot":"select-group",...props})}function SelectValue({...props}){return jsx(SelectPrimitive.Value,{"data-slot":"select-value",...props})}function SelectTrigger({className,size="default",children,...props}){return jsxs(SelectPrimitive.Trigger,{className:cn("flex w-fit select-none items-center justify-between gap-1.5 whitespace-nowrap rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-placeholder:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:hover:bg-input/50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",className),"data-size":size,"data-slot":"select-trigger",...props,children:[children,jsx(SelectPrimitive.Icon,{asChild:!0,children:jsx(ChevronDownIcon,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function SelectContent({className,children,position="item-aligned",align="center",...props}){return jsx(SelectPrimitive.Portal,{children:jsxs(SelectPrimitive.Content,{align,className:cn("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 relative z-50 max-h-(--loke-select-content-available-height) min-w-36 origin-(--loke-select-content-transform-origin) overflow-y-auto overflow-x-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-closed:animate-out data-open:animate-in",position==="popper"&&"data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",className),"data-align-trigger":position==="item-aligned","data-slot":"select-content",position,...props,children:[jsx(SelectScrollUpButton,{}),jsx(SelectPrimitive.Viewport,{className:cn("data-[position=popper]:h-(--loke-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--loke-select-trigger-width)",position==="popper"&&""),"data-position":position,children}),jsx(SelectScrollDownButton,{})]})})}function SelectLabel({className,...props}){return jsx(SelectPrimitive.Label,{className:cn("px-1.5 py-1 text-muted-foreground text-xs",className),"data-slot":"select-label",...props})}function SelectItem({className,children,...props}){return jsxs(SelectPrimitive.Item,{className:cn("relative flex w-full cursor-default select-none items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",className),"data-slot":"select-item",...props,children:[jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:jsx(SelectPrimitive.ItemIndicator,{children:jsx(CheckIcon,{className:"pointer-events-none"})})}),jsx(SelectPrimitive.ItemText,{children})]})}function SelectSeparator({className,...props}){return jsx(SelectPrimitive.Separator,{className:cn("pointer-events-none -mx-1 my-1 h-px bg-border",className),"data-slot":"select-separator",...props})}function SelectScrollUpButton({className,...props}){return jsx(SelectPrimitive.ScrollUpButton,{className:cn("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",className),"data-slot":"select-scroll-up-button",...props,children:jsx(ChevronUpIcon,{})})}function SelectScrollDownButton({className,...props}){return jsx(SelectPrimitive.ScrollDownButton,{className:cn("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",className),"data-slot":"select-scroll-down-button",...props,children:jsx(ChevronDownIcon,{})})}export{SelectValue,SelectTrigger,SelectSeparator,SelectScrollUpButton,SelectScrollDownButton,SelectLabel,SelectItem,SelectGroup,SelectContent,Select};