Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combobox improvements; ui@4.2.1 #114

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/ui",
"version": "4.2.0",
"version": "4.2.1",
"description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
12 changes: 6 additions & 6 deletions pkg/ui/primitives/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const DefaultTriggerInner = <T,>(
disabled={disabled}
>
<div className='flex justify-start items-center gap-2'>
{current ? (
{(current && imageUrl) ? (
<img
src={imageUrl!}
src={imageUrl}
alt={currentLabel + ' image'}
height={imageSize}
width={imageSize}
Expand Down Expand Up @@ -158,7 +158,7 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
return !!curr && adaptor.equals(el, curr)
}

const toSpread = current ? {
const _triggerProps = current ? {
...triggerProps,
current,
currentLabel: adaptor.getLabel ? adaptor.getLabel(current) : adaptor.getValue(current),
Expand All @@ -176,9 +176,9 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
<Popover open={_open} onOpenChange={_setOpen}>
<PopoverTrigger asChild>
{Trigger ? (
<Trigger<T, P> {...toSpread} />
<Trigger<T, P> {..._triggerProps} />
) : (
<DefaultTrigger<T, P> {...toSpread} />
<DefaultTrigger<T, P> {..._triggerProps} />
)}
</PopoverTrigger>
<PopoverContent className={cn('p-0', popoverClx)} align={popoverAlign} sideOffset={popoverSideOffset}>
Expand All @@ -202,7 +202,7 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
<div className='flex justify-start items-center gap-2'>
{ (adaptor.getImageUrl && adaptor.getImageUrl(el)) ? (
<img
src={adaptor.getImageUrl(el)}
src={adaptor.getImageUrl(el)!}
alt={adaptor.getValue(el) + ' image'}
height={listItemImageSize}
width={listItemImageSize}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/primitives/list-adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface ListAdaptor<T> {
equals: (el1: T, el2: T) => boolean
valueEquals: (el: T, v: string) => boolean
getLabel?: (el: T) => string
getImageUrl?: (el: T) => string
getImageUrl?: (el: T) => string | null
}

export {
Expand Down
Loading