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

Use typed SelectProps #2467

Merged
merged 6 commits into from
Nov 29, 2022
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
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe an alert is a better option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so, it is rather invasive and we dont do it anywhere else


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