The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fix `InputSelect` icons
Tim Wilson82694184ef66
diff --git a/packages/ui/src/input-select.tsx b/packages/ui/src/input-select.tsxindex f6c568b253..960ed5a74f 100644--- a/packages/ui/src/input-select.tsx+++ b/packages/ui/src/input-select.tsx@@ -11,6 +11,7 @@ import { Command, useCommandState } from "cmdk";import { Check, ChevronDown, Search, X } from "lucide-react";import {Dispatch,+ HTMLAttributes,InputHTMLAttributes,ReactNode,SetStateAction,@@ -187,20 +188,7 @@ export function InputSelect({shouldFilter={false}loop>- <div- className={cn(- "group relative rounded-md border border-neutral-300 bg-white px-1 focus-within:border-neutral-500 focus-within:ring-1 focus-within:ring-neutral-500 md:min-w-[140px]",- className,- )}- >- <div className="absolute inset-y-0 left-0 flex items-center justify-center pl-3 text-neutral-400">- {iconElement}- </div>- <div className="flex h-10 px-8">- <CommandInput />- <CloseChevron />- </div>- </div>+ <InputGroup className={className} iconElement={iconElement} /></Command></Drawer.Trigger><Drawer.Overlay className="fixed inset-0 z-40 bg-neutral-100 bg-opacity-10 backdrop-blur" />@@ -223,20 +211,7 @@ export function InputSelect({shouldFilter={false}loop>- <div- className={cn(- "group relative mb-2 rounded-t-md border-b border-neutral-300 bg-white p-1 sm:border sm:py-0 sm:focus-within:border-neutral-500 sm:focus-within:ring-1 sm:focus-within:ring-neutral-200",- className,- )}- >- <div className="absolute inset-y-0 left-0 flex items-center justify-center pl-3 text-neutral-400">- {iconElement}- </div>- <div className="flex h-10 px-8">- <CommandInput />- <CloseChevron />- </div>- </div>+ <InputGroup className={className} iconElement={iconElement} />{openCommandList && (<Command.List className="dub-scrollbar h-[70vh] overflow-y-auto p-2">{items.length === 0 &&@@ -268,26 +243,12 @@ export function InputSelect({shouldFilter={false}loop>- <div- className={cn(- "group rounded-md border border-neutral-200 bg-white px-1 transition-all focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",- className,- )}- >- <div- onClick={() => setOpenCommandList((prev) => !prev)}- className="absolute inset-y-0 left-0 flex cursor-pointer items-center justify-center pl-3 text-neutral-400"- >- {iconElement}- </div>- <div className="flex h-10 px-8">- <CommandInput- ref={floatingRefs.setReference}- {...getReferenceProps()}- />- <CloseChevron />- </div>- </div>+ <InputGroup+ className={className}+ iconElement={iconElement}+ ref={floatingRefs.setReference}+ {...getReferenceProps()}+ />{openCommandList && (<divref={floatingRefs.setFloating}@@ -332,6 +293,33 @@ export function InputSelect({);}+type InputGroupProps = {+ iconElement: ReactNode;+} & HTMLAttributes<HTMLLabelElement>;++const InputGroup = forwardRef<HTMLLabelElement, InputGroupProps>(+ ({ iconElement, className, ...rest }: InputGroupProps, ref) => {+ return (+ <label+ ref={ref}+ className={cn(+ "group relative flex cursor-pointer gap-2 rounded-md border border-neutral-200 bg-white px-1 pl-3 transition-all focus-within:border-neutral-500 focus-within:ring-4 focus-within:ring-neutral-200",+ className,+ )}+ {...rest}+ >+ <div className="flex shrink-0 items-center justify-center text-neutral-400">+ {iconElement}+ </div>+ <div className="flex h-10 grow">+ <CommandInput />+ <CloseChevron />+ </div>+ </label>+ );+ },+);+const CommandInput = forwardRef<HTMLInputElement>((_, ref) => {const isEmpty = useCommandState((state: any) => state.filtered.count === 0);