@fle-ui/plus-address-selection 1.0.3-beta.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import { CascaderProps } from 'antd';
3
- export declare type CascaderValueType = string | (string | number)[];
3
+ export declare type CascaderValueType = string | Array<string | number>;
4
4
  export interface CascaderOptionType {
5
5
  value?: string | number;
6
6
  label?: React.ReactNode;
7
7
  disabled?: boolean;
8
8
  isLeaf?: boolean;
9
9
  loading?: boolean;
10
- children?: Array<CascaderOptionType>;
10
+ children?: CascaderOptionType[];
11
11
  hasChildren?: boolean;
12
12
  [key: string]: any;
13
13
  }
@@ -24,7 +24,7 @@ export interface addressItem {
24
24
  }
25
25
  export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'value'> {
26
26
  /**
27
- * @description 格式化value
27
+ * @description 格式化 value
28
28
  * @default
29
29
  */
30
30
  valueDivision?: string;
@@ -39,12 +39,12 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
39
39
  */
40
40
  level?: number;
41
41
  /**
42
- * @description 指定选中项-
42
+ * @description 指定选中项
43
43
  * @default []
44
44
  */
45
45
  value?: CascaderValueType;
46
46
  /**
47
- * @description 可选项数据源-
47
+ * @description 可选项数据源
48
48
  * @default []
49
49
  */
50
50
  options?: CascaderOptionType[];
package/es/index.js CHANGED
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
- import React, { useEffect, useRef, useState } from 'react';
21
+ import React, { useEffect, useState } from 'react';
22
22
  import _ from 'lodash';
23
23
  import { httpClient } from './utils';
24
24
  var AddressSelection = function AddressSelection(props) {
@@ -40,29 +40,46 @@ var AddressSelection = function AddressSelection(props) {
40
40
  _useState6 = _slicedToArray(_useState5, 2),
41
41
  stateValue = _useState6[0],
42
42
  setStateValue = _useState6[1];
43
- var firstTime = useRef(true);
44
43
  useEffect(function () {
45
- var _props$defaultValue;
46
- var val = value;
47
- if (firstTime.current && !(value === null || value === void 0 ? void 0 : value.length) && ((_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.length)) {
48
- val = formatValue(props.defaultValue || '');
44
+ var val = formatValue((value === null || value === void 0 ? void 0 : value.length) ? value : props.defaultValue || '');
45
+ function init() {
46
+ return _init.apply(this, arguments);
49
47
  }
50
- if (!isLoad && level) {
51
- initAddress(formatValue(val), 0);
52
- setStateValue(formatValue(val));
53
- } else {
54
- setStateValue([]);
48
+ function _init() {
49
+ _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
50
+ var data, provinceList;
51
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
52
+ while (1) switch (_context.prev = _context.next) {
53
+ case 0:
54
+ _context.next = 2;
55
+ return getAddressAPI({
56
+ parentCode: 0
57
+ });
58
+ case 2:
59
+ data = _context.sent;
60
+ provinceList = formatArea(data, level === 1);
61
+ setAddressList(provinceList);
62
+ setStateValue(val);
63
+ case 6:
64
+ case "end":
65
+ return _context.stop();
66
+ }
67
+ }, _callee);
68
+ }));
69
+ return _init.apply(this, arguments);
55
70
  }
56
- // leval改变后需要更新,不然动态切换 level会有bug
57
- if (isLoad && !firstTime.current && level) {
58
- initAddress(formatValue(val), 0);
59
- setStateValue(formatValue(val));
71
+ init();
72
+ }, [level]);
73
+ useEffect(function () {
74
+ var val = formatValue((value === null || value === void 0 ? void 0 : value.length) ? value : props.defaultValue || '');
75
+ if (addressList.length && (val === null || val === void 0 ? void 0 : val.length) && !isLoad) {
76
+ initAddress(val);
77
+ setStateValue(val);
60
78
  }
61
- firstTime.current = false;
62
- }, [value, level]);
79
+ }, [value, addressList.length, isLoad]);
63
80
  var formatValue = function formatValue(value) {
64
81
  var localvalue = [];
65
- if (!!value) {
82
+ if (value) {
66
83
  if (!!valueDivision && !_.isArray(value)) {
67
84
  localvalue = value.split(valueDivision);
68
85
  } else {
@@ -89,62 +106,56 @@ var AddressSelection = function AddressSelection(props) {
89
106
  });
90
107
  };
91
108
  var getAddressAPI = /*#__PURE__*/function () {
92
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
109
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
93
110
  var params,
94
111
  _yield$httpClient$pos,
95
112
  data,
96
- _args = arguments;
97
- return _regeneratorRuntime().wrap(function _callee$(_context) {
98
- while (1) switch (_context.prev = _context.next) {
113
+ _args2 = arguments;
114
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
115
+ while (1) switch (_context2.prev = _context2.next) {
99
116
  case 0:
100
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
101
- _context.next = 3;
117
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
118
+ _context2.next = 3;
102
119
  return httpClient.post(apiUrl || '/basic/area/areas', params);
103
120
  case 3:
104
- _yield$httpClient$pos = _context.sent;
121
+ _yield$httpClient$pos = _context2.sent;
105
122
  data = _yield$httpClient$pos.data;
106
- return _context.abrupt("return", data);
123
+ return _context2.abrupt("return", data);
107
124
  case 6:
108
125
  case "end":
109
- return _context.stop();
126
+ return _context2.stop();
110
127
  }
111
- }, _callee);
128
+ }, _callee2);
112
129
  }));
113
130
  return function getAddressAPI() {
114
131
  return _ref.apply(this, arguments);
115
132
  };
116
133
  }();
117
134
  var initAddress = /*#__PURE__*/function () {
118
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
119
- var data, provinceList, len, thisAddress, _loop, i;
120
- return _regeneratorRuntime().wrap(function _callee2$(_context3) {
121
- while (1) switch (_context3.prev = _context3.next) {
135
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
136
+ var provinceList, len, thisAddress, _loop, i;
137
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
138
+ while (1) switch (_context4.prev = _context4.next) {
122
139
  case 0:
123
- _context3.next = 2;
124
- return getAddressAPI({
125
- parentCode: parentCode
126
- });
127
- case 2:
128
- data = _context3.sent;
129
- provinceList = formatArea(data, level === 1);
130
- if (!defaultValue) {
131
- _context3.next = 14;
140
+ provinceList = _.cloneDeep(addressList);
141
+ len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
142
+ if (!len) {
143
+ _context4.next = 11;
132
144
  break;
133
145
  }
134
- len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
135
146
  thisAddress = provinceList;
136
147
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
137
148
  var _thisAddress;
138
149
  var levelData, thisIndex;
139
- return _regeneratorRuntime().wrap(function _loop$(_context2) {
140
- while (1) switch (_context2.prev = _context2.next) {
150
+ return _regeneratorRuntime().wrap(function _loop$(_context3) {
151
+ while (1) switch (_context3.prev = _context3.next) {
141
152
  case 0:
142
- _context2.next = 2;
153
+ _context3.next = 2;
143
154
  return getAddressAPI({
144
155
  parentCode: defaultValue[i]
145
156
  });
146
157
  case 2:
147
- levelData = _context2.sent;
158
+ levelData = _context3.sent;
148
159
  thisIndex = -1;
149
160
  (_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
150
161
  if (item.value === defaultValue[i]) {
@@ -155,51 +166,54 @@ var AddressSelection = function AddressSelection(props) {
155
166
  if (thisIndex !== -1 && thisAddress[thisIndex].children) {
156
167
  thisAddress = thisAddress[thisIndex].children;
157
168
  }
158
- case 6:
169
+ if (i === len - 2) {
170
+ setIsLoad(true);
171
+ }
172
+ case 7:
159
173
  case "end":
160
- return _context2.stop();
174
+ return _context3.stop();
161
175
  }
162
176
  }, _loop);
163
177
  });
164
178
  i = 0;
165
- case 9:
179
+ case 6:
166
180
  if (!(i < len - 1)) {
167
- _context3.next = 14;
181
+ _context4.next = 11;
168
182
  break;
169
183
  }
170
- return _context3.delegateYield(_loop(i), "t0", 11);
171
- case 11:
184
+ return _context4.delegateYield(_loop(i), "t0", 8);
185
+ case 8:
172
186
  i++;
173
- _context3.next = 9;
187
+ _context4.next = 6;
174
188
  break;
175
- case 14:
189
+ case 11:
176
190
  setAddressList(provinceList);
177
- case 15:
191
+ case 12:
178
192
  case "end":
179
- return _context3.stop();
193
+ return _context4.stop();
180
194
  }
181
- }, _callee2);
195
+ }, _callee3);
182
196
  }));
183
197
  return function initAddress(_x, _x2) {
184
198
  return _ref2.apply(this, arguments);
185
199
  };
186
200
  }();
187
201
  var loadData = /*#__PURE__*/function () {
188
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
202
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
189
203
  var targetOption, data;
190
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
191
- while (1) switch (_context4.prev = _context4.next) {
204
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
205
+ while (1) switch (_context5.prev = _context5.next) {
192
206
  case 0:
193
207
  targetOption = selectedOptions[selectedOptions.length - 1];
194
208
  targetOption.loading = true;
195
- _context4.next = 4;
209
+ _context5.next = 4;
196
210
  return getAddressAPI({
197
211
  parentCode: targetOption.value
198
212
  });
199
213
  case 4:
200
- data = _context4.sent;
214
+ data = _context5.sent;
201
215
  targetOption.loading = false;
202
- if (!!data.length) {
216
+ if (data.length) {
203
217
  targetOption.children = formatArea(data, targetOption.level + 1 === level);
204
218
  } else {
205
219
  targetOption.isLeaf = true;
@@ -208,9 +222,9 @@ var AddressSelection = function AddressSelection(props) {
208
222
  setAddressList(_toConsumableArray(addressList));
209
223
  case 9:
210
224
  case "end":
211
- return _context4.stop();
225
+ return _context5.stop();
212
226
  }
213
- }, _callee3);
227
+ }, _callee4);
214
228
  }));
215
229
  return function loadData(_x3) {
216
230
  return _ref3.apply(this, arguments);
@@ -218,13 +232,14 @@ var AddressSelection = function AddressSelection(props) {
218
232
  }();
219
233
  var handleChange = function handleChange(info, selectedOptions) {
220
234
  var cascaderValue = info;
221
- if (!!valueDivision) {
235
+ if (valueDivision) {
222
236
  cascaderValue = cascaderValue.join(valueDivision);
223
237
  }
224
238
  setStateValue(info);
225
239
  onChange && onChange(cascaderValue, selectedOptions);
226
240
  };
227
241
  return /*#__PURE__*/React.createElement(_Cascader, _extends({}, otherProps, {
242
+ defaultValue: props.defaultValue,
228
243
  loadData: loadData,
229
244
  options: addressList,
230
245
  onChange: handleChange,
package/lib/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import { CascaderProps } from 'antd';
3
- export declare type CascaderValueType = string | (string | number)[];
3
+ export declare type CascaderValueType = string | Array<string | number>;
4
4
  export interface CascaderOptionType {
5
5
  value?: string | number;
6
6
  label?: React.ReactNode;
7
7
  disabled?: boolean;
8
8
  isLeaf?: boolean;
9
9
  loading?: boolean;
10
- children?: Array<CascaderOptionType>;
10
+ children?: CascaderOptionType[];
11
11
  hasChildren?: boolean;
12
12
  [key: string]: any;
13
13
  }
@@ -24,7 +24,7 @@ export interface addressItem {
24
24
  }
25
25
  export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'value'> {
26
26
  /**
27
- * @description 格式化value
27
+ * @description 格式化 value
28
28
  * @default
29
29
  */
30
30
  valueDivision?: string;
@@ -39,12 +39,12 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
39
39
  */
40
40
  level?: number;
41
41
  /**
42
- * @description 指定选中项-
42
+ * @description 指定选中项
43
43
  * @default []
44
44
  */
45
45
  value?: CascaderValueType;
46
46
  /**
47
- * @description 可选项数据源-
47
+ * @description 可选项数据源
48
48
  * @default []
49
49
  */
50
50
  options?: CascaderOptionType[];
package/lib/index.js CHANGED
@@ -48,29 +48,46 @@ var AddressSelection = function AddressSelection(props) {
48
48
  _useState6 = _slicedToArray(_useState5, 2),
49
49
  stateValue = _useState6[0],
50
50
  setStateValue = _useState6[1];
51
- var firstTime = (0, _react.useRef)(true);
52
51
  (0, _react.useEffect)(function () {
53
- var _props$defaultValue;
54
- var val = value;
55
- if (firstTime.current && !(value === null || value === void 0 ? void 0 : value.length) && ((_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.length)) {
56
- val = formatValue(props.defaultValue || '');
52
+ var val = formatValue((value === null || value === void 0 ? void 0 : value.length) ? value : props.defaultValue || '');
53
+ function init() {
54
+ return _init.apply(this, arguments);
57
55
  }
58
- if (!isLoad && level) {
59
- initAddress(formatValue(val), 0);
60
- setStateValue(formatValue(val));
61
- } else {
62
- setStateValue([]);
56
+ function _init() {
57
+ _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
58
+ var data, provinceList;
59
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ _context.next = 2;
63
+ return getAddressAPI({
64
+ parentCode: 0
65
+ });
66
+ case 2:
67
+ data = _context.sent;
68
+ provinceList = formatArea(data, level === 1);
69
+ setAddressList(provinceList);
70
+ setStateValue(val);
71
+ case 6:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }, _callee);
76
+ }));
77
+ return _init.apply(this, arguments);
63
78
  }
64
- // leval改变后需要更新,不然动态切换 level会有bug
65
- if (isLoad && !firstTime.current && level) {
66
- initAddress(formatValue(val), 0);
67
- setStateValue(formatValue(val));
79
+ init();
80
+ }, [level]);
81
+ (0, _react.useEffect)(function () {
82
+ var val = formatValue((value === null || value === void 0 ? void 0 : value.length) ? value : props.defaultValue || '');
83
+ if (addressList.length && (val === null || val === void 0 ? void 0 : val.length) && !isLoad) {
84
+ initAddress(val);
85
+ setStateValue(val);
68
86
  }
69
- firstTime.current = false;
70
- }, [value, level]);
87
+ }, [value, addressList.length, isLoad]);
71
88
  var formatValue = function formatValue(value) {
72
89
  var localvalue = [];
73
- if (!!value) {
90
+ if (value) {
74
91
  if (!!valueDivision && !_lodash.default.isArray(value)) {
75
92
  localvalue = value.split(valueDivision);
76
93
  } else {
@@ -97,62 +114,56 @@ var AddressSelection = function AddressSelection(props) {
97
114
  });
98
115
  };
99
116
  var getAddressAPI = /*#__PURE__*/function () {
100
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
117
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
101
118
  var params,
102
119
  _yield$httpClient$pos,
103
120
  data,
104
- _args = arguments;
105
- return _regeneratorRuntime().wrap(function _callee$(_context) {
106
- while (1) switch (_context.prev = _context.next) {
121
+ _args2 = arguments;
122
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
123
+ while (1) switch (_context2.prev = _context2.next) {
107
124
  case 0:
108
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
109
- _context.next = 3;
125
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
126
+ _context2.next = 3;
110
127
  return _utils.httpClient.post(apiUrl || '/basic/area/areas', params);
111
128
  case 3:
112
- _yield$httpClient$pos = _context.sent;
129
+ _yield$httpClient$pos = _context2.sent;
113
130
  data = _yield$httpClient$pos.data;
114
- return _context.abrupt("return", data);
131
+ return _context2.abrupt("return", data);
115
132
  case 6:
116
133
  case "end":
117
- return _context.stop();
134
+ return _context2.stop();
118
135
  }
119
- }, _callee);
136
+ }, _callee2);
120
137
  }));
121
138
  return function getAddressAPI() {
122
139
  return _ref.apply(this, arguments);
123
140
  };
124
141
  }();
125
142
  var initAddress = /*#__PURE__*/function () {
126
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
127
- var data, provinceList, len, thisAddress, _loop, i;
128
- return _regeneratorRuntime().wrap(function _callee2$(_context3) {
129
- while (1) switch (_context3.prev = _context3.next) {
143
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
144
+ var provinceList, len, thisAddress, _loop, i;
145
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
146
+ while (1) switch (_context4.prev = _context4.next) {
130
147
  case 0:
131
- _context3.next = 2;
132
- return getAddressAPI({
133
- parentCode: parentCode
134
- });
135
- case 2:
136
- data = _context3.sent;
137
- provinceList = formatArea(data, level === 1);
138
- if (!defaultValue) {
139
- _context3.next = 14;
148
+ provinceList = _lodash.default.cloneDeep(addressList);
149
+ len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
150
+ if (!len) {
151
+ _context4.next = 11;
140
152
  break;
141
153
  }
142
- len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
143
154
  thisAddress = provinceList;
144
155
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
145
156
  var _thisAddress;
146
157
  var levelData, thisIndex;
147
- return _regeneratorRuntime().wrap(function _loop$(_context2) {
148
- while (1) switch (_context2.prev = _context2.next) {
158
+ return _regeneratorRuntime().wrap(function _loop$(_context3) {
159
+ while (1) switch (_context3.prev = _context3.next) {
149
160
  case 0:
150
- _context2.next = 2;
161
+ _context3.next = 2;
151
162
  return getAddressAPI({
152
163
  parentCode: defaultValue[i]
153
164
  });
154
165
  case 2:
155
- levelData = _context2.sent;
166
+ levelData = _context3.sent;
156
167
  thisIndex = -1;
157
168
  (_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
158
169
  if (item.value === defaultValue[i]) {
@@ -163,51 +174,54 @@ var AddressSelection = function AddressSelection(props) {
163
174
  if (thisIndex !== -1 && thisAddress[thisIndex].children) {
164
175
  thisAddress = thisAddress[thisIndex].children;
165
176
  }
166
- case 6:
177
+ if (i === len - 2) {
178
+ setIsLoad(true);
179
+ }
180
+ case 7:
167
181
  case "end":
168
- return _context2.stop();
182
+ return _context3.stop();
169
183
  }
170
184
  }, _loop);
171
185
  });
172
186
  i = 0;
173
- case 9:
187
+ case 6:
174
188
  if (!(i < len - 1)) {
175
- _context3.next = 14;
189
+ _context4.next = 11;
176
190
  break;
177
191
  }
178
- return _context3.delegateYield(_loop(i), "t0", 11);
179
- case 11:
192
+ return _context4.delegateYield(_loop(i), "t0", 8);
193
+ case 8:
180
194
  i++;
181
- _context3.next = 9;
195
+ _context4.next = 6;
182
196
  break;
183
- case 14:
197
+ case 11:
184
198
  setAddressList(provinceList);
185
- case 15:
199
+ case 12:
186
200
  case "end":
187
- return _context3.stop();
201
+ return _context4.stop();
188
202
  }
189
- }, _callee2);
203
+ }, _callee3);
190
204
  }));
191
205
  return function initAddress(_x, _x2) {
192
206
  return _ref2.apply(this, arguments);
193
207
  };
194
208
  }();
195
209
  var loadData = /*#__PURE__*/function () {
196
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
210
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
197
211
  var targetOption, data;
198
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
199
- while (1) switch (_context4.prev = _context4.next) {
212
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
213
+ while (1) switch (_context5.prev = _context5.next) {
200
214
  case 0:
201
215
  targetOption = selectedOptions[selectedOptions.length - 1];
202
216
  targetOption.loading = true;
203
- _context4.next = 4;
217
+ _context5.next = 4;
204
218
  return getAddressAPI({
205
219
  parentCode: targetOption.value
206
220
  });
207
221
  case 4:
208
- data = _context4.sent;
222
+ data = _context5.sent;
209
223
  targetOption.loading = false;
210
- if (!!data.length) {
224
+ if (data.length) {
211
225
  targetOption.children = formatArea(data, targetOption.level + 1 === level);
212
226
  } else {
213
227
  targetOption.isLeaf = true;
@@ -216,9 +230,9 @@ var AddressSelection = function AddressSelection(props) {
216
230
  setAddressList(_toConsumableArray(addressList));
217
231
  case 9:
218
232
  case "end":
219
- return _context4.stop();
233
+ return _context5.stop();
220
234
  }
221
- }, _callee3);
235
+ }, _callee4);
222
236
  }));
223
237
  return function loadData(_x3) {
224
238
  return _ref3.apply(this, arguments);
@@ -226,13 +240,14 @@ var AddressSelection = function AddressSelection(props) {
226
240
  }();
227
241
  var handleChange = function handleChange(info, selectedOptions) {
228
242
  var cascaderValue = info;
229
- if (!!valueDivision) {
243
+ if (valueDivision) {
230
244
  cascaderValue = cascaderValue.join(valueDivision);
231
245
  }
232
246
  setStateValue(info);
233
247
  onChange && onChange(cascaderValue, selectedOptions);
234
248
  };
235
249
  return /*#__PURE__*/_react.default.createElement(_antd.Cascader, _extends({}, otherProps, {
250
+ defaultValue: props.defaultValue,
236
251
  loadData: loadData,
237
252
  options: addressList,
238
253
  onChange: handleChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/plus-address-selection",
3
- "version": "1.0.3-beta.2",
3
+ "version": "1.0.3",
4
4
  "description": "@fle-ui/plus-address-selection",
5
5
  "private": false,
6
6
  "main": "lib/index.js",
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "@types/js-cookie": "^3.0.0"
43
43
  },
44
- "gitHead": "75b9376fa7e8dd672e468d237643943b5868e20a"
44
+ "gitHead": "41fb85a0e9ef436c6a33ce1af9a6a48053987f17"
45
45
  }