1.0.0 • Published 4 years ago

@jswork/react-ant-input v1.0.0

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

react-ant-input

Ant input.

version license size download

installation

npm install -S @jswork/react-ant-input

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valueanyfalse-Default value.
shouldTrimboolfalsefalseIf the value should be trim before returned.
autoCompletestringfalse'off'Should autoComplete on.
onChangefuncfalsenoopThe change handler.

usage

  1. import css

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

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactAntInput from '@jswork/react-ant-input';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        value: '',
        value2: ''
      };
    
      handleChange = (inEvent) => {
        this.setState({
          [inEvent.target.name]: inEvent.target.value
        });
      };
    
      render() {
        const { value, value2 } = this.state;
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-ant-input">
            <article className="message is-info">
              <div className="message-header">Preview:</div>
              <div className="message-body">
                <ReactAntInput
                  name="value"
                  value={value}
                  placeholder="Please input text1..."
                  className="mb-2"
                  onChange={this.handleChange}
                />
    
                <ReactAntInput
                  shouldTrim
                  name="value2"
                  placeholder="Please input text2..."
                  value={value2}
                  onChange={this.handleChange}
                />
              </div>
            </article>
    
            <article className="message">
              <div className="message-header">Status changed:</div>
              <div className="message-body">
                {JSON.stringify(this.state, null, 2)}
              </div>
            </article>
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.