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

ui/combobox and listadaptor: support for disabled list items #115

Merged
merged 2 commits into from
Dec 29, 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.4",
"version": "4.2.5",
"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
6 changes: 5 additions & 1 deletion pkg/ui/primitives/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
popoverClx='',
listItemClx='',
listItemSelectedClx='',
listItemDisabledClx='',
noCheckmark=false,
listItemImageClx='',
searchPlaceholder='Search...',
Expand All @@ -117,6 +118,7 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
popoverClx?: string
listItemClx?: string
listItemSelectedClx?: string
listItemDisabledClx?: string
listItemImageClx?: string
listItemImageSize?: number
noCheckmark?: boolean
Expand Down Expand Up @@ -192,11 +194,13 @@ const Combobox = <T, P extends ComboboxTriggerProps<T>>({
key={adaptor.getValue(el)}
value={adaptor.getValue(el)}
onSelect={handleSelect}
disabled={adaptor.isDisabled ? adaptor.isDisabled(el) : false}
className={cn(
'flex',
noCheckmark ? 'justify-start' : 'justify-between',
listItemClx,
(isCurrent(el) ? listItemSelectedClx : '')
(isCurrent(el) ? listItemSelectedClx : ''),
((adaptor.isDisabled && adaptor.isDisabled(el)) ? listItemDisabledClx : '')
)}
>
<div className='flex justify-start items-center gap-2'>
Expand Down
4 changes: 2 additions & 2 deletions pkg/ui/primitives/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ const CommandItem = React.forwardRef<
ref={ref}
className={cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none',
'aria-selected:bg-level-3 aria-selected:text-accent',
'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
'data-selected:bg-level-3 aria-selected:text-accent',
'data-[disabled]:pointer-events-none data-[disabled]:opacity-35',
className
)}
{...props}
Expand Down
1 change: 1 addition & 0 deletions pkg/ui/primitives/list-adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface ListAdaptor<T> {
valueEquals: (el: T, v: string) => boolean
getLabel?: (el: T) => string
getImageUrl?: (el: T) => string | null
isDisabled?: (el: T) => boolean
}

export {
Expand Down
5 changes: 5 additions & 0 deletions pkg/ui/tailwind/tailwind.config.hanzo-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,17 @@ export default {
20: '0.2',
25: '0.25',
30: '0.3',
35: '0.35',
40: '0.4',
45: '0.45',
50: '0.5',
55: '0.55',
60: '0.6',
65: '0.65',
70: '0.7',
75: '0.75',
80: '0.8',
85: '0.85',
90: '0.9',
95: '0.95',
100: '1',
Expand Down
Loading