react-bootstrap-multiselect-ts
v1.0.8
Published
react-bootstrap-multiselect adapted for TypeScript
Downloads
131
Maintainers
Readme
react-bootstrap-multiselect-ts
A multiselect component for react (with bootstrap). This is a TypeScript wrapper on top of: https://github.com/skratchdot/react-bootstrap-multiselect
Installation
npm i -S react-bootstrap-multiselect-ts
Usage
import {MultiselectProps, Multiselect} from "react-bootstrap-multiselect-ts";
class MultiselectWrapper extends React.Component<MultiselectProps, {}> {
static defaultProps = {
onChange: () => {
},
};
protected buttonText = (options: any, checked: any) => {
const selected = options.length;
const all = checked[0].length;
if (all === 0 || selected === 0) {
return "Nothing selected";
} else if (selected === all) {
return "All selected";
} else {
return `${selected} options selected`;
}
};
render(): JSX.Element {
return (
<Multiselect multiple
buttonText={this.buttonText}
selectAllText="Select all"
{...this.props}/>
);
}
}