1.0.5 • Published 3 years ago

@jswork/react-ant-draggable-tree v1.0.5

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

react-ant-draggable-tree

Draggable tree for antd.

version license size download

installation

npm install -S @jswork/react-ant-draggable-tree

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
itemsarrayfalse[]The data source for tree.
uniqKeystringfalse'value'The unique id key.
onChangefuncfalsenoopThe change handler.
dropValidatefuncfalse() => { return true; }When drag and drop validation passed.

usage

  1. import css

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

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactAntDraggableTree from '@jswork/react-ant-draggable-tree';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        items: require('./assets/tree.json')
      };
    
      render() {
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-ant-draggable-tree">
            <ReactAntDraggableTree
              items={this.state.items}
              className="mb-5 has-text-white"
              onChange={(e) => {
                console.log('event onChange:', e.target.value);
              }}
            />
            <button
              className="button is-primary"
              onClick={(e) => {
                this.setState({ items: [] });
              }}>
              Set items
            </button>
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.