-
Notifications
You must be signed in to change notification settings - Fork 8
feat(combobox): implement component #807
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
base: ods-react
Are you sure you want to change the base?
Conversation
271a191
to
44c6a33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- find and replace all
import type { ... }
withimport { type }
@@ -0,0 +1,96 @@ | |||
import type { ComboboxProp } from '../../context/useCombobox'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge with non type
export type ComboboxProp = Omit<ComponentPropsWithRef<'div'>, 'onSelect'> & { | ||
allowCustomValue?: boolean, | ||
children?: ReactNode, | ||
className?: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
children
and className
already come from ComponentPropsWithRef
children?: ReactNode, | ||
className?: string, | ||
customOptionRenderer?: (item: ComboboxItemOrGroup) => JSX.Element, | ||
defaultValue?: string[] | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove | undefined
, the ?
already does the same
|
||
interface ComboboxContextType { | ||
allowCustomValue: boolean; | ||
customOptionRenderer?: (item: ComboboxItemOrGroup) => ReactNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> JSX.Element
to be inline with the customOptionRenderer
return type of ComboboxProp
value?: string[] | ||
} | ||
|
||
interface ComboboxContextType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ComboboxContextType = ComboboxProp & { ... custom prop }
?
This will also avoid this diff between those two regarding ?
{ label: 'Goldfish', value: 'goldfish' }, | ||
]} | ||
value={value} | ||
onValueChange={details => setValue(details.value ?? [])} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can detail.value
actually be undefined?
noResultLabel = 'No results found', | ||
onValueChange, | ||
readOnly = false, | ||
value = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave empty as other components
newElementLabel = 'Add ', | ||
noResultLabel = 'No results found', | ||
onValueChange, | ||
readOnly = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave empty as other components
className, | ||
customOptionRenderer, | ||
defaultValue, | ||
disabled = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave empty as other components
...props | ||
}, ref): JSX.Element => { | ||
const [inputValue, setInputValue] = useState(''); | ||
const [internalValue, setInternalValue] = useState<string[]>(defaultValue || []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really mandatory to store the value? it should be available in the ark context already (see https://zagjs.com/components/react/combobox#machine-context)
No description provided.