v1.0.0
This commit is contained in:
		
							parent
							
								
									cda365b8a6
								
							
						
					
					
						commit
						4a05409085
					
				@ -6,7 +6,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#### 新增
 | 
					#### 新增
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- 键盘操作,up,down,enter
 | 
					- 键盘操作,up(上),down(下),Left(上一页),Right(下一页),enter(选中、取消)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#### Bug fixes
 | 
					#### Bug fixes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								dist/static/2.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/static/2.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/static/3.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/static/3.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/xm-select.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/xm-select.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@ -8,7 +8,8 @@
 | 
				
			|||||||
var demo1 = xmSelect.render({
 | 
					var demo1 = xmSelect.render({
 | 
				
			||||||
	el: '#demo1', 
 | 
						el: '#demo1', 
 | 
				
			||||||
	autoRow: true,
 | 
						autoRow: true,
 | 
				
			||||||
	filterable: true,
 | 
						paging: true,
 | 
				
			||||||
 | 
						pageSize: 2,
 | 
				
			||||||
	tree: {
 | 
						tree: {
 | 
				
			||||||
		strict: true,
 | 
							strict: true,
 | 
				
			||||||
		show: false,
 | 
							show: false,
 | 
				
			||||||
 | 
				
			|||||||
@ -89,8 +89,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
| 参数		| 说明				| 类型		| 可选值  | 默认值 	|
 | 
					| 参数		| 说明				| 类型		| 可选值  | 默认值 	|
 | 
				
			||||||
| --------- | ----------------- | --------- | ------ | -------- |
 | 
					| --------- | ----------------- | --------- | ------ | -------- |
 | 
				
			||||||
| color		| 主题颜色   			| string	|	-	 |	#009688 |
 | 
					| color		| 主题颜色   		| string	|	-	 |	#009688 |
 | 
				
			||||||
| maxColor	| 选中上限闪烁边框颜色	| string	|	-	 |	#e54d42 |
 | 
					| maxColor	| 选中上限闪烁边框颜色| string	|	-	 |	#e54d42 |
 | 
				
			||||||
 | 
					| hover		| 键盘操作的背景色	| string	|	-	 |	#f2f2f2 |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### model
 | 
					### model
 | 
				
			||||||
 | 
				
			|||||||
@ -298,6 +298,10 @@ class Framework extends Component{
 | 
				
			|||||||
		//树状结构数据更新
 | 
							//树状结构数据更新
 | 
				
			||||||
		if(type === 'treeData'){
 | 
							if(type === 'treeData'){
 | 
				
			||||||
			this.value(this.state.sels, null, true)
 | 
								this.value(this.state.sels, null, true)
 | 
				
			||||||
 | 
							}else
 | 
				
			||||||
 | 
							//树状结构数据更新
 | 
				
			||||||
 | 
							if(type === 'close'){
 | 
				
			||||||
 | 
								this.onClick();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -351,6 +355,7 @@ class Framework extends Component{
 | 
				
			|||||||
			onClick: this.onClick.bind(this),
 | 
								onClick: this.onClick.bind(this),
 | 
				
			||||||
			ua: checkUserAgent(),
 | 
								ua: checkUserAgent(),
 | 
				
			||||||
			size: config.size,
 | 
								size: config.size,
 | 
				
			||||||
 | 
								tabindex: 1,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if(tmpColor){
 | 
							if(tmpColor){
 | 
				
			||||||
			xmSelectProps.style.borderColor = tmpColor;
 | 
								xmSelectProps.style.borderColor = tmpColor;
 | 
				
			||||||
@ -385,6 +390,13 @@ class Framework extends Component{
 | 
				
			|||||||
	//组件完成挂载
 | 
						//组件完成挂载
 | 
				
			||||||
	componentDidMount(){
 | 
						componentDidMount(){
 | 
				
			||||||
		this.prepare = true;
 | 
							this.prepare = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.base.addEventListener('keydown', e => {
 | 
				
			||||||
 | 
								let keyCode = e.keyCode;
 | 
				
			||||||
 | 
								if(keyCode === 13){
 | 
				
			||||||
 | 
									this.onClick()
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//此时页面又被重新渲染了
 | 
						//此时页面又被重新渲染了
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,7 @@ class General extends Component{
 | 
				
			|||||||
		this.inputOver = true;
 | 
							this.inputOver = true;
 | 
				
			||||||
		this.__value = '';
 | 
							this.__value = '';
 | 
				
			||||||
		this.tempData = [];
 | 
							this.tempData = [];
 | 
				
			||||||
 | 
							this.size = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	optionClick(item, selected, disabled, e){
 | 
						optionClick(item, selected, disabled, e){
 | 
				
			||||||
@ -45,16 +46,17 @@ class General extends Component{
 | 
				
			|||||||
			this.props.onReset(arr, 'auto');
 | 
								this.props.onReset(arr, 'auto');
 | 
				
			||||||
		}else if(isFunction(m)){
 | 
							}else if(isFunction(m)){
 | 
				
			||||||
			m(item);
 | 
								m(item);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							this.focus();
 | 
				
			||||||
		//阻止父组件上的事件冒泡
 | 
							//阻止父组件上的事件冒泡
 | 
				
			||||||
		this.blockClick(e);
 | 
							this.blockClick(e);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	blockClick(e){
 | 
						blockClick(e){
 | 
				
			||||||
		e.stopPropagation();
 | 
							e.stopPropagation();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pagePrevClick(e){
 | 
						pagePrevClick(size = this.size){
 | 
				
			||||||
		let index = this.state.pageIndex;
 | 
							let index = this.state.pageIndex;
 | 
				
			||||||
		if(index <= 1){
 | 
							if(index <= 1){
 | 
				
			||||||
			return ;
 | 
								return ;
 | 
				
			||||||
@ -62,7 +64,7 @@ class General extends Component{
 | 
				
			|||||||
		this.changePageIndex(index - 1);
 | 
							this.changePageIndex(index - 1);
 | 
				
			||||||
		this.props.pageRemote && this.postData(index - 1, true);
 | 
							this.props.pageRemote && this.postData(index - 1, true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pageNextClick(e, size){
 | 
						pageNextClick(size = this.size){
 | 
				
			||||||
		let index = this.state.pageIndex;
 | 
							let index = this.state.pageIndex;
 | 
				
			||||||
		if(index >= size){
 | 
							if(index >= size){
 | 
				
			||||||
			return ;
 | 
								return ;
 | 
				
			||||||
@ -135,9 +137,24 @@ class General extends Component{
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//键盘事件
 | 
						//键盘事件
 | 
				
			||||||
	keydown(e){
 | 
						keydown(type, e){
 | 
				
			||||||
		let keyCode = e.keyCode;
 | 
							let keyCode = e.keyCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(type === 'div'){
 | 
				
			||||||
 | 
								//Esc, Tab
 | 
				
			||||||
 | 
								if(keyCode === 27 || keyCode === 9){
 | 
				
			||||||
 | 
									this.props.onReset(false, 'close');
 | 
				
			||||||
 | 
								}else
 | 
				
			||||||
 | 
								//Left
 | 
				
			||||||
 | 
								if(keyCode === 37){
 | 
				
			||||||
 | 
									this.pagePrevClick();
 | 
				
			||||||
 | 
								}else
 | 
				
			||||||
 | 
								//Right 键
 | 
				
			||||||
 | 
								if(keyCode === 39){
 | 
				
			||||||
 | 
									this.pageNextClick();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const { value, optgroup, disabled } = this.props.prop;
 | 
							const { value, optgroup, disabled } = this.props.prop;
 | 
				
			||||||
		let data = this.tempData.filter(item => !item[optgroup] && !item[disabled]);
 | 
							let data = this.tempData.filter(item => !item[optgroup] && !item[disabled]);
 | 
				
			||||||
		let len = data.length - 1;
 | 
							let len = data.length - 1;
 | 
				
			||||||
@ -186,7 +203,13 @@ class General extends Component{
 | 
				
			|||||||
				this.searchInputRef && (this.searchInputRef.value = '');
 | 
									this.searchInputRef && (this.searchInputRef.value = '');
 | 
				
			||||||
			}else{
 | 
								}else{
 | 
				
			||||||
				//聚焦输入框
 | 
									//聚焦输入框
 | 
				
			||||||
				setTimeout(() => this.focus(), 0);
 | 
									setTimeout(() => {
 | 
				
			||||||
 | 
										if(props.filterable){
 | 
				
			||||||
 | 
											this.focus()
 | 
				
			||||||
 | 
										}else{
 | 
				
			||||||
 | 
											this.base.focus()
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}, 0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -279,13 +302,14 @@ class General extends Component{
 | 
				
			|||||||
			pageIndex <= 1 && (prevStyle = disabledStyle);
 | 
								pageIndex <= 1 && (prevStyle = disabledStyle);
 | 
				
			||||||
			pageIndex == size && (nextStyle = disabledStyle);
 | 
								pageIndex == size && (nextStyle = disabledStyle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			this.state.pageIndex !== pageIndex && this.changePageIndex(pageIndex);
 | 
								this.state.pageIndex !== pageIndex && this.changePageIndex(pageIndex);
 | 
				
			||||||
 | 
								this.size = size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			paging = (
 | 
								paging = (
 | 
				
			||||||
				<div class='xm-paging'>
 | 
									<div class='xm-paging'>
 | 
				
			||||||
					<span style={ prevStyle } onClick={ this.pagePrevClick.bind(this) }>上一页</span>
 | 
										<span style={ prevStyle } onClick={ this.pagePrevClick.bind(this, size) }>上一页</span>
 | 
				
			||||||
					<span>{ this.state.pageIndex } / { size }</span>
 | 
										<span>{ this.state.pageIndex } / { size }</span>
 | 
				
			||||||
					<span style={ nextStyle } onClick={ e => this.pageNextClick.bind(this, e, size)() }>下一页</span>
 | 
										<span style={ nextStyle } onClick={ this.pageNextClick.bind(this, size) }>下一页</span>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		}else{
 | 
							}else{
 | 
				
			||||||
@ -363,7 +387,8 @@ class General extends Component{
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					return (<div class={ toolClass } style={ toolStyle } onClick={ () => {
 | 
										return (<div class={ toolClass } style={ toolStyle } onClick={ () => {
 | 
				
			||||||
						isFunction(info.method) && info.method(safetyArr)
 | 
											isFunction(info.method) && info.method(safetyArr)
 | 
				
			||||||
 | 
											this.focus()
 | 
				
			||||||
					} } onMouseEnter={ hoverChange } onMouseLeave={ hoverChange }>
 | 
										} } onMouseEnter={ hoverChange } onMouseLeave={ hoverChange }>
 | 
				
			||||||
						{ config.toolbar.showIcon && <i class={ info.icon }></i> }
 | 
											{ config.toolbar.showIcon && <i class={ info.icon }></i> }
 | 
				
			||||||
						<span>{ info.name }</span>
 | 
											<span>{ info.name }</span>
 | 
				
			||||||
@ -386,14 +411,26 @@ class General extends Component{
 | 
				
			|||||||
				itemStyle.backgroundColor = theme.color;
 | 
									itemStyle.backgroundColor = theme.color;
 | 
				
			||||||
				item[disabled] && (itemStyle.backgroundColor = '#C2C2C2');
 | 
									item[disabled] && (itemStyle.backgroundColor = '#C2C2C2');
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if(item[value] === this.state.val){
 | 
					 | 
				
			||||||
				itemStyle.backgroundColor = '#f2f2f2'
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			const className = ['xm-option', (item[disabled] ? ' disabled' : ''), (selected ? ' selected' : ''), (showIcon ? 'show-icon' : 'hide-icon') ].join(' ');
 | 
								const className = ['xm-option', (item[disabled] ? ' disabled' : ''), (selected ? ' selected' : ''), (showIcon ? 'show-icon' : 'hide-icon') ].join(' ');
 | 
				
			||||||
			const iconClass = ['xm-option-icon xm-iconfont', radio ? 'xm-icon-danx' : 'xm-icon-duox'].join(' ');
 | 
								const iconClass = ['xm-option-icon xm-iconfont', radio ? 'xm-icon-danx' : 'xm-icon-duox'].join(' ');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//处理键盘的选择背景色
 | 
				
			||||||
 | 
								if(item[value] === this.state.val){
 | 
				
			||||||
 | 
									itemStyle.backgroundColor = theme.hover
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								//处理鼠标选择的背景色
 | 
				
			||||||
 | 
								const hoverChange = e => {
 | 
				
			||||||
 | 
									if(e.type === 'mouseenter'){
 | 
				
			||||||
 | 
										if(!item[disabled]){
 | 
				
			||||||
 | 
											this.setState({ val: item[value] })
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return (
 | 
								return (
 | 
				
			||||||
				<div class={ className } style={ itemStyle } value={ item[value] } onClick={ this.optionClick.bind(this, item, selected, item[disabled]) }>
 | 
									<div class={ className } style={ itemStyle } value={ item[value] } onClick={
 | 
				
			||||||
 | 
										this.optionClick.bind(this, item, selected, item[disabled])
 | 
				
			||||||
 | 
									} onMouseEnter={ hoverChange } onMouseLeave={ hoverChange }>
 | 
				
			||||||
					{ showIcon && <i class={ iconClass } style={ iconStyle }></i> }
 | 
										{ showIcon && <i class={ iconClass } style={ iconStyle }></i> }
 | 
				
			||||||
					<div class='xm-option-content' dangerouslySetInnerHTML={{ __html: template({ data, item, arr: sels, name: item[name], value: item[value] }) }}></div>
 | 
										<div class='xm-option-content' dangerouslySetInnerHTML={{ __html: template({ data, item, arr: sels, name: item[name], value: item[value] }) }}></div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
@ -424,7 +461,7 @@ class General extends Component{
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return (
 | 
							return (
 | 
				
			||||||
			<div onClick={ this.blockClick }>
 | 
								<div onClick={ this.blockClick } tabindex="1" style="outline: none;">
 | 
				
			||||||
				<div>
 | 
									<div>
 | 
				
			||||||
					{ config.toolbar.show && toolbar }
 | 
										{ config.toolbar.show && toolbar }
 | 
				
			||||||
					{ filterable && search }
 | 
										{ filterable && search }
 | 
				
			||||||
@ -445,10 +482,10 @@ class General extends Component{
 | 
				
			|||||||
			input.addEventListener('compositionstart', this.handleComposition.bind(this));
 | 
								input.addEventListener('compositionstart', this.handleComposition.bind(this));
 | 
				
			||||||
			input.addEventListener('compositionupdate', this.handleComposition.bind(this));
 | 
								input.addEventListener('compositionupdate', this.handleComposition.bind(this));
 | 
				
			||||||
			input.addEventListener('compositionend', this.handleComposition.bind(this));
 | 
								input.addEventListener('compositionend', this.handleComposition.bind(this));
 | 
				
			||||||
			input.addEventListener('input', this.searchInput.bind(this));
 | 
								input.addEventListener('input', this.searchInput.bind(this, 'input'));
 | 
				
			||||||
			input.addEventListener('keydown', this.keydown.bind(this));
 | 
					 | 
				
			||||||
			this.searchInputRef = input;
 | 
								this.searchInputRef = input;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							this.base.addEventListener('keydown', this.keydown.bind(this, 'div'));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//此时页面又被重新渲染了
 | 
						//此时页面又被重新渲染了
 | 
				
			||||||
 | 
				
			|||||||
@ -298,7 +298,7 @@ class Tree extends Component{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		return (
 | 
							return (
 | 
				
			||||||
			<div onClick={ this.blockClick } class="xm-body-tree" >
 | 
								<div onClick={ this.blockClick } class="xm-body-tree" >
 | 
				
			||||||
				{ config.toolbar.show && toolbar }
 | 
									// { config.toolbar.show && toolbar }
 | 
				
			||||||
				{ filterable && search }
 | 
									{ filterable && search }
 | 
				
			||||||
				<div class="scroll-body" style={ {maxHeight: config.height} }>{ arr }</div>
 | 
									<div class="scroll-body" style={ {maxHeight: config.height} }>{ arr }</div>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -114,8 +114,9 @@ export default function (lan = 'zn') {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		//主题配置
 | 
							//主题配置
 | 
				
			||||||
		theme: {
 | 
							theme: {
 | 
				
			||||||
			color: '#009688',	   //默认主题颜色
 | 
								color: '#009688',		//默认主题颜色
 | 
				
			||||||
			maxColor: '#e54d42',	//多选上限边框闪烁颜色
 | 
								maxColor: '#e54d42',	//多选上限边框闪烁颜色
 | 
				
			||||||
 | 
								hover: '#f2f2f2',		//键盘hover的颜色
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		//模型
 | 
							//模型
 | 
				
			||||||
		model: {
 | 
							model: {
 | 
				
			||||||
 | 
				
			|||||||
@ -59,6 +59,7 @@ xm-select{
 | 
				
			|||||||
	display: block;
 | 
						display: block;
 | 
				
			||||||
	width: 100%;
 | 
						width: 100%;
 | 
				
			||||||
	cursor: pointer;
 | 
						cursor: pointer;
 | 
				
			||||||
 | 
						outline: none;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	&:hover{
 | 
						&:hover{
 | 
				
			||||||
		border-color: #C0C4CC;
 | 
							border-color: #C0C4CC;
 | 
				
			||||||
@ -212,9 +213,9 @@ xm-select{
 | 
				
			|||||||
			padding: 0 10px;
 | 
								padding: 0 10px;
 | 
				
			||||||
			cursor: pointer;
 | 
								cursor: pointer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			&:hover{
 | 
								// &:hover{
 | 
				
			||||||
				background-color: #f2f2f2;
 | 
								// 	background-color: #f2f2f2;
 | 
				
			||||||
			}
 | 
								// }
 | 
				
			||||||
			&-icon{
 | 
								&-icon{
 | 
				
			||||||
				color: transparent;
 | 
									color: transparent;
 | 
				
			||||||
				display: flex;
 | 
									display: flex;
 | 
				
			||||||
@ -305,7 +306,6 @@ xm-select{
 | 
				
			|||||||
			&>span:last-child{
 | 
								&>span:last-child{
 | 
				
			||||||
				border-radius: 0 2px 2px 0
 | 
									border-radius: 0 2px 2px 0
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					 | 
				
			||||||
			&>span{
 | 
								&>span{
 | 
				
			||||||
				display: flex;
 | 
									display: flex;
 | 
				
			||||||
				flex: auto;
 | 
									flex: auto;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user