2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
27 * The HTML structure here is aligned with bootstrap HTML structure for form
28 * elements. In this way we have proper styling and it is aligned with other
29 * form elements on screen.
31 * Select and MultiSelect options:
33 * label - the label to be shown which paired with the input
35 * all other "react-select" props - as documented on
36 * http://jedwatson.github.io/react-select/
38 * https://github.com/JedWatson/react-select
40 import React, {Component} from 'react';
41 import Select from 'react-select';
43 class SelectInput extends Component {
48 let {label, value, ...other} = this.props;
50 <div className='validation-input-wrapper dropdown-multi-select'>
51 <div className='form-group'>
52 {label && <label className='control-label'>{label}</label>}
53 <Select ref='_myInput'
54 onChange={value => this.onSelectChanged(value)} {...other}
62 return this.inputValue && this.inputValue.length ? this.inputValue : '';
65 onSelectChanged(value) {
66 this.props.onMultiSelectChanged(value);
70 let {value} = this.props;
71 this.inputValue = value ? value : [];
74 componentDidUpdate() {
75 if (this.inputValue !== this.props.value) {
76 this.inputValue = this.props.value;
81 export default SelectInput;