ac-city-select
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -55,3 +55,3 @@ 'use strict'; | ||
defaultValue: _provinceData.zh.defaultValue, | ||
value: null, | ||
value: _provinceData.zh.defaultValue, | ||
onChange: function onChange() {}, | ||
@@ -154,10 +154,28 @@ provinceData: _provinceData.zh.provinceData, | ||
area = _nextProps$value.area; | ||
// if(province !== oldProvince || city !== oldCity || area !== oldArea) { | ||
// this.setState({ | ||
// province, | ||
// secondCity: city, | ||
// secondArea: area | ||
// }); | ||
// this.handleProvinceChange(province, city, area); | ||
// } | ||
if (province !== oldProvince || city !== oldCity || area !== oldArea) { | ||
if (province !== oldProvince) { | ||
this.setState({ | ||
province: province, | ||
secondCity: city, | ||
province: province | ||
}); | ||
return this.handleProvinceChange(province, city, area); | ||
} | ||
if (city !== oldCity) { | ||
this.setState({ | ||
secondCity: city | ||
}); | ||
return this.handleCityChange(city); | ||
} | ||
if (area !== oldArea) { | ||
this.setState({ | ||
secondArea: area | ||
}); | ||
this.handleProvinceChange(province, city, area); | ||
this.onSecondAreaChange(area); | ||
} | ||
@@ -191,2 +209,3 @@ }; | ||
var provinceOptions = provinceData.map(function (province, index) { | ||
@@ -247,3 +266,3 @@ if (province.disabled) { | ||
disabled: this.props.disabled, | ||
allowClear: this.props.allowClear, | ||
allowClear: this.state.province && this.props.allowClear, | ||
onChange: function onChange(value) { | ||
@@ -259,3 +278,3 @@ return _this2.handleProvinceChange(value); | ||
disabled: this.props.disabled, | ||
allowClear: this.props.allowClear, | ||
allowClear: this.state.secondCity && this.props.allowClear, | ||
className: 'city', | ||
@@ -272,3 +291,3 @@ onChange: function onChange(value) { | ||
className: 'area', | ||
allowClear: this.props.allowClear, | ||
allowClear: this.state.secondArea && this.props.allowClear, | ||
disabled: this.props.disabled, | ||
@@ -275,0 +294,0 @@ onChange: function onChange(value) { |
@@ -0,1 +1,6 @@ | ||
<a name="0.0.5"></a> | ||
## [0.0.5](https://github.com/tinper-bee/ac-city-select/compare/v0.0.4...v0.0.5) (2019-08-15) | ||
<a name="0.0.4"></a> | ||
@@ -2,0 +7,0 @@ ## [0.0.4](https://github.com/tinper-bee/ac-city-select/compare/v0.0.3...v0.0.4) (2019-08-09) |
{ | ||
"name": "ac-city-select", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "CitySelect ui component for react", | ||
@@ -51,2 +51,3 @@ "keywords": [ | ||
"bee-drawer": "0.0.2", | ||
"bee-form": "^2.0.11", | ||
"bee-layout": "latest", | ||
@@ -53,0 +54,0 @@ "bee-panel": "latest", |
@@ -24,3 +24,3 @@ | ||
defaultValue: zh.defaultValue, | ||
value: null, | ||
value: zh.defaultValue, | ||
onChange: () => { }, | ||
@@ -93,11 +93,29 @@ provinceData: zh.provinceData, | ||
if (!nextProps.value) return; | ||
const { province:oldProvince, city:oldCity, area:oldArea } = this.props.value | ||
const { province:oldProvince, city:oldCity, area:oldArea } = this.props.value; | ||
const { province, city, area } = nextProps.value; | ||
if(province !== oldProvince || city !== oldCity || area !== oldArea) { | ||
// if(province !== oldProvince || city !== oldCity || area !== oldArea) { | ||
// this.setState({ | ||
// province, | ||
// secondCity: city, | ||
// secondArea: area | ||
// }); | ||
// this.handleProvinceChange(province, city, area); | ||
// } | ||
if(province !== oldProvince) { | ||
this.setState({ | ||
province, | ||
}); | ||
return this.handleProvinceChange(province, city, area); | ||
} | ||
if(city !== oldCity) { | ||
this.setState({ | ||
secondCity: city, | ||
}); | ||
return this.handleCityChange(city); | ||
} | ||
if(area !== oldArea) { | ||
this.setState({ | ||
secondArea: area | ||
}); | ||
this.handleProvinceChange(province, city, area); | ||
this.onSecondAreaChange(area); | ||
} | ||
@@ -245,2 +263,3 @@ } | ||
let { provinceData, cities, areas } = this.state; | ||
const provinceOptions = provinceData.map((province, index) => { | ||
@@ -274,3 +293,3 @@ if (province.disabled) { | ||
disabled={this.props.disabled} | ||
allowClear = {this.props.allowClear} | ||
allowClear = {this.state.province && this.props.allowClear} | ||
onChange={(value) => this.handleProvinceChange(value)}> | ||
@@ -282,3 +301,3 @@ {provinceOptions} | ||
disabled={this.props.disabled} | ||
allowClear = {this.props.allowClear} | ||
allowClear = {this.state.secondCity && this.props.allowClear} | ||
className="city" | ||
@@ -291,3 +310,3 @@ onChange={(value) => this.handleCityChange(value)}> | ||
className="area" | ||
allowClear = {this.props.allowClear} | ||
allowClear = {this.state.secondArea && this.props.allowClear} | ||
disabled={this.props.disabled} | ||
@@ -294,0 +313,0 @@ onChange={(value) => this.onSecondAreaChange(value)}> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5171177
56833
13