1.0.8 • Published 6 years ago

react-bootstrap-multiselect-ts v1.0.8

Weekly downloads
32
License
MIT
Repository
github
Last release
6 years ago

react-bootstrap-multiselect-ts

NPM version Dependency Status devDependency Status

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}/>
        );
    }
}