Skip to content

Commit

Permalink
improve types, add missing render prop arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Jul 15, 2022
1 parent 1cdddae commit b4d9ce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ interface ComboboxRenderPropArg<T> {
disabled: boolean
activeIndex: number | null
activeOption: T | null
value: T
}

let ComboboxRoot = forwardRefWithAs(function Combobox<
Expand Down
7 changes: 4 additions & 3 deletions packages/@headlessui-react/src/components/listbox/listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ function stateReducer(state: StateDefinition, action: Actions) {
// ---

let DEFAULT_LISTBOX_TAG = Fragment
interface ListboxRenderPropArg {
interface ListboxRenderPropArg<TType> {
open: boolean
disabled: boolean
value: TType
}

let ListboxRoot = forwardRefWithAs(function Listbox<
Expand All @@ -311,7 +312,7 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
>(
props: Props<
TTag,
ListboxRenderPropArg,
ListboxRenderPropArg<TType>,
'value' | 'defaultValue' | 'onChange' | 'by' | 'disabled' | 'horizontal' | 'name' | 'multiple'
> & {
value?: TType
Expand Down Expand Up @@ -414,7 +415,7 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
listboxState === ListboxStates.Open
)

let slot = useMemo<ListboxRenderPropArg>(
let slot = useMemo<ListboxRenderPropArg<TType>>(
() => ({ open: listboxState === ListboxStates.Open, disabled, value }),
[listboxState, disabled, value]
)
Expand Down

0 comments on commit b4d9ce7

Please sign in to comment.