ToolJet/frontend/src/Editor/Components/Table/CustomSelect.jsx

30 lines
730 B
React
Raw Normal View History

2021-05-09 07:26:54 +00:00
import React from 'react';
import SelectSearch from 'react-select-search';
export const CustomSelect = ({ options, value, multiple, onChange }) => {
function renderValue(valueProps) {
if (valueProps) {
return valueProps.value.split(', ').map((value, index) => (
<span key={index} {...valueProps} className="badge bg-blue-lt p-2 mx-1">
{value}
</span>
));
2021-05-09 07:26:54 +00:00
}
}
2021-05-09 07:26:54 +00:00
return (
<div className="custom-select">
<SelectSearch
options={options}
printOptions="on-focus"
value={value}
renderValue={renderValue}
search={false}
onChange={onChange}
multiple={multiple}
placeholder="Select.."
/>
</div>
);
};