PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / src / components / multipleSelect / multipleSelect.js

multipleSelect.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at src/components/multipleSelect/multipleSelect.js

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import Select from "react-select";
2 import "./editor.scss";
3
4 const MultipleSelect = ({
5 attributes,
6 setAttributes,
7 attributesKey,
8 label,
9 items,
10 objectData = false,
11 value = false,
12 onChange = false,
13 flex = false,
14 reset = false,
15 onInputChange = false,
16 helpText = "",
17 }) => {
18 const defaultValues = items?.filter((f) => attributes.includes(f.value));
19 const updateValue = (data) => {
20 if (objectData) {
21 const updatedValues = data?.map((d) => {
22 return { value: d.value, type: d.type };
23 });
24 setAttributes({ [attributesKey]: updatedValues });
25 } else {
26 const updatedValues = data?.map((d) => d.value);
27 setAttributes({ [attributesKey]: updatedValues });
28 }
29 };
30
31 return (
32 <div className={`sp-smart-post-multi-select ${flex ? "d-flex" : ""} sp-smart-post-component-mb`}>
33 <p className="sp-smart-post-component-title">{label}</p>
34 <Select
35 defaultValue={value ? value : defaultValues}
36 // value={ value ?? defaultValues }
37 isMulti
38 options={items}
39 isClearable={reset}
40 onChange={(data) => (onChange ? onChange(data) : updateValue(data))}
41 onInputChange={(e) => (onInputChange ? onInputChange(e) : "")}
42 className="sp-smart-post-basic-multi-select"
43 />
44 {helpText && <p className="sp-smart-help-text">{helpText}</p>}
45 </div>
46 );
47 };
48
49 export default MultipleSelect;
50