@@ -18,19 +18,20 @@ function stopDefaultEvent(event) {
1818}
1919
2020type Props = {
21- allowInvalidPills : boolean ,
21+ allowInvalidPills ? : boolean ,
2222 className ?: string ,
2323 disabled ?: boolean ,
2424 error ?: React . Node ,
2525 /** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
2626 getPillClassName ?: ( option : Option ) => string ,
2727 /** Function to retrieve the image URL associated with a pill */
2828 getPillImageUrl ?: ( data : { id : string | number , [ key : string ] : any } ) => string ,
29- inputProps : Object ,
29+ innerRef ?: React . Ref < any > ,
30+ inputProps ?: Object ,
3031 onInput : Function ,
3132 onRemove : Function ,
3233 onSuggestedPillAdd ?: Function ,
33- placeholder : string ,
34+ placeholder ? : string ,
3435 selectedOptions : Array < Object > | List < Object > ,
3536 /** Whether to show avatars in pills (if rounded style is enabled) */
3637 showAvatars ? : boolean ,
@@ -39,7 +40,7 @@ type Props = {
3940 suggestedPillsData ?: Array < Object > ,
4041 suggestedPillsFilter ?: SuggestedPillsFilter ,
4142 suggestedPillsTitle ?: string ,
42- validator : ( option : Option | OptionValue ) => boolean ,
43+ validator ? : ( option : Option | OptionValue ) => boolean ,
4344} ;
4445
4546type State = {
@@ -54,6 +55,7 @@ class PillSelector extends React.Component<Props, State> {
5455 error : '' ,
5556 inputProps : { } ,
5657 placeholder : '' ,
58+ // $FlowFixMe
5759 selectedOptions : [ ] ,
5860 validator : ( ) => true ,
5961 } ;
@@ -179,6 +181,7 @@ class PillSelector extends React.Component<Props, State> {
179181 onRemove ,
180182 onSuggestedPillAdd ,
181183 placeholder ,
184+ innerRef ,
182185 selectedOptions ,
183186 showAvatars ,
184187 showRoundedPills ,
@@ -213,13 +216,15 @@ class PillSelector extends React.Component<Props, State> {
213216 onClick = { this . handleClick }
214217 onFocus = { this . handleFocus }
215218 onKeyDown = { this . handleKeyDown }
219+ ref = { innerRef }
216220 >
217221 { showRoundedPills
218222 ? selectedOptions . map ( ( option : RoundOption , index : number ) => {
219223 return (
220224 < RoundPill
221225 className = { getPillClassName ? getPillClassName ( option ) : undefined }
222226 getPillImageUrl = { getPillImageUrl }
227+ // $FlowFixMe
223228 isValid = { allowInvalidPills ? validator ( option ) : true }
224229 isDisabled = { disabled }
225230 isSelected = { index === selectedIndex }
@@ -238,6 +243,7 @@ class PillSelector extends React.Component<Props, State> {
238243 // TODO: This and associated types will be removed once all views are updates with round pills.
239244 return (
240245 < Pill
246+ // $FlowFixMe
241247 isValid = { allowInvalidPills ? validator ( option ) : true }
242248 isDisabled = { disabled }
243249 isSelected = { index === selectedIndex }
@@ -289,4 +295,10 @@ class PillSelector extends React.Component<Props, State> {
289295 }
290296}
291297
292- export default PillSelector ;
298+ export { PillSelector as PillSelectorBase } ;
299+ const PillSelectorContainer = React . forwardRef < Props , React . Ref < any >> ( ( props : Props , ref : React . Ref < any > ) => (
300+ < PillSelector { ...props } innerRef = { ref } />
301+ ));
302+ PillSelectorContainer.displayName = 'PillSelector';
303+
304+ export default PillSelectorContainer;
0 commit comments