v1.1.2
This commit is contained in:
@@ -97,12 +97,3 @@ if (!Array.prototype.findIndex) {
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
//拓展Object values方法
|
||||
if (!Object.values) {
|
||||
Object.prototype.values = function(obj) {
|
||||
return Object.keys(obj).map(function(e) {
|
||||
return obj[e];
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,7 +39,10 @@ class Framework extends Component{
|
||||
let dataObj = {};
|
||||
let flatData = [];
|
||||
this.load(data, dataObj, flatData);
|
||||
sels = this.exchangeValue(initValue ? initValue : Object.values(dataObj).filter(item => item[prop.selected] === true), dataObj)
|
||||
sels = this.exchangeValue(initValue ? initValue : Object.keys(dataObj).filter(key => {
|
||||
let item = dataObj[key]
|
||||
return item[prop.selected] === true
|
||||
}), dataObj)
|
||||
if(radio && sels.length > 1){
|
||||
sels = sels.slice(0, 1)
|
||||
}
|
||||
|
||||
@@ -406,7 +406,13 @@ class General extends Component{
|
||||
} : {
|
||||
borderColor: theme.color,
|
||||
};
|
||||
const itemStyle = {}
|
||||
const itemStyle = {}
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
}
|
||||
//不显示图标时候的背景色处理
|
||||
if(!showIcon && selected){
|
||||
itemStyle.backgroundColor = theme.color;
|
||||
item[disabled] && (itemStyle.backgroundColor = '#C2C2C2');
|
||||
@@ -414,10 +420,6 @@ class General extends Component{
|
||||
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(' ');
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
}
|
||||
//处理鼠标选择的背景色
|
||||
const hoverChange = e => {
|
||||
if(e.type === 'mouseenter'){
|
||||
|
||||
@@ -52,6 +52,7 @@ class Tree extends Component{
|
||||
|
||||
//不是父节点的不需要处理
|
||||
if(!tree.lazy && !item[prop.optgroup]){
|
||||
this.props.ck(item, selected, disabled);
|
||||
return
|
||||
}
|
||||
|
||||
@@ -198,7 +199,15 @@ class Tree extends Component{
|
||||
} : {
|
||||
borderColor: theme.color,
|
||||
};
|
||||
|
||||
const itemStyle = { paddingLeft: indent + 'px' }
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
}
|
||||
|
||||
//隐藏图标的处理
|
||||
if(!showIcon && selected){
|
||||
itemStyle.backgroundColor = theme.color;
|
||||
dis && (itemStyle.backgroundColor = '#C2C2C2');
|
||||
@@ -217,11 +226,8 @@ class Tree extends Component{
|
||||
iconArray.push(<i class='top-line' style={ { left: indent - tree.indent + 3 + 'px', width: tree.indent + (expand === 0 ? 10 : -2) + 'px' } }></i>);
|
||||
}
|
||||
}
|
||||
|
||||
//处理键盘的选择背景色
|
||||
if(item[value] === this.state.val){
|
||||
itemStyle.backgroundColor = theme.hover
|
||||
}
|
||||
|
||||
|
||||
//处理鼠标选择的背景色
|
||||
const hoverChange = e => {
|
||||
if(e.type === 'mouseenter'){
|
||||
@@ -232,8 +238,8 @@ class Tree extends Component{
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={ className } style={ itemStyle } value={ item[value] } onClick={
|
||||
this.optionClick.bind(this, item, selected, item[disabled], 'line')
|
||||
<div class={ className } style={ itemStyle } value={ item[value] } onClick={
|
||||
this.optionClick.bind(this, item, selected, item[disabled], 'line')
|
||||
} onMouseEnter={ hoverChange } onMouseLeave={ hoverChange }>
|
||||
{ iconArray }
|
||||
{ item.__node.loading && <span class="loader"></span> }
|
||||
|
||||
@@ -8,7 +8,12 @@ const moduleName = 'xmSelect';
|
||||
/**
|
||||
* 监听全页面点击关闭事件
|
||||
*/
|
||||
window.addEventListener('click', () => Object.values(datas).forEach(item => item && item.closed && item.closed()))
|
||||
window.addEventListener('click', () => {
|
||||
Object.keys(datas).forEach(key => {
|
||||
let item = datas[key]
|
||||
item && item.closed && item.closed()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
|
||||
|
||||
Reference in New Issue
Block a user