iglooform 2.5.50 → 2.5.52

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.
@@ -1,8 +1,11 @@
1
1
  import { DatePickerProps, RangePickerProps, MonthPickerProps, WeekPickerProps } from 'antd/es/date-picker';
2
2
  import { FC, IglooComponentProps } from '../types';
3
+ import { Moment } from 'moment';
3
4
  import './style/index.less';
4
5
  export { default as IglooBuddhistDatePicker } from './buddhist';
5
- declare type Props = DatePickerProps & IglooComponentProps;
6
+ declare type Props = Omit<DatePickerProps, 'value'> & IglooComponentProps & {
7
+ value?: Moment | null | 0;
8
+ };
6
9
  declare const IglooDatePicker: FC<Props>;
7
10
  export default IglooDatePicker;
8
11
  export declare const IglooRangePicker: FC<RangePickerProps & IglooComponentProps>;
@@ -62,7 +62,7 @@ var IglooDatePicker = function IglooDatePicker(_ref) {
62
62
  setFocus = _useState2[1];
63
63
 
64
64
  return _jsx(_DatePicker, _objectSpread(_objectSpread({}, omit(props, formMethods)), {}, {
65
- value: moment(value),
65
+ value: value || value === 0 ? moment(value) : undefined,
66
66
  placeholder: placeholder || dateFormater,
67
67
  format: format || dateFormater,
68
68
  inputReadOnly: true,
@@ -89,7 +89,7 @@ IglooDatePicker.formItemPropsHandler = function (_ref2) {
89
89
  return moment(value).format(format || dateFormater);
90
90
  },
91
91
  valueFormater: function valueFormater(value) {
92
- return +moment(value);
92
+ return value ? +moment(value) : value;
93
93
  },
94
94
  'element-allowClear': false
95
95
  };
@@ -91,7 +91,8 @@ var Element = function Element(_ref) {
91
91
  subscribedFields = config.subscribedFields,
92
92
  disabled = config.disabled,
93
93
  extraLabel = config.extraLabel,
94
- requiredAsserts = config.requiredAsserts;
94
+ requiredAsserts = config.requiredAsserts,
95
+ shouldRenderCode = config.shouldRenderCode;
95
96
  var dependentField = dependencies || [];
96
97
 
97
98
  if (Array.isArray(subscribedFields)) {
@@ -123,7 +124,7 @@ var Element = function Element(_ref) {
123
124
  });
124
125
  }
125
126
 
126
- if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
127
+ if ((shouldRender || shouldRenderCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
127
128
  dependentField.push('SUBSCRIBE_ALL');
128
129
  }
129
130
 
@@ -32,7 +32,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
32
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
33
33
  import { useState, useContext, useEffect, useReducer, useRef } from 'react';
34
34
  import HStep from '../hstep';
35
- import { calcNamePath, getRuleValidation } from '../../utils/form-utils';
35
+ import { calcNamePath, getRuleValidation, calcShouldRender } from '../../utils/form-utils';
36
36
  import FormContext from '../../form-context';
37
37
  import StepContext from '../../form-step-context';
38
38
  import './style/index.less';
@@ -105,26 +105,45 @@ var HSteps = function HSteps(_ref) {
105
105
  useEffect(function () {
106
106
  var subscribe = elements.some(function (_ref2) {
107
107
  var shouldRender = _ref2.shouldRender,
108
- getButtonDisabledState = _ref2.getButtonDisabledState;
109
- return Boolean(shouldRender) || Boolean(getButtonDisabledState);
108
+ getButtonDisabledState = _ref2.getButtonDisabledState,
109
+ shouldRenderCode = _ref2.shouldRenderCode;
110
+ return Boolean(shouldRender) || Boolean(getButtonDisabledState) || Boolean(shouldRenderCode);
110
111
  });
111
112
 
112
113
  if (subscribe) {
113
114
  Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
114
115
  }
116
+
117
+ var dependentField = [];
118
+ elements.forEach(function (_ref3) {
119
+ var asserts = _ref3.asserts;
120
+ if (!(asserts === null || asserts === void 0 ? void 0 : asserts.length)) return;
121
+ asserts.forEach(function (_ref4) {
122
+ var field = _ref4.field;
123
+ return dependentField.push(field);
124
+ });
125
+ });
126
+ dependentField.length && registerDependencies(dependentField, dispatch);
115
127
  }, []);
116
128
  useEffect(function () {
117
129
  if (currentStep === undefined || currentStep === current) return;
118
130
  setCurrent(currentStep);
119
131
  }, [currentStep]);
120
- var renderElements = elements.filter(function (step) {
121
- invariant(step.type === 'Step', 'Child of steps should be Step');
122
- invariant(!step.validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
123
- return typeof step.shouldRender !== 'function' || step.shouldRender(form);
132
+ var renderElements = elements.filter(function (_ref5) {
133
+ var type = _ref5.type,
134
+ curName = _ref5.name,
135
+ validationRule = _ref5.validationRule,
136
+ dependencies = _ref5.dependencies,
137
+ asserts = _ref5.asserts,
138
+ shouldRender = _ref5.shouldRender,
139
+ shouldRenderCode = _ref5.shouldRenderCode;
140
+ invariant(type === 'Step', 'Child of steps should be Step');
141
+ invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
142
+ return calcShouldRender(calcNamePath(calcNamePath(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
124
143
  });
125
144
 
126
145
  var handleNext = /*#__PURE__*/function () {
127
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
146
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
128
147
  var _allFields$filter;
129
148
 
130
149
  var allFields, allValues, _renderElements$curre, currentName, handleNext, validationRule, namePath, fields, _iterator, _step, collapseSection, res, errors;
@@ -137,11 +156,11 @@ var HSteps = function HSteps(_ref) {
137
156
  allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
138
157
  _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext, validationRule = _renderElements$curre.validationRule;
139
158
  namePath = calcNamePath(name, currentName);
140
- fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
141
- var name = _ref4.name;
159
+ fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref7) {
160
+ var name = _ref7.name;
142
161
  return name.join().startsWith(namePath === null || namePath === void 0 ? void 0 : namePath.join());
143
- })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
144
- var name = _ref5.name;
162
+ })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref8) {
163
+ var name = _ref8.name;
145
164
  return name;
146
165
  });
147
166
  _context.prev = 5;
@@ -245,7 +264,7 @@ var HSteps = function HSteps(_ref) {
245
264
  }));
246
265
 
247
266
  return function handleNext() {
248
- return _ref3.apply(this, arguments);
267
+ return _ref6.apply(this, arguments);
249
268
  };
250
269
  }();
251
270
 
@@ -392,14 +411,14 @@ var HSteps = function HSteps(_ref) {
392
411
  margin: 0
393
412
  },
394
413
  children: _jsx(Confirmation, {})
395
- }), confirmations && Object.entries(confirmations).map(function (_ref6) {
396
- var _ref7 = _slicedToArray(_ref6, 2),
397
- key = _ref7[0],
398
- _ref7$ = _ref7[1],
399
- required = _ref7$.required,
400
- _ref7$$confirmation = _ref7$.confirmation,
401
- confirmation = _ref7$$confirmation === void 0 ? {} : _ref7$$confirmation,
402
- requiredMessage = _ref7$.requiredMessage;
414
+ }), confirmations && Object.entries(confirmations).map(function (_ref9) {
415
+ var _ref10 = _slicedToArray(_ref9, 2),
416
+ key = _ref10[0],
417
+ _ref10$ = _ref10[1],
418
+ required = _ref10$.required,
419
+ _ref10$$confirmation = _ref10$.confirmation,
420
+ confirmation = _ref10$$confirmation === void 0 ? {} : _ref10$$confirmation,
421
+ requiredMessage = _ref10$.requiredMessage;
403
422
 
404
423
  return _jsx(_Form.Item, {
405
424
  name: calcNamePath(parentName, key),
@@ -19,7 +19,7 @@ import { useState, useContext, useEffect, useReducer, useRef } from 'react';
19
19
  import invariant from 'invariant';
20
20
  import classnames from 'classnames';
21
21
  import Step from '../step';
22
- import { calcNamePath, getRuleValidation } from '../../utils/form-utils';
22
+ import { calcNamePath, getRuleValidation, calcShouldRender } from '../../utils/form-utils';
23
23
  import FormContext from '../../form-context';
24
24
  import StepContext from '../../form-step-context';
25
25
  import { LocaleContext } from '../../locale';
@@ -74,24 +74,41 @@ var Steps = function Steps(_ref) {
74
74
  useEffect(function () {
75
75
  var subscribe = elements.some(function (_ref2) {
76
76
  var shouldRender = _ref2.shouldRender,
77
- getButtonDisabledState = _ref2.getButtonDisabledState;
78
- return Boolean(shouldRender) || Boolean(getButtonDisabledState);
77
+ getButtonDisabledState = _ref2.getButtonDisabledState,
78
+ shouldRenderCode = _ref2.shouldRenderCode;
79
+ return Boolean(shouldRender) || Boolean(getButtonDisabledState) || Boolean(shouldRenderCode);
79
80
  });
80
81
 
81
82
  if (subscribe) {
82
83
  Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
83
84
  }
85
+
86
+ var dependentField = [];
87
+ elements.forEach(function (_ref3) {
88
+ var asserts = _ref3.asserts;
89
+ if (!(asserts === null || asserts === void 0 ? void 0 : asserts.length)) return;
90
+ asserts.forEach(function (_ref4) {
91
+ var field = _ref4.field;
92
+ return dependentField.push(field);
93
+ });
94
+ });
95
+ dependentField.length && registerDependencies(dependentField, dispatch);
84
96
  }, []);
85
97
  useEffect(function () {
86
98
  if (currentStep === undefined || currentStep === current) return;
87
99
  setCurrent(currentStep);
88
100
  }, [currentStep]);
89
- var renderElements = elements.filter(function (step) {
90
- return typeof step.shouldRender !== 'function' || step.shouldRender(form);
101
+ var renderElements = elements.filter(function (_ref5) {
102
+ var curName = _ref5.name,
103
+ dependencies = _ref5.dependencies,
104
+ asserts = _ref5.asserts,
105
+ shouldRender = _ref5.shouldRender,
106
+ shouldRenderCode = _ref5.shouldRenderCode;
107
+ return calcShouldRender(calcNamePath(calcNamePath(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
91
108
  });
92
109
 
93
110
  var handleNext = /*#__PURE__*/function () {
94
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
111
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
95
112
  var _allFields$filter;
96
113
 
97
114
  var allFields, allValues, _renderElements$curre, currentName, handleNext, validationRule, namePath, fields, res, errors;
@@ -104,11 +121,11 @@ var Steps = function Steps(_ref) {
104
121
  allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
105
122
  _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext, validationRule = _renderElements$curre.validationRule;
106
123
  namePath = calcNamePath(name, currentName);
107
- fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
108
- var name = _ref4.name;
124
+ fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref7) {
125
+ var name = _ref7.name;
109
126
  return name.join().startsWith(namePath === null || namePath === void 0 ? void 0 : namePath.join());
110
- })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
111
- var name = _ref5.name;
127
+ })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref8) {
128
+ var name = _ref8.name;
112
129
  return name;
113
130
  });
114
131
  _context.prev = 5;
@@ -199,7 +216,7 @@ var Steps = function Steps(_ref) {
199
216
  }));
200
217
 
201
218
  return function handleNext() {
202
- return _ref3.apply(this, arguments);
219
+ return _ref6.apply(this, arguments);
203
220
  };
204
221
  }();
205
222
 
@@ -16,7 +16,6 @@ export interface StepProps extends FormItemConfig {
16
16
  editButtonLabel?: string;
17
17
  disableEditButton?: boolean;
18
18
  buttonText?: string;
19
- validationRule?: string;
20
19
  }
21
20
  declare const Step: FC<StepProps>;
22
21
  export default Step;
@@ -33,7 +33,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
33
33
  import { useContext, useState, useRef, useEffect, useMemo, useReducer, cloneElement, isValidElement } from 'react';
34
34
  import { LocaleContext } from '../../locale';
35
35
  import Button from '../../button';
36
- import { calcNamePath, getRuleValidation } from '../../utils/form-utils';
36
+ import { calcNamePath, getRuleValidation, calcShouldRender } from '../../utils/form-utils';
37
37
  import FormContext from '../../form-context';
38
38
  import invariant from 'invariant';
39
39
  import './style/index.less';
@@ -63,7 +63,10 @@ var Step = function Step(_ref) {
63
63
  shouldRender = _ref.shouldRender,
64
64
  subscribedFields = _ref.subscribedFields,
65
65
  buttonText = _ref.buttonText,
66
- validationRule = _ref.validationRule;
66
+ validationRule = _ref.validationRule,
67
+ asserts = _ref.asserts,
68
+ dependencies = _ref.dependencies,
69
+ shouldRenderCode = _ref.shouldRenderCode;
67
70
 
68
71
  var _useContext = useContext(LocaleContext),
69
72
  formatMessage = _useContext.formatMessage,
@@ -98,6 +101,14 @@ var Step = function Step(_ref) {
98
101
  if (shouldRender || getButtonDisabledState) {
99
102
  registerDependencies(Array.isArray(subscribedFields) ? subscribedFields : 'SUBSCRIBE_ALL', dispatch);
100
103
  }
104
+
105
+ if (asserts === null || asserts === void 0 ? void 0 : asserts.length) {
106
+ var dependentField = asserts.map(function (_ref2) {
107
+ var field = _ref2.field;
108
+ return field;
109
+ });
110
+ registerDependencies(dependentField, dispatch);
111
+ }
101
112
  }, []);
102
113
  var pName = useMemo(function () {
103
114
  return calcNamePath(parentName, name);
@@ -150,7 +161,7 @@ var Step = function Step(_ref) {
150
161
  };
151
162
 
152
163
  var handleNext = /*#__PURE__*/function () {
153
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
164
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
154
165
  var _allFields$filter;
155
166
 
156
167
  var allFields, allValues, fields, res, errors;
@@ -160,11 +171,11 @@ var Step = function Step(_ref) {
160
171
  case 0:
161
172
  allFields = (form === null || form === void 0 ? void 0 : form.getFieldsError()) || [];
162
173
  allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
163
- fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref3) {
164
- var name = _ref3.name;
165
- return name.join().startsWith(pName === null || pName === void 0 ? void 0 : pName.join());
166
- })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref4) {
174
+ fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
167
175
  var name = _ref4.name;
176
+ return name.join().startsWith(pName === null || pName === void 0 ? void 0 : pName.join());
177
+ })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
178
+ var name = _ref5.name;
168
179
  return name;
169
180
  });
170
181
  _context.prev = 3;
@@ -249,11 +260,11 @@ var Step = function Step(_ref) {
249
260
  }));
250
261
 
251
262
  return function handleNext() {
252
- return _ref2.apply(this, arguments);
263
+ return _ref3.apply(this, arguments);
253
264
  };
254
265
  }();
255
266
 
256
- if (typeof shouldRender === 'function' && !shouldRender(form)) {
267
+ if (!calcShouldRender(pName, dependencies, asserts, shouldRender, shouldRenderCode, form)) {
257
268
  return null;
258
269
  }
259
270
 
package/es/types.d.ts CHANGED
@@ -123,6 +123,7 @@ export interface FormItemExtraConfig extends FormItemProps {
123
123
  maxLength?: number;
124
124
  idType?: 'KTP' | 'NIK';
125
125
  validationRule?: string;
126
+ shouldRenderCode?: string;
126
127
  [key: string]: any;
127
128
  }
128
129
  export interface FormItemConfig extends FormItemExtraConfig {
@@ -168,6 +168,31 @@ var IglooUpload = function IglooUpload(props) {
168
168
  });
169
169
  };
170
170
  }, []);
171
+ useEffect(function () {
172
+ if (!(value === null || value === void 0 ? void 0 : value.length) && !files.length) return;
173
+
174
+ if (files.length) {
175
+ var urls = files.map(function (f) {
176
+ var status = f.status,
177
+ name = f.name,
178
+ errorMsg = f.errorMsg;
179
+
180
+ if (status === 'failed') {
181
+ return {
182
+ name: name,
183
+ errorMsg: errorMsg
184
+ };
185
+ }
186
+
187
+ if (f.url || f.dataUrl) {
188
+ return f.url || f.dataUrl;
189
+ }
190
+ });
191
+ onChange && onChange(urls);
192
+ } else {
193
+ onChange && onChange([]);
194
+ }
195
+ }, [files]);
171
196
  invariant(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
172
197
 
173
198
  var onUpload = /*#__PURE__*/function () {
@@ -197,7 +222,8 @@ var IglooUpload = function IglooUpload(props) {
197
222
  return _context2.abrupt("return", Promise.reject(errorMsg));
198
223
 
199
224
  case 8:
200
- limitNumError.current = undefined;
225
+ limitNumError.current = undefined; // 上传过程中 status为‘progress’,后续通过state更新
226
+
201
227
  setFiles(function (files) {
202
228
  return [].concat(_toConsumableArray(files), [{
203
229
  name: name,
@@ -211,39 +237,21 @@ var IglooUpload = function IglooUpload(props) {
211
237
  }); // 符合文件个数限制之后 上传时的错误处理
212
238
 
213
239
  return _context2.abrupt("return", handleUploadPromise(file, function (url) {
214
- var urls = [];
215
- setFiles(function (files) {
240
+ return setFiles(function (files) {
216
241
  return files.map(function (f) {
217
- // 这里不能只处理成功的文件 因为这次上传的文件是成功了 但是这次之前可能会有上传失败的 需要将错误信息提取出来 否则错误提示会丢失
218
242
  if (f.uid === uid) {
219
- urls.push(url);
220
243
  return _objectSpread(_objectSpread({}, f), {}, {
221
244
  url: url,
222
245
  status: 'success'
223
246
  });
224
247
  }
225
248
 
226
- var status = f.status,
227
- name = f.name,
228
- errorMsg = f.errorMsg;
229
-
230
- if (status === 'failed') {
231
- urls.push({
232
- name: name,
233
- errorMsg: errorMsg
234
- });
235
- } else {
236
- f.url && urls.push(f.url);
237
- }
238
-
239
249
  return f;
240
250
  });
241
251
  });
242
- onChange && onChange(urls);
243
252
  }, function (errorMsg) {
244
- var fileList = [];
245
- setFiles(function (files) {
246
- var newList = files.map(function (f) {
253
+ return setFiles(function (files) {
254
+ return files.map(function (f) {
247
255
  if (f.uid === uid) {
248
256
  return _objectSpread(_objectSpread({}, f), {}, {
249
257
  status: 'failed',
@@ -253,23 +261,7 @@ var IglooUpload = function IglooUpload(props) {
253
261
 
254
262
  return f;
255
263
  });
256
- fileList = newList;
257
- return newList;
258
264
  });
259
- var fileListWithError = fileList.map(function (f) {
260
- if (f.uid === uid) {
261
- return {
262
- name: f.name,
263
- status: 'failed',
264
- errorMsg: errorMsg
265
- };
266
- }
267
-
268
- return f.url;
269
- }); // 需要触发onchange 在form级别报错
270
-
271
- // 需要触发onchange 在form级别报错
272
- typeof onChange === 'function' && onChange(fileListWithError);
273
265
  }));
274
266
 
275
267
  case 11:
@@ -324,51 +316,19 @@ var IglooUpload = function IglooUpload(props) {
324
316
 
325
317
  var handleDelete = /*#__PURE__*/function () {
326
318
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
327
- var arr, hasError, rst;
328
319
  return regeneratorRuntime.wrap(function _callee4$(_context4) {
329
320
  while (1) {
330
321
  switch (_context4.prev = _context4.next) {
331
322
  case 0:
332
323
  limitNumError.current = null;
333
- arr = files;
334
- _context4.next = 4;
335
- return setFiles(function (files) {
324
+ setFiles(function (files) {
336
325
  var newArr = files.filter(function (_, i) {
337
326
  return i !== index;
338
327
  });
339
- arr = newArr;
340
328
  return newArr;
341
329
  });
342
330
 
343
- case 4:
344
- // 删除之后找一下是否存在上传过程中错误的文件
345
- hasError = arr.some(function (f) {
346
- return f.status === 'failed';
347
- });
348
-
349
- if (!hasError) {
350
- _context4.next = 8;
351
- break;
352
- }
353
-
354
- rst = arr.map(function (f) {
355
- if (f.status === 'failed') {
356
- return {
357
- errorMsg: f.errorMsg
358
- };
359
- }
360
-
361
- return f.url;
362
- });
363
- return _context4.abrupt("return", typeof onChange === 'function' && onChange(rst));
364
-
365
- case 8:
366
- typeof onChange === 'function' && onChange(arr.map(function (_ref5) {
367
- var url = _ref5.url;
368
- return url;
369
- }));
370
-
371
- case 9:
331
+ case 2:
372
332
  case "end":
373
333
  return _context4.stop();
374
334
  }
@@ -382,8 +342,8 @@ var IglooUpload = function IglooUpload(props) {
382
342
  }();
383
343
 
384
344
  var handleReUpload = /*#__PURE__*/function () {
385
- var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(index) {
386
- var _files$index, originFile, reUpUid, rst, latestFiles, fileListWithError, newList, _rst;
345
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(index) {
346
+ var _files$index, originFile, reUpUid, rst;
387
347
 
388
348
  return regeneratorRuntime.wrap(function _callee5$(_context5) {
389
349
  while (1) {
@@ -414,81 +374,41 @@ var IglooUpload = function IglooUpload(props) {
414
374
 
415
375
  case 8:
416
376
  rst = _context5.sent;
417
- latestFiles = [];
418
- _context5.next = 12;
377
+ _context5.next = 11;
419
378
  return setFiles(function (files) {
420
379
  var newFiles = _toConsumableArray(files);
421
380
 
422
381
  newFiles[index].url = rst;
423
382
  newFiles[index].status = 'success';
424
- latestFiles = newFiles;
425
383
  return newFiles;
426
384
  });
427
385
 
428
- case 12:
429
- // 查找出现在file 列表中地错误信息
430
- fileListWithError = latestFiles.map(function (f) {
431
- var status = f.status,
432
- errorMsg = f.errorMsg,
433
- url = f.url,
434
- name = f.name;
435
-
436
- if (status === 'failed') {
437
- return {
438
- errorMsg: errorMsg,
439
- name: name
440
- };
441
- }
442
-
443
- return url;
444
- });
445
- onChange && onChange(fileListWithError);
446
- _context5.next = 23;
386
+ case 11:
387
+ _context5.next = 17;
447
388
  break;
448
389
 
449
- case 16:
450
- _context5.prev = 16;
390
+ case 13:
391
+ _context5.prev = 13;
451
392
  _context5.t0 = _context5["catch"](5);
452
- newList = [];
453
- _context5.next = 21;
393
+ _context5.next = 17;
454
394
  return setFiles(function (files) {
455
395
  var newFiles = _toConsumableArray(files);
456
396
 
457
397
  newFiles[index].status = 'failed';
458
398
  newFiles[index].errorMsg = _context5.t0;
459
- newList = newFiles;
460
399
  return newFiles;
461
400
  });
462
401
 
463
- case 21:
464
- // 报错之后要重置报错信息
465
- _rst = newList.map(function (f) {
466
- var name = f.name,
467
- errorMsg = f.errorMsg,
468
- url = f.url,
469
- uid = f.uid;
470
-
471
- if (uid === reUpUid) {
472
- return {
473
- name: name,
474
- errorMsg: errorMsg
475
- };
476
- }
477
-
478
- return url;
479
- });
480
- typeof onChange === 'function' && onChange(_rst);
481
-
482
- case 23:
402
+ case 17:
483
403
  case "end":
484
404
  return _context5.stop();
485
405
  }
486
406
  }
487
- }, _callee5, null, [[5, 16]]);
407
+ }, _callee5, null, [[5, 13]]);
488
408
  }));
489
409
 
490
410
  return function handleReUpload(_x7) {
491
- return _ref6.apply(this, arguments);
411
+ return _ref5.apply(this, arguments);
492
412
  };
493
413
  }();
494
414
 
@@ -572,14 +492,14 @@ var IglooUpload = function IglooUpload(props) {
572
492
  });
573
493
  };
574
494
 
575
- var FileList = function FileList(_ref7) {
576
- var containerRef = _ref7.containerRef,
577
- files = _ref7.files,
578
- limit = _ref7.limit,
579
- handleDelete = _ref7.handleDelete,
580
- handlePreview = _ref7.handlePreview,
581
- handleReUpload = _ref7.handleReUpload,
582
- disabled = _ref7.disabled;
495
+ var FileList = function FileList(_ref6) {
496
+ var containerRef = _ref6.containerRef,
497
+ files = _ref6.files,
498
+ limit = _ref6.limit,
499
+ handleDelete = _ref6.handleDelete,
500
+ handlePreview = _ref6.handlePreview,
501
+ handleReUpload = _ref6.handleReUpload,
502
+ disabled = _ref6.disabled;
583
503
 
584
504
  var _useState3 = useState(false),
585
505
  _useState4 = _slicedToArray(_useState3, 2),
@@ -593,11 +513,11 @@ var FileList = function FileList(_ref7) {
593
513
 
594
514
  var children = _jsx("div", {
595
515
  className: "igloo-upload-preview-list",
596
- children: files.map(function (_ref8, index) {
597
- var type = _ref8.type,
598
- name = _ref8.name,
599
- size = _ref8.size,
600
- status = _ref8.status;
516
+ children: files.map(function (_ref7, index) {
517
+ var type = _ref7.type,
518
+ name = _ref7.name,
519
+ size = _ref7.size,
520
+ status = _ref7.status;
601
521
  return _jsxs("div", {
602
522
  className: classnames('igloo-upload-preview-item', {
603
523
  'igloo-upload-preview-item-failed': status === 'failed'
@@ -703,9 +623,9 @@ function checkFileList(value) {
703
623
  return Promise.resolve();
704
624
  }
705
625
 
706
- IglooUpload.formItemPropsHandler = function (_ref9) {
707
- var previewFormater = _ref9.previewFormater,
708
- label = _ref9.label;
626
+ IglooUpload.formItemPropsHandler = function (_ref8) {
627
+ var previewFormater = _ref8.previewFormater,
628
+ label = _ref8.label;
709
629
  return {
710
630
  previewFormater: previewFormater || function (value) {
711
631
  return _jsx(UploadPreview, {