@fle-ui/plus-address-selection 1.0.13 → 1.0.15

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
@@ -20,7 +20,7 @@ export interface addressItem {
20
20
  tree?: string;
21
21
  level?: string;
22
22
  isLeaf?: boolean;
23
- hasChildren?: boolean;
23
+ hasChildren?: boolean | 0 | 1;
24
24
  children?: addressItem[];
25
25
  }
26
26
  export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'value'> {
package/es/index.js CHANGED
@@ -74,9 +74,10 @@ var AddressSelection = function AddressSelection(props) {
74
74
  case 2:
75
75
  data = _context.sent;
76
76
  provinceList = formatArea(data, level === 1);
77
+ console.log(apiUrl, provinceList);
77
78
  setAddressList(provinceList);
78
79
  setStateValue(val);
79
- case 6:
80
+ case 7:
80
81
  case "end":
81
82
  return _context.stop();
82
83
  }
@@ -112,12 +113,16 @@ var AddressSelection = function AddressSelection(props) {
112
113
  };
113
114
  var formatArea = function formatArea(list, isLeaf) {
114
115
  return list === null || list === void 0 ? void 0 : list.map(function (item) {
116
+ var _isLeaf = isLeaf;
117
+ if (item.hasChildren === 0) {
118
+ _isLeaf = true;
119
+ }
115
120
  return {
116
121
  value: item.code,
117
122
  label: item.name,
118
123
  tree: item.tree,
119
124
  level: item.level,
120
- isLeaf: item.hasChildren ? isLeaf : !item.hasChildren
125
+ isLeaf: _isLeaf
121
126
  };
122
127
  });
123
128
  };
@@ -195,18 +200,12 @@ var AddressSelection = function AddressSelection(props) {
195
200
  while (1) switch (_context4.prev = _context4.next) {
196
201
  case 0:
197
202
  targetOption = selectedOptions[selectedOptions.length - 1];
198
- if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
199
- _context4.next = 3;
200
- break;
201
- }
202
- return _context4.abrupt("return");
203
- case 3:
204
203
  targetOption.loading = true;
205
- _context4.next = 6;
204
+ _context4.next = 4;
206
205
  return getAddress({
207
206
  parentCode: targetOption.value
208
207
  });
209
- case 6:
208
+ case 4:
210
209
  data = _context4.sent;
211
210
  targetOption.loading = false;
212
211
  if (data.length) {
@@ -216,7 +215,7 @@ var AddressSelection = function AddressSelection(props) {
216
215
  }
217
216
  setIsLoad(true);
218
217
  setAddressList(_toConsumableArray(addressList));
219
- case 11:
218
+ case 9:
220
219
  case "end":
221
220
  return _context4.stop();
222
221
  }
@@ -228,6 +227,7 @@ var AddressSelection = function AddressSelection(props) {
228
227
  }();
229
228
  var handleChange = function handleChange(info, selectedOptions) {
230
229
  var cascaderValue = info || [];
230
+ console.log(cascaderValue, 'cascaderValue');
231
231
  if (valueDivision) {
232
232
  cascaderValue = cascaderValue.join(valueDivision);
233
233
  }
package/lib/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export interface addressItem {
20
20
  tree?: string;
21
21
  level?: string;
22
22
  isLeaf?: boolean;
23
- hasChildren?: boolean;
23
+ hasChildren?: boolean | 0 | 1;
24
24
  children?: addressItem[];
25
25
  }
26
26
  export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'value'> {
package/lib/index.js CHANGED
@@ -82,9 +82,10 @@ var AddressSelection = function AddressSelection(props) {
82
82
  case 2:
83
83
  data = _context.sent;
84
84
  provinceList = formatArea(data, level === 1);
85
+ console.log(apiUrl, provinceList);
85
86
  setAddressList(provinceList);
86
87
  setStateValue(val);
87
- case 6:
88
+ case 7:
88
89
  case "end":
89
90
  return _context.stop();
90
91
  }
@@ -120,12 +121,16 @@ var AddressSelection = function AddressSelection(props) {
120
121
  };
121
122
  var formatArea = function formatArea(list, isLeaf) {
122
123
  return list === null || list === void 0 ? void 0 : list.map(function (item) {
124
+ var _isLeaf = isLeaf;
125
+ if (item.hasChildren === 0) {
126
+ _isLeaf = true;
127
+ }
123
128
  return {
124
129
  value: item.code,
125
130
  label: item.name,
126
131
  tree: item.tree,
127
132
  level: item.level,
128
- isLeaf: item.hasChildren ? isLeaf : !item.hasChildren
133
+ isLeaf: _isLeaf
129
134
  };
130
135
  });
131
136
  };
@@ -203,18 +208,12 @@ var AddressSelection = function AddressSelection(props) {
203
208
  while (1) switch (_context4.prev = _context4.next) {
204
209
  case 0:
205
210
  targetOption = selectedOptions[selectedOptions.length - 1];
206
- if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
207
- _context4.next = 3;
208
- break;
209
- }
210
- return _context4.abrupt("return");
211
- case 3:
212
211
  targetOption.loading = true;
213
- _context4.next = 6;
212
+ _context4.next = 4;
214
213
  return getAddress({
215
214
  parentCode: targetOption.value
216
215
  });
217
- case 6:
216
+ case 4:
218
217
  data = _context4.sent;
219
218
  targetOption.loading = false;
220
219
  if (data.length) {
@@ -224,7 +223,7 @@ var AddressSelection = function AddressSelection(props) {
224
223
  }
225
224
  setIsLoad(true);
226
225
  setAddressList(_toConsumableArray(addressList));
227
- case 11:
226
+ case 9:
228
227
  case "end":
229
228
  return _context4.stop();
230
229
  }
@@ -236,6 +235,7 @@ var AddressSelection = function AddressSelection(props) {
236
235
  }();
237
236
  var handleChange = function handleChange(info, selectedOptions) {
238
237
  var cascaderValue = info || [];
238
+ console.log(cascaderValue, 'cascaderValue');
239
239
  if (valueDivision) {
240
240
  cascaderValue = cascaderValue.join(valueDivision);
241
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/plus-address-selection",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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": "efedcaf9e8359b7bc34f9687d38c66c14c5516af"
44
+ "gitHead": "7a7bd43ac08bdf95ee9040639078b87d121df077"
45
45
  }