@jswork/react-ant-select

1.0.5 • Public • Published

react-ant-select

React ant select builder.

version license size download

installation

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

properties

Name Type Required Default Description
className string false - The extended className for component.
value any false - Default value.
placeholder string false '请选择' Placeholder.
items array false [] The data source.
template func false RctplAntSelect The data item template.
onChange func false noop The change handler.

usage

  1. import css
@import "~@jswork/react-ant-select/dist/style.css";

// or use sass
@import "~@jswork/react-ant-select/dist/style.scss";

// customize your styles:
$react-ant-select-options: ()
  1. import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactAntSelect from '@jswork/react-ant-select';
import Tpl1 from '@jswork/rctpl-ant-select-default';
import './assets/style.scss';

class App extends React.Component {
  state = {
    items2: ['001', '002', '003'],
    items: [
      {
        value: 'op1',
        label: 'option1d'
      },
      {
        value: 'op2',
        label: 'option2d'
      },
      {
        value: 'op3',
        label: 'option3d'
      }
    ]
  };

  handleChange = (inEvent) => {
    console.log('value:', inEvent.target.value);
  };

  render() {
    const { items, items2 } = this.state;

    return (
      <ReactDemokit
        className="p-3 app-container"
        url="https://github.com/afeiship/react-ant-select">
        <h1>Has value:</h1>
        <ReactAntSelect
          template={Tpl1}
          items={items}
          onChange={this.handleChange}
        />
        <ReactAntSelect
          template={Tpl1}
          items={items2}
          onChange={this.handleChange}
        />
        <h1>Select is empty</h1>
        <ReactAntSelect items={[]} onChange={this.handleChange} />
      </ReactDemokit>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

tempalte migrate

import ReactAntSelect from '@jswork/react-ant-select';
import RctplAntSelectDefault from '@jswork/rctpl-ant-select-default';

Object.assign(
  ReactAntSelect.defaultProps, 
  { template: RctplAntSelectDefault }
);

documentation

license

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @jswork/react-ant-select

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

21.5 kB

Total Files

7

Last publish

Collaborators

  • afeiship