Skip to content

Commit

Permalink
fix: update type definition to prevent primitive values as items
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-manba committed May 5, 2024
1 parent be805e4 commit 5d035f6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
11 changes: 11 additions & 0 deletions .changeset/great-singers-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@nextui-org/autocomplete": patch
"@nextui-org/dropdown": patch
"@nextui-org/listbox": patch
"@nextui-org/menu": patch
"@nextui-org/select": patch
"@nextui-org/tabs": patch
"@nextui-org/use-aria-multiselect": patch
---

Fix update type definition to prevent primitive values as items
4 changes: 2 additions & 2 deletions packages/components/autocomplete/src/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ function Autocomplete<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLI
);
}

export type AutocompleteProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type AutocompleteProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(Autocomplete) as <T = object>(
export default forwardRef(Autocomplete) as <T extends object>(
props: AutocompleteProps<T>,
) => ReactElement;

Expand Down
4 changes: 2 additions & 2 deletions packages/components/dropdown/src/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function DropdownMenu<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLU
);
}

export type DropdownMenuProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type DropdownMenuProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(DropdownMenu) as <T = object>(
export default forwardRef(DropdownMenu) as <T extends object>(
props: DropdownMenuProps<T>,
) => ReactElement;

Expand Down
4 changes: 2 additions & 2 deletions packages/components/listbox/src/listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function Listbox<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLUListE

Listbox.displayName = "NextUI.Listbox";

export type ListboxProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type ListboxProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(Listbox) as <T = object>(props: ListboxProps<T>) => ReactElement;
export default forwardRef(Listbox) as <T extends object>(props: ListboxProps<T>) => ReactElement;
4 changes: 2 additions & 2 deletions packages/components/menu/src/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ function Menu<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLUListElem
);
}

export type MenuProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type MenuProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(Menu) as <T = object>(props: MenuProps<T>) => ReactElement;
export default forwardRef(Menu) as <T extends object>(props: MenuProps<T>) => ReactElement;

Menu.displayName = "NextUI.Menu";
4 changes: 2 additions & 2 deletions packages/components/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ function Select<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLSelectE
);
}

export type SelectProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type SelectProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(Select) as <T = object>(props: SelectProps<T>) => ReactElement;
export default forwardRef(Select) as <T extends object>(props: SelectProps<T>) => ReactElement;

Select.displayName = "NextUI.Select";
4 changes: 2 additions & 2 deletions packages/components/tabs/src/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ function Tabs<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLDivElemen
return renderTabs;
}

export type TabsProps<T = object> = Props<T> & {ref?: Ref<HTMLElement>};
export type TabsProps<T extends object = object> = Props<T> & {ref?: Ref<HTMLElement>};

// forwardRef doesn't support generic parameters, so cast the result to the correct type
export default forwardRef(Tabs) as <T = object>(props: TabsProps<T>) => ReactElement;
export default forwardRef(Tabs) as <T extends object>(props: TabsProps<T>) => ReactElement;

Tabs.displayName = "NextUI.Tabs";

0 comments on commit 5d035f6

Please sign in to comment.