r-dropdown-button
Advanced tools
Comparing version 1.0.4 to 1.0.5
11
index.js
@@ -251,3 +251,4 @@ "use strict"; | ||
key: i, | ||
item: item | ||
item: item, | ||
index: i | ||
}); | ||
@@ -301,3 +302,5 @@ }); | ||
value: function click() { | ||
var item = this.props.item; | ||
var _this$props2 = this.props, | ||
item = _this$props2.item, | ||
index = _this$props2.index; | ||
var _this$context2 = this.context, | ||
@@ -314,5 +317,5 @@ toggle = _this$context2.toggle, | ||
if (item.onClick) { | ||
item.onClick(item, this.context); | ||
item.onClick(item, index, this.context); | ||
} else if (onClick) { | ||
onClick(item, this.context); | ||
onClick(item, index, this.context); | ||
} | ||
@@ -319,0 +322,0 @@ |
{ | ||
"name": "r-dropdown-button", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -116,3 +116,3 @@ import React,{Component,Fragment,createRef,createContext} from 'react'; | ||
return item.text.indexOf(searchValue) !== -1 | ||
}).map((item, i)=><ListItem key={i} item={item}/>) | ||
}).map((item, i)=><ListItem key={i} item={item} index={i}/>) | ||
return( | ||
@@ -138,8 +138,8 @@ <div className="r-dropdown-button-popup" ref={this.dom} style={this.getStyle(popupStyle)}> | ||
click(){ | ||
var {item} = this.props; | ||
var {item,index} = this.props; | ||
var {toggle,onClick,getValue} = this.context; | ||
var disabled = getValue(item.disabled); | ||
if(disabled){return;} | ||
if(item.onClick){item.onClick(item,this.context);} | ||
else if(onClick){onClick(item,this.context);} | ||
if(item.onClick){item.onClick(item,index,this.context);} | ||
else if(onClick){onClick(item,index,this.context);} | ||
if(item.close !== false){toggle();} | ||
@@ -146,0 +146,0 @@ } |
26613
703