From 0b4e5af82d5afc17bafb4b143d3694b5ebc3588c Mon Sep 17 00:00:00 2001
From: SupriyaKalghatgi <>
Date: Wed, 20 Jun 2018 17:14:37 +0530
Subject: [PATCH] Picker: Fixed Header Left Button alignment
---
dist/src/basic/Picker.ios.js | 55 +++++++------
dist/src/basic/Picker.ios.js.map | 2 +-
src/basic/Picker.ios.js | 133 ++++++++++++++++---------------
3 files changed, 100 insertions(+), 90 deletions(-)
diff --git a/dist/src/basic/Picker.ios.js b/dist/src/basic/Picker.ios.js
index 93a0fdaf3..9a0ed8df2 100644
--- a/dist/src/basic/Picker.ios.js
+++ b/dist/src/basic/Picker.ios.js
@@ -94,17 +94,19 @@ return children;
{
return _react2.default.cloneElement(this.props.iosIcon,{
-style:[{
+style:[
+{
fontSize:22,
lineHeight:26},_extends({},
+
this.props.iosIcon.props.style)]});
+
}},{key:"renderButton",value:function renderButton()
{var _this3=this;
var onPress=function onPress(){
-if(_this3.props.enabled!==undefined&&!_this3.props.enabled)
-return;
+if(_this3.props.enabled!==undefined&&!_this3.props.enabled)return;
_this3._setModalVisible(true);
};
var text=this.state.currentLabel?
@@ -124,16 +126,16 @@ style:this.props.style,
dark:true,
picker:true,
transparent:true,
-onPress:onPress,__source:{fileName:_jsxFileName,lineNumber:122}},
+onPress:onPress,__source:{fileName:_jsxFileName,lineNumber:124}},
this.state.currentLabel?
-_react2.default.createElement(_Text.Text,{style:this.props.textStyle,note:this.props.note,__source:{fileName:_jsxFileName,lineNumber:130}},
+_react2.default.createElement(_Text.Text,{style:this.props.textStyle,note:this.props.note,__source:{fileName:_jsxFileName,lineNumber:132}},
this.state.currentLabel):
_react2.default.createElement(_Text.Text,{
style:[this.props.textStyle,this.props.placeholderStyle],
-note:this.props.note===false?false:true,__source:{fileName:_jsxFileName,lineNumber:134}},
+note:this.props.note===false?false:true,__source:{fileName:_jsxFileName,lineNumber:136}},
this.props.placeholder),
@@ -147,39 +149,40 @@ this.props.iosIcon===undefined?null:this.renderIcon()));
return this.props.renderHeader?
this.props.renderHeader(function(){return _this4._setModalVisible(false);}):
-_react2.default.createElement(_Header.Header,{style:this.props.headerStyle,__source:{fileName:_jsxFileName,lineNumber:150}},
-_react2.default.createElement(_Left.Left,{__source:{fileName:_jsxFileName,lineNumber:151}},
+_react2.default.createElement(_Header.Header,{style:this.props.headerStyle,__source:{fileName:_jsxFileName,lineNumber:152}},
+_react2.default.createElement(_Left.Left,{__source:{fileName:_jsxFileName,lineNumber:153}},
_react2.default.createElement(_Button.Button,{
style:_extends({
shadowOffset:null,
shadowColor:null,
shadowRadius:null,
-shadowOpacity:null},
+shadowOpacity:null,
+marginLeft:3},
this.props.headerBackButtonStyle),
transparent:true,
onPress:function onPress(){
_this4._setModalVisible(false);
-},__source:{fileName:_jsxFileName,lineNumber:152}},
+},__source:{fileName:_jsxFileName,lineNumber:154}},
-_react2.default.createElement(_Text.Text,{style:this.props.headerBackButtonTextStyle,__source:{fileName:_jsxFileName,lineNumber:165}},
+_react2.default.createElement(_Text.Text,{style:this.props.headerBackButtonTextStyle,__source:{fileName:_jsxFileName,lineNumber:168}},
this.props.headerBackButtonText||"Back"))),
-_react2.default.createElement(_Body.Body,{__source:{fileName:_jsxFileName,lineNumber:170}},
-_react2.default.createElement(_Title.Title,{style:this.props.headerTitleStyle,__source:{fileName:_jsxFileName,lineNumber:171}},
+_react2.default.createElement(_Body.Body,{__source:{fileName:_jsxFileName,lineNumber:173}},
+_react2.default.createElement(_Title.Title,{style:this.props.headerTitleStyle,__source:{fileName:_jsxFileName,lineNumber:174}},
this.props.iosHeader||"Select One")),
-_react2.default.createElement(_Right.Right,{__source:{fileName:_jsxFileName,lineNumber:175}}));
+_react2.default.createElement(_Right.Right,{__source:{fileName:_jsxFileName,lineNumber:178}}));
}},{key:"render",value:function render()
{var _this5=this;
return(
-_react2.default.createElement(_reactNative.View,{ref:function ref(c){return _this5._root=c;},__source:{fileName:_jsxFileName,lineNumber:182}},
+_react2.default.createElement(_reactNative.View,{ref:function ref(c){return _this5._root=c;},__source:{fileName:_jsxFileName,lineNumber:185}},
this.renderButton(),
_react2.default.createElement(_reactNative.Modal,{
supportedOrientations:this.props.supportedOrientations||null,
@@ -188,14 +191,15 @@ transparent:false,
visible:this.state.modalVisible,
onRequestClose:function onRequestClose(){
_this5._setModalVisible(false);
-},__source:{fileName:_jsxFileName,lineNumber:184}},
+},__source:{fileName:_jsxFileName,lineNumber:187}},
-_react2.default.createElement(_Container.Container,{style:this.props.modalStyle,__source:{fileName:_jsxFileName,lineNumber:193}},
+_react2.default.createElement(_Container.Container,{style:this.props.modalStyle,__source:{fileName:_jsxFileName,lineNumber:196}},
this.renderHeader(),
_react2.default.createElement(_reactNative.FlatList,{
data:this.state.dataSource,
keyExtractor:function keyExtractor(item,index){return String(index);},
-renderItem:function renderItem(_ref){var item=_ref.item;return _react2.default.createElement(_ListItem.ListItem,{
+renderItem:function renderItem(_ref){var item=_ref.item;return(
+_react2.default.createElement(_ListItem.ListItem,{
selected:item.props.value===_this5.props.selectedValue,
button:true,
style:_this5.props.itemStyle,
@@ -203,18 +207,19 @@ onPress:function onPress(){
_this5._setModalVisible(false);
_this5.props.onValueChange(item.props.value);
_this5.setState({current:item.props.label});
-},__source:{fileName:_jsxFileName,lineNumber:198}},
+},__source:{fileName:_jsxFileName,lineNumber:202}},
-_react2.default.createElement(_Left.Left,{__source:{fileName:_jsxFileName,lineNumber:208}},
-_react2.default.createElement(_Text.Text,{style:_this5.props.itemTextStyle,__source:{fileName:_jsxFileName,lineNumber:209}},
+_react2.default.createElement(_Left.Left,{__source:{fileName:_jsxFileName,lineNumber:212}},
+_react2.default.createElement(_Text.Text,{style:_this5.props.itemTextStyle,__source:{fileName:_jsxFileName,lineNumber:213}},
item.props.label)),
-_react2.default.createElement(_Right.Right,{__source:{fileName:_jsxFileName,lineNumber:213}},
+_react2.default.createElement(_Right.Right,{__source:{fileName:_jsxFileName,lineNumber:217}},
item.props.value===_this5.props.selectedValue?
-_react2.default.createElement(_Radio.Radio,{selected:true,__source:{fileName:_jsxFileName,lineNumber:215}}):
+_react2.default.createElement(_Radio.Radio,{selected:true,__source:{fileName:_jsxFileName,lineNumber:219}}):
+
+_react2.default.createElement(_Radio.Radio,{selected:false,__source:{fileName:_jsxFileName,lineNumber:221}}))));},__source:{fileName:_jsxFileName,lineNumber:198}})))));
-_react2.default.createElement(_Radio.Radio,{selected:false,__source:{fileName:_jsxFileName,lineNumber:217}})));},__source:{fileName:_jsxFileName,lineNumber:195}})))));
@@ -228,7 +233,7 @@ _react2.default.createElement(_Radio.Radio,{selected:false,__source:{fileName:_j
PickerNB.Item=(0,_createReactClass2.default)({displayName:"Item",
render:function render(){
-return _react2.default.createElement(_reactNative.Picker.Item,_extends({},this.props(),{__source:{fileName:_jsxFileName,lineNumber:231}}));
+return _react2.default.createElement(_reactNative.Picker.Item,_extends({},this.props(),{__source:{fileName:_jsxFileName,lineNumber:236}}));
}});
diff --git a/dist/src/basic/Picker.ios.js.map b/dist/src/basic/Picker.ios.js.map
index 741b79f34..51084523f 100644
--- a/dist/src/basic/Picker.ios.js.map
+++ b/dist/src/basic/Picker.ios.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../../../src/basic/Picker.ios.js"],"names":["PickerNB","props","state","modalVisible","currentLabel","getLabel","dataSource","getChildren","children","nextProps","nextLabel","currentDS","nextDS","setState","picker","pickerItem","visible","defaultProps","style","getInitialStyle","itemStyle","item","_","find","child","value","selectedValue","get","Array","isArray","concat","React","cloneElement","iosIcon","fontSize","lineHeight","onPress","enabled","undefined","_setModalVisible","text","placeholder","renderButton","selectedItem","getSelectedItem","textStyle","note","placeholderStyle","renderIcon","renderHeader","headerStyle","shadowOffset","shadowColor","shadowRadius","shadowOpacity","headerBackButtonStyle","headerBackButtonTextStyle","headerBackButtonText","headerTitleStyle","iosHeader","_root","c","supportedOrientations","modalStyle","index","String","onValueChange","current","label","itemTextStyle","Component","Item","render","propTypes","ViewPropTypes","PropTypes","func","StyledPickerNB","mapPropsToStyleNames"],"mappings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AWmE,KADd,CADF,CAVwB;;;AAexB,8BAAC,YAAD;AACG/C,KAAKpB,KAAL,CAAWwB,KAAX,GAAqB,OAAKxB,KAAL,CAAWyB,aAAhC;AACC,8BAAC,YAAD,EAAO,aAAP,kDADD;;AAGG,8BAAC,YAAD,EAAO,SAAU,KAAjB,kDAJN,CAfwB,CAAd,EAHd,kDAFF,CATF,CAFF,CADF;;;;;;;;;AA6CD,C,sBA3MoB4C,gB;;;AA8MvBtE,SAASuE,IAAT,CAAgB,+BAAiB;AAC/BC,MAD+B,kBACtB;AACP,MAAO,+BAAC,mBAAD,CAAQ,IAAR,aAAiB,KAAKvE,KAAL,EAAjB,oDAAP;AACD,CAH8B,CAAjB,CAAhB;;;AAMAD,SAASyE,SAAT;AACKC,0BADL;AAEEhC,aAAciC,oBAAUC,IAF1B;;;AAKA,GAAMC,gBAAiB;AACrB,qBADqB;AAErB,EAFqB;AAGrBC,8BAHqB;AAIrB9E,QAJqB,CAAvB,C;;AAM2BA,Q,CAAlB6E,c","file":"Picker.ios.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport createReactClass from \"create-react-class\";\nimport { Picker, Modal, View, ViewPropTypes, FlatList } from \"react-native\";\nimport _ from \"lodash\";\nimport { Text } from \"./Text\";\nimport { List } from \"./List\";\nimport { IconNB as Icon } from \"./IconNB\";\nimport { Radio } from \"./Radio\";\nimport { Container } from \"./Container\";\nimport { ListItem } from \"./ListItem\";\nimport { Button } from \"./Button\";\nimport { Header } from \"./Header\";\nimport { Title } from \"./Title\";\nimport { Left } from \"./Left\";\nimport { Right } from \"./Right\";\nimport { Body } from \"./Body\";\nimport { connectStyle } from \"native-base-shoutem-theme\";\nimport computeProps from \"../utils/computeProps\";\n\nimport mapPropsToStyleNames from \"../utils/mapPropsToStyleNames\";\n\nclass PickerNB extends Component {\n constructor(props) {\n super(props);\n this.state = {\n modalVisible: false,\n currentLabel: this.getLabel(props),\n dataSource: this.getChildren(props.children)\n };\n }\n\n componentWillReceiveProps(nextProps) {\n const currentLabel = this.state.currentLabel;\n const nextLabel = this.getLabel(nextProps);\n const currentDS = this.state.dataSource;\n const nextDS = this.getChildren(nextProps.children);\n\n if (currentLabel !== nextLabel) {\n this.setState({\n currentLabel: nextLabel\n });\n }\n if (currentDS !== nextDS) {\n this.setState({\n dataSource: nextDS\n });\n }\n }\n\n getInitialStyle() {\n return {\n picker: {\n // alignItems: 'flex-end'\n },\n pickerItem: {}\n };\n }\n _setModalVisible(visible) {\n this.setState({ modalVisible: visible });\n }\n\n prepareRootProps() {\n const defaultProps = {\n style: this.getInitialStyle().picker,\n itemStyle: this.getInitialStyle().pickerItem\n };\n\n return computeProps(this.props, defaultProps);\n }\n\n getLabel(props) {\n let children = this.getChildren(props.children);\n const item = _.find(\n children,\n child => child.props.value === props.selectedValue\n );\n return _.get(item, \"props.label\");\n }\n\n getSelectedItem() {\n return _.find(\n this.props.children,\n child => child.props.value === this.props.selectedValue\n );\n }\n\n getChildren(children) {\n if (children && !Array.isArray(children)) {\n return [].concat(children)\n }\n return children;\n }\n\n renderIcon() {\n return React.cloneElement(this.props.iosIcon, {\n style: [{\n fontSize: 22,\n lineHeight: 26\n }, { ...this.props.iosIcon.props.style }]\n });\n }\n\n renderButton() {\n const onPress = () => {\n if (this.props.enabled !== undefined && !this.props.enabled)\n return;\n this._setModalVisible(true);\n };\n const text = this.state.currentLabel\n ? this.state.currentLabel\n : this.props.placeholder;\n if (this.props.renderButton) {\n return this.props.renderButton({\n onPress,\n text,\n picker: this,\n selectedItem: this.getSelectedItem()\n });\n }\n return (\n \n );\n }\n\n renderHeader() {\n return this.props.renderHeader ? (\n this.props.renderHeader(() => this._setModalVisible(false))\n ) : (\n \n \n \n \n \n \n {this.props.iosHeader || \"Select One\"}\n \n \n \n \n );\n }\n\n render() {\n return (\n (this._root = c)}>\n {this.renderButton()}\n {\n this._setModalVisible(false);\n }}\n >\n \n {this.renderHeader()}\n String(index)}\n renderItem={({ item }) => {\n this._setModalVisible(false);\n this.props.onValueChange(item.props.value);\n this.setState({ current: item.props.label });\n }}\n >\n \n \n {item.props.label}\n \n \n \n {item.props.value === this.props.selectedValue ? (\n \n ) : (\n \n )}\n \n }\n />\n \n \n \n );\n }\n}\n\nPickerNB.Item = createReactClass({\n render() {\n return ;\n }\n});\n\nPickerNB.propTypes = {\n ...ViewPropTypes,\n renderButton: PropTypes.func\n};\n\nconst StyledPickerNB = connectStyle(\n \"NativeBase.PickerNB\",\n {},\n mapPropsToStyleNames\n)(PickerNB);\n\nexport { StyledPickerNB as PickerNB };\n"]}
\ No newline at end of file
+{"version":3,"sources":["../../../src/basic/Picker.ios.js"],"names":["PickerNB","props","state","modalVisible","currentLabel","getLabel","dataSource","getChildren","children","nextProps","nextLabel","currentDS","nextDS","setState","picker","pickerItem","visible","defaultProps","style","getInitialStyle","itemStyle","item","_","find","child","value","selectedValue","get","Array","isArray","concat","React","cloneElement","iosIcon","fontSize","lineHeight","onPress","enabled","undefined","_setModalVisible","text","placeholder","renderButton","selectedItem","getSelectedItem","textStyle","note","placeholderStyle","renderIcon","renderHeader","headerStyle","shadowOffset","shadowColor","shadowRadius","shadowOpacity","marginLeft","headerBackButtonStyle","headerBackButtonTextStyle","headerBackButtonText","headerTitleStyle","iosHeader","_root","c","supportedOrientations","modalStyle","index","String","onValueChange","current","label","itemTextStyle","Component","Item","render","propTypes","ViewPropTypes","PropTypes","func","StyledPickerNB","mapPropsToStyleNames"],"mappings":"61BAAA,4B;AACA,qC;AACA,oD;AACA;AACA,8B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mD;;AAEA,mE;;AAEMA,Q;AACJ,kBAAYC,KAAZ,CAAmB;AACXA,KADW;AAEjB,MAAKC,KAAL,CAAa;AACXC,aAAc,KADH;AAEXC,aAAc,MAAKC,QAAL,CAAcJ,KAAd,CAFH;AAGXK,WAAY,MAAKC,WAAL,CAAiBN,MAAMO,QAAvB,CAHD,CAAb,C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AiB;AAC/BC,MAD+B,kBACtB;AACP,MAAO,+BAAC,mBAAD,CAAQ,IAAR,aAAiB,KAAKxE,KAAL,EAAjB,oDAAP;AACD,CAH8B,CAAjB,CAAhB;;;AAMAD,SAAS0E,SAAT;AACKC,0BADL;AAEEjC,aAAckC,oBAAUC,IAF1B;;;AAKA,GAAMC,gBAAiB;AACrB,qBADqB;AAErB,EAFqB;AAGrBC,8BAHqB;AAIrB/E,QAJqB,CAAvB,C;;AAM2BA,Q,CAAlB8E,c","file":"Picker.ios.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport createReactClass from \"create-react-class\";\nimport { Picker, Modal, View, ViewPropTypes, FlatList } from \"react-native\";\nimport _ from \"lodash\";\nimport { Text } from \"./Text\";\nimport { List } from \"./List\";\nimport { IconNB as Icon } from \"./IconNB\";\nimport { Radio } from \"./Radio\";\nimport { Container } from \"./Container\";\nimport { ListItem } from \"./ListItem\";\nimport { Button } from \"./Button\";\nimport { Header } from \"./Header\";\nimport { Title } from \"./Title\";\nimport { Left } from \"./Left\";\nimport { Right } from \"./Right\";\nimport { Body } from \"./Body\";\nimport { connectStyle } from \"native-base-shoutem-theme\";\nimport computeProps from \"../utils/computeProps\";\n\nimport mapPropsToStyleNames from \"../utils/mapPropsToStyleNames\";\n\nclass PickerNB extends Component {\n constructor(props) {\n super(props);\n this.state = {\n modalVisible: false,\n currentLabel: this.getLabel(props),\n dataSource: this.getChildren(props.children)\n };\n }\n\n componentWillReceiveProps(nextProps) {\n const currentLabel = this.state.currentLabel;\n const nextLabel = this.getLabel(nextProps);\n const currentDS = this.state.dataSource;\n const nextDS = this.getChildren(nextProps.children);\n\n if (currentLabel !== nextLabel) {\n this.setState({\n currentLabel: nextLabel\n });\n }\n if (currentDS !== nextDS) {\n this.setState({\n dataSource: nextDS\n });\n }\n }\n\n getInitialStyle() {\n return {\n picker: {\n // alignItems: 'flex-end'\n },\n pickerItem: {}\n };\n }\n _setModalVisible(visible) {\n this.setState({ modalVisible: visible });\n }\n\n prepareRootProps() {\n const defaultProps = {\n style: this.getInitialStyle().picker,\n itemStyle: this.getInitialStyle().pickerItem\n };\n\n return computeProps(this.props, defaultProps);\n }\n\n getLabel(props) {\n let children = this.getChildren(props.children);\n const item = _.find(\n children,\n child => child.props.value === props.selectedValue\n );\n return _.get(item, \"props.label\");\n }\n\n getSelectedItem() {\n return _.find(\n this.props.children,\n child => child.props.value === this.props.selectedValue\n );\n }\n\n getChildren(children) {\n if (children && !Array.isArray(children)) {\n return [].concat(children);\n }\n return children;\n }\n\n renderIcon() {\n return React.cloneElement(this.props.iosIcon, {\n style: [\n {\n fontSize: 22,\n lineHeight: 26\n },\n { ...this.props.iosIcon.props.style }\n ]\n });\n }\n\n renderButton() {\n const onPress = () => {\n if (this.props.enabled !== undefined && !this.props.enabled) return;\n this._setModalVisible(true);\n };\n const text = this.state.currentLabel\n ? this.state.currentLabel\n : this.props.placeholder;\n if (this.props.renderButton) {\n return this.props.renderButton({\n onPress,\n text,\n picker: this,\n selectedItem: this.getSelectedItem()\n });\n }\n return (\n \n );\n }\n\n renderHeader() {\n return this.props.renderHeader ? (\n this.props.renderHeader(() => this._setModalVisible(false))\n ) : (\n \n \n \n \n \n \n {this.props.iosHeader || \"Select One\"}\n \n \n \n \n );\n }\n\n render() {\n return (\n (this._root = c)}>\n {this.renderButton()}\n {\n this._setModalVisible(false);\n }}\n >\n \n {this.renderHeader()}\n String(index)}\n renderItem={({ item }) => (\n {\n this._setModalVisible(false);\n this.props.onValueChange(item.props.value);\n this.setState({ current: item.props.label });\n }}\n >\n \n \n {item.props.label}\n \n \n \n {item.props.value === this.props.selectedValue ? (\n \n ) : (\n \n )}\n \n \n )}\n />\n \n \n \n );\n }\n}\n\nPickerNB.Item = createReactClass({\n render() {\n return ;\n }\n});\n\nPickerNB.propTypes = {\n ...ViewPropTypes,\n renderButton: PropTypes.func\n};\n\nconst StyledPickerNB = connectStyle(\n \"NativeBase.PickerNB\",\n {},\n mapPropsToStyleNames\n)(PickerNB);\n\nexport { StyledPickerNB as PickerNB };\n"]}
\ No newline at end of file
diff --git a/src/basic/Picker.ios.js b/src/basic/Picker.ios.js
index 2b1e83a4a..f666d439c 100644
--- a/src/basic/Picker.ios.js
+++ b/src/basic/Picker.ios.js
@@ -87,24 +87,26 @@ class PickerNB extends Component {
getChildren(children) {
if (children && !Array.isArray(children)) {
- return [].concat(children)
+ return [].concat(children);
}
return children;
}
renderIcon() {
return React.cloneElement(this.props.iosIcon, {
- style: [{
- fontSize: 22,
- lineHeight: 26
- }, { ...this.props.iosIcon.props.style }]
+ style: [
+ {
+ fontSize: 22,
+ lineHeight: 26
+ },
+ { ...this.props.iosIcon.props.style }
+ ]
});
}
renderButton() {
const onPress = () => {
- if (this.props.enabled !== undefined && !this.props.enabled)
- return;
+ if (this.props.enabled !== undefined && !this.props.enabled) return;
this._setModalVisible(true);
};
const text = this.state.currentLabel
@@ -131,13 +133,13 @@ class PickerNB extends Component {
{this.state.currentLabel}
) : (
-
- {this.props.placeholder}
-
- )}
+
+ {this.props.placeholder}
+
+ )}
{this.props.iosIcon === undefined ? null : this.renderIcon()}
);
@@ -147,34 +149,35 @@ class PickerNB extends Component {
return this.props.renderHeader ? (
this.props.renderHeader(() => this._setModalVisible(false))
) : (
-
-
-
-
-
-
- {this.props.iosHeader || "Select One"}
-
-
-
-
- );
+
+
+
+
+
+
+ {this.props.iosHeader || "Select One"}
+
+
+
+
+ );
}
render() {
@@ -195,33 +198,35 @@ class PickerNB extends Component {
String(index)}
- renderItem={({ item }) => {
- this._setModalVisible(false);
- this.props.onValueChange(item.props.value);
- this.setState({ current: item.props.label });
- }}
- >
-
-
- {item.props.label}
-
-
-
- {item.props.value === this.props.selectedValue ? (
-
- ) : (
+ renderItem={({ item }) => (
+ {
+ this._setModalVisible(false);
+ this.props.onValueChange(item.props.value);
+ this.setState({ current: item.props.label });
+ }}
+ >
+
+
+ {item.props.label}
+
+
+
+ {item.props.value === this.props.selectedValue ? (
+
+ ) : (
)}
-
- }
+
+
+ )}
/>
-
+
);
}
}