4.1.1 • Published 7 years ago

uxcore-pickable v4.1.1

Weekly downloads
21
License
MIT
Repository
github
Last release
7 years ago

uxcore-pickable Dependency Status devDependency Status

TL;DR

uxcore-pickable ui component for react

setup develop environment

$ git clone https://github.com/uxcore/uxcore-pickable
$ cd uxcore-pickable
$ npm install
$ gulp server

Usage

const classnames = require('classnames');

const Pickable = require('uxcore-pickable');
const {Item} = Pickable;

class Demo extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
          value: [1]
        }
    }

    handleChange(value) {
      this.setState({
        value: value
      })
    }

    render() {
      let items = [{
        text: '条件一',
        value: 1,
        num: 15
      }, {
        text: '条件二',
        value: 2,
        num: 20
      }, {
        text: '条件三',
        value: 3,
        disable: true
      }];
      return <div>
        <div>
          <Pickable onChange={this.handleChange.bind(this)} value={this.state.value}>
            {items.map((item, index) => {
              return <Item key={index} value={item.value} number={item.num} disabled={item.disable}>{item.text}</Item>
            })}
          </Pickable>
        </div>
        <div>
          <Pickable onChange={this.handleChange.bind(this)} value={this.state.value} type="simple">
            {items.map((item, index) => {
              return <Item key={index} value={item.value} number={item.num} disabled={item.disable}>{item.text}</Item>
            })}
          </Pickable>
        </div>
      </div>;
    }
};

module.exports = Demo;

demo

http://uxco.re/components/pickable/

API

  • values(): 获得选中的值

Props

配置项类型必填默认值功能/备注
prefixClsstringoptionalkuma-pickable类名前缀,不使用 kuma 主题时使用
classNamestringrequired-增加额外的class
onChangefunc(value, changedKeys)optional-选中情况变化时触发,返回选中的项,以及目前发生变动的值
multiplebooloptionaltrue是否多选
maxnumberoptional99最大显示的数字,超过 max,显示 max+,2.0 版本后此项废弃,改为传入 children 时实现。
typestringoptionalnormal样式风格,可选值为 normal, simple, hook, simpleHook
enableFoldbooloptionalfalse是否启用折行后自动折叠, 3.0 版本后支持
defaultfoldItemsbooloptionaltrue是否在折行的情况下默认折叠, 3.0 版本后支持
maxLinesnumberoptonal1超过几行的情况下使用折叠, 3.0 版本后支持
localestringoptionalzh-cn国际化,zh-cn/en-us, 3.0 版本后支持
simpleValueInSingleModebooloptionalfalse单选时,输出和接收的值变成简单的值类型,而非数组,从 1 变成 1

Item Props

配置项类型必填默认值功能/备注
valuestring/numberrequired-该 Item 对应的值
disabledbooleanoptionalfalse是否禁用
numbernumberoptional-number 有值时会显示对应的值,2.0 版本后此项废弃,改为传入 children 时实现。
maxnumberoptional99最大显示的数字,超过 max,显示 max+,2.0 版本后此项废弃,改为传入 children 时实现。
4.1.1

7 years ago

4.1.0

7 years ago

4.0.0

7 years ago

3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

1.1.4

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago