1.0.5 • Published 2 years ago

@jswork/react-ant-editable-tag-group v1.0.5

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

react-ant-editable-tag-group

Editable tag group for ant.

version license size download

installation

npm install -S @jswork/react-ant-editable-tag-group

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valuearrayfalse[]Default value.
onChangefuncfalsenoopThe change handler.
minnumberfalse0The minimum tag number.
maxnumberfalse20The maximum tags number.
quickboolfalsefalseIf use keymap enter key to quick add tag.
readOnlyboolfalse-If set readOnly.
disabledboolfalse-If set disabed.

usage

  1. import css

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

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactAntEditableTagGroup from '@jswork/react-ant-editable-tag-group';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        items: ['tag1', 'tag2', 'tag3']
      };
    
      onRandom = (inEvent) => {
        const random = Math.floor(Math.random() * 10);
        const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        const _items = items.slice(0, random);
        this.setState({ items: _items });
      };
    
      render() {
        const { items } = this.state;
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-ant-editable-tag-group">
            <p>
              <button className="button is-primary is-fullwidth" onClick={this.onRandom}>Set Random Items</button>
            </p>
            <ReactAntEditableTagGroup
              quick
              value={items}
              onChange={(e) => {
                console.log(e.target.value);
                this.setState({ items: e.target.value });
              }}
            />
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.