iglooform 2.4.9 → 2.4.13

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.
Files changed (208) hide show
  1. package/es/admin-upload/index.d.ts +2 -0
  2. package/es/admin-upload/index.js +25 -11
  3. package/es/admin-upload/job-list.js +2 -2
  4. package/es/alert-message/index.js +2 -2
  5. package/es/amount/index.js +2 -2
  6. package/es/back-top/index.js +2 -2
  7. package/es/button/index.js +2 -2
  8. package/es/button/style/index.less +23 -19
  9. package/es/card-detail/card-item.js +1 -1
  10. package/es/card-detail/card.js +2 -2
  11. package/es/card-detail/utils.js +3 -3
  12. package/es/checkbox/index.js +2 -2
  13. package/es/claim-list/index.js +2 -2
  14. package/es/confirmation/index.js +2 -2
  15. package/es/date-picker/buddhist.js +2 -2
  16. package/es/date-picker/index.js +2 -2
  17. package/es/declaration/index.js +2 -2
  18. package/es/detail-panel/index.js +2 -2
  19. package/es/example/index.js +6 -7
  20. package/es/filter/index.d.ts +1 -0
  21. package/es/filter/index.js +10 -6
  22. package/es/form/addable-section/index.d.ts +19 -0
  23. package/es/form/addable-section/index.js +211 -0
  24. package/es/form/addable-section/style/index.d.ts +1 -0
  25. package/es/form/addable-section/style/index.js +1 -0
  26. package/es/form/addable-section/style/index.less +22 -0
  27. package/es/form/divider/index.js +2 -2
  28. package/es/form/element/index.js +30 -11
  29. package/es/form/element/style/index.less +5 -0
  30. package/es/form/index.js +7 -5
  31. package/es/form/login/index.js +1 -1
  32. package/es/form/page/index.js +1 -1
  33. package/es/form/page/style/index.less +1 -1
  34. package/es/form/pages/index.js +2 -3
  35. package/es/form/pages/style/index.less +3 -1
  36. package/es/form/render/index.js +1 -1
  37. package/es/form/section/index.js +4 -4
  38. package/es/form/step/index.js +1 -1
  39. package/es/form/steps/index.js +2 -3
  40. package/es/{form/context.d.ts → form-context.d.ts} +1 -0
  41. package/es/{form/context.js → form-context.js} +0 -0
  42. package/es/free-form/addable-section/index.d.ts +18 -0
  43. package/es/free-form/addable-section/index.js +286 -0
  44. package/es/free-form/addable-section/style/index.d.ts +1 -0
  45. package/es/free-form/addable-section/style/index.js +1 -0
  46. package/es/free-form/addable-section/style/index.less +22 -0
  47. package/es/free-form/element/index.js +22 -14
  48. package/es/free-form/element/style/index.less +8 -2
  49. package/es/free-form/index.d.ts +5 -1
  50. package/es/free-form/index.js +8 -5
  51. package/es/free-form/page/index.js +8 -7
  52. package/es/free-form/page/style/index.less +3 -1
  53. package/es/free-form/pages/index.js +2 -2
  54. package/es/free-form/section/index.js +10 -9
  55. package/es/free-form/section/style/index.less +4 -0
  56. package/es/free-form/step/index.js +7 -6
  57. package/es/free-form/steps/index.js +2 -2
  58. package/es/global-message/index.js +1 -1
  59. package/es/index.d.ts +1 -0
  60. package/es/index.js +2 -1
  61. package/es/input/amount.js +2 -2
  62. package/es/input/credit-card.js +2 -2
  63. package/es/input/email.js +2 -2
  64. package/es/input/expiry-date.js +2 -2
  65. package/es/input/input-number.js +2 -2
  66. package/es/input/input.js +2 -2
  67. package/es/input/otp.js +2 -2
  68. package/es/input/password.js +2 -2
  69. package/es/input/style/index.less +9 -1
  70. package/es/input/text-area.js +2 -2
  71. package/es/layout/header.js +3 -3
  72. package/es/layout/index.js +2 -2
  73. package/es/locale/en-US/messages.json +2 -0
  74. package/es/locale/id-ID/messages.json +2 -0
  75. package/es/locale/locale-provider.js +2 -2
  76. package/es/locale/th-TH/messages.json +2 -0
  77. package/es/locale/vi-VN/messages.json +2 -0
  78. package/es/locale/zh-CN/messages.json +2 -0
  79. package/es/media/preview.js +2 -2
  80. package/es/mobile-insurer-detail/index.js +2 -2
  81. package/es/mobile-insurer-list/index.js +2 -2
  82. package/es/modal/index.d.ts +4 -3
  83. package/es/modal/index.js +6 -3
  84. package/es/modal/style/index.less +24 -5
  85. package/es/policy-list/index.js +2 -2
  86. package/es/policy-list/policy-card.js +2 -2
  87. package/es/radio/index.js +2 -2
  88. package/es/select/attached-select.js +2 -2
  89. package/es/select/select.js +2 -2
  90. package/es/select/style/index.less +1 -1
  91. package/es/status-box/index.js +2 -2
  92. package/es/table/index.js +3 -3
  93. package/es/tabs/index.js +2 -2
  94. package/es/tabs/style/index.less +1 -1
  95. package/es/types.d.ts +5 -2
  96. package/es/upload/index.d.ts +2 -1
  97. package/es/upload/index.js +121 -77
  98. package/es/upload-photo/index.d.ts +2 -1
  99. package/es/upload-photo/index.js +123 -79
  100. package/es/utils/form-utils.d.ts +1 -0
  101. package/es/utils/form-utils.js +34 -12
  102. package/lib/admin-upload/index.d.ts +2 -0
  103. package/lib/admin-upload/index.js +25 -11
  104. package/lib/admin-upload/job-list.js +2 -2
  105. package/lib/alert-message/index.js +2 -2
  106. package/lib/amount/index.js +2 -2
  107. package/lib/back-top/index.js +2 -2
  108. package/lib/button/index.js +2 -2
  109. package/lib/button/style/index.less +23 -19
  110. package/lib/card-detail/card-item.js +1 -1
  111. package/lib/card-detail/card.js +2 -2
  112. package/lib/card-detail/utils.js +3 -3
  113. package/lib/checkbox/index.js +2 -2
  114. package/lib/claim-list/index.js +2 -2
  115. package/lib/confirmation/index.js +2 -2
  116. package/lib/date-picker/buddhist.js +2 -2
  117. package/lib/date-picker/index.js +2 -2
  118. package/lib/declaration/index.js +2 -2
  119. package/lib/detail-panel/index.js +2 -2
  120. package/lib/example/index.js +7 -8
  121. package/lib/filter/index.d.ts +1 -0
  122. package/lib/filter/index.js +10 -6
  123. package/lib/form/addable-section/index.d.ts +19 -0
  124. package/lib/form/addable-section/index.js +232 -0
  125. package/lib/form/addable-section/style/index.d.ts +1 -0
  126. package/lib/form/addable-section/style/index.js +3 -0
  127. package/lib/form/addable-section/style/index.less +22 -0
  128. package/lib/form/divider/index.js +2 -2
  129. package/lib/form/element/index.js +32 -12
  130. package/lib/form/element/style/index.less +5 -0
  131. package/lib/form/elements.js +1 -1
  132. package/lib/form/index.js +8 -6
  133. package/lib/form/login/index.js +2 -2
  134. package/lib/form/page/index.js +2 -2
  135. package/lib/form/page/style/index.less +1 -1
  136. package/lib/form/pages/index.js +3 -4
  137. package/lib/form/pages/style/index.less +3 -1
  138. package/lib/form/render/index.js +2 -2
  139. package/lib/form/section/index.js +5 -5
  140. package/lib/form/step/index.js +2 -2
  141. package/lib/form/steps/index.js +3 -4
  142. package/lib/{form/context.d.ts → form-context.d.ts} +1 -0
  143. package/lib/{form/context.js → form-context.js} +0 -0
  144. package/lib/free-form/addable-section/index.d.ts +18 -0
  145. package/lib/free-form/addable-section/index.js +306 -0
  146. package/lib/free-form/addable-section/style/index.d.ts +1 -0
  147. package/lib/free-form/addable-section/style/index.js +3 -0
  148. package/lib/free-form/addable-section/style/index.less +22 -0
  149. package/lib/free-form/element/index.js +23 -15
  150. package/lib/free-form/element/style/index.less +8 -2
  151. package/lib/free-form/index.d.ts +5 -1
  152. package/lib/free-form/index.js +9 -6
  153. package/lib/free-form/page/index.js +9 -8
  154. package/lib/free-form/page/style/index.less +3 -1
  155. package/lib/free-form/pages/index.js +2 -2
  156. package/lib/free-form/section/index.js +11 -10
  157. package/lib/free-form/section/style/index.less +4 -0
  158. package/lib/free-form/step/index.js +8 -7
  159. package/lib/free-form/steps/index.js +3 -3
  160. package/lib/global-message/index.js +1 -1
  161. package/lib/index.d.ts +1 -0
  162. package/lib/index.js +11 -2
  163. package/lib/input/amount.js +2 -2
  164. package/lib/input/credit-card.js +2 -2
  165. package/lib/input/email.js +2 -2
  166. package/lib/input/expiry-date.js +2 -2
  167. package/lib/input/input-number.js +2 -2
  168. package/lib/input/input.js +2 -2
  169. package/lib/input/otp.js +2 -2
  170. package/lib/input/password.js +2 -2
  171. package/lib/input/style/index.less +9 -1
  172. package/lib/input/text-area.js +2 -2
  173. package/lib/layout/header.js +3 -3
  174. package/lib/layout/index.js +2 -2
  175. package/lib/locale/en-US/messages.json +2 -0
  176. package/lib/locale/id-ID/messages.json +2 -0
  177. package/lib/locale/locale-provider.js +2 -2
  178. package/lib/locale/th-TH/messages.json +2 -0
  179. package/lib/locale/vi-VN/messages.json +2 -0
  180. package/lib/locale/zh-CN/messages.json +2 -0
  181. package/lib/media/preview.js +2 -2
  182. package/lib/mobile-insurer-detail/index.js +2 -2
  183. package/lib/mobile-insurer-list/index.js +2 -2
  184. package/lib/modal/index.d.ts +4 -3
  185. package/lib/modal/index.js +6 -3
  186. package/lib/modal/style/index.less +24 -5
  187. package/lib/policy-list/index.js +2 -2
  188. package/lib/policy-list/policy-card.js +2 -2
  189. package/lib/radio/index.js +2 -2
  190. package/lib/select/attached-select.js +2 -2
  191. package/lib/select/select.js +2 -2
  192. package/lib/select/style/index.less +1 -1
  193. package/lib/status-box/index.js +2 -2
  194. package/lib/table/index.js +3 -3
  195. package/lib/tabs/index.js +2 -2
  196. package/lib/tabs/style/index.less +1 -1
  197. package/lib/types.d.ts +5 -2
  198. package/lib/upload/index.d.ts +2 -1
  199. package/lib/upload/index.js +122 -77
  200. package/lib/upload-photo/index.d.ts +2 -1
  201. package/lib/upload-photo/index.js +124 -79
  202. package/lib/utils/form-utils.d.ts +1 -0
  203. package/lib/utils/form-utils.js +33 -12
  204. package/package.json +1 -1
  205. package/es/free-form/context.d.ts +0 -19
  206. package/es/free-form/context.js +0 -7
  207. package/lib/free-form/context.d.ts +0 -19
  208. package/lib/free-form/context.js +0 -19
@@ -37,15 +37,17 @@ var _locale = require("../locale");
37
37
 
38
38
  var _media = _interopRequireDefault(require("../upload-preview/media"));
39
39
 
40
- var _excluded = ["className", "placeholder", "handleUpload", "value", "onChange", "limit", "limitErrorMessage", "containerRef", "setFieldError", "descriptions", "validateField"];
40
+ var _formContext = _interopRequireDefault(require("../form-context"));
41
+
42
+ var _excluded = ["value", "limit", "limitErrorMessage", "descriptions", "onChange", "bizKey", "handleUpload", "setFieldError", "className", "validateField", "containerRef", "placeholder"];
41
43
 
42
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
45
 
44
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
46
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
45
47
 
46
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
48
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
47
49
 
48
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
50
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
51
 
50
52
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
51
53
 
@@ -57,10 +59,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
57
59
 
58
60
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
59
61
 
60
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
61
-
62
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
63
-
64
62
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
65
63
 
66
64
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -73,31 +71,79 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
73
71
 
74
72
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
75
73
 
74
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
75
+
76
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
77
+
76
78
  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; }
77
79
 
78
80
  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; }
79
81
 
80
82
  var Dragger = _upload.default.Dragger;
81
83
 
82
- var IglooUpload = function IglooUpload(_ref) {
83
- var className = _ref.className,
84
- placeholder = _ref.placeholder,
85
- handleUpload = _ref.handleUpload,
86
- _ref$value = _ref.value,
87
- value = _ref$value === void 0 ? [] : _ref$value,
88
- onChange = _ref.onChange,
89
- limit = _ref.limit,
90
- limitErrorMessage = _ref.limitErrorMessage,
91
- containerRef = _ref.containerRef,
92
- setFieldError = _ref.setFieldError,
93
- descriptions = _ref.descriptions,
94
- validateField = _ref.validateField,
95
- rest = _objectWithoutProperties(_ref, _excluded);
96
-
84
+ var IglooUpload = function IglooUpload(props) {
97
85
  var limitNumError = (0, _react.useRef)();
98
86
  var DomRef = (0, _react.useRef)();
99
87
  var dataUrlRef = (0, _react.useRef)([]);
100
88
 
89
+ var _useContext = (0, _react.useContext)(_formContext.default),
90
+ uploadApi = _useContext.uploadApi;
91
+
92
+ (0, _invariant.default)(typeof props.handleUpload === 'function' || uploadApi, '"handleUpload" should be a function. Or uploadApi should be set at Form/FreeForm');
93
+ (0, _invariant.default)(!uploadApi || props.bizKey, '"bizKey" should be set if Upload is used with uploadApi');
94
+
95
+ var _props$value = props.value,
96
+ value = _props$value === void 0 ? [] : _props$value,
97
+ limit = props.limit,
98
+ limitErrorMessage = props.limitErrorMessage,
99
+ descriptions = props.descriptions,
100
+ onChange = props.onChange,
101
+ bizKey = props.bizKey,
102
+ _props$handleUpload = props.handleUpload,
103
+ handleUpload = _props$handleUpload === void 0 ? /*#__PURE__*/function () {
104
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(file) {
105
+ var formData, response, rst;
106
+ return regeneratorRuntime.wrap(function _callee$(_context) {
107
+ while (1) {
108
+ switch (_context.prev = _context.next) {
109
+ case 0:
110
+ formData = new FormData();
111
+ formData.append('file', file);
112
+ formData.append('biz_key', bizKey);
113
+ _context.next = 5;
114
+ return fetch(uploadApi, {
115
+ method: 'post',
116
+ body: formData
117
+ });
118
+
119
+ case 5:
120
+ response = _context.sent;
121
+ _context.next = 8;
122
+ return response.json();
123
+
124
+ case 8:
125
+ rst = _context.sent;
126
+ return _context.abrupt("return", rst.url);
127
+
128
+ case 10:
129
+ case "end":
130
+ return _context.stop();
131
+ }
132
+ }
133
+ }, _callee);
134
+ }));
135
+
136
+ return function (_x) {
137
+ return _ref.apply(this, arguments);
138
+ };
139
+ }() : _props$handleUpload,
140
+ setFieldError = props.setFieldError,
141
+ className = props.className,
142
+ validateField = props.validateField,
143
+ containerRef = props.containerRef,
144
+ placeholder = props.placeholder,
145
+ rest = _objectWithoutProperties(props, _excluded);
146
+
101
147
  var _useState = (0, _react.useState)(value.map(function (url, index) {
102
148
  return {
103
149
  url: url,
@@ -119,7 +165,7 @@ var IglooUpload = function IglooUpload(_ref) {
119
165
  return;
120
166
  }
121
167
 
122
- if (!DomRef.current.contains(e.target) && limitNumError.current) {
168
+ if (DomRef.current && !DomRef.current.contains(e.target) && limitNumError.current) {
123
169
  validateField && validateField();
124
170
  limitNumError.current = undefined;
125
171
  }
@@ -137,8 +183,8 @@ var IglooUpload = function IglooUpload(_ref) {
137
183
  }
138
184
  });
139
185
 
140
- var _useContext = (0, _react.useContext)(_locale.LocaleContext),
141
- formatMessage = _useContext.formatMessage;
186
+ var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
187
+ formatMessage = _useContext2.formatMessage;
142
188
 
143
189
  (0, _react.useEffect)(function () {
144
190
  return function () {
@@ -147,22 +193,21 @@ var IglooUpload = function IglooUpload(_ref) {
147
193
  });
148
194
  };
149
195
  }, []);
150
- (0, _invariant.default)(typeof handleUpload === 'function', '"handleUpload" should be a function.');
151
196
  (0, _invariant.default)(limit === undefined || limit > 0, "\"limit\" should be a pasitive number.");
152
197
 
153
198
  var onUpload = /*#__PURE__*/function () {
154
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(file) {
199
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file) {
155
200
  var dataUrl, name, size, type, uid, errorMsg;
156
- return regeneratorRuntime.wrap(function _callee$(_context) {
201
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
157
202
  while (1) {
158
- switch (_context.prev = _context.next) {
203
+ switch (_context2.prev = _context2.next) {
159
204
  case 0:
160
205
  dataUrl = URL.createObjectURL(file);
161
206
  dataUrlRef.current.push(dataUrl);
162
207
  name = file.name, size = file.size, type = file.type, uid = file.uid;
163
208
 
164
209
  if (!(limit && files.length >= limit)) {
165
- _context.next = 8;
210
+ _context2.next = 8;
166
211
  break;
167
212
  }
168
213
 
@@ -174,7 +219,7 @@ var IglooUpload = function IglooUpload(_ref) {
174
219
  });
175
220
  limitNumError.current = errorMsg;
176
221
  setFieldError && setFieldError(errorMsg);
177
- return _context.abrupt("return", Promise.reject(errorMsg));
222
+ return _context2.abrupt("return", Promise.reject(errorMsg));
178
223
 
179
224
  case 8:
180
225
  limitNumError.current = undefined;
@@ -190,7 +235,7 @@ var IglooUpload = function IglooUpload(_ref) {
190
235
  }]);
191
236
  }); // 符合文件个数限制之后 上传时的错误处理
192
237
 
193
- return _context.abrupt("return", handleUploadPromise(file, function (url) {
238
+ return _context2.abrupt("return", handleUploadPromise(file, function (url) {
194
239
  var urls = [];
195
240
  setFiles(function (files) {
196
241
  return files.map(function (f) {
@@ -254,64 +299,64 @@ var IglooUpload = function IglooUpload(_ref) {
254
299
 
255
300
  case 11:
256
301
  case "end":
257
- return _context.stop();
302
+ return _context2.stop();
258
303
  }
259
304
  }
260
- }, _callee);
305
+ }, _callee2);
261
306
  }));
262
307
 
263
- return function onUpload(_x) {
308
+ return function onUpload(_x2) {
264
309
  return _ref2.apply(this, arguments);
265
310
  };
266
311
  }();
267
312
 
268
313
  var handleUploadPromise = /*#__PURE__*/function () {
269
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file, onSuccess, onFailed) {
314
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(file, onSuccess, onFailed) {
270
315
  var rst, errorMsg;
271
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
316
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
272
317
  while (1) {
273
- switch (_context2.prev = _context2.next) {
318
+ switch (_context3.prev = _context3.next) {
274
319
  case 0:
275
- _context2.prev = 0;
276
- _context2.next = 3;
320
+ _context3.prev = 0;
321
+ _context3.next = 3;
277
322
  return handleUpload(file);
278
323
 
279
324
  case 3:
280
- rst = _context2.sent;
325
+ rst = _context3.sent;
281
326
  onSuccess(rst);
282
- return _context2.abrupt("return", Promise.resolve(rst));
327
+ return _context3.abrupt("return", Promise.resolve(rst));
283
328
 
284
329
  case 8:
285
- _context2.prev = 8;
286
- _context2.t0 = _context2["catch"](0);
287
- errorMsg = _typeof(_context2.t0) === 'object' ? _context2.t0.message : _context2.t0;
330
+ _context3.prev = 8;
331
+ _context3.t0 = _context3["catch"](0);
332
+ errorMsg = _typeof(_context3.t0) === 'object' ? _context3.t0.message : _context3.t0;
288
333
  onFailed(errorMsg);
289
- return _context2.abrupt("return", Promise.reject(errorMsg));
334
+ return _context3.abrupt("return", Promise.reject(errorMsg));
290
335
 
291
336
  case 13:
292
337
  case "end":
293
- return _context2.stop();
338
+ return _context3.stop();
294
339
  }
295
340
  }
296
- }, _callee2, null, [[0, 8]]);
341
+ }, _callee3, null, [[0, 8]]);
297
342
  }));
298
343
 
299
- return function handleUploadPromise(_x2, _x3, _x4) {
344
+ return function handleUploadPromise(_x3, _x4, _x5) {
300
345
  return _ref3.apply(this, arguments);
301
346
  };
302
347
  }(); // 错误提示的优先级,上传报错 > 'quantity of files should be less than {limit}' > 'Please re-upload this file:{name}'
303
348
 
304
349
 
305
350
  var handleDelete = /*#__PURE__*/function () {
306
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(index) {
351
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
307
352
  var arr, hasError, rst;
308
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
353
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
309
354
  while (1) {
310
- switch (_context3.prev = _context3.next) {
355
+ switch (_context4.prev = _context4.next) {
311
356
  case 0:
312
357
  limitNumError.current = null;
313
358
  arr = files;
314
- _context3.next = 4;
359
+ _context4.next = 4;
315
360
  return setFiles(function (files) {
316
361
  var newArr = files.filter(function (_, i) {
317
362
  return i !== index;
@@ -327,7 +372,7 @@ var IglooUpload = function IglooUpload(_ref) {
327
372
  });
328
373
 
329
374
  if (!hasError) {
330
- _context3.next = 8;
375
+ _context4.next = 8;
331
376
  break;
332
377
  }
333
378
 
@@ -340,7 +385,7 @@ var IglooUpload = function IglooUpload(_ref) {
340
385
 
341
386
  return f.url;
342
387
  });
343
- return _context3.abrupt("return", typeof onChange === 'function' && onChange(rst));
388
+ return _context4.abrupt("return", typeof onChange === 'function' && onChange(rst));
344
389
 
345
390
  case 8:
346
391
  typeof onChange === 'function' && onChange(arr.map(function (_ref5) {
@@ -350,36 +395,36 @@ var IglooUpload = function IglooUpload(_ref) {
350
395
 
351
396
  case 9:
352
397
  case "end":
353
- return _context3.stop();
398
+ return _context4.stop();
354
399
  }
355
400
  }
356
- }, _callee3);
401
+ }, _callee4);
357
402
  }));
358
403
 
359
- return function handleDelete(_x5) {
404
+ return function handleDelete(_x6) {
360
405
  return _ref4.apply(this, arguments);
361
406
  };
362
407
  }();
363
408
 
364
409
  var handleReUpload = /*#__PURE__*/function () {
365
- var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(index) {
410
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(index) {
366
411
  var _files$index, originFile, reUpUid, rst, latestFiles, fileListWithError, newList, _rst;
367
412
 
368
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
413
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
369
414
  while (1) {
370
- switch (_context4.prev = _context4.next) {
415
+ switch (_context5.prev = _context5.next) {
371
416
  case 0:
372
417
  _files$index = files[index], originFile = _files$index.originFile, reUpUid = _files$index.uid;
373
418
 
374
419
  if (originFile) {
375
- _context4.next = 3;
420
+ _context5.next = 3;
376
421
  break;
377
422
  }
378
423
 
379
- return _context4.abrupt("return");
424
+ return _context5.abrupt("return");
380
425
 
381
426
  case 3:
382
- _context4.next = 5;
427
+ _context5.next = 5;
383
428
  return setFiles(function (files) {
384
429
  var newFiles = _toConsumableArray(files);
385
430
 
@@ -388,14 +433,14 @@ var IglooUpload = function IglooUpload(_ref) {
388
433
  });
389
434
 
390
435
  case 5:
391
- _context4.prev = 5;
392
- _context4.next = 8;
436
+ _context5.prev = 5;
437
+ _context5.next = 8;
393
438
  return handleUpload(originFile);
394
439
 
395
440
  case 8:
396
- rst = _context4.sent;
441
+ rst = _context5.sent;
397
442
  latestFiles = [];
398
- _context4.next = 12;
443
+ _context5.next = 12;
399
444
  return setFiles(function (files) {
400
445
  var newFiles = _toConsumableArray(files);
401
446
 
@@ -423,19 +468,19 @@ var IglooUpload = function IglooUpload(_ref) {
423
468
  return url;
424
469
  });
425
470
  onChange && onChange(fileListWithError);
426
- _context4.next = 23;
471
+ _context5.next = 23;
427
472
  break;
428
473
 
429
474
  case 16:
430
- _context4.prev = 16;
431
- _context4.t0 = _context4["catch"](5);
475
+ _context5.prev = 16;
476
+ _context5.t0 = _context5["catch"](5);
432
477
  newList = [];
433
- _context4.next = 21;
478
+ _context5.next = 21;
434
479
  return setFiles(function (files) {
435
480
  var newFiles = _toConsumableArray(files);
436
481
 
437
482
  newFiles[index].status = 'failed';
438
- newFiles[index].errorMsg = _context4.t0;
483
+ newFiles[index].errorMsg = _context5.t0;
439
484
  newList = newFiles;
440
485
  return newFiles;
441
486
  });
@@ -461,13 +506,13 @@ var IglooUpload = function IglooUpload(_ref) {
461
506
 
462
507
  case 23:
463
508
  case "end":
464
- return _context4.stop();
509
+ return _context5.stop();
465
510
  }
466
511
  }
467
- }, _callee4, null, [[5, 16]]);
512
+ }, _callee5, null, [[5, 16]]);
468
513
  }));
469
514
 
470
- return function handleReUpload(_x6) {
515
+ return function handleReUpload(_x7) {
471
516
  return _ref6.apply(this, arguments);
472
517
  };
473
518
  }();
@@ -1,7 +1,7 @@
1
1
  import { FC, IglooComponentProps } from '../types';
2
2
  import './style/index.less';
3
3
  export interface Props extends IglooComponentProps {
4
- handleUpload(file: File): PromiseLike<string>;
4
+ handleUpload?(file: File): PromiseLike<string>;
5
5
  value?: (string | {
6
6
  name: string;
7
7
  status: 'failed';
@@ -15,6 +15,7 @@ export interface Props extends IglooComponentProps {
15
15
  samples?: Sample[];
16
16
  className?: any;
17
17
  id?: string;
18
+ bizKey?: string;
18
19
  }
19
20
  export declare type Sample = {
20
21
  src: string;