1.0.9 • Published 4 years ago

@feizheng/react-ant-form v1.0.9

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

react-ant-form

React basic ant form builder.

installation

npm install -S @feizheng/react-ant-form

update

npm update @feizheng/react-ant-form

properties

NameTypeDefaultDescription
classNamestring-The extended className for component.
fieldsValueobject{}Default fileds value object.
itemsarray[]Form schema.
defaultComponentanyInputDefault item component.
onSubmitfuncnoopThe onSubmit event.
onLoadfuncnoopWhen component did mount.
formLayoutobject-The formLayout for antd.Form.
submitLabelstring' 'The submit label.
submitPropsobject-The submit props.

usage

  1. import css

    @import "~@feizheng/react-ant-form/dist/style.scss";
    
    // customize your styles:
    $react-ant-form-options: ()
  2. import js

    import ReactAntForm from '@feizheng/react-ant-form';
    import { Input, Checkbox } from 'antd';
    import ReactDOM from 'react-dom';
    import React from 'react';
    import ReactAntCheckbox from '@feizheng/react-ant-checkbox';
    import noop from '@feizheng/noop';
    import '@feizheng/next-ant-fields-value';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        fieldsValue: nx.antFieldsValue({
          username: 'fei',
          password: 'test',
          chk: false,
          text: 'etst...'
        }),
        items: [
          {
            label: 'username',
            field: 'username'
          },
          {
            label: 'password',
            field: 'password'
          },
          {
            label: 'test-checkbox',
            field: 'chk',
            component: ReactAntCheckbox,
            props: {
              children: 'Agree the agreement'
            }
          },
          {
            label: 'Text',
            field: 'text',
            component: Input.TextArea
          }
        ]
      };
    
      handleSubmit = (e) => {
        console.log(e);
        return {
          then: nx.noop
        };
      };
    
      render() {
        return (
          <div className="app-container">
            <ReactAntForm
              fieldsValue={this.state.fieldsValue}
              onSubmit={this.handleSubmit}
              items={this.state.items}
              submitProps={{
                type: 'primary',
                htmlType: 'submit',
                className: 'wp-10',
                children: '保存'
              }}
            />
          </div>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

1.0.9

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago