Code Monkey home page Code Monkey logo

react-multiselect-two-sides's Introduction

react-multiselect-two-sides

Commitizen friendly XO code style

NPM version Build Status Dependency Status DevDependency Status

React multiselect two sides component

Demo: vovanr.github.io/react-multiselect-two-sides

Install

npm install --save react-multiselect-two-sides

Usage

See: example

const App = React.createClass({
    getInitialState() {
        return {
            options: [
                {name: 'Foo', value: 0},
                {name: 'Bar', value: 1},
                {name: 'Baz', value: 2, disabled: true},
                {name: 'Qux', value: 3},
                {name: 'Quux', value: 4},
                {name: 'Corge', value: 5},
                {name: 'Grault', value: 6},
                {name: 'Garply', value: 7},
                {name: 'Waldo', value: 8},
                {name: 'Fred', value: 9},
                {name: 'Plugh', value: 10},
                {name: 'Xyzzy', value: 11},
                {name: 'Thud', value: 12}
            ],
            value: [0, 3, 9]
        };
    },

    handleChange(value) {
        this.setState({value});
    },

    render() {
        const {options, value} = this.state;
        const selectedCount = value.length;
        const availableCount = options.length - selectedCount;

        return (
            <MultiselectTwoSides
                {...this.state}
                className="msts_theme_example"
                onChange={this.handleChange}
                availableHeader="Available"
                availableFooter={`Available: ${availableCount}`}
                selectedHeader="Selected"
                selectedFooter={`Selected: ${selectedCount}`}
                showControls
                searchable
                />
        );
    }
});

ReactDOM.render(<App/>, document.getElementById('app'));

Api

MultiselectTwoSides.propTypes = {
    availableFooter: React.PropTypes.node,
    availableHeader: React.PropTypes.node,
    className: React.PropTypes.string,
    clearFilterText: React.PropTypes.string,
    clearable: React.PropTypes.bool,
    deselectAllText: React.PropTypes.string,
    disabled: React.PropTypes.bool,
    filterComponent: React.PropTypes.func,
    highlight: React.PropTypes.array,
    labelKey: React.PropTypes.string,
    limit: React.PropTypes.number,
    onChange: React.PropTypes.func,
    options: React.PropTypes.array,
    placeholder: React.PropTypes.string,
    searchable: React.PropTypes.bool,
    selectAllText: React.PropTypes.string,
    selectedFooter: React.PropTypes.node,
    selectedHeader: React.PropTypes.node,
    showControls: React.PropTypes.bool,
    value: React.PropTypes.array,
    valueKey: React.PropTypes.string
};

MultiselectTwoSides.defaultProps = {
    clearFilterText: 'Clear',
    clearable: true,
    deselectAllText: 'Deselect all',
    disabled: false,
    highlight: [],
    labelKey: 'label',
    options: [],
    searchable: false,
    selectAllText: 'Select all',
    showControls: false,
    value: [],
    valueKey: 'value'
};

License

MIT © Vladimir Rodkin

react-multiselect-two-sides's People

Contributors

vovanr avatar icenine457 avatar ex13 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.