11import React , { Component , createRef , Fragment } from 'react' ;
22import isEqual from 'lodash/isEqual' ;
33import './react-select.scss' ;
4+ import PropTypes from 'prop-types' ;
45
5- import NewSelect from '@data-driven-forms/common/src/select' ;
6+ import DataDrivenSelect from '@data-driven-forms/common/src/select' ;
67import { DropdownButton } from 'patternfly-react' ;
78import fnToString from '@data-driven-forms/common/src/utils/fn-to-string' ;
89import clsx from 'clsx' ;
910import Option from './option' ;
1011import DropdownIndicator from './dropdown-indicator' ;
1112import ClearIndicator from './clear-indicator' ;
1213import './react-select.scss' ;
14+ import { optionsPropType } from '@data-driven-forms/common/src/prop-types-templates' ;
1315
1416const getDropdownText = ( value , placeholder , options ) => {
1517 if ( Array . isArray ( value ) ) {
@@ -55,6 +57,10 @@ class SearchInput extends Component {
5557
5658}
5759
60+ SearchInput . propTypes = {
61+ value : PropTypes . any ,
62+ } ;
63+
5864const SelectTitle = ( { title, classNamePrefix, isClearable, value, onClear, isFetching, isDisabled } ) => (
5965 < Fragment >
6066 < span key = "searchable-select-value-label" className = { `${ classNamePrefix } -value` } > { title } </ span >
@@ -77,6 +83,16 @@ const SelectTitle = ({ title, classNamePrefix, isClearable, value, onClear, isFe
7783 </ Fragment >
7884) ;
7985
86+ SelectTitle . propTypes = {
87+ title : PropTypes . string . isRequired ,
88+ classNamePrefix : PropTypes . string ,
89+ isClearable : PropTypes . bool ,
90+ value : PropTypes . any ,
91+ onClear : PropTypes . func ,
92+ isFetching : PropTypes . bool ,
93+ isDisabled : PropTypes . bool ,
94+ } ;
95+
8096class Select extends Component { constructor ( props ) {
8197 super ( props ) ;
8298 this . state = {
@@ -171,7 +187,7 @@ class Select extends Component { constructor(props){
171187 disabled = { props . isDisabled }
172188 noCaret
173189 open = { isOpen }
174- id = { props . id || props . input . name }
190+ id = { props . id || input . name }
175191 title = { < SelectTitle
176192 isDisabled = { props . isDisabled }
177193 isFetching = { isFetching }
@@ -185,7 +201,7 @@ class Select extends Component { constructor(props){
185201 'is-empty' : isPlaceholder ,
186202 } ) } >
187203 { isOpen &&
188- < NewSelect
204+ < DataDrivenSelect
189205 isFetching = { isFetching }
190206 input = { searchableInput }
191207 { ...props }
@@ -216,7 +232,7 @@ class Select extends Component { constructor(props){
216232 }
217233
218234 return (
219- < NewSelect
235+ < DataDrivenSelect
220236 { ...this . props }
221237 isFetching = { isFetching }
222238 options = { options }
@@ -237,4 +253,15 @@ Select.defaultProps = {
237253 placeholder : 'Search...' ,
238254} ;
239255
256+ Select . propTypes = {
257+ input : PropTypes . shape ( {
258+ name : PropTypes . string . isRequired ,
259+ onChange : PropTypes . func . isRequired ,
260+ value : PropTypes . any ,
261+ } ) . isRequired ,
262+ classNamePrefix : PropTypes . string ,
263+ loadOptions : PropTypes . func ,
264+ options : optionsPropType ,
265+ } ;
266+
240267export default Select ;
0 commit comments