1.0.24 • Published 22 days ago

@jswork/ant-abstract-form v1.0.24

Weekly downloads
-
License
MIT
Repository
-
Last release
22 days ago

ant-abstract-form

For curd form based on react.

version license size download

installation

npm install -S @jswork/ant-abstract-form

usage

  1. import css

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

    import React from 'react';
    import AntAbstractForm from '@jswork/ant-abstract-form';
    import styled from 'styled-components';
    import nx from '@jswork/next';
    
    const Container = styled.div`
      width: 80%;
      margin: 30px auto 0;
      .is-body {
        padding: 20px;
        background: #fff;
        width: 50%;
        min-width: 320px;
        margin: 0 auto;
      }
    
      .mr-5_ {
        > * {
          margin-right: 5px;
        }
      }
    
      .mr-10_ {
        > * {
          margin-right: 10px;
        }
      }
    `;
    
    // Mock api
    nx.$api = {
      curds_index: function () {
        return Promise.resolve('index');
      },
      curds_show: function () {
        return Promise.resolve('show');
      },
      curds_update: function () {
        return Promise.resolve('update');
      }
    };
    
    nx.$route = {
      back: function () {
        console.log('back');
      }
    };
    
    class App extends AntAbstractForm {
      apiService = nx.$api;
      routeService = nx.$route;
    
      constructor(props) {
        super(props);
        this.state = {
          meta: {
            formItemLayout: [6, 18],
            initialValues: {},
            fields: [
              {
                key: 'username',
                label: 'User Name',
                tooltip: '用户名',
                rules: [{ max: 10, min: 5 }]
              },
              { key: 'password', label: 'Password', widget: 'password' }
            ]
          }
        };
      }
    
      componentDidMount() {
        const { meta } = this.state;
        meta.initialValues = {
          username: 'afeiship'
        };
        this.setState({ meta });
      }
    
      render() {
        return this.view();
      }
    }
    
    export default () => {
      return (
        <Container>
          <App />
        </Container>
      );
    };

preview

license

Code released under the MIT license.

1.0.24

22 days ago

1.0.23

3 months ago

1.0.21

4 months ago

1.0.20

6 months ago

1.0.19

6 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

10 months ago

1.0.2

10 months ago