PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Views / Components / Select / index.js

index.js in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Views/Components/Select/index.js

32 lines 1018 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import PropTypes from 'prop-types';
2 import classNames from 'classnames';
3
4 import style from './style.module.scss';
5
6 const Select = ({options, onChange, defaultValue, className, ...rest}) => {
7 const optionElements = options.map((option) => (
8 <option key={option.value} value={option.value}>
9 {option.label}
10 </option>
11 ));
12 return (
13 <div key={defaultValue} className={classNames(style.select, className)}>
14 <select onChange={onChange} defaultValue={defaultValue} {...rest}>
15 {optionElements}
16 </select>
17 </div>
18 );
19 };
20
21 Select.propTypes = {
22 // Array of objects with labels and values defining select options (ex: {label: Option A, value: option-a})
23 options: PropTypes.array.isRequired,
24 // Fired on select change event
25 onChange: PropTypes.func,
26 // Default value of select element
27 defaultValue: PropTypes.string.isRequired,
28 // Additional class
29 className: PropTypes.string,
30 };
31 export default Select;
32