PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 / MultiFormGoals / resources / js / components / multi-select-control / index.js

index.js in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/MultiFormGoals/resources/js/components/multi-select-control/index.js

80 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Vendor dependencies
3 */
4 import PropTypes from 'prop-types';
5 import Select from 'react-select';
6
7 /**
8 * WordPress dependencies
9 */
10 const {useInstanceId} = wp.compose;
11 const {BaseControl} = wp.components;
12 import { __ } from '@wordpress/i18n'
13
14 /**
15 * Styles
16 */
17 import './style.scss';
18
19 const MultiSelectControl = ({
20 name,
21 label = null,
22 help,
23 className,
24 value = null,
25 placeholder = `${__('Select', 'give')}...`,
26 hideLabelFromVision,
27 isLoading,
28 isDisabled,
29 onChange = null,
30 options = null,
31 }) => {
32 const instanceId = useInstanceId(MultiSelectControl);
33 const id = `give-multi-select-control-${name}-${instanceId}`;
34
35 if (options && options.length < 1) {
36 return null;
37 }
38 return (
39 <BaseControl label={label} hideLabelFromVision={hideLabelFromVision} id={id} help={help} className={className}>
40 <Select
41 isLoading={isLoading}
42 inputId={id}
43 value={value}
44 onChange={(selectedOptions) => onChange(selectedOptions)}
45 options={options}
46 maxMenuHeight="200px"
47 isDisabled={isDisabled}
48 placeholder={placeholder}
49 isMulti={true}
50 theme={(theme) => ({
51 ...theme,
52 colors: {
53 ...theme.colors,
54 primary: '#007cba',
55 primary75: '#31a6e0',
56 primary50: '#5dbae8',
57 primary25: '#9edaf7',
58 },
59 })}
60 />
61 </BaseControl>
62 );
63 };
64
65 MultiSelectControl.propTypes = {
66 label: PropTypes.string,
67 value: PropTypes.any.isRequired,
68 onChange: PropTypes.func,
69 options: PropTypes.array.isRequired,
70 name: PropTypes.string.isRequired,
71 help: PropTypes.string,
72 className: PropTypes.string,
73 hideLabelFromVision: PropTypes.bool,
74 isLoading: PropTypes.bool,
75 isDisabled: PropTypes.bool,
76 placeholder: PropTypes.string,
77 };
78
79 export default MultiSelectControl;
80