1.0.5 • Published 3 years ago

@jswork/react-ant-checkbox-group v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-ant-checkbox-group

React ant checkbox group.

version license size download

installation

npm install -S @jswork/react-ant-checkbox-group

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valuearrayfalse-Default value.
onChangefuncfalsenoopThe change handler.
onSearchfuncfalsenoopThe handler when search.
itemsarrayfalse[]The checkbox data source.
templatefuncfalseRctplAntCheckboxThe item template.
stylelessboolfalsefalseIf no checkbox ui.

usage

  1. import css

    @import "~@jswork/react-ant-checkbox-group/dist/style.css";
    
    // or use sass
    @import "~@jswork/react-ant-checkbox-group/dist/style.scss";
    
    // customize your styles:
    $react-ant-checkbox-group-options: ()
  2. import js

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactAntCheckboxGroup from '@jswork/react-ant-checkbox-group';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        value: ['k1', 'k3'],
        items: [
          { value: 'k1', label: 'label1' },
          { value: 'k2', label: 'label2' },
          { value: 'k3', label: 'label3' }
        ]
      };
    
      onChange = (inEvent) => {
        // console.log('chk change:', inEvent.target.value);
        this.setState({ value: inEvent.target.value });
      };
    
      render() {
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-ant-checkbox-group">
            <article className="message is-info mb-3">
              <div className="message-header">Demo</div>
              <div className="message-body">
                <div className="p-2">
                  <ReactAntCheckboxGroup
                    name="abc"
                    value={this.state.value}
                    onChange={this.onChange}
                    onSearch={(e) => {
                      console.log('event:', e.target.value);
                    }}
                    items={this.state.items}
                  />
                </div>
    
                <ReactAntCheckboxGroup
                  name="abcd"
                  styleless
                  value={this.state.value}
                  onChange={this.onChange}
                  items={this.state.items}
                />
              </div>
            </article>
    
            <article className="message">
              <div className="message-header">Output</div>
              <div className="message-body">{JSON.stringify(this.state.value)}</div>
            </article>
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.