0.2.43 • Published 5 years ago

@beisen/auto-complete v0.2.43

Weekly downloads
2
License
ISC
Repository
gitlab
Last release
5 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

5 years ago

0.2.42

5 years ago

0.2.41

5 years ago

0.2.40

5 years ago

0.2.39

5 years ago

0.2.38

5 years ago

0.2.37

5 years ago

0.0.45

5 years ago

0.2.36

5 years ago

0.2.35

5 years ago

0.2.34

5 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.30

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

1.0.2

5 years ago

0.2.21-2

5 years ago

0.2.21-1

6 years ago

0.2.20

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

6 years ago

0.2.16

6 years ago

0.2.15

6 years ago

0.2.14

6 years ago

0.2.13

6 years ago

0.2.12

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.99

6 years ago

0.1.98

6 years ago

0.1.97

6 years ago

0.1.96

6 years ago

0.1.95

6 years ago

0.1.94

6 years ago

0.1.93

6 years ago

0.1.92

6 years ago

0.1.91

6 years ago

0.1.90

6 years ago

0.1.89

6 years ago

0.1.88

6 years ago

0.1.87

7 years ago

0.1.85

7 years ago

0.1.84

7 years ago

0.1.83

7 years ago

0.1.82

7 years ago

0.1.81

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.0.99

7 years ago

0.1.1

7 years ago

0.0.98

7 years ago

0.0.97

7 years ago

0.0.96

7 years ago

0.0.95

7 years ago

0.0.94

7 years ago

0.0.93

7 years ago

0.0.92

7 years ago

0.0.91

7 years ago

0.0.90

7 years ago

0.0.89

7 years ago

0.0.88

7 years ago

0.0.87

7 years ago

0.0.86

7 years ago

0.0.85

7 years ago

0.0.84

7 years ago

0.0.83

7 years ago

0.0.82

7 years ago

0.0.81

7 years ago

0.0.80

7 years ago

0.0.79

7 years ago

0.0.78

7 years ago

0.0.77

7 years ago

0.0.76

7 years ago

0.0.75

7 years ago

0.0.74

7 years ago

0.0.73

7 years ago