0.2.43 • Published 6 years ago

@beisen/auto-complete v0.2.43

Weekly downloads
2
License
ISC
Repository
gitlab
Last release
6 years ago

AutoComplete

参数

State

isFocus: false,  // 输入框样式控制
inputValue: props && props.inputDefaultValue || '' //input表单值

Props

hidden: false, // 是否渲染
disabled: false, // 不可用
readOnly: true, // 只读
labelText: 'AutoComplete', //左侧 label 文字
placeholder: '请输入', // input placeholder
inputDefaultValue: null, // input 默认值
defaultItems: [], // autocomplete 数据 需传入一个DOM数组 nodeName为li
keyUpCallBack: (value, event) => console.log(value, event), // input keyup输入回调
itemCallBack: (event, data) => console.log(event), // autocomplete 点击回调 event事件回调,data为li上attribute的值
focusCallBack: (value) => console.log(value), // input keyup输入回调
blurCallBack: (event) => console.log(event), // autocomplete 点击回调
changeCallBack: (event, data) => console.log(value) // input keyup输入回调 event事件回调 data为li上attribute的值

PropTypes

hidden: PropTypes.bool,
disabled: PropTypes.bool,
readOnly: PropTypes.bool,
labelText: PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.number,
]).isRequired,
placeholder: PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.number,
]),
inputDefaultValue: PropTypes.oneOfType([
  PropTypes.string,
  PropTypes.number,
]),
defaultItems: PropTypes.arrayOf(PropTypes.element).isRequired,
keyUpCallBack: PropTypes.func.isRequired,
itemCallBack: PropTypes.func.isRequired,
focusCallBack: PropTypes.func,
blurCallBack: PropTypes.func,
changeCallBack: PropTypes.func

使用方法

class App extends Component {

	constructor(props) {
		super(props)
		this.state = {
			autoValue: this.setDefaultValue()
		}
	}
	
	// 返回defaultItems
	setDefaultValue(count = 5) {
		let items = [];

		for (let i = 0; i < count; i++) {
			items.push(<li key={i}>{i}</li>);
		}
		return items;
	}	
	
	// 根据keyup返回新的defaultItems
	setNewValue(count) {
		this.setState({autoValue: this.setDefaultValue(count)})
	}
	
	// 清空defaultItems
	restValue(event, data) {
		console.log(event, data)
		this.setState({autoValue: null});
	}

  	render () {
		const {autoValue} = this.state;
		const options = {
			labelText: 'AutoComplete',
			placeholder: '请输入',
			inputDefaultValue: null
		}
	    return (
	     	 <AutoComplete {...options} defaultItems={autoValue} keyUpCallBack={::this.setNewValue} itemCallBack={::this.restValue} />
	    )
  	}
}
render(<App />, document.getElementById('content'))
0.2.43

6 years ago

0.2.42

6 years ago

0.2.41

6 years ago

0.2.40

6 years ago

0.2.39

6 years ago

0.2.38

6 years ago

0.2.37

6 years ago

0.0.45

6 years ago

0.2.36

6 years ago

0.2.35

6 years ago

0.2.34

6 years ago

0.2.33

6 years ago

0.2.32

6 years ago

0.2.31

6 years ago

0.2.30

6 years ago

0.2.29

6 years ago

0.2.28

6 years ago

1.0.2

6 years ago

0.2.21-2

6 years ago

0.2.21-1

7 years ago

0.2.20

7 years ago

0.2.19

7 years ago

0.2.18

7 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.99

7 years ago

0.1.98

7 years ago

0.1.97

7 years ago

0.1.96

7 years ago

0.1.95

7 years ago

0.1.94

7 years ago

0.1.93

7 years ago

0.1.92

7 years ago

0.1.91

7 years ago

0.1.90

7 years ago

0.1.89

8 years ago

0.1.88

8 years ago

0.1.87

8 years ago

0.1.85

8 years ago

0.1.84

8 years ago

0.1.83

8 years ago

0.1.82

8 years ago

0.1.81

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.0.99

8 years ago

0.1.1

8 years ago

0.0.98

8 years ago

0.0.97

8 years ago

0.0.96

8 years ago

0.0.95

8 years ago

0.0.94

8 years ago

0.0.93

8 years ago

0.0.92

8 years ago

0.0.91

8 years ago

0.0.90

8 years ago

0.0.89

8 years ago

0.0.88

8 years ago

0.0.87

8 years ago

0.0.86

8 years ago

0.0.85

8 years ago

0.0.84

8 years ago

0.0.83

8 years ago

0.0.82

8 years ago

0.0.81

8 years ago

0.0.80

8 years ago

0.0.79

8 years ago

0.0.78

8 years ago

0.0.77

8 years ago

0.0.76

8 years ago

0.0.75

8 years ago

0.0.74

8 years ago

0.0.73

8 years ago