Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2467 from teamleadercrm/guild/typescript-select-p…
Browse files Browse the repository at this point in the history
…rops

Use typed SelectProps
  • Loading branch information
qubis741 authored Nov 29, 2022
2 parents 16d4a07 + 2f44dce commit 9f73b63
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

### Dependency updates

## [18.0.0] - 2022-11-29

### Changed

- [BREAKING] `Typescript`: All components and their props are typescript ([@qubis741](https://github.com/qubis741)) in [#2467](https://github.com/teamleadercrm/ui/pull/2467))

## [17.1.1] - 2022-11-23

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@teamleader/ui",
"description": "Teamleader UI library",
"version": "17.1.1",
"version": "18.0.0",
"author": "Teamleader <[email protected]>",
"bugs": {
"url": "https://github.com/teamleadercrm/ui/issues"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import MarketingMenuItem from './MarketingMenuItem';
import { IconExternalLinkSmallOutline } from '@teamleader/ui-icons';
import Menu, { MenuDivider, MenuItem } from '../menu';
import Box, { BoxProps } from '../box';
import { MenuListProps } from 'react-select';
import Select from '../select';
import Select, { Option, SelectComponentsProps } from '../select';
import { useCallback } from '@storybook/addons';

export default {
Expand Down Expand Up @@ -36,7 +35,7 @@ const options = [

export const DropdownWithUpsell: ComponentStory<typeof MarketingMenuItem> = (args) => {
const MenuList = useCallback(
(props: MenuListProps) => {
(props: SelectComponentsProps['MenuList']) => {
const { children, getStyles, innerRef, innerProps } = props;

return (
Expand All @@ -57,8 +56,9 @@ export const DropdownWithUpsell: ComponentStory<typeof MarketingMenuItem> = (arg
},
[args],
);
const handleChange = (option: Option) => console.log(option);

return <Select options={options} components={{ MenuList }} />;
return <Select options={options} onChange={handleChange} components={{ MenuList }} />;
};

DropdownWithUpsell.args = {
Expand Down
11 changes: 1 addition & 10 deletions src/components/select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,8 @@ const minHeightBySizeMap: Record<string, number> = {

export interface SelectRef<Option extends OptionType = OptionType, IsMulti extends boolean = false>
extends SelectType<Option, IsMulti> {}

export interface SelectProps<
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Option extends OptionType = OptionType,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IsMulti extends boolean = false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IsClearable extends boolean = false,
> {
[key: string]: any;
}
export interface SelectPropsFull<
Option extends OptionType = OptionType,
IsMulti extends boolean = false,
IsClearable extends boolean = false,
Expand Down
5 changes: 4 additions & 1 deletion src/components/select/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export interface Option<V = Value> {
[key: string]: any;
}

export interface GroupOption<O = Option> extends GroupBase<O> {}
export interface GroupOption<O = Option> {
options: O[];
label?: string;
}
export interface SelectComponentsProps<
OptionType extends Option = Option,
IsMulti extends boolean = false,
Expand Down

0 comments on commit 9f73b63

Please sign in to comment.