1
1
import { action } from "@storybook/addon-actions" ;
2
2
import { useEffect , useState } from "react" ;
3
- import { MultiValue , SingleValue } from "react-select" ;
4
3
5
4
import Select from "." ;
6
- import { ISelectProps , Option } from "./types" ;
5
+ import { ISelectProps } from "./types" ;
7
6
8
7
export default {
9
8
title : "Input/Select" ,
@@ -17,43 +16,7 @@ export default {
17
16
} ;
18
17
19
18
export const SingleSelect = ( args : ISelectProps ) => {
20
- const [ input , setInput ] = useState <
21
- Record <
22
- string ,
23
- MultiValue < Option | undefined > | SingleValue < Option | undefined >
24
- >
25
- > ( {
26
- foo : {
27
- value : "foo" ,
28
- label : "foo"
29
- }
30
- } ) ;
31
-
32
- useEffect ( ( ) => {
33
- console . log ( input ) ;
34
- } , [ input ] ) ;
35
-
36
- return < Select { ...args } name = 'foo' value = { input . foo } onChange = { setInput } /> ;
37
- } ;
38
-
39
- SingleSelect . args = {
40
- name : "single-select" ,
41
- onChange : action ( "onChange" ) ,
42
- options : [
43
- { value : "foo" , label : "Foo" } ,
44
- { value : "bar" , label : "Bar" } ,
45
- { value : "baz" , label : "Baz" }
46
- ] ,
47
- value : "foo"
48
- } ;
49
-
50
- export const SingleSelectWithStringValue = ( args : ISelectProps ) => {
51
- const [ input , setInput ] = useState <
52
- Record <
53
- string ,
54
- MultiValue < Option | undefined > | SingleValue < Option | undefined | string >
55
- >
56
- > ( {
19
+ const [ input , setInput ] = useState < Record < string , string [ ] | string > > ( {
57
20
foo : "foo"
58
21
} ) ;
59
22
@@ -64,7 +27,7 @@ export const SingleSelectWithStringValue = (args: ISelectProps) => {
64
27
return < Select { ...args } name = 'foo' value = { input . foo } onChange = { setInput } /> ;
65
28
} ;
66
29
67
- SingleSelectWithStringValue . args = {
30
+ SingleSelect . args = {
68
31
name : "single-select" ,
69
32
onChange : action ( "onChange" ) ,
70
33
options : [
@@ -76,43 +39,7 @@ SingleSelectWithStringValue.args = {
76
39
} ;
77
40
78
41
export const MultiSelect = ( args : ISelectProps ) => {
79
- const [ input , setInput ] = useState <
80
- Record <
81
- string ,
82
- MultiValue < Option | undefined > | SingleValue < Option | undefined >
83
- >
84
- > ( {
85
- foo : [
86
- { value : "foo" , label : "foo" } ,
87
- { value : "bar" , label : "bar" }
88
- ]
89
- } ) ;
90
-
91
- useEffect ( ( ) => {
92
- console . log ( input ) ;
93
- } , [ input ] ) ;
94
-
95
- return < Select { ...args } value = { input . foo } onChange = { setInput } /> ;
96
- } ;
97
-
98
- MultiSelect . args = {
99
- name : "foo" ,
100
- isMulti : true ,
101
- options : [
102
- { value : "foo" , label : "Foo" } ,
103
- { value : "bar" , label : "Bar" } ,
104
- { value : "baz" , label : "Baz" }
105
- ]
106
- } ;
107
-
108
- export const MultiSelectWithStringArray = ( args : ISelectProps ) => {
109
- const [ input , setInput ] = useState <
110
- Record <
111
- string ,
112
- | MultiValue < Option | undefined >
113
- | SingleValue < Option | undefined | string [ ] >
114
- >
115
- > ( {
42
+ const [ input , setInput ] = useState < Record < string , string [ ] | string > > ( {
116
43
foo : [ "foo" , "bar" ]
117
44
} ) ;
118
45
@@ -123,7 +50,7 @@ export const MultiSelectWithStringArray = (args: ISelectProps) => {
123
50
return < Select { ...args } value = { input . foo } onChange = { setInput } /> ;
124
51
} ;
125
52
126
- MultiSelectWithStringArray . args = {
53
+ MultiSelect . args = {
127
54
name : "foo" ,
128
55
isMulti : true ,
129
56
options : [
0 commit comments