6
6
import React from "react" ;
7
7
import PT from "prop-types" ;
8
8
import Select from "react-select" ;
9
+ import CreatableSelect from "react-select/creatable" ;
9
10
import "./styles.module.scss" ;
10
11
11
12
const ReactSelect = ( props ) => {
@@ -69,19 +70,38 @@ const ReactSelect = (props) => {
69
70
70
71
return (
71
72
< div styleName = "select-wrapper" >
72
- < Select
73
- value = { props . value }
74
- styles = { customStyles }
75
- onChange = { props . onChange }
76
- options = { props . options }
77
- styleName = { props . error ? "error" : "" }
78
- isMulti = { props . isMulti }
79
- onBlur = { props . onBlur }
80
- onFocus = { props . onFocus }
81
- placeholder = { props . placeholder }
82
- onInputChange = { props . onInputChange }
83
- isDisabled = { props . disabled }
84
- />
73
+ { props . isCreatable ? (
74
+ < CreatableSelect
75
+ value = { props . value }
76
+ styles = { customStyles }
77
+ onChange = { props . onChange }
78
+ options = { props . options }
79
+ styleName = { props . error ? "error" : "" }
80
+ isMulti = { props . isMulti }
81
+ onBlur = { props . onBlur }
82
+ onFocus = { props . onFocus }
83
+ placeholder = { props . placeholder }
84
+ onInputChange = { props . onInputChange }
85
+ noOptionsMessage = { ( ) => props . noOptionsText }
86
+ createOptionPosition = "first"
87
+ isDisabled = { props . disabled }
88
+ />
89
+ ) : (
90
+ < Select
91
+ value = { props . value }
92
+ styles = { customStyles }
93
+ onChange = { props . onChange }
94
+ options = { props . options }
95
+ styleName = { props . error ? "error" : "" }
96
+ isMulti = { props . isMulti }
97
+ onBlur = { props . onBlur }
98
+ onFocus = { props . onFocus }
99
+ placeholder = { props . placeholder }
100
+ onInputChange = { props . onInputChange }
101
+ noOptionsMessage = { ( ) => props . noOptionsText }
102
+ isDisabled = { props . disabled }
103
+ />
104
+ ) }
85
105
</ div >
86
106
) ;
87
107
} ;
@@ -101,6 +121,8 @@ ReactSelect.propTypes = {
101
121
label : PT . string . isRequired ,
102
122
} ) . isRequired
103
123
) ,
124
+ isCreatable : PT . bool ,
125
+ noOptionsText : PT . string ,
104
126
disabled : PT . bool ,
105
127
} ;
106
128
0 commit comments